-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
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 7f1c32b
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Siedlerchr c540ff4
fix l10n and error in fxml
Siedlerchr e82abdd
Convert db properties to javafx
Siedlerchr d246d37
fix checkstyle and l10n
Siedlerchr b54535f
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Siedlerchr e9db4bf
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Siedlerchr 06ed9ec
fix package error
Siedlerchr 49e3600
add new fxml
Siedlerchr 872d436
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Siedlerchr 5657fed
Create properties in view Model for SaveOrderConfig
Siedlerchr 466f40f
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Siedlerchr 159c48a
create empty dialog pane for preferences dialog to make root componen…
Siedlerchr 20d6c05
fix checkstyle
Siedlerchr 8db78c2
add missing controller and fix disable property
Siedlerchr f6564f1
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Siedlerchr 760a6c2
remove old save order config display
Siedlerchr 28d3f56
some layout stuff
Siedlerchr 1a05b8f
reduce sizes
Siedlerchr 0cf3c87
add method for changing the radio button texts to save
Siedlerchr 9e9450f
move radio button toggle group back as property
Siedlerchr 028cbc1
store values for sort order radio box
Siedlerchr ad5291f
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Siedlerchr 5ce22f2
move css rule to base.css
Siedlerchr e214240
fix css
Siedlerchr c1707d9
Merge remote-tracking branch 'upstream/master' into libraryproperties…
Siedlerchr 28d46fd
introduce second boolean for export in specified order to reflect tab…
Siedlerchr ab9de54
remove empty line
Siedlerchr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 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,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> |
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
75 changes: 75 additions & 0 deletions
75
src/main/java/org/jabref/gui/SaveOrderConfigDisplayView.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,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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
151
src/main/java/org/jabref/gui/SaveOrderConfigDisplayViewModel.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,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
21
src/main/java/org/jabref/gui/actions/DatabasePropertiesAction.java
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
src/main/java/org/jabref/gui/actions/LibraryPropertiesAction.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,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
|
||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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)