From 856c170f2ed4b6eb72907c372e239c32e7fe13f6 Mon Sep 17 00:00:00 2001 From: Ali Date: Tue, 9 Apr 2019 09:01:07 +0300 Subject: [PATCH 1/8] #4795 disable menu item if database not connected (#4828) * #4795 disable menu item if database not connected * resolve merge conflict * resolve merge conflict * resolve merge conflicts * resolve check style * fix import order * resolve merge * delete duplicate code * change push to application implementation * fix check style * delete action * put deprecated annotation on OldDatabaseCommandWrapper --- src/main/java/org/jabref/gui/JabRefFrame.java | 11 +-- .../actions/OldDatabaseCommandWrapper.java | 3 + .../gui/push/PushToApplicationAction.java | 68 +++++++++++--- .../gui/push/PushToApplicationButton.java | 90 ------------------- 4 files changed, 63 insertions(+), 109 deletions(-) delete mode 100644 src/main/java/org/jabref/gui/push/PushToApplicationButton.java diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 214530e363e..abc4abf83a2 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -100,7 +100,7 @@ import org.jabref.gui.metadata.BibtexStringEditorAction; import org.jabref.gui.metadata.PreambleEditor; import org.jabref.gui.protectedterms.ManageProtectedTermsAction; -import org.jabref.gui.push.PushToApplicationButton; +import org.jabref.gui.push.PushToApplicationAction; import org.jabref.gui.push.PushToApplications; import org.jabref.gui.search.GlobalSearchBar; import org.jabref.gui.specialfields.SpecialFieldMenuItemFactory; @@ -559,7 +559,8 @@ private Node createToolbar() { leftSide.setMinWidth(100); leftSide.prefWidthProperty().bind(sidePane.widthProperty()); leftSide.maxWidthProperty().bind(sidePane.widthProperty()); - PushToApplicationButton pushToExternal = new PushToApplicationButton(this, pushApplications.getApplications()); + + PushToApplicationAction pushToApplicationAction = new PushToApplicationAction(this, Globals.stateManager); HBox rightSide = new HBox( factory.createIconButton(StandardActions.NEW_ARTICLE, new NewEntryAction(this, BiblatexEntryTypes.ARTICLE, dialogService, Globals.prefs)), factory.createIconButton(StandardActions.DELETE_ENTRY, new OldDatabaseCommandWrapper(Actions.DELETE, this, Globals.stateManager)), @@ -570,7 +571,7 @@ private Node createToolbar() { factory.createIconButton(StandardActions.COPY, new OldDatabaseCommandWrapper(Actions.COPY, this, Globals.stateManager)), factory.createIconButton(StandardActions.PASTE, new OldDatabaseCommandWrapper(Actions.PASTE, this, Globals.stateManager)), new Separator(Orientation.VERTICAL), - factory.createIconButton(pushToExternal.getMenuAction(), pushToExternal), + factory.createIconButton(pushToApplicationAction.getActionInformation(), pushToApplicationAction), factory.createIconButton(StandardActions.GENERATE_CITE_KEYS, new OldDatabaseCommandWrapper(Actions.MAKE_KEY, this, Globals.stateManager)), factory.createIconButton(StandardActions.CLEANUP_ENTRIES, new OldDatabaseCommandWrapper(Actions.CLEANUP, this, Globals.stateManager)), new Separator(Orientation.VERTICAL), @@ -798,7 +799,7 @@ private MenuBar createMenu() { factory.createMenuItem(StandardActions.SET_FILE_LINKS, new AutoLinkFilesAction(this, prefs)) ); - PushToApplicationButton pushToExternal = new PushToApplicationButton(this, pushApplications.getApplications()); + final PushToApplicationAction pushToApplicationAction = new PushToApplicationAction(this, Globals.stateManager); tools.getItems().addAll( factory.createMenuItem(StandardActions.NEW_SUB_LIBRARY_FROM_AUX, new NewSubLibraryAction(this)), factory.createMenuItem(StandardActions.FIND_UNLINKED_FILES, new FindUnlinkedFilesAction(this)), @@ -815,7 +816,7 @@ private MenuBar createMenu() { factory.createMenuItem(StandardActions.GENERATE_CITE_KEYS, new OldDatabaseCommandWrapper(Actions.MAKE_KEY, this, Globals.stateManager)), factory.createMenuItem(StandardActions.REPLACE_ALL, new OldDatabaseCommandWrapper(Actions.REPLACE_ALL, this, Globals.stateManager)), factory.createMenuItem(StandardActions.SEND_AS_EMAIL, new OldDatabaseCommandWrapper(Actions.SEND_AS_EMAIL, this, Globals.stateManager)), - factory.createMenuItem(pushToExternal.getMenuAction(), pushToExternal), + factory.createMenuItem(pushToApplicationAction.getActionInformation(), pushToApplicationAction), factory.createSubMenu(StandardActions.ABBREVIATE, factory.createMenuItem(StandardActions.ABBREVIATE_ISO, new OldDatabaseCommandWrapper(Actions.ABBREVIATE_ISO, this, Globals.stateManager)), diff --git a/src/main/java/org/jabref/gui/actions/OldDatabaseCommandWrapper.java b/src/main/java/org/jabref/gui/actions/OldDatabaseCommandWrapper.java index a752da3ce9c..58a702e4190 100644 --- a/src/main/java/org/jabref/gui/actions/OldDatabaseCommandWrapper.java +++ b/src/main/java/org/jabref/gui/actions/OldDatabaseCommandWrapper.java @@ -14,7 +14,10 @@ /** * A command that is only executable if a database is open. + * Deprecated use instead + * @see org.jabref.gui.actions.SimpleCommand */ +@Deprecated public class OldDatabaseCommandWrapper extends CommandBase { private static final Logger LOGGER = LoggerFactory.getLogger(OldDatabaseCommandWrapper.class); diff --git a/src/main/java/org/jabref/gui/push/PushToApplicationAction.java b/src/main/java/org/jabref/gui/push/PushToApplicationAction.java index 468fb8b57dc..e514a8fec55 100644 --- a/src/main/java/org/jabref/gui/push/PushToApplicationAction.java +++ b/src/main/java/org/jabref/gui/push/PushToApplicationAction.java @@ -1,39 +1,79 @@ package org.jabref.gui.push; -import java.awt.event.ActionEvent; import java.util.List; import java.util.Optional; -import javax.swing.AbstractAction; -import javax.swing.Action; import javax.swing.SwingUtilities; +import org.jabref.Globals; import org.jabref.JabRefExecutorService; import org.jabref.gui.BasePanel; import org.jabref.gui.JabRefFrame; +import org.jabref.gui.StateManager; +import org.jabref.gui.actions.Action; +import org.jabref.gui.actions.SimpleCommand; +import org.jabref.gui.icon.JabRefIcon; +import org.jabref.gui.keyboard.KeyBinding; import org.jabref.logic.l10n.Localization; import org.jabref.model.entry.BibEntry; +import org.jabref.preferences.JabRefPreferences; + +import org.fxmisc.easybind.EasyBind; /** * An Action class representing the process of invoking a PushToApplication operation. */ -class PushToApplicationAction extends AbstractAction implements Runnable { +public class PushToApplicationAction extends SimpleCommand implements Runnable { - private final PushToApplication operation; - private final JabRefFrame frame; + private PushToApplication operation; + private JabRefFrame frame; private BasePanel panel; private List entries; - public PushToApplicationAction(JabRefFrame frame, PushToApplication operation) { + public PushToApplicationAction(final JabRefFrame frame, final StateManager stateManager) { this.frame = frame; - putValue(Action.SMALL_ICON, operation.getIcon()); - putValue(Action.NAME, operation.getName()); - putValue(Action.SHORT_DESCRIPTION, operation.getTooltip()); - this.operation = operation; + this.operation = getLastUsedApplication(frame.getPushApplications().getApplications()); + this.executable.bind(EasyBind.map(stateManager.activeDatabaseProperty(), Optional::isPresent)); + } + + private PushToApplication getLastUsedApplication(List pushActions) { + String appSelected = Globals.prefs.get(JabRefPreferences.PUSH_TO_APPLICATION); + for (PushToApplication application : pushActions) { + if (application.getApplicationName().equals(appSelected)) { + return application; + } + } + + // Nothing found, pick first + return pushActions.get(0); + } + + public Action getActionInformation() { + return new Action() { + @Override + public Optional getIcon() { + return Optional.of(operation.getIcon()); + } + + @Override + public Optional getKeyBinding() { + return Optional.of(KeyBinding.PUSH_TO_APPLICATION); + } + + @Override + public String getText() { + return Localization.lang("Push entries to external application (%0)", operation.getApplicationName()); + } + + @Override + public String getDescription() { + return ""; + } + }; } @Override - public void actionPerformed(ActionEvent e) { + public void execute() { panel = frame.getCurrentBasePanel(); // Check if a BasePanel exists: @@ -44,7 +84,7 @@ public void actionPerformed(ActionEvent e) { // Check if any entries are selected: entries = panel.getSelectedEntries(); if (entries.isEmpty()) { - frame.getDialogService().showErrorDialogAndWait((String) getValue(Action.NAME), + frame.getDialogService().showErrorDialogAndWait(operation.getApplicationName(), Localization.lang("This operation requires one or more entries to be selected.")); return; @@ -54,7 +94,7 @@ public void actionPerformed(ActionEvent e) { if (operation.requiresBibtexKeys()) { for (BibEntry entry : entries) { if (!(entry.getCiteKeyOptional().isPresent()) || entry.getCiteKeyOptional().get().trim().isEmpty()) { - frame.getDialogService().showErrorDialogAndWait((String) getValue(Action.NAME), + frame.getDialogService().showErrorDialogAndWait(operation.getApplicationName(), Localization.lang("This operation requires all selected entries to have BibTeX keys defined.")); return; diff --git a/src/main/java/org/jabref/gui/push/PushToApplicationButton.java b/src/main/java/org/jabref/gui/push/PushToApplicationButton.java deleted file mode 100644 index 5ab8fefd4aa..00000000000 --- a/src/main/java/org/jabref/gui/push/PushToApplicationButton.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.jabref.gui.push; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import org.jabref.Globals; -import org.jabref.gui.JabRefFrame; -import org.jabref.gui.actions.SimpleCommand; -import org.jabref.gui.icon.JabRefIcon; -import org.jabref.gui.keyboard.KeyBinding; -import org.jabref.logic.l10n.Localization; -import org.jabref.preferences.JabRefPreferences; - -/** - * Customized UI component for pushing to external applications. Has a selection popup menu to change the selected - * external application. This class implements the ActionListener interface. When actionPerformed() is invoked, the - * currently selected PushToApplication is activated. The actionPerformed() method can be called with a null argument. - */ -public class PushToApplicationButton extends SimpleCommand implements ActionListener { - - private final JabRefFrame frame; - private final List pushActions; - private final PushToApplication toApp; - private final Map actions = new HashMap<>(); - - public PushToApplicationButton(JabRefFrame frame, List pushActions) { - this.frame = frame; - this.pushActions = pushActions; - // Set the last used external application - toApp = getLastUsedApplication(); - } - - private PushToApplication getLastUsedApplication() { - String appSelected = Globals.prefs.get(JabRefPreferences.PUSH_TO_APPLICATION); - for (PushToApplication application : pushActions) { - if (application.getApplicationName().equals(appSelected)) { - return application; - } - } - - // Nothing found, pick first - return pushActions.get(0); - } - - public org.jabref.gui.actions.Action getMenuAction() { - PushToApplication application = getLastUsedApplication(); - - return new org.jabref.gui.actions.Action() { - @Override - public Optional getIcon() { - return Optional.of(application.getIcon()); - } - - @Override - public Optional getKeyBinding() { - return Optional.of(KeyBinding.PUSH_TO_APPLICATION); - } - - @Override - public String getText() { - return Localization.lang("Push entries to external application (%0)", application.getApplicationName()); - } - - @Override - public String getDescription() { - return ""; - } - }; - } - - @Override - public void actionPerformed(ActionEvent e) { - execute(); - } - - @Override - public void execute() { - // Lazy initialization of the push action: - PushToApplicationAction action = actions.get(toApp); - if (action == null) { - action = new PushToApplicationAction(frame, toApp); - actions.put(toApp, action); - } - action.actionPerformed(new ActionEvent(toApp, 0, "push")); - } -} From 0dd091f31b86b02dd9e44b4ac86aa204d4dec9ef Mon Sep 17 00:00:00 2001 From: Marco Konersmann Date: Tue, 9 Apr 2019 15:36:38 +0200 Subject: [PATCH 2/8] Fix JabRef dying silently without enough inotify instances (#4875) * Logs exceptions in file monitor as errors An exception in the initialization of DefaultFileUpdateMonitor is now logged as error * Describes fix for issue #4874 --- CHANGELOG.md | 1 + src/main/java/org/jabref/gui/util/DefaultFileUpdateMonitor.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a941e10ce1..3ec7d2b519a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# ### Fixed +- We fixed an issue where JabRef died silently for the user without enough inotify instances [#4874](https://github.com/JabRef/jabref/issues/4847) - We fixed an issue where corresponding groups are sometimes not highlighted when clicking on entries [#3112](https://github.com/JabRef/jabref/issues/3112) - We fixed an issue where custom exports could not be selected in the 'Export (selected) entries' dialog [#4013](https://github.com/JabRef/jabref/issues/4013) - Italic text is now rendered correctly. https://github.com/JabRef/jabref/issues/3356 diff --git a/src/main/java/org/jabref/gui/util/DefaultFileUpdateMonitor.java b/src/main/java/org/jabref/gui/util/DefaultFileUpdateMonitor.java index 28de7285f3f..bdf0b51e2a6 100644 --- a/src/main/java/org/jabref/gui/util/DefaultFileUpdateMonitor.java +++ b/src/main/java/org/jabref/gui/util/DefaultFileUpdateMonitor.java @@ -59,7 +59,7 @@ public void run() { Thread.yield(); } } catch (Throwable e) { - LOGGER.debug("FileUpdateMonitor has been interrupted. Terminating...", e); + LOGGER.error("FileUpdateMonitor has been interrupted.", e); } } From e1a01d2a6afd7498e3382f74b172d3b8c5e55293 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 11 Apr 2019 08:06:54 +0200 Subject: [PATCH 3/8] Bump java-string-similarity from 1.1.0 to 1.2.1 (#4878) Bumps [java-string-similarity](https://github.com/tdebatty/java-string-similarity) from 1.1.0 to 1.2.1. - [Release notes](https://github.com/tdebatty/java-string-similarity/releases) - [Commits](https://github.com/tdebatty/java-string-similarity/compare/v1.1.0...v1.2.1) Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b20bd600e17..9b0ba62711c 100644 --- a/build.gradle +++ b/build.gradle @@ -112,7 +112,7 @@ dependencies { compile "org.libreoffice:unoil:6.2.2" compile 'io.github.java-diff-utils:java-diff-utils:4.0' - compile 'info.debatty:java-string-similarity:1.1.0' + compile 'info.debatty:java-string-similarity:1.2.1' antlr3 'org.antlr:antlr:3.5.2' compile 'org.antlr:antlr-runtime:3.5.2' From 6e062d9484e31f917c877d9e6fd72e5f62bcb7ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 11 Apr 2019 08:07:28 +0200 Subject: [PATCH 4/8] Bump mockito-core from 2.26.0 to 2.27.0 (#4879) Bumps [mockito-core](https://github.com/mockito/mockito) from 2.26.0 to 2.27.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v2.26.0...v2.27.0) Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9b0ba62711c..5154e337837 100644 --- a/build.gradle +++ b/build.gradle @@ -167,7 +167,7 @@ dependencies { testRuntime 'org.apache.logging.log4j:log4j-core:2.11.1' testRuntime 'org.apache.logging.log4j:log4j-jul:2.11.2' - testCompile 'org.mockito:mockito-core:2.26.0' + testCompile 'org.mockito:mockito-core:2.27.0' testCompile 'com.github.tomakehurst:wiremock:2.22.0' testCompile 'org.reflections:reflections:0.9.11' testCompile 'org.xmlunit:xmlunit-core:2.6.2' From f0e548935fdfe8d4b87e37df0d1eb16b2251500e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Sat, 13 Apr 2019 13:46:44 +0200 Subject: [PATCH 5/8] Bump xmpbox from 2.0.14 to 2.0.15 (#4883) Bumps xmpbox from 2.0.14 to 2.0.15. Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 5154e337837..55b978e8782 100644 --- a/build.gradle +++ b/build.gradle @@ -97,7 +97,7 @@ dependencies { compile 'org.apache.pdfbox:pdfbox:2.0.14' compile 'org.apache.pdfbox:fontbox:2.0.14' - compile 'org.apache.pdfbox:xmpbox:2.0.14' + compile 'org.apache.pdfbox:xmpbox:2.0.15' compile group: 'org.apache.tika', name: 'tika-core', version: '1.20' From d68bcb30f14a11dc7c54d965e3195669fdf8944c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Sat, 13 Apr 2019 13:46:58 +0200 Subject: [PATCH 6/8] Bump pdfbox from 2.0.14 to 2.0.15 (#4881) Bumps pdfbox from 2.0.14 to 2.0.15. Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 55b978e8782..8123dcd0a1d 100644 --- a/build.gradle +++ b/build.gradle @@ -95,7 +95,7 @@ dependencies { compile 'com.jgoodies:jgoodies-common:1.8.1' compile 'com.jgoodies:jgoodies-forms:1.9.0' - compile 'org.apache.pdfbox:pdfbox:2.0.14' + compile 'org.apache.pdfbox:pdfbox:2.0.15' compile 'org.apache.pdfbox:fontbox:2.0.14' compile 'org.apache.pdfbox:xmpbox:2.0.15' From b7989072fd68fe472dd712e18cc72bed69da2247 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Sat, 13 Apr 2019 14:14:07 +0200 Subject: [PATCH 7/8] Bump fontbox from 2.0.14 to 2.0.15 (#4882) Bumps fontbox from 2.0.14 to 2.0.15. Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8123dcd0a1d..277af5824b9 100644 --- a/build.gradle +++ b/build.gradle @@ -96,7 +96,7 @@ dependencies { compile 'com.jgoodies:jgoodies-forms:1.9.0' compile 'org.apache.pdfbox:pdfbox:2.0.15' - compile 'org.apache.pdfbox:fontbox:2.0.14' + compile 'org.apache.pdfbox:fontbox:2.0.15' compile 'org.apache.pdfbox:xmpbox:2.0.15' compile group: 'org.apache.tika', name: 'tika-core', version: '1.20' From 3d770b858f3a028cdfd9c37aac6c881b0b5fb738 Mon Sep 17 00:00:00 2001 From: Deepak Kumar Date: Sat, 13 Apr 2019 21:20:23 +0530 Subject: [PATCH 8/8] Fix right clicking on any entry and selecting "Open folder" results in the NullPointer exception (#4797) * Add an option in preference settings to set what action to be taken by JabRef when user clicks 'open folder' on a entry. * Fix #4763 and add added required changes in CHANGELOG.md and JabRef_en.properties * Refactor and Reformat code. * Fix issue #4802, where option 'open terminal here' with custom command was passing wrong argument * Fix failure of LocalizationConsistencyTest after code changes. --- .mailmap | 3 +- CHANGELOG.md | 4 +- .../org/jabref/gui/desktop/JabRefDesktop.java | 39 +++++++++++---- .../java/org/jabref/gui/desktop/os/Linux.java | 19 ++++---- .../jabref/gui/preferences/ExternalTab.java | 48 +++++++++++++++++++ .../jabref/preferences/JabRefPreferences.java | 6 +++ src/main/resources/l10n/JabRef_en.properties | 7 ++- 7 files changed, 105 insertions(+), 21 deletions(-) diff --git a/.mailmap b/.mailmap index b8698d75865..3af3033fd28 100644 --- a/.mailmap +++ b/.mailmap @@ -142,4 +142,5 @@ Johannes Manner Dominik Traczyk Cerrianne Santos Stefan Scheffel -Stefan Gerzmann \ No newline at end of file +Stefan Gerzmann +Deepak Kumar diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ec7d2b519a..651ab6ab391 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We changed the title of Group Dialog to "Add subgroup" from "Edit group" when we select Add subgroup option. - We enable import button only if entries are selected. [#4755](https://github.com/JabRef/jabref/issues/4755) - We made modifications to improve contrast of UI elements. [#4583](https://github.com/JabRef/jabref/issues/4583) +- We added an option in the settings to set the default action in JabRef when right clicking on any entry in any database and selecting "Open folder". [#4763](https://github.com/JabRef/jabref/issues/4763) - The Medline fetcher now normalizes the author names according to the BibTeX-Standard [#4345](https://github.com/JabRef/jabref/issues/4345) @@ -105,13 +106,14 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We fixed an issue where only one PDF file could be imported [#4422](https://github.com/JabRef/jabref/issues/4422) - We fixed an issue where "Move to group" would always move the first entry in the library and not the selected [#4414](https://github.com/JabRef/jabref/issues/4414) - We fixed an issue where an older dialog appears when downloading full texts from the quality menu. [#4489](https://github.com/JabRef/jabref/issues/4489) +- We fixed an issue where right clicking on any entry in any database and selecting "Open folder" results in the NullPointer exception. [#4763](https://github.com/JabRef/jabref/issues/4763) +- We fixed an issue where option 'open terminal here' with custom command was passing wrong argument. [#4802](https://github.com/JabRef/jabref/issues/4802) - We fixed an issue where ranking an entry would generate an IllegalArgumentException. [#4754](https://github.com/JabRef/jabref/issues/4754) - We fixed an issue where special characters where removed from non label key generation pattern parts [#4767](https://github.com/JabRef/jabref/issues/4767) - We fixed an issue where the RIS import would overwite the article date with the value of the acessed date [#4816](https://github.com/JabRef/jabref/issues/4816) - ### Removed - The feature to "mark entries" was removed and merged with the groups functionality. For migration, a group is created for every value of the `__markedentry` field and the entry is added to this group. - The number column was removed. diff --git a/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java b/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java index fbd9478789b..befd35ed0af 100644 --- a/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java +++ b/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java @@ -166,7 +166,33 @@ private static void openExternalFilePlatformIndependent(Optional updateExecuteConsoleButtonAndFieldEnabledState()); executeConsole.setOnAction(e -> updateExecuteConsoleButtonAndFieldEnabledState()); browseButton.setOnAction(e -> showConsoleChooser()); + fileBrowserButton.disableProperty().bind(executeFileBrowser.selectedProperty().not()); + fileBrowserCommand.disableProperty().bind(executeFileBrowser.selectedProperty().not()); + fileBrowserButton.setOnAction(e -> showFileBrowserCommandChooser()); + browseAdobeAcrobatReader.setOnAction(e -> showAdobeChooser()); GridPane consoleOptionPanel = new GridPane(); @@ -83,6 +99,17 @@ public ExternalTab(JabRefFrame frame, PreferencesDialog prefsDiag, JabRefPrefere adobeAcrobatReader.setToggleGroup(pdfReaderGroup); pdfOptionPanel.add(browseAdobeAcrobatReader, 3, 1); + Label fileBrowserCommandDescription = new Label(Localization.lang("Note: Use the placeholder %0 for the location of the opened library file.", "%DIR")); + GridPane fileBrowserOptionPanel = new GridPane(); + final ToggleGroup fileBrowserGroup = new ToggleGroup(); + defaultFileBrowser.setToggleGroup(fileBrowserGroup); + executeFileBrowser.setToggleGroup(fileBrowserGroup); + fileBrowserOptionPanel.add(defaultFileBrowser, 1, 1); + fileBrowserOptionPanel.add(executeFileBrowser, 1, 2); + fileBrowserOptionPanel.add(fileBrowserCommand, 2, 2); + fileBrowserOptionPanel.add(fileBrowserButton, 3, 2); + fileBrowserOptionPanel.add(fileBrowserCommandDescription, 2, 3); + if (OS.WINDOWS) { browseSumatraReader.setOnAction(e -> showSumatraChooser()); pdfOptionPanel.add(sumatraReader, 1, 2); @@ -133,6 +160,12 @@ public ExternalTab(JabRefFrame frame, PreferencesDialog prefsDiag, JabRefPrefere builder.add(pdfOptionPanel, 1, 13); + Label openFileBrowser = new Label(Localization.lang("Open File Browser")); + openFileBrowser.getStyleClass().add("sectionHeader"); + builder.add(openFileBrowser, 1, 14); + + builder.add(fileBrowserOptionPanel, 1, 15); + } @Override @@ -165,6 +198,10 @@ public void setValues() { consoleCommand.setText(Globals.prefs.get(JabRefPreferences.CONSOLE_COMMAND)); + defaultFileBrowser.setSelected(Globals.prefs.getBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION)); + executeFileBrowser.setSelected(!Globals.prefs.getBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION)); + fileBrowserCommand.setText(Globals.prefs.get(JabRefPreferences.FILE_BROWSER_COMMAND)); + adobeAcrobatReaderPath.setText(Globals.prefs.get(JabRefPreferences.ADOBE_ACROBAT_COMMAND)); if (OS.WINDOWS) { sumatraReaderPath.setText(Globals.prefs.get(JabRefPreferences.SUMATRA_PDF_COMMAND)); @@ -187,6 +224,13 @@ public void storeSettings() { prefs.putBoolean(JabRefPreferences.USE_DEFAULT_CONSOLE_APPLICATION, defaultConsole.isSelected()); prefs.put(JabRefPreferences.CONSOLE_COMMAND, consoleCommand.getText()); prefs.put(JabRefPreferences.ADOBE_ACROBAT_COMMAND, adobeAcrobatReaderPath.getText()); + + prefs.putBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION, defaultFileBrowser.isSelected()); + if (StringUtil.isNotBlank(fileBrowserCommand.getText())) { + prefs.put(JabRefPreferences.FILE_BROWSER_COMMAND, fileBrowserCommand.getText()); + } else { + prefs.putBoolean(JabRefPreferences.USE_DEFAULT_FILE_BROWSER_APPLICATION, true); //default if no command specified + } if (OS.WINDOWS) { prefs.put(JabRefPreferences.SUMATRA_PDF_COMMAND, sumatraReaderPath.getText()); } @@ -220,6 +264,10 @@ private void showSumatraChooser() { dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> sumatraReaderPath.setText(file.toAbsolutePath().toString())); } + private void showFileBrowserCommandChooser() { + dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> fileBrowserCommand.setText(file.toAbsolutePath().toString())); + } + private void readerSelected() { if (adobeAcrobatReader.isSelected()) { prefs.put(JabRefPreferences.USE_PDF_READER, adobeAcrobatReaderPath.getText()); diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 88eae71f20a..92b6fa622a0 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -244,6 +244,9 @@ public class JabRefPreferences implements PreferencesService { public static final String ADOBE_ACROBAT_COMMAND = "adobeAcrobatCommand"; public static final String SUMATRA_PDF_COMMAND = "sumatraCommand"; public static final String USE_PDF_READER = "usePDFReader"; + public static final String USE_DEFAULT_FILE_BROWSER_APPLICATION = "userDefaultFileBrowserApplication"; + public static final String FILE_BROWSER_COMMAND = "fileBrowserCommand"; + // Currently, it is not possible to specify defaults for specific entry types // When this should be made possible, the code to inspect is org.jabref.gui.preferences.BibtexKeyPatternPrefTab.storeSettings() -> LabelPattern keypatterns = getCiteKeyPattern(); etc public static final String DEFAULT_BIBTEX_KEY_PATTERN = "defaultBibtexKeyPattern"; @@ -729,16 +732,19 @@ private JabRefPreferences() { defaults.put(USE_UNIT_FORMATTER_ON_SEARCH, Boolean.TRUE); defaults.put(USE_DEFAULT_CONSOLE_APPLICATION, Boolean.TRUE); + defaults.put(USE_DEFAULT_FILE_BROWSER_APPLICATION, Boolean.TRUE); if (OS.WINDOWS) { defaults.put(CONSOLE_COMMAND, "C:\\Program Files\\ConEmu\\ConEmu64.exe /single /dir \"%DIR\""); defaults.put(ADOBE_ACROBAT_COMMAND, "C:\\Program Files (x86)\\Adobe\\Acrobat Reader DC\\Reader"); defaults.put(SUMATRA_PDF_COMMAND, "C:\\Program Files\\SumatraPDF"); defaults.put(USE_PDF_READER, ADOBE_ACROBAT_COMMAND); + defaults.put(FILE_BROWSER_COMMAND, "explorer.exe /select, \"%DIR\""); } else { defaults.put(CONSOLE_COMMAND, ""); defaults.put(ADOBE_ACROBAT_COMMAND, ""); defaults.put(SUMATRA_PDF_COMMAND, ""); defaults.put(USE_PDF_READER, ""); + defaults.put(FILE_BROWSER_COMMAND, ""); } //versioncheck defaults diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 7398d8fc491..1d75fc2d918 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -1689,7 +1689,6 @@ Open\ console=Open console Use\ default\ terminal\ emulator=Use default terminal emulator Execute\ command=Execute command Note\:\ Use\ the\ placeholder\ %0\ for\ the\ location\ of\ the\ opened\ library\ file.=Note: Use the placeholder %0 for the location of the opened library file. -Executing\ command\ \"%0\"...=Executing command \"%0\"... Error\ occured\ while\ executing\ the\ command\ \"%0\".=Error occured while executing the command \"%0\". Reformat\ ISSN=Reformat ISSN @@ -2081,6 +2080,12 @@ Use\ selected\ document=Use selected document Accept\ changes=Accept changes Dismiss\ changes=Dismiss changes The\ library\ has\ been\ modified\ by\ another\ program.=The library has been modified by another program. + +Browser=Browser +Execute\ Command=Execute Command +Open\ File\ Browser=Open File Browser +Use\ default\ file\ browser=Use default file browser + Set\ rank\ to\ one=Set rank to one Set\ rank\ to\ two=Set rank to two Set\ rank\ to\ three=Set rank to three