-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Completed General Fields Customizer conversion to JavaFX (#4346)
* temp commit 09 06 18 * starting work on converting Customize General Fields dialog from Swing to JavaFX * More work on converting JavaFX dialog * Even more work on converting JavaFX dialog * more work JavaFX * Further work, now cannot load * Cleaned up comments * create newlines at ends of files * fix missing ids change bidirectional binding use string property * Fix default and help * Got the dialog running, but it is not saving * Removed _def * fix bug * Reformat customize general fields dialog as JavaFX * Small code fixes * make fxml support multiple languages * minor code fixes * added javadoc * change class name and code fix * Add English localization * remove old Swing dialog * comment fix * English localization change * fix indentation * remove cancelButton from controller
- Loading branch information
1 parent
5dca3b6
commit 2f433d2
Showing
10 changed files
with
252 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 2 additions & 10 deletions
12
src/main/java/org/jabref/gui/actions/SetupGeneralFieldsAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/org/jabref/gui/customizefields/CustomizeGeneralFieldsDialog.fxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.ButtonType?> | ||
<?import javafx.scene.control.DialogPane?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.control.TextArea?> | ||
<?import javafx.scene.layout.VBox?> | ||
<DialogPane xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" | ||
fx:controller="org.jabref.gui.customizefields.CustomizeGeneralFieldsDialogView"> | ||
<content> | ||
<VBox prefHeight="300.0" prefWidth="650.0"> | ||
<children> | ||
<Label text="%General Fields" /> | ||
<Label text="%Create custom fields for each BibTeX entry" /> | ||
<TextArea fx:id="fieldsTextArea" minHeight="200.0" minWidth="628.0" /> | ||
<Label text="%Format: Tab:field;field;... (e.g. General:url;pdf;note...)" /> | ||
</children> | ||
</VBox> | ||
</content> | ||
<ButtonType fx:id="okButton" fx:constant="OK" /> | ||
<ButtonType fx:id="resetButton" buttonData="LEFT" text="%Default" /> | ||
<ButtonType fx:id="helpButton" text="%Help" /> | ||
<ButtonType fx:constant="CANCEL" /> | ||
</DialogPane> |
71 changes: 71 additions & 0 deletions
71
src/main/java/org/jabref/gui/customizefields/CustomizeGeneralFieldsDialogView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.jabref.gui.customizefields; | ||
|
||
import javax.inject.Inject; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.control.ButtonType; | ||
import javafx.scene.control.TextArea; | ||
|
||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.help.HelpAction; | ||
import org.jabref.gui.util.BaseDialog; | ||
import org.jabref.gui.util.ControlHelper; | ||
import org.jabref.logic.help.HelpFile; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.preferences.PreferencesService; | ||
|
||
import com.airhacks.afterburner.views.ViewLoader; | ||
|
||
public class CustomizeGeneralFieldsDialogView extends BaseDialog<Void> { | ||
|
||
@FXML private ButtonType resetButton; | ||
@FXML private ButtonType helpButton; | ||
@FXML private ButtonType okButton; | ||
@FXML private TextArea fieldsTextArea; | ||
|
||
@Inject private DialogService dialogService; | ||
@Inject private PreferencesService preferences; | ||
private CustomizeGeneralFieldsDialogViewModel viewModel; | ||
|
||
public CustomizeGeneralFieldsDialogView() { | ||
this.setTitle(Localization.lang("Set General Fields")); | ||
this.setResizable(true); | ||
this.getDialogPane().setPrefSize(300, 650); | ||
|
||
ViewLoader.view(this) | ||
.load() | ||
.setAsDialogPane(this); | ||
|
||
HelpAction helpCommand = new HelpAction(HelpFile.GENERAL_FIELDS); | ||
//HelpAction is written with Swing, not JavaFX, so runCommand() cannot be used normally. Here I am reaching into | ||
//the command and running execute. When HelpAction is converted to JavaFX, | ||
//the following will need to be changed. | ||
ControlHelper.setAction(helpButton, getDialogPane(), event -> helpCommand.getCommand().execute()); | ||
ControlHelper.setAction(resetButton, getDialogPane(), event -> resetFields()); | ||
ControlHelper.setAction(okButton, getDialogPane(), event -> saveFieldsAndCloseDialog()); | ||
|
||
} | ||
|
||
@FXML | ||
private void initialize() { | ||
viewModel = new CustomizeGeneralFieldsDialogViewModel(dialogService, preferences); | ||
fieldsTextArea.textProperty().bindBidirectional(viewModel.fieldsTextProperty()); | ||
|
||
} | ||
|
||
@FXML | ||
private void closeDialog() { | ||
close(); | ||
} | ||
|
||
@FXML | ||
private void saveFieldsAndCloseDialog() { | ||
viewModel.saveFields(); | ||
closeDialog(); | ||
} | ||
|
||
private void resetFields() { | ||
viewModel.resetFields(); | ||
} | ||
|
||
} |
Oops, something went wrong.