Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert LibraryProperties to JavaFX #4617

Merged
merged 28 commits into from
Mar 9, 2019
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e18d236
[WIP] Convert LibraryProperties to JavaFX
Siedlerchr Jan 26, 2019
7f1c32b
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Siedlerchr Jan 27, 2019
c540ff4
fix l10n and error in fxml
Siedlerchr Jan 27, 2019
e82abdd
Convert db properties to javafx
Siedlerchr Jan 28, 2019
d246d37
fix checkstyle and l10n
Siedlerchr Jan 28, 2019
b54535f
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Siedlerchr Feb 16, 2019
e9db4bf
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Siedlerchr Feb 18, 2019
06ed9ec
fix package error
Siedlerchr Feb 18, 2019
49e3600
add new fxml
Siedlerchr Feb 19, 2019
872d436
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Siedlerchr Feb 19, 2019
5657fed
Create properties in view Model for SaveOrderConfig
Siedlerchr Feb 21, 2019
466f40f
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Siedlerchr Feb 24, 2019
159c48a
create empty dialog pane for preferences dialog to make root componen…
Siedlerchr Feb 24, 2019
20d6c05
fix checkstyle
Siedlerchr Feb 25, 2019
8db78c2
add missing controller and fix disable property
Siedlerchr Feb 27, 2019
f6564f1
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Siedlerchr Mar 1, 2019
760a6c2
remove old save order config display
Siedlerchr Mar 1, 2019
28d3f56
some layout stuff
Siedlerchr Mar 1, 2019
1a05b8f
reduce sizes
Siedlerchr Mar 1, 2019
0cf3c87
add method for changing the radio button texts to save
Siedlerchr Mar 1, 2019
9e9450f
move radio button toggle group back as property
Siedlerchr Mar 2, 2019
028cbc1
store values for sort order radio box
Siedlerchr Mar 3, 2019
ad5291f
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Siedlerchr Mar 8, 2019
5ce22f2
move css rule to base.css
Siedlerchr Mar 8, 2019
e214240
fix css
Siedlerchr Mar 9, 2019
c1707d9
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Siedlerchr Mar 9, 2019
28d46fd
introduce second boolean for export in specified order to reflect tab…
Siedlerchr Mar 9, 2019
ab9de54
remove empty line
Siedlerchr Mar 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@

.separator:horizontal .line {
-fx-border-color: -jr-separator;
-fx-border-width: 0;
-fx-border-width: 0.5;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is no need to have visible separators. Just use normal Labels for these section headings and increase the font-size / make them bold. (I think I have done something similar lately, but cannot remember where - there might be a "heading" class defined in the base.css)

-fx-border-insets: 1 0 0 0;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
import org.jabref.gui.actions.CopyFilesAction;
import org.jabref.gui.actions.CustomizeEntryAction;
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 @@ -849,7 +849,7 @@ private MenuBar createMenu() {

new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new DatabasePropertiesAction(this)),
factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new LibraryPropertiesAction(this, dialogService)),
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
factory.createMenuItem(StandardActions.EDIT_PREAMBLE, new PreambleEditor(this)),
factory.createMenuItem(StandardActions.EDIT_STRINGS, new BibtexStringEditorAction(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 type="javafx.scene.layout.GridPane" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
<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 minHeight="-Infinity" prefHeight="30.0" />
<RowConstraints minHeight="-Infinity" prefHeight="30.0" />
<RowConstraints minHeight="-Infinity" prefHeight="30.0" />
<RowConstraints minHeight="-Infinity" prefHeight="30.0" />
<RowConstraints minHeight="-Infinity" prefHeight="30.0" />
<RowConstraints minHeight="-Infinity" 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" GridPane.columnSpan="3" GridPane.rowIndex="2" toggleGroup="$saveOrderToggleGroup"/>
<RadioButton fx:id="exportInTableOrder" mnemonicParsing="false" text="%Export in current table sort order" GridPane.columnSpan="3" GridPane.rowIndex="1" toggleGroup="$saveOrderToggleGroup"/>
<RadioButton fx:id="exportInOriginalOrder" mnemonicParsing="false" text="%Export entries in their original order" GridPane.columnSpan="3" toggleGroup="$saveOrderToggleGroup"/>
<CheckBox fx:id="savePriDesc" mnemonicParsing="false" text="Descending" GridPane.columnIndex="2" GridPane.rowIndex="3" disabled="${!exportInSpecifiedOrder.selected}"/>
<CheckBox fx:id="saveSecDesc" mnemonicParsing="false" text="Descending" GridPane.columnIndex="2" GridPane.rowIndex="4" disabled="${!exportInSpecifiedOrder.selected}" />
<CheckBox fx:id="saveTerDesc" mnemonicParsing="false" text="Descending" GridPane.columnIndex="2" GridPane.rowIndex="5" disabled="${!exportInSpecifiedOrder.selected}" />
<Label text="Primary sort criterion" GridPane.rowIndex="3" disabled="${!exportInSpecifiedOrder.selected}" />
<Label text="Secondary sort criterion" GridPane.rowIndex="4" disabled="${!exportInSpecifiedOrder.selected}" />
<Label text="Tertiary sort criterion" GridPane.rowIndex="5" disabled="${!exportInSpecifiedOrder.selected}"/>
</children>
</fx:root>
5 changes: 0 additions & 5 deletions src/main/java/org/jabref/gui/SaveOrderConfigDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Font;

import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.BibEntry;
Expand Down Expand Up @@ -49,22 +48,18 @@ private void init() {
saveSecDesc = new CheckBox(Localization.lang("Descending"));
saveTerDesc = new CheckBox(Localization.lang("Descending"));

Font font = new Font(10);
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
GridPane builder = new GridPane();
Label primarySortCriterion = new Label(Localization.lang("Primary sort criterion"));
primarySortCriterion.setFont(font);
builder.add(primarySortCriterion, 1, 1);
builder.add(savePriSort, 2, 1);
builder.add(savePriDesc, 3, 1);

Label secondarySortCriterion = new Label(Localization.lang("Secondary sort criterion"));
secondarySortCriterion.setFont(font);
builder.add(secondarySortCriterion, 1, 2);
builder.add(saveSecSort, 2, 2);
builder.add(saveSecDesc, 3, 2);

Label tertiarySortCriterion = new Label(Localization.lang("Tertiary sort criterion"));
tertiarySortCriterion.setFont(font);
builder.add(tertiarySortCriterion, 1, 3);
builder.add(saveTerSort, 2, 3);
builder.add(saveTerDesc, 3, 3);
Expand Down
75 changes: 75 additions & 0 deletions src/main/java/org/jabref/gui/SaveOrderConfigDisplayView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package org.jabref.gui;

import javax.inject.Inject;

import javafx.fxml.FXML;
import javafx.scene.Node;
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.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)
.controller(this)
Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove controller(this) statement as this is not required

.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 storeConfig() {
viewModel.storeConfig();
}

public Node getJFXPanel() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method seems really unnecessary

return this;
}
}
151 changes: 151 additions & 0 deletions src/main/java/org/jabref/gui/SaveOrderConfigDisplayViewModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
package org.jabref.gui;

import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Objects;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;

import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.InternalBibtexFields;
import org.jabref.model.metadata.SaveOrderConfig;
import org.jabref.model.metadata.SaveOrderConfig.SortCriterion;
import org.jabref.preferences.PreferencesService;

public class SaveOrderConfigDisplayViewModel {

private final ListProperty<String> priSortFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
private final ListProperty<String> secSortFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
private final ListProperty<String> terSortFieldsProperty = new SimpleListProperty<>(FXCollections.observableArrayList());

private final BooleanProperty savePriDescPropertySelected = new SimpleBooleanProperty();
private final BooleanProperty saveSecDescPropertySelected = new SimpleBooleanProperty();
private final BooleanProperty saveTerDescPropertySelected = new SimpleBooleanProperty();

private final StringProperty savePriSortSelectedValueProperty = new SimpleStringProperty("");
private final StringProperty saveSecSortSelectedValueProperty = new SimpleStringProperty("");
private final StringProperty saveTerSortSelectedValueProperty = new SimpleStringProperty("");

private final BooleanProperty saveInOriginalProperty = new SimpleBooleanProperty();
private final BooleanProperty saveInTableOrderProperty = new SimpleBooleanProperty();
private final BooleanProperty saveInSpecifiedOrderProperty = new SimpleBooleanProperty();

private final SaveOrderConfig config;
private final PreferencesService prefs;

public SaveOrderConfigDisplayViewModel(SaveOrderConfig config, PreferencesService prefs) {
this.config = config;
this.prefs = prefs;

SaveOrderConfig storedSaveOrderConfig = config;
List<String> fieldNames = InternalBibtexFields.getAllPublicFieldNames();
fieldNames.add(BibEntry.KEY_FIELD);
Collections.sort(fieldNames);

priSortFieldsProperty.addAll(fieldNames);
secSortFieldsProperty.addAll(fieldNames);
terSortFieldsProperty.addAll(fieldNames);

if (config.saveInOriginalOrder()) {
saveInOriginalProperty.setValue(true);
} else if (config.saveInSpecifiedOrder()) {
saveInSpecifiedOrderProperty.setValue(true);
} else {
saveInTableOrderProperty.setValue(true);
}
setSaveOrderConfig(config);

}

public ListProperty<String> priSortFieldsProperty() {
return priSortFieldsProperty;
}

public ListProperty<String> secSortFieldsProperty() {
return secSortFieldsProperty;
}

public ListProperty<String> terSortFieldsProperty() {
return terSortFieldsProperty;
}

public SaveOrderConfig getSaveOrderConfig() {

SortCriterion primary = new SortCriterion(getSelectedItemAsLowerCaseTrim(savePriSortSelectedValueProperty), savePriDescPropertySelected.getValue());
SortCriterion secondary = new SortCriterion(getSelectedItemAsLowerCaseTrim(saveSecSortSelectedValueProperty), saveSecDescPropertySelected.getValue());
SortCriterion tertiary = new SortCriterion(getSelectedItemAsLowerCaseTrim(saveTerSortSelectedValueProperty), saveTerDescPropertySelected.getValue());

SaveOrderConfig saveOrderConfig = new SaveOrderConfig(saveInOriginalProperty.getValue(), primary, secondary, tertiary);

return saveOrderConfig;
}

public void setSaveOrderConfig(SaveOrderConfig saveOrderConfig) {
Objects.requireNonNull(saveOrderConfig);

savePriSortSelectedValueProperty.setValue(saveOrderConfig.getSortCriteria().get(0).field);
savePriDescPropertySelected.setValue(saveOrderConfig.getSortCriteria().get(0).descending);
saveSecSortSelectedValueProperty.setValue(saveOrderConfig.getSortCriteria().get(1).field);
saveSecDescPropertySelected.setValue(saveOrderConfig.getSortCriteria().get(1).descending);
saveTerSortSelectedValueProperty.setValue(saveOrderConfig.getSortCriteria().get(2).field);
saveTerDescPropertySelected.setValue(saveOrderConfig.getSortCriteria().get(2).descending);

if (saveInOriginalProperty.getValue()) {
saveOrderConfig.setSaveInOriginalOrder();
} else {
saveOrderConfig.setSaveInSpecifiedOrder();
}
}

private String getSelectedItemAsLowerCaseTrim(StringProperty string) {
return string.getValue().toLowerCase(Locale.ROOT).trim();
}

public BooleanProperty savePriDescPropertySelected() {
return savePriDescPropertySelected;
}

public BooleanProperty saveSecDescPropertySelected() {
return saveSecDescPropertySelected;
}

public BooleanProperty saveTerDescPropertySelected() {
return saveTerDescPropertySelected;
}

public StringProperty savePriSortSelectedValueProperty() {
return savePriSortSelectedValueProperty;
}

public StringProperty saveSecSortSelectedValueProperty() {
return saveSecSortSelectedValueProperty;
}

public StringProperty saveTerSortSelectedValueProperty() {
return saveTerSortSelectedValueProperty;
}

public void storeConfig() {
prefs.storeExportSaveOrder(this.getSaveOrderConfig());
}

public BooleanProperty saveInOriginalProperty() {
return saveInOriginalProperty;
}

public BooleanProperty saveInTableOrderProperty() {
return saveInTableOrderProperty;
}

public BooleanProperty saveInSpecifiedOrderProperty() {
return this.saveInSpecifiedOrderProperty;
}

}
21 changes: 0 additions & 21 deletions src/main/java/org/jabref/gui/actions/DatabasePropertiesAction.java

This file was deleted.

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

import org.jabref.gui.DialogService;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.libraryproperties.LibraryPropertiesDialogView;

public class LibraryPropertiesAction extends SimpleCommand {

private final JabRefFrame frame;
private final DialogService dialogService;

public LibraryPropertiesAction(JabRefFrame frame, DialogService dialogService) {
this.frame = frame;
this.dialogService = dialogService;
}

@Override
public void execute() {
LibraryPropertiesDialogView propertiesDialog = new LibraryPropertiesDialogView(frame.getCurrentBasePanel(), dialogService);
propertiesDialog.showAndWait();

Siedlerchr marked this conversation as resolved.
Show resolved Hide resolved
}

}
Loading