Skip to content

Commit

Permalink
Fix for issue 3861 : Preferences Dialog to javafx (#4253)
Browse files Browse the repository at this point in the history
* Convert swing dialog to JavaFx

* convert the swing dialog to javafx

* Change the code style to meet the standard

* Update CHANGELOG.md

* Update SaveOrderConfigDisplay.java

* Merge the latest commits

* Merge the latest commits

* merge the latest commits

* Polish the code style

* resolve the conficts

* polish the code style

* reslove the conflicts

* resolve the conflict

* Change the CHANGELOG.md

* polish the code style

* polish the code style

* Modify the code to make test-suite pass

* polish the code style

* Beautify the option panes

* Polish the code style

* Merge the latest commits

* merge the latest commits

* Merge the latest commits

* Polish the code style

* Polish the code style

* Polish the code style

* Polish the code style

* Beautify the dialog

* Simplify the long method in PreferencesDialog.java

* Polish the code style

* Polish the code style

* Merge the latest commits

* Change Integer.parseInt to Double.parseDouble

* Change the font size of several labels

* fix a bug regarding the storeing of settings

* fix the code style

* Fix NullPointerException in settings for External Applications

* Polish code style

* Add a row

* Fix NullPointerException in settings for External Application

* push again to make test pass

* Push again to make test pass

* push again to make test pass

* Push again to make test pass

* Push again to make test pass

* Update JabRefGUI.java

* Update JabRefGUI.java

* correct the wrong label name in settings for external Application

* remove the duplicates and cleanup the code

* remove unused imports

* remove the duplicates in SaveOrderConfigDisplay.java

* remove the unused imports in SaveOrderConfigDisplay.java

* Change the return type to Interface Type

* Change to lambda expression

* cleanup the code

* Merge latest commits

* remove the Swing contron in BibtexKeyPatternPanel

* Code style :(
  • Loading branch information
Super-Tang authored and tobiasdiez committed Aug 19, 2018
1 parent db881c0 commit 6e27922
Show file tree
Hide file tree
Showing 40 changed files with 2,087 additions and 2,575 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,4 @@ The changelog of JabRef 2.11 and all previous versions is available as [text fil
[4.0-beta]: https://github.com/JabRef/jabref/compare/v3.8.2...v4.0-beta
[2.11.1]: https://github.com/JabRef/jabref/compare/v2.11...v2.11.1
[JavaFX]: https://en.wikipedia.org/wiki/JavaFX

26 changes: 13 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,12 @@ dependencyUpdates.resolutionStrategy = {
}
rules.withModule("org.controlsfx:controlsfx") { ComponentSelection selection ->
if (selection.candidate.version ==~ /9.*/) { // Reject version 9 or higher
selection.reject("Cannot be updated to 9.*.* until Jabref works with Java 9")
selection.reject("Cannot be updated to 9.*.* until Jabref works with Java 9")
}
}
rules.withModule("com.github.tomtung:latex2unicode_2.12") { ComponentSelection selection ->
if (selection.candidate.version ==~ /0.2.2/) { // Reject version higher than 2.0.2
selection.reject("Cannot be updated to 0.2.4 until JabRef is prepared for it")
selection.reject("Cannot be updated to 0.2.4 until JabRef is prepared for it")
}
}
rules.withModule("de.jensd:fontawesomefx-materialdesignfont") { ComponentSelection selection ->
Expand Down Expand Up @@ -505,16 +505,16 @@ jmh {

// Source: https://stackoverflow.com/a/44168582/873282
task downloadDependencies {
description "Pre-downloads *most* dependencies"
doLast {
configurations.getAsMap().each { name, config ->
println "Retrieving dependencies for $name"
try {
config.files
} catch (e) {
// some cannot be resolved, just log them
project.logger.info e.message
}
description "Pre-downloads *most* dependencies"
doLast {
configurations.getAsMap().each { name, config ->
println "Retrieving dependencies for $name"
try {
config.files
} catch (e) {
// some cannot be resolved, just log them
project.logger.info e.message
}
}
}
}
}
20 changes: 10 additions & 10 deletions src/main/java/org/jabref/JabRefGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public JabRefGUI(Stage mainStage, List<ParserResult> argsDatabases, boolean isBl

// passed file (we take the first one) should be focused
focusedFile = argsDatabases.stream()
.findFirst()
.flatMap(ParserResult::getFile)
.map(File::getAbsolutePath)
.orElse(Globals.prefs.get(JabRefPreferences.LAST_FOCUSED));
.findFirst()
.flatMap(ParserResult::getFile)
.map(File::getAbsolutePath)
.orElse(Globals.prefs.get(JabRefPreferences.LAST_FOCUSED));

openWindow(mainStage);
JabRefGUI.checkForNewVersion(false);
Expand Down Expand Up @@ -109,15 +109,15 @@ private void openWindow(Stage mainStage) {
try {
new SharedDatabaseUIManager(mainFrame).openSharedDatabaseFromParserResult(pr);
} catch (SQLException | DatabaseNotSupportedException | InvalidDBMSConnectionPropertiesException |
NotASharedDatabaseException e) {
NotASharedDatabaseException e) {
pr.getDatabaseContext().clearDatabaseFile(); // do not open the original file
pr.getDatabase().clearSharedDatabaseID();

LOGGER.error("Connection error", e);
dialogService.showErrorDialogAndWait(
Localization.lang("Connection error"),
Localization.lang("A local copy will be opened."),
e);
Localization.lang("Connection error"),
Localization.lang("A local copy will be opened."),
e);
}
toOpenTab.add(pr);
} else if (pr.toOpenTab()) {
Expand Down Expand Up @@ -166,7 +166,7 @@ private void openWindow(Stage mainStage) {

for (ParserResult pr : failed) {
String message = Localization.lang("Error opening file '%0'.", pr.getFile().get().getName()) + "\n"
+ pr.getErrorMessage();
+ pr.getErrorMessage();

dialogService.showErrorDialogAndWait(Localization.lang("Error opening file"), message);

Expand Down Expand Up @@ -223,7 +223,7 @@ private void openLastEditedDatabases() {
}

ParserResult parsedDatabase = OpenDatabase.loadDatabase(fileName,
Globals.prefs.getImportFormatPreferences(), Globals.getFileUpdateMonitor());
Globals.prefs.getImportFormatPreferences(), Globals.getFileUpdateMonitor());

if (parsedDatabase.isEmpty()) {
LOGGER.error(Localization.lang("Error opening file") + " '" + dbFile.getPath() + "'");
Expand Down
82 changes: 41 additions & 41 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -396,33 +396,33 @@ private void setupActions() {
actions.put(Actions.REPLACE_ALL, ()-> (new ReplaceStringAction(this)).execute());

actions.put(new SpecialFieldValueViewModel(SpecialField.RELEVANCE.getValues().get(0)).getCommand(),
new SpecialFieldViewModel(SpecialField.RELEVANCE, undoManager).getSpecialFieldAction(SpecialField.RELEVANCE.getValues().get(0), frame));
new SpecialFieldViewModel(SpecialField.RELEVANCE, undoManager).getSpecialFieldAction(SpecialField.RELEVANCE.getValues().get(0), frame));

actions.put(new SpecialFieldValueViewModel(SpecialField.QUALITY.getValues().get(0)).getCommand(),
new SpecialFieldViewModel(SpecialField.QUALITY, undoManager).getSpecialFieldAction(SpecialField.QUALITY.getValues().get(0), frame));
new SpecialFieldViewModel(SpecialField.QUALITY, undoManager).getSpecialFieldAction(SpecialField.QUALITY.getValues().get(0), frame));

actions.put(new SpecialFieldValueViewModel(SpecialField.PRINTED.getValues().get(0)).getCommand(),
new SpecialFieldViewModel(SpecialField.PRINTED, undoManager).getSpecialFieldAction(SpecialField.PRINTED.getValues().get(0), frame));
new SpecialFieldViewModel(SpecialField.PRINTED, undoManager).getSpecialFieldAction(SpecialField.PRINTED.getValues().get(0), frame));

for (SpecialFieldValue prio : SpecialField.PRIORITY.getValues()) {
actions.put(new SpecialFieldValueViewModel(prio).getCommand(),
new SpecialFieldViewModel(SpecialField.PRIORITY, undoManager).getSpecialFieldAction(prio, this.frame));
new SpecialFieldViewModel(SpecialField.PRIORITY, undoManager).getSpecialFieldAction(prio, this.frame));
}
for (SpecialFieldValue rank : SpecialField.RANKING.getValues()) {
actions.put(new SpecialFieldValueViewModel(rank).getCommand(),
new SpecialFieldViewModel(SpecialField.RANKING, undoManager).getSpecialFieldAction(rank, this.frame));
new SpecialFieldViewModel(SpecialField.RANKING, undoManager).getSpecialFieldAction(rank, this.frame));
}
for (SpecialFieldValue status : SpecialField.READ_STATUS.getValues()) {
actions.put(new SpecialFieldValueViewModel(status).getCommand(),
new SpecialFieldViewModel(SpecialField.READ_STATUS, undoManager).getSpecialFieldAction(status, this.frame));
new SpecialFieldViewModel(SpecialField.READ_STATUS, undoManager).getSpecialFieldAction(status, this.frame));
}

actions.put(Actions.TOGGLE_PREVIEW, () -> {
PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences();
boolean enabled = !previewPreferences.isPreviewPanelEnabled();
PreviewPreferences newPreviewPreferences = previewPreferences.getBuilder()
.withPreviewPanelEnabled(enabled)
.build();
.withPreviewPanelEnabled(enabled)
.build();
Globals.prefs.storePreviewPreferences(newPreviewPreferences);
DefaultTaskExecutor.runInJavaFXThread(() -> setPreviewActiveBasePanels(enabled));
});
Expand Down Expand Up @@ -516,9 +516,9 @@ private void copyTitle() {
if (!selectedBibEntries.isEmpty()) {
// Collect all non-null titles.
List<String> titles = selectedBibEntries.stream()
.filter(bibEntry -> bibEntry.getTitle().isPresent())
.map(bibEntry -> bibEntry.getTitle().get())
.collect(Collectors.toList());
.filter(bibEntry -> bibEntry.getTitle().isPresent())
.map(bibEntry -> bibEntry.getTitle().get())
.collect(Collectors.toList());

if (titles.isEmpty()) {
output(Localization.lang("None of the selected entries have titles."));
Expand Down Expand Up @@ -550,8 +550,8 @@ private void copyCiteKey() {

String sb = String.join(",", keys);
String citeCommand = Optional.ofNullable(Globals.prefs.get(JabRefPreferences.CITE_COMMAND))
.filter(cite -> cite.contains("\\")) // must contain \
.orElse("\\cite");
.filter(cite -> cite.contains("\\")) // must contain \
.orElse("\\cite");
Globals.clipboardManager.setContent(citeCommand + "{" + sb + '}');

if (keys.size() == bes.size()) {
Expand Down Expand Up @@ -595,7 +595,7 @@ private void copyKeyAndTitle() {
Layout layout;
try {
layout = new LayoutHelper(sr, Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader))
.getLayoutFromText();
.getLayoutFromText();
} catch (IOException e) {
LOGGER.info("Could not get layout", e);
return;
Expand Down Expand Up @@ -685,7 +685,7 @@ private boolean saveDatabase(File file, boolean selectedOnly, Charset encoding,
final String SAVE_DATABASE = Localization.lang("Save library");
try {
SavePreferences prefs = Globals.prefs.loadForSaveFromPreferences()
.withEncoding(encoding)
.withEncoding(encoding)
.withSaveType(saveType);
BibtexDatabaseWriter<SaveSession> databaseWriter = new BibtexDatabaseWriter<>(
FileSaveSession::new);
Expand Down Expand Up @@ -718,7 +718,7 @@ private boolean saveDatabase(File file, boolean selectedOnly, Charset encoding,
boolean commit = true;
if (!session.getWriter().couldEncodeAll()) {
FormBuilder builder = FormBuilder.create()
.layout(new FormLayout("left:pref, 4dlu, fill:pref", "pref, 4dlu, pref"));
.layout(new FormLayout("left:pref, 4dlu, fill:pref", "pref, 4dlu, pref"));
JTextArea ta = new JTextArea(session.getWriter().getProblemCharacters());
ta.setEditable(false);
builder.add(Localization.lang("The chosen encoding '%0' could not encode the following characters:", session.getEncoding().displayName())).xy(1, 1);
Expand Down Expand Up @@ -867,12 +867,12 @@ private void createMainTable() {

// Update entry editor and preview according to selected entries
mainTable.addSelectionListener(event -> mainTable.getSelectedEntries()
.stream()
.findFirst()
.ifPresent(entry -> {
preview.setEntry(entry);
entryEditor.setEntry(entry);
}));
.stream()
.findFirst()
.ifPresent(entry -> {
preview.setEntry(entry);
entryEditor.setEntry(entry);
}));

// TODO: Register these actions globally
/*
Expand Down Expand Up @@ -962,8 +962,8 @@ public void setupMainPanel() {
// Saves the divider position as soon as it changes
// We need to keep a reference to the subscription, otherwise the binding gets garbage collected
dividerPositionSubscription = EasyBind.monadic(Bindings.valueAt(splitPane.getDividers(), 0))
.flatMap(SplitPane.Divider::positionProperty)
.subscribe((observable, oldValue, newValue) -> saveDividerLocation(newValue));
.flatMap(SplitPane.Divider::positionProperty)
.subscribe((observable, oldValue, newValue) -> saveDividerLocation(newValue));
}

/**
Expand Down Expand Up @@ -1093,9 +1093,9 @@ public void previousPreviewStyle() {

private void cyclePreview(int newPosition) {
PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences()
.getBuilder()
.withPreviewCyclePosition(newPosition)
.build();
.getBuilder()
.withPreviewCyclePosition(newPosition)
.build();
Globals.prefs.storePreviewPreferences(previewPreferences);

preview.updateLayout(previewPreferences);
Expand Down Expand Up @@ -1259,11 +1259,11 @@ public boolean showDeleteConfirmationDialog(int numberOfEntries) {
}

return dialogService.showConfirmationDialogWithOptOutAndWait(title,
message,
okButton,
cancelButton,
Localization.lang("Disable this confirmation dialog"),
optOut -> Globals.prefs.putBoolean(JabRefPreferences.CONFIRM_DELETE, !optOut));
message,
okButton,
cancelButton,
Localization.lang("Disable this confirmation dialog"),
optOut -> Globals.prefs.putBoolean(JabRefPreferences.CONFIRM_DELETE, !optOut));
} else {
return true;
}
Expand Down Expand Up @@ -1303,9 +1303,9 @@ private void saveDividerLocation(Number position) {

if (mode == BasePanelMode.SHOWING_PREVIEW) {
PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences()
.getBuilder()
.withPreviewPanelDividerPosition(position)
.build();
.getBuilder()
.withPreviewPanelDividerPosition(position)
.build();
Globals.prefs.storePreviewPreferences(previewPreferences);
} else if (mode == BasePanelMode.SHOWING_EDITOR) {
preferences.setEntryEditorDividerPosition(position.doubleValue());
Expand Down Expand Up @@ -1600,18 +1600,18 @@ public void action() {
List<LinkedFile> files = bes.get(0).getFiles();

Optional<LinkedFile> linkedFile = files.stream()
.filter(file -> (FieldName.URL.equalsIgnoreCase(file.getFileType())
|| FieldName.PS.equalsIgnoreCase(file.getFileType())
|| FieldName.PDF.equalsIgnoreCase(file.getFileType())))
.findFirst();
.filter(file -> (FieldName.URL.equalsIgnoreCase(file.getFileType())
|| FieldName.PS.equalsIgnoreCase(file.getFileType())
|| FieldName.PDF.equalsIgnoreCase(file.getFileType())))
.findFirst();

if (linkedFile.isPresent()) {

try {

JabRefDesktop.openExternalFileAnyFormat(bibDatabaseContext,
linkedFile.get().getLink(),
ExternalFileTypes.getInstance().fromLinkedFile(linkedFile.get(), true));
linkedFile.get().getLink(),
ExternalFileTypes.getInstance().fromLinkedFile(linkedFile.get(), true));

output(Localization.lang("External viewer called") + '.');
} catch (IOException e) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/ReplaceString.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<TextField fx:id="replaceField" GridPane.columnIndex="1" GridPane.rowIndex="2"
GridPane.columnSpan="4"/>
<CheckBox fx:id="selectFieldOnly" GridPane.columnIndex="0" GridPane.rowIndex="4" GridPane.columnSpan="2"
text="%Limit to Selected Entries"/>
text="%Limit to Selected Entries"/>
<RadioButton fx:id="allReplace" GridPane.columnIndex="0" GridPane.rowIndex="5" GridPane.columnSpan="2"
selected="true" text="%All Field Replace">
<toggleGroup>
Expand Down
Loading

0 comments on commit 6e27922

Please sign in to comment.