Skip to content

Commit

Permalink
Merge pull request #4617 from JabRef/librarypropertiestofx
Browse files Browse the repository at this point in the history
Convert LibraryProperties to JavaFX
  • Loading branch information
Siedlerchr authored Mar 9, 2019
2 parents f9a5575 + ab9de54 commit e16d115
Show file tree
Hide file tree
Showing 22 changed files with 732 additions and 573 deletions.
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -1027,3 +1027,8 @@ We want to have a look that matches our icons in the tool-bar */
.tooltip-error {
-fx-background-color: -jr-error;
}

.sectionHeader {
-fx-font-size: 1.5em;
-fx-padding: 1em 0em 1em 0em;
}
7 changes: 3 additions & 4 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
import org.jabref.gui.actions.ConnectToSharedDatabaseCommand;
import org.jabref.gui.actions.CopyFilesAction;
import org.jabref.gui.actions.CustomizeKeyBindingAction;
import org.jabref.gui.actions.DatabasePropertiesAction;
import org.jabref.gui.actions.EditExternalFileTypesAction;
import org.jabref.gui.actions.ErrorConsoleAction;
import org.jabref.gui.actions.LibraryPropertiesAction;
import org.jabref.gui.actions.LookupIdentifierAction;
import org.jabref.gui.actions.ManageContentSelectorAction;
import org.jabref.gui.actions.ManageCustomExportsAction;
Expand Down Expand Up @@ -818,15 +818,15 @@ private MenuBar createMenu() {
edit.getItems().add(new SeparatorMenuItem());
}
}

//@formatter:off
library.getItems().addAll(
factory.createMenuItem(StandardActions.NEW_ENTRY, new NewEntryAction(this, dialogService, Globals.prefs)),
factory.createMenuItem(StandardActions.NEW_ENTRY_FROM_PLAINTEX, new NewEntryFromPlainTextAction(this, Globals.prefs.getUpdateFieldPreferences(), dialogService, Globals.prefs)),
factory.createMenuItem(StandardActions.DELETE_ENTRY, new OldDatabaseCommandWrapper(Actions.DELETE, this, Globals.stateManager)),

new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new DatabasePropertiesAction(this)),
factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new LibraryPropertiesAction(this, dialogService)),
factory.createMenuItem(StandardActions.EDIT_PREAMBLE, new PreambleEditor(this)),
factory.createMenuItem(StandardActions.EDIT_STRINGS, new BibtexStringEditorAction(this)),
factory.createMenuItem(StandardActions.MASS_SET_FIELDS, new MassSetFieldsAction(this))
Expand All @@ -838,7 +838,6 @@ private MenuBar createMenu() {
lookupIdentifiers.getItems().add(factory.createMenuItem(identifierAction.getAction(), identifierAction));
}

//@formatter:off
quality.getItems().addAll(
factory.createMenuItem(StandardActions.FIND_DUPLICATES, new DuplicateSearch(this, dialogService)),
factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(this)),
Expand Down
43 changes: 43 additions & 0 deletions src/main/java/org/jabref/gui/SaveOrderConfigDisplay.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>

<fx:root prefHeight="200.0" prefWidth="600.0" type="javafx.scene.layout.GridPane" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.jabref.gui.SaveOrderConfigDisplayView">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="-Infinity" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints prefHeight="30.0" />
<RowConstraints prefHeight="30.0" />
<RowConstraints prefHeight="30.0" />
<RowConstraints prefHeight="30.0" />
<RowConstraints prefHeight="30.0" />
<RowConstraints prefHeight="30.0" />
</rowConstraints>
<fx:define>
<ToggleGroup fx:id="saveOrderToggleGroup" />
</fx:define>
<children>
<ComboBox fx:id="savePriSort" editable="true" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<ComboBox fx:id="saveSecSort" editable="true" GridPane.columnIndex="1" GridPane.rowIndex="4" />
<ComboBox fx:id="saveTerSort" editable="true" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<RadioButton fx:id="exportInSpecifiedOrder" mnemonicParsing="false" prefHeight="5.0" prefWidth="206.0" text="%Export entries ordered as specified" toggleGroup="$saveOrderToggleGroup" GridPane.columnSpan="3" GridPane.rowIndex="2" />
<RadioButton fx:id="exportInTableOrder" mnemonicParsing="false" text="%Export in current table sort order" toggleGroup="$saveOrderToggleGroup" GridPane.columnSpan="3" GridPane.rowIndex="1" />
<RadioButton fx:id="exportInOriginalOrder" mnemonicParsing="false" text="%Export entries in their original order" toggleGroup="$saveOrderToggleGroup" GridPane.columnSpan="3" />
<CheckBox fx:id="savePriDesc" disable="${!exportInSpecifiedOrder.selected}" mnemonicParsing="false" text="%Descending" GridPane.columnIndex="2" GridPane.rowIndex="3" />
<CheckBox fx:id="saveSecDesc" disable="${!exportInSpecifiedOrder.selected}" mnemonicParsing="false" text="%Descending" GridPane.columnIndex="2" GridPane.rowIndex="4" />
<CheckBox fx:id="saveTerDesc" disable="${!exportInSpecifiedOrder.selected}" mnemonicParsing="false" text="%Descending" GridPane.columnIndex="2" GridPane.rowIndex="5" />
<Label disabled="${!exportInSpecifiedOrder.selected}" text="%Primary sort criterion" GridPane.rowIndex="3" />
<Label disabled="${!exportInSpecifiedOrder.selected}" text="%Secondary sort criterion" GridPane.rowIndex="4" />
<Label disabled="${!exportInSpecifiedOrder.selected}" text="%Tertiary sort criterion" GridPane.rowIndex="5" />
</children>
</fx:root>
113 changes: 0 additions & 113 deletions src/main/java/org/jabref/gui/SaveOrderConfigDisplay.java

This file was deleted.

81 changes: 81 additions & 0 deletions src/main/java/org/jabref/gui/SaveOrderConfigDisplayView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package org.jabref.gui;

import javax.inject.Inject;

import javafx.fxml.FXML;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;

import org.jabref.logic.l10n.Localization;
import org.jabref.model.metadata.SaveOrderConfig;
import org.jabref.preferences.PreferencesService;

import com.airhacks.afterburner.views.ViewLoader;

public class SaveOrderConfigDisplayView extends GridPane {

private final SaveOrderConfig config;

@FXML private ToggleGroup saveOrderToggleGroup;
@FXML private ComboBox<String> savePriSort;
@FXML private ComboBox<String> saveSecSort;
@FXML private ComboBox<String> saveTerSort;
@FXML private RadioButton exportInSpecifiedOrder;
@FXML private RadioButton exportInTableOrder;
@FXML private RadioButton exportInOriginalOrder;
@FXML private CheckBox savePriDesc;
@FXML private CheckBox saveSecDesc;
@FXML private CheckBox saveTerDesc;
@Inject private PreferencesService preferencesService;

private SaveOrderConfigDisplayViewModel viewModel;

public SaveOrderConfigDisplayView(SaveOrderConfig config) {
this.config = config;

ViewLoader.view(this)
.root(this)
.load();
}

@FXML
private void initialize() {

viewModel = new SaveOrderConfigDisplayViewModel(config, preferencesService);

exportInSpecifiedOrder.selectedProperty().bindBidirectional(viewModel.saveInSpecifiedOrderProperty());
exportInTableOrder.selectedProperty().bindBidirectional(viewModel.saveInTableOrderProperty());
exportInOriginalOrder.selectedProperty().bindBidirectional(viewModel.saveInOriginalProperty());

savePriSort.itemsProperty().bindBidirectional(viewModel.priSortFieldsProperty());
saveSecSort.itemsProperty().bindBidirectional(viewModel.secSortFieldsProperty());
saveTerSort.itemsProperty().bindBidirectional(viewModel.terSortFieldsProperty());

savePriSort.valueProperty().bindBidirectional(viewModel.savePriSortSelectedValueProperty());
saveSecSort.valueProperty().bindBidirectional(viewModel.saveSecSortSelectedValueProperty());
saveTerSort.valueProperty().bindBidirectional(viewModel.saveTerSortSelectedValueProperty());

savePriDesc.selectedProperty().bindBidirectional(viewModel.savePriDescPropertySelected());
saveSecDesc.selectedProperty().bindBidirectional(viewModel.saveSecDescPropertySelected());
saveTerDesc.selectedProperty().bindBidirectional(viewModel.saveTerDescPropertySelected());

}

public void changeExportDescriptionToSave() {
exportInOriginalOrder.setText(Localization.lang("Save entries in their original order"));
exportInSpecifiedOrder.setText(Localization.lang("Save entries ordered as specified"));
exportInTableOrder.setText(Localization.lang("Save in current table sort order"));
}

public void storeConfig() {
viewModel.storeConfigInPrefs();
}

public SaveOrderConfig getSaveOrderConfig() {
return viewModel.getSaveOrderConfig();
}

}
Loading

0 comments on commit e16d115

Please sign in to comment.