Skip to content

Commit

Permalink
Completed General Fields Customizer conversion to JavaFX (#4346)
Browse files Browse the repository at this point in the history
* 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
abepolk authored and tobiasdiez committed Sep 25, 2018
1 parent 5dca3b6 commit 2f433d2
Show file tree
Hide file tree
Showing 10 changed files with 252 additions and 192 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
## [Unreleased]

### Changed
- We updated the dialog for setting up general fields.
- URL field formatting is updated. All whitespace chars, located at the beginning/ending of the url, are trimmed automatically
- We changed the behavior of the field formatting dialog such that the `bibtexkey` is not changed when formatting all fields or all text fields.
- We added a "Move file to file directory and rename file" option for simultaneously moving and renaming of document file. [#4166](https://github.com/JabRef/jabref/issues/4166)
Expand Down
175 changes: 0 additions & 175 deletions src/main/java/org/jabref/gui/GenFieldsCustomizer.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ private MenuBar createMenu() {

new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.SETUP_GENERAL_FIELDS, new SetupGeneralFieldsAction(this)),
factory.createMenuItem(StandardActions.SETUP_GENERAL_FIELDS, new SetupGeneralFieldsAction()),
factory.createMenuItem(StandardActions.MANAGE_CUSTOM_IMPORTS, new ManageCustomImportsAction(this)),
factory.createMenuItem(StandardActions.MANAGE_CUSTOM_EXPORTS, new ManageCustomExportsAction(this)),
factory.createMenuItem(StandardActions.MANAGE_EXTERNAL_FILETYPES, new EditExternalFileTypesAction()),
Expand Down
12 changes: 2 additions & 10 deletions src/main/java/org/jabref/gui/actions/SetupGeneralFieldsAction.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
package org.jabref.gui.actions;

import org.jabref.gui.GenFieldsCustomizer;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.customizefields.CustomizeGeneralFieldsDialogView;

public class SetupGeneralFieldsAction extends SimpleCommand {

private final JabRefFrame jabRefFrame;

public SetupGeneralFieldsAction(JabRefFrame jabRefFrame) {
this.jabRefFrame = jabRefFrame;
}

@Override
public void execute() {
GenFieldsCustomizer gf = new GenFieldsCustomizer(jabRefFrame);
gf.setVisible(true);
new CustomizeGeneralFieldsDialogView().show();

}

Expand Down
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>
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();
}

}
Loading

0 comments on commit 2f433d2

Please sign in to comment.