Skip to content

Commit

Permalink
Convert SharedBD Dialog to javafx
Browse files Browse the repository at this point in the history
add stub
  • Loading branch information
Siedlerchr committed May 18, 2018
1 parent 845b384 commit a2f99df
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 0 deletions.
75 changes: 75 additions & 0 deletions src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialog.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.Group?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.DialogPane?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>


<DialogPane xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.jabref.gui.shared.SharedDatabaseLoginDialogView">
<content>
<BorderPane>
<center>
<BorderPane BorderPane.alignment="CENTER">
<center>
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="Database Type:" />
<ComboBox fx:id="cmbDbType" prefHeight="25.0" prefWidth="606.0" GridPane.columnIndex="1" GridPane.columnSpan="2" />
<Label text="Host/Port:" GridPane.rowIndex="1" />
<TextField fx:id="tbHost" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField fx:id="tbDb" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="2" />
<TextField fx:id="tbPort" prefHeight="25.0" prefWidth="66.0" GridPane.columnIndex="2" GridPane.rowIndex="1" />
<Label text="Database:" GridPane.rowIndex="2" />
<Label text="User:" GridPane.rowIndex="3" />
<TextField fx:id="tbUser" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="3" />
<Label text="Password:" GridPane.rowIndex="4" />
<PasswordField fx:id="tbPwd" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="4" />
<CheckBox fx:id="chkRememberPassword" mnemonicParsing="false" text="Remember Password" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.rowIndex="5" />
</children>
</GridPane>
</center>
<bottom>
<GridPane BorderPane.alignment="CENTER">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<CheckBox mnemonicParsing="false" text="Automatically save library to" GridPane.columnSpan="2" />
<TextField fx:id="tbFolder" GridPane.rowIndex="1" />
<Button fx:id="btnBrowse" mnemonicParsing="false" onAction="#openFileDialog" text="Browse" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Group />
</children>
</GridPane>
</bottom>
</BorderPane>
</center>
</BorderPane>
</content>
</DialogPane>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package org.jabref.gui.shared;

import java.nio.file.Path;
import java.util.Optional;

import javax.inject.Inject;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;

import org.jabref.Globals;
import org.jabref.gui.DialogService;
import org.jabref.gui.util.BaseDialog;
import org.jabref.gui.util.FileDialogConfiguration;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.FileType;
import org.jabref.model.database.shared.DBMSType;
import org.jabref.preferences.JabRefPreferences;

import com.airhacks.afterburner.views.ViewLoader;

public class SharedDatabaseLoginDialogView extends BaseDialog<Void> {

@FXML private ComboBox<DBMSType> cmbDbType;
@FXML private TextField tbHost;
@FXML private TextField tbDb;
@FXML private TextField tbPort;
@FXML private TextField tbUser;
@FXML private PasswordField tbPwd;
@FXML private CheckBox chkRememberPassword;
@FXML private TextField tbFolder;
@FXML private Button btnBrowse;

@Inject private DialogService dialogService;

private final SharedDatabaseLoginDialogViewModel viewModel;

@FXML
private void initialize() {
//todo
}

public SharedDatabaseLoginDialogView() {
this.setTitle(Localization.lang("Connect to shared database"));
this.setResizable(true);

this.getDialogPane().getButtonTypes().addAll(ButtonType.OK);

viewModel = new SharedDatabaseLoginDialogViewModel();

ViewLoader.view(this)
.load()
.setAsContent(this.getDialogPane());
}

@FXML
void openFileDialog(ActionEvent event) {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.addExtensionFilter(FileType.BIBTEX_DB)
.withDefaultExtension(FileType.BIBTEX_DB)
.withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY))
.build();
Optional<Path> exportPath = dialogService.showFileSaveDialog(fileDialogConfiguration);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.jabref.gui.shared;

import org.jabref.gui.AbstractViewModel;

public class SharedDatabaseLoginDialogViewModel extends AbstractViewModel {

}

0 comments on commit a2f99df

Please sign in to comment.