From 9b2640c6c8e27d4ba11e0d8340bc646d9d0eabca Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Thu, 26 May 2022 17:50:36 +0200 Subject: [PATCH 01/11] Fix linux file opening by using Process Builder Fixes #8831 Co-authored-by: ThiloteE --- .../java/org/jabref/gui/desktop/os/Linux.java | 63 ++++++++++++------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/jabref/gui/desktop/os/Linux.java b/src/main/java/org/jabref/gui/desktop/os/Linux.java index 51684b5a77a..93c15968ea8 100644 --- a/src/main/java/org/jabref/gui/desktop/os/Linux.java +++ b/src/main/java/org/jabref/gui/desktop/os/Linux.java @@ -89,41 +89,58 @@ public void openFileWithApplication(String filePath, String application) throws public void openFolderAndSelectFile(Path filePath) throws IOException { String desktopSession = System.getenv("DESKTOP_SESSION"); - String cmd = "xdg-open " + filePath.toAbsolutePath().getParent().toString(); // default command + String cmd = "xdg-open";// default command if (desktopSession != null) { desktopSession = desktopSession.toLowerCase(Locale.ROOT); if (desktopSession.contains("gnome")) { - cmd = "nautilus --select " + filePath.toString().replace(" ", "\\ "); + cmd = "nautilus --select"; } else if (desktopSession.contains("kde") || desktopSession.contains("plasma")) { - cmd = "dolphin --select " + filePath.toString().replace(" ", "\\ "); + cmd = "dolphin --select"; } else if (desktopSession.contains("mate")) { - cmd = "caja --select " + filePath.toString().replace(" ", "\\ "); + cmd = "caja --select"; } else if (desktopSession.contains("cinnamon")) { - cmd = "nemo --select " + filePath.toString().replace(" ", "\\ "); - } + cmd = "nemo"; + } } - Runtime.getRuntime().exec(cmd); + ProcessBuilder processBuilder = new ProcessBuilder(cmd, filePath.toAbsolutePath().toString()); + Process process = processBuilder.start(); + + StreamGobbler streamGobblerInput = new StreamGobbler(process.getInputStream(), LOGGER::debug); + StreamGobbler streamGobblerError = new StreamGobbler(process.getErrorStream(), LOGGER::debug); + + JabRefExecutorService.INSTANCE.execute(streamGobblerInput); + JabRefExecutorService.INSTANCE.execute(streamGobblerError); } @Override public void openConsole(String absolutePath) throws IOException { - Runtime runtime = Runtime.getRuntime(); - Process p = runtime.exec("readlink /etc/alternatives/x-terminal-emulator"); - BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); - - String emulatorName = reader.readLine(); - if (emulatorName != null) { - emulatorName = emulatorName.substring(emulatorName.lastIndexOf(File.separator) + 1); - - if (emulatorName.contains("gnome")) { - runtime.exec("gnome-terminal --working-directory=" + absolutePath); - } else if (emulatorName.contains("xfce4")) { - runtime.exec("xfce4-terminal --working-directory=" + absolutePath); - } else if (emulatorName.contains("konsole")) { - runtime.exec("konsole --workdir=" + absolutePath); - } else { - runtime.exec(emulatorName, null, new File(absolutePath)); + + ProcessBuilder processBuilder = new ProcessBuilder("readlink /etc/alternatives/x-terminal-emulator"); + Process process = processBuilder.start(); + + try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) { + String emulatorName = reader.readLine(); + if (emulatorName != null) { + emulatorName = emulatorName.substring(emulatorName.lastIndexOf(File.separator) + 1); + + String cmd = ""; + if (emulatorName.contains("gnome")) { + cmd = "gnome-terminal --working-directory="; + } else if (emulatorName.contains("xfce4")) { + cmd = ("xfce4-terminal --working-directory="); + } else if (emulatorName.contains("konsole")) { + cmd = ("konsole --workdir="); + } else { + cmd = emulatorName; + } + process = new ProcessBuilder(cmd, absolutePath).start(); + + StreamGobbler streamGobblerInput = new StreamGobbler(process.getInputStream(), LOGGER::debug); + StreamGobbler streamGobblerError = new StreamGobbler(process.getErrorStream(), LOGGER::debug); + + JabRefExecutorService.INSTANCE.execute(streamGobblerInput); + JabRefExecutorService.INSTANCE.execute(streamGobblerError); } } } From 11cd454f6da808252796e700d62bd7fd4cfa45f8 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Thu, 26 May 2022 17:54:05 +0200 Subject: [PATCH 02/11] checkstyle --- src/main/java/org/jabref/gui/desktop/os/Linux.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/gui/desktop/os/Linux.java b/src/main/java/org/jabref/gui/desktop/os/Linux.java index 93c15968ea8..776c0f7de49 100644 --- a/src/main/java/org/jabref/gui/desktop/os/Linux.java +++ b/src/main/java/org/jabref/gui/desktop/os/Linux.java @@ -89,7 +89,7 @@ public void openFileWithApplication(String filePath, String application) throws public void openFolderAndSelectFile(Path filePath) throws IOException { String desktopSession = System.getenv("DESKTOP_SESSION"); - String cmd = "xdg-open";// default command + String cmd = "xdg-open"; // default command if (desktopSession != null) { desktopSession = desktopSession.toLowerCase(Locale.ROOT); @@ -101,9 +101,9 @@ public void openFolderAndSelectFile(Path filePath) throws IOException { cmd = "caja --select"; } else if (desktopSession.contains("cinnamon")) { cmd = "nemo"; - } + } } - ProcessBuilder processBuilder = new ProcessBuilder(cmd, filePath.toAbsolutePath().toString()); + ProcessBuilder processBuilder = new ProcessBuilder(cmd, filePath.toAbsolutePath().toString()); Process process = processBuilder.start(); StreamGobbler streamGobblerInput = new StreamGobbler(process.getInputStream(), LOGGER::debug); From 1391274221318416fc1e31615a38eaa7bc8e9e9f Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Thu, 26 May 2022 17:55:15 +0200 Subject: [PATCH 03/11] add comment on nemo Co-authored-by: ThiloteE --- src/main/java/org/jabref/gui/desktop/os/Linux.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/desktop/os/Linux.java b/src/main/java/org/jabref/gui/desktop/os/Linux.java index 776c0f7de49..5960908763f 100644 --- a/src/main/java/org/jabref/gui/desktop/os/Linux.java +++ b/src/main/java/org/jabref/gui/desktop/os/Linux.java @@ -100,7 +100,7 @@ public void openFolderAndSelectFile(Path filePath) throws IOException { } else if (desktopSession.contains("mate")) { cmd = "caja --select"; } else if (desktopSession.contains("cinnamon")) { - cmd = "nemo"; + cmd = "nemo"; // Although nemo is based on nautilus it does not support --select, it directly highlights the file } } ProcessBuilder processBuilder = new ProcessBuilder(cmd, filePath.toAbsolutePath().toString()); From 0ad5405714fd389d236b9b11db282b6daca15418 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Thu, 26 May 2022 19:07:24 +0200 Subject: [PATCH 04/11] Refactor terminal opening as well Co-authored-by: ThiloteE --- .../java/org/jabref/gui/desktop/os/Linux.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/jabref/gui/desktop/os/Linux.java b/src/main/java/org/jabref/gui/desktop/os/Linux.java index 5960908763f..e71e5116884 100644 --- a/src/main/java/org/jabref/gui/desktop/os/Linux.java +++ b/src/main/java/org/jabref/gui/desktop/os/Linux.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.nio.file.Path; +import java.util.Arrays; import java.util.Locale; import java.util.Optional; @@ -116,7 +117,7 @@ public void openFolderAndSelectFile(Path filePath) throws IOException { @Override public void openConsole(String absolutePath) throws IOException { - ProcessBuilder processBuilder = new ProcessBuilder("readlink /etc/alternatives/x-terminal-emulator"); + ProcessBuilder processBuilder = new ProcessBuilder("readlink", "/etc/alternatives/x-terminal-emulator"); Process process = processBuilder.start(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) { @@ -124,17 +125,20 @@ public void openConsole(String absolutePath) throws IOException { if (emulatorName != null) { emulatorName = emulatorName.substring(emulatorName.lastIndexOf(File.separator) + 1); - String cmd = ""; + absolutePath = "\"" + absolutePath + "\""; + + String[] cmd = {}; if (emulatorName.contains("gnome")) { - cmd = "gnome-terminal --working-directory="; + cmd = new String[] {"gnome-terminal", "--working-directory=" + absolutePath}; } else if (emulatorName.contains("xfce4")) { - cmd = ("xfce4-terminal --working-directory="); + cmd = new String[] {"xfce4-terminal", "--working-directory=" + absolutePath}; } else if (emulatorName.contains("konsole")) { - cmd = ("konsole --workdir="); + cmd = new String[] {"konsole --workdir=" + absolutePath}; } else { - cmd = emulatorName; + cmd = new String[] {emulatorName, absolutePath}; } - process = new ProcessBuilder(cmd, absolutePath).start(); + LOGGER.debug("Terminal cmd {}", Arrays.toString(cmd)); + process = new ProcessBuilder(cmd).start(); StreamGobbler streamGobblerInput = new StreamGobbler(process.getInputStream(), LOGGER::debug); StreamGobbler streamGobblerError = new StreamGobbler(process.getErrorStream(), LOGGER::debug); From 4c21b3618550cf4b390d8162b368495ea51b7283 Mon Sep 17 00:00:00 2001 From: Benedikt Tutzer Date: Tue, 31 May 2022 20:40:29 +0200 Subject: [PATCH 05/11] Split ProcessBuilder arguments into Array Co-authored-by: Siedlerchr siedlerkiller@gmail.com --- src/main/java/org/jabref/gui/desktop/os/Linux.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jabref/gui/desktop/os/Linux.java b/src/main/java/org/jabref/gui/desktop/os/Linux.java index e71e5116884..9bae91d49d5 100644 --- a/src/main/java/org/jabref/gui/desktop/os/Linux.java +++ b/src/main/java/org/jabref/gui/desktop/os/Linux.java @@ -90,21 +90,22 @@ public void openFileWithApplication(String filePath, String application) throws public void openFolderAndSelectFile(Path filePath) throws IOException { String desktopSession = System.getenv("DESKTOP_SESSION"); - String cmd = "xdg-open"; // default command + String absoluteFilePath = filePath.toAbsolutePath().toString(); + String[] cmd = {"xdg-open", absoluteFilePath}; // default command if (desktopSession != null) { desktopSession = desktopSession.toLowerCase(Locale.ROOT); if (desktopSession.contains("gnome")) { - cmd = "nautilus --select"; + cmd = new String[] {"nautilus", "--select", absoluteFilePath}; } else if (desktopSession.contains("kde") || desktopSession.contains("plasma")) { - cmd = "dolphin --select"; + cmd = new String[] {"dolphin", "--select", absoluteFilePath}; } else if (desktopSession.contains("mate")) { - cmd = "caja --select"; + cmd = new String[] {"caja", "--select", absoluteFilePath}; } else if (desktopSession.contains("cinnamon")) { - cmd = "nemo"; // Although nemo is based on nautilus it does not support --select, it directly highlights the file + cmd = new String[] {"nemo", absoluteFilePath}; // Although nemo is based on nautilus it does not support --select, it directly highlights the file } } - ProcessBuilder processBuilder = new ProcessBuilder(cmd, filePath.toAbsolutePath().toString()); + ProcessBuilder processBuilder = new ProcessBuilder((cmd)); Process process = processBuilder.start(); StreamGobbler streamGobblerInput = new StreamGobbler(process.getInputStream(), LOGGER::debug); From 51d9b32fc4a9264c924fd5b15f4bbe09ce792dd1 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Wed, 1 Jun 2022 21:29:00 +0200 Subject: [PATCH 06/11] Refactor passing of dialog servie Set directory for terminal --- src/main/java/org/jabref/gui/JabRefFrame.java | 31 ++++++++++--------- .../org/jabref/gui/OpenConsoleAction.java | 10 +++--- .../org/jabref/gui/SendAsEMailAction.java | 2 +- .../org/jabref/gui/desktop/JabRefDesktop.java | 20 ++++++------ .../jabref/gui/desktop/os/DefaultDesktop.java | 3 +- .../java/org/jabref/gui/desktop/os/Linux.java | 23 +++++++++----- .../jabref/gui/desktop/os/NativeDesktop.java | 5 ++- .../java/org/jabref/gui/desktop/os/OSX.java | 8 ++--- .../org/jabref/gui/desktop/os/Windows.java | 3 +- .../DuplicateResolverDialog.java | 7 +++-- .../duplicationFinder/DuplicateSearch.java | 2 +- .../jabref/gui/edit/OpenBrowserAction.java | 7 +++-- .../jabref/gui/entryeditor/EntryEditor.java | 2 +- .../jabref/gui/exporter/ExportCommand.java | 2 +- .../gui/externalfiles/ImportHandler.java | 2 +- .../gui/fieldeditors/LinkedFileViewModel.java | 2 +- .../gui/groups/GroupDialogViewModel.java | 2 +- .../java/org/jabref/gui/help/HelpAction.java | 19 +++++------- .../org/jabref/gui/help/NewVersionDialog.java | 7 +++-- .../org/jabref/gui/help/VersionWorker.java | 2 +- .../gui/importer/ImportEntriesViewModel.java | 4 +-- .../importer/fetcher/WebSearchPaneView.java | 4 ++- .../constants/ConstantsPropertiesView.java | 4 ++- .../ConstantsPropertiesViewModel.java | 8 +++-- .../keypattern/KeyPatternPropertiesView.java | 2 +- .../gui/openoffice/OpenOfficePanel.java | 2 +- .../CitationKeyPatternTab.java | 2 +- .../CustomEditorFieldsTab.java | 2 +- .../jabref/gui/preferences/file/FileTab.java | 2 +- .../gui/preferences/general/GeneralTab.java | 2 +- .../linkedfiles/LinkedFilesTab.java | 2 +- .../nameformatter/NameFormatterTab.java | 2 +- .../gui/preferences/network/NetworkTab.java | 2 +- .../gui/preferences/table/TableTab.java | 2 +- .../SharedDatabaseLoginDialogViewModel.java | 2 +- .../gui/util/OpenConsoleActionTest.java | 6 ++-- 36 files changed, 117 insertions(+), 90 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index c140bb85c0d..efd992dd688 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -124,6 +124,7 @@ import org.jabref.logic.autosaveandbackup.AutosaveManager; import org.jabref.logic.autosaveandbackup.BackupManager; import org.jabref.logic.citationstyle.CitationStyleOutputFormat; +import org.jabref.logic.help.HelpFile; import org.jabref.logic.importer.IdFetcher; import org.jabref.logic.importer.ImportCleanup; import org.jabref.logic.importer.ParserResult; @@ -337,7 +338,7 @@ public void openAction(String filePath) { * The MacAdapter calls this method when "About" is selected from the application menu. */ public void about() { - HelpAction.getMainHelpPageCommand().execute(); + new HelpAction(HelpFile.CONTENTS, dialogService).execute(); } /** @@ -534,7 +535,7 @@ private Node createToolbar() { new Separator(Orientation.VERTICAL), new HBox( - factory.createIconButton(StandardActions.OPEN_GITHUB, new OpenBrowserAction("https://github.com/JabRef/jabref")))); + factory.createIconButton(StandardActions.OPEN_GITHUB, new OpenBrowserAction("https://github.com/JabRef/jabref", dialogService)))); leftSpacer.setPrefWidth(50); leftSpacer.setMinWidth(Region.USE_PREF_SIZE); @@ -854,7 +855,7 @@ private MenuBar createMenu() { factory.createMenuItem(StandardActions.SHOW_PDF_VIEWER, new ShowDocumentViewerAction(stateManager, prefs)), factory.createMenuItem(StandardActions.EDIT_ENTRY, new OpenEntryEditorAction(this, stateManager)), - factory.createMenuItem(StandardActions.OPEN_CONSOLE, new OpenConsoleAction(stateManager, prefs)) + factory.createMenuItem(StandardActions.OPEN_CONSOLE, new OpenConsoleAction(stateManager, prefs, dialogService)) ); options.getItems().addAll( @@ -867,8 +868,8 @@ private MenuBar createMenu() { ); help.getItems().addAll( - factory.createMenuItem(StandardActions.HELP, HelpAction.getMainHelpPageCommand()), - factory.createMenuItem(StandardActions.OPEN_FORUM, new OpenBrowserAction("http://discourse.jabref.org/")), + factory.createMenuItem(StandardActions.HELP, new HelpAction(HelpFile.CONTENTS, dialogService)), + factory.createMenuItem(StandardActions.OPEN_FORUM, new OpenBrowserAction("http://discourse.jabref.org/", dialogService)), new SeparatorMenuItem(), @@ -876,19 +877,19 @@ private MenuBar createMenu() { new SeparatorMenuItem(), - factory.createMenuItem(StandardActions.DONATE, new OpenBrowserAction("https://donations.jabref.org")), + factory.createMenuItem(StandardActions.DONATE, new OpenBrowserAction("https://donations.jabref.org", dialogService)), factory.createMenuItem(StandardActions.SEARCH_FOR_UPDATES, new SearchForUpdateAction(Globals.BUILD_INFO, prefs.getInternalPreferences(), dialogService, Globals.TASK_EXECUTOR)), factory.createSubMenu(StandardActions.WEB_MENU, - factory.createMenuItem(StandardActions.OPEN_WEBPAGE, new OpenBrowserAction("https://jabref.org/")), - factory.createMenuItem(StandardActions.OPEN_BLOG, new OpenBrowserAction("https://blog.jabref.org/")), - factory.createMenuItem(StandardActions.OPEN_FACEBOOK, new OpenBrowserAction("https://www.facebook.com/JabRef/")), - factory.createMenuItem(StandardActions.OPEN_TWITTER, new OpenBrowserAction("https://twitter.com/jabref_org")), - factory.createMenuItem(StandardActions.OPEN_GITHUB, new OpenBrowserAction("https://github.com/JabRef/jabref")), + factory.createMenuItem(StandardActions.OPEN_WEBPAGE, new OpenBrowserAction("https://jabref.org/", dialogService)), + factory.createMenuItem(StandardActions.OPEN_BLOG, new OpenBrowserAction("https://blog.jabref.org/", dialogService)), + factory.createMenuItem(StandardActions.OPEN_FACEBOOK, new OpenBrowserAction("https://www.facebook.com/JabRef/", dialogService)), + factory.createMenuItem(StandardActions.OPEN_TWITTER, new OpenBrowserAction("https://twitter.com/jabref_org", dialogService)), + factory.createMenuItem(StandardActions.OPEN_GITHUB, new OpenBrowserAction("https://github.com/JabRef/jabref", dialogService)), new SeparatorMenuItem(), - factory.createMenuItem(StandardActions.OPEN_DEV_VERSION_LINK, new OpenBrowserAction("https://builds.jabref.org/master/")), - factory.createMenuItem(StandardActions.OPEN_CHANGELOG, new OpenBrowserAction("https://github.com/JabRef/jabref/blob/main/CHANGELOG.md")) + factory.createMenuItem(StandardActions.OPEN_DEV_VERSION_LINK, new OpenBrowserAction("https://builds.jabref.org/master/", dialogService)), + factory.createMenuItem(StandardActions.OPEN_CHANGELOG, new OpenBrowserAction("https://github.com/JabRef/jabref/blob/main/CHANGELOG.md", dialogService)) ), factory.createMenuItem(StandardActions.ABOUT, new AboutAction()) ); @@ -1043,7 +1044,7 @@ private ContextMenu createTabContextMenuFor(LibraryTab tab, KeyBindingRepository contextMenu.getItems().addAll( factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new LibraryPropertiesAction(tab::getBibDatabaseContext, stateManager)), factory.createMenuItem(StandardActions.OPEN_DATABASE_FOLDER, new OpenDatabaseFolder(tab::getBibDatabaseContext)), - factory.createMenuItem(StandardActions.OPEN_CONSOLE, new OpenConsoleAction(tab::getBibDatabaseContext, stateManager, prefs)), + factory.createMenuItem(StandardActions.OPEN_CONSOLE, new OpenConsoleAction(tab::getBibDatabaseContext, stateManager, prefs, dialogService)), new SeparatorMenuItem(), factory.createMenuItem(StandardActions.CLOSE_LIBRARY, new CloseDatabaseAction(tab)), factory.createMenuItem(StandardActions.CLOSE_OTHER_LIBRARIES, new CloseOthersDatabaseAction(tab)), @@ -1341,7 +1342,7 @@ public OpenDatabaseFolder(Supplier databaseContext) { public void execute() { Optional.of(databaseContext.get()).flatMap(BibDatabaseContext::getDatabasePath).ifPresent(path -> { try { - JabRefDesktop.openFolderAndSelectFile(path, prefs); + JabRefDesktop.openFolderAndSelectFile(path, prefs, dialogService); } catch (IOException e) { LOGGER.info("Could not open folder", e); } diff --git a/src/main/java/org/jabref/gui/OpenConsoleAction.java b/src/main/java/org/jabref/gui/OpenConsoleAction.java index 52ddf7fb4a0..b470e1e3ef0 100644 --- a/src/main/java/org/jabref/gui/OpenConsoleAction.java +++ b/src/main/java/org/jabref/gui/OpenConsoleAction.java @@ -19,6 +19,7 @@ public class OpenConsoleAction extends SimpleCommand { private final Supplier databaseContext; private final StateManager stateManager; private final PreferencesService preferencesService; + private final DialogService dialogService; /** * Creates a command that opens the console at the path of the supplied database, @@ -26,10 +27,11 @@ public class OpenConsoleAction extends SimpleCommand { * {@link #OpenConsoleAction(StateManager, PreferencesService)} if not supplying * another database. */ - public OpenConsoleAction(Supplier databaseContext, StateManager stateManager, PreferencesService preferencesService) { + public OpenConsoleAction(Supplier databaseContext, StateManager stateManager, PreferencesService preferencesService, DialogService dialogService) { this.databaseContext = databaseContext; this.stateManager = stateManager; this.preferencesService = preferencesService; + this.dialogService = dialogService; this.executable.bind(ActionHelper.needsDatabase(stateManager)); } @@ -37,15 +39,15 @@ public OpenConsoleAction(Supplier databaseContext, StateMana /** * Using this constructor will result in executing the command on the active database. */ - public OpenConsoleAction(StateManager stateManager, PreferencesService preferencesService) { - this(() -> null, stateManager, preferencesService); + public OpenConsoleAction(StateManager stateManager, PreferencesService preferencesService, DialogService dialogService) { + this(() -> null, stateManager, preferencesService, dialogService); } @Override public void execute() { Optional.ofNullable(databaseContext.get()).or(stateManager::getActiveDatabase).flatMap(BibDatabaseContext::getDatabasePath).ifPresent(path -> { try { - JabRefDesktop.openConsole(path.toFile(), preferencesService); + JabRefDesktop.openConsole(path.toFile(), preferencesService, dialogService); } catch (IOException e) { LOGGER.info("Could not open console", e); } diff --git a/src/main/java/org/jabref/gui/SendAsEMailAction.java b/src/main/java/org/jabref/gui/SendAsEMailAction.java index 6ef1150cbe6..016b4a039ba 100644 --- a/src/main/java/org/jabref/gui/SendAsEMailAction.java +++ b/src/main/java/org/jabref/gui/SendAsEMailAction.java @@ -100,7 +100,7 @@ private String sendEmail() throws Exception { attachments.add(path.toAbsolutePath().toString()); if (openFolders) { try { - JabRefDesktop.openFolderAndSelectFile(path.toAbsolutePath(), preferencesService); + JabRefDesktop.openFolderAndSelectFile(path.toAbsolutePath(), preferencesService, dialogService); } catch (IOException e) { LOGGER.debug("Cannot open file", e); } diff --git a/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java b/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java index 75d22919cb8..96bc258e134 100644 --- a/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java +++ b/src/main/java/org/jabref/gui/desktop/JabRefDesktop.java @@ -12,7 +12,6 @@ import org.jabref.gui.DialogService; import org.jabref.gui.Globals; -import org.jabref.gui.JabRefGUI; import org.jabref.gui.desktop.os.DefaultDesktop; import org.jabref.gui.desktop.os.Linux; import org.jabref.gui.desktop.os.NativeDesktop; @@ -184,7 +183,7 @@ private static void openExternalFilePlatformIndependent(Optional" if the app is specified, and just "open " otherwise: String[] cmd = (application != null) && !application.isEmpty() ? new String[] {"/usr/bin/open", "-a", application, filePath} : new String[] {"/usr/bin/open", filePath}; - Runtime.getRuntime().exec(cmd); + new ProcessBuilder(cmd).start(); } @Override @@ -38,8 +38,8 @@ public void openFolderAndSelectFile(Path file) throws IOException { } @Override - public void openConsole(String absolutePath) throws IOException { - Runtime.getRuntime().exec("open -a Terminal " + absolutePath, null, new File(absolutePath)); + public void openConsole(String absolutePath, DialogService dialogService) throws IOException { + new ProcessBuilder("open", "-a", "Terminal", absolutePath).start(); } @Override diff --git a/src/main/java/org/jabref/gui/desktop/os/Windows.java b/src/main/java/org/jabref/gui/desktop/os/Windows.java index 560a404653c..a5a6acfe79a 100644 --- a/src/main/java/org/jabref/gui/desktop/os/Windows.java +++ b/src/main/java/org/jabref/gui/desktop/os/Windows.java @@ -6,6 +6,7 @@ import java.nio.file.Path; import java.util.Optional; +import org.jabref.gui.DialogService; import org.jabref.gui.externalfiletype.ExternalFileType; import org.jabref.gui.externalfiletype.ExternalFileTypes; @@ -79,7 +80,7 @@ public void openFolderAndSelectFile(Path filePath) throws IOException { } @Override - public void openConsole(String absolutePath) throws IOException { + public void openConsole(String absolutePath, DialogService dialogService) throws IOException { ProcessBuilder process = new ProcessBuilder("cmd.exe", "/c", "start"); process.directory(new File(absolutePath)); process.start(); diff --git a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java index a890007c220..1dad9cae973 100644 --- a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java +++ b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateResolverDialog.java @@ -6,6 +6,7 @@ import javafx.scene.control.ButtonType; import javafx.scene.layout.BorderPane; +import org.jabref.gui.DialogService; import org.jabref.gui.StateManager; import org.jabref.gui.duplicationFinder.DuplicateResolverDialog.DuplicateResolverResult; import org.jabref.gui.help.HelpAction; @@ -39,16 +40,18 @@ public enum DuplicateResolverResult { } private MergeEntries mergeEntries; + private final DialogService dialogService; - public DuplicateResolverDialog(BibEntry one, BibEntry two, DuplicateResolverType type, BibDatabaseContext database, StateManager stateManager) { + public DuplicateResolverDialog(BibEntry one, BibEntry two, DuplicateResolverType type, BibDatabaseContext database, StateManager stateManager, DialogService dialogService) { this.setTitle(Localization.lang("Possible duplicate entries")); this.database = database; this.stateManager = stateManager; + this.dialogService = dialogService; init(one, two, type); } private void init(BibEntry one, BibEntry two, DuplicateResolverType type) { - HelpAction helpCommand = new HelpAction(HelpFile.FIND_DUPLICATES); + HelpAction helpCommand = new HelpAction(HelpFile.FIND_DUPLICATES, dialogService); ButtonType help = new ButtonType(Localization.lang("Help"), ButtonData.HELP); ButtonType cancel = ButtonType.CANCEL; diff --git a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java index 64af1bc9143..7ccc1b19402 100644 --- a/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java +++ b/src/main/java/org/jabref/gui/duplicationFinder/DuplicateSearch.java @@ -142,7 +142,7 @@ private DuplicateSearchResult verifyDuplicates() { } private void askResolveStrategy(DuplicateSearchResult result, BibEntry first, BibEntry second, DuplicateResolverType resolverType) { - DuplicateResolverDialog dialog = new DuplicateResolverDialog(first, second, resolverType, frame.getCurrentLibraryTab().getBibDatabaseContext(), stateManager); + DuplicateResolverDialog dialog = new DuplicateResolverDialog(first, second, resolverType, frame.getCurrentLibraryTab().getBibDatabaseContext(), stateManager, dialogService); dialog.titleProperty().bind(Bindings.concat(dialog.getTitle()).concat(" (").concat(duplicateProgress.getValue()).concat("/").concat(duplicateTotal).concat(")")); diff --git a/src/main/java/org/jabref/gui/edit/OpenBrowserAction.java b/src/main/java/org/jabref/gui/edit/OpenBrowserAction.java index 503f0711b3c..c6eb7653ae8 100644 --- a/src/main/java/org/jabref/gui/edit/OpenBrowserAction.java +++ b/src/main/java/org/jabref/gui/edit/OpenBrowserAction.java @@ -1,18 +1,21 @@ package org.jabref.gui.edit; +import org.jabref.gui.DialogService; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.desktop.JabRefDesktop; public class OpenBrowserAction extends SimpleCommand { private final String urlToOpen; + private final DialogService dialogService; - public OpenBrowserAction(String urlToOpen) { + public OpenBrowserAction(String urlToOpen, DialogService dialogService) { this.urlToOpen = urlToOpen; + this.dialogService = dialogService; } @Override public void execute() { - JabRefDesktop.openBrowserShowPopup(urlToOpen); + JabRefDesktop.openBrowserShowPopup(urlToOpen, dialogService); } } diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index 995461c638b..a5b513203a2 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -195,7 +195,7 @@ private void setupKeyBindings() { event.consume(); break; case HELP: - HelpAction.openHelpPage(HelpFile.ENTRY_EDITOR); + new HelpAction(HelpFile.ENTRY_EDITOR, dialogService).execute(); event.consume(); break; case CLOSE: diff --git a/src/main/java/org/jabref/gui/exporter/ExportCommand.java b/src/main/java/org/jabref/gui/exporter/ExportCommand.java index 78198252c98..f3c6812a764 100644 --- a/src/main/java/org/jabref/gui/exporter/ExportCommand.java +++ b/src/main/java/org/jabref/gui/exporter/ExportCommand.java @@ -139,7 +139,7 @@ private void export(Path file, FileChooser.ExtensionFilter selectedExtensionFilt Localization.lang("Export operation finished successfully."), List.of(new Action(Localization.lang("Reveal in File Explorer"), event -> { try { - JabRefDesktop.openFolderAndSelectFile(file, preferences); + JabRefDesktop.openFolderAndSelectFile(file, preferences, dialogService); } catch (IOException e) { LOGGER.error("Could not open export folder.", e); } diff --git a/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java b/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java index 668d2579d2b..7de10cf7b35 100644 --- a/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java +++ b/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java @@ -184,7 +184,7 @@ public void importEntryWithDuplicateCheck(BibDatabaseContext bibDatabaseContext, Optional existingDuplicateInLibrary = new DuplicateCheck(Globals.entryTypesManager).containsDuplicate(bibDatabaseContext.getDatabase(), entryToInsert, bibDatabaseContext.getMode()); if (existingDuplicateInLibrary.isPresent()) { - DuplicateResolverDialog dialog = new DuplicateResolverDialog(existingDuplicateInLibrary.get(), entryToInsert, DuplicateResolverDialog.DuplicateResolverType.IMPORT_CHECK, bibDatabaseContext, stateManager); + DuplicateResolverDialog dialog = new DuplicateResolverDialog(existingDuplicateInLibrary.get(), entryToInsert, DuplicateResolverDialog.DuplicateResolverType.IMPORT_CHECK, bibDatabaseContext, stateManager, dialogService); switch (dialogService.showCustomDialogAndWait(dialog).orElse(DuplicateResolverDialog.DuplicateResolverResult.BREAK)) { case KEEP_LEFT: bibDatabaseContext.getDatabase().removeEntry(existingDuplicateInLibrary.get()); diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java index db615c074aa..89a943d9e1f 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java @@ -218,7 +218,7 @@ public void openFolder() { preferences.getFilePreferences()); if (resolvedPath.isPresent()) { - JabRefDesktop.openFolderAndSelectFile(resolvedPath.get(), preferences); + JabRefDesktop.openFolderAndSelectFile(resolvedPath.get(), preferences, dialogService); } else { dialogService.showErrorDialogAndWait(Localization.lang("File not found")); } diff --git a/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java b/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java index 1d4d7d97804..0a1de76104c 100644 --- a/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java @@ -446,7 +446,7 @@ public void texGroupBrowse() { } public void openHelpPage() { - HelpAction.openHelpPage(HelpFile.GROUPS); + new HelpAction(HelpFile.GROUPS, dialogService).execute(); } private List getFileDirectoriesAsPaths() { diff --git a/src/main/java/org/jabref/gui/help/HelpAction.java b/src/main/java/org/jabref/gui/help/HelpAction.java index 1cfe14937ff..a225685a2dd 100644 --- a/src/main/java/org/jabref/gui/help/HelpAction.java +++ b/src/main/java/org/jabref/gui/help/HelpAction.java @@ -1,5 +1,6 @@ package org.jabref.gui.help; +import org.jabref.gui.DialogService; import org.jabref.gui.actions.SimpleCommand; import org.jabref.gui.desktop.JabRefDesktop; import org.jabref.logic.help.HelpFile; @@ -10,26 +11,20 @@ */ public class HelpAction extends SimpleCommand { - private HelpFile helpPage; + private final HelpFile helpPage; + private final DialogService dialogService; - public HelpAction(HelpFile helpPage) { + public HelpAction(HelpFile helpPage, DialogService dialogService) { this.helpPage = helpPage; + this.dialogService = dialogService; } - public static void openHelpPage(HelpFile helpPage) { + void openHelpPage(HelpFile helpPage) { StringBuilder sb = new StringBuilder("https://docs.jabref.org/"); sb.append(helpPage.getPageName()); - JabRefDesktop.openBrowserShowPopup(sb.toString()); + JabRefDesktop.openBrowserShowPopup(sb.toString(), dialogService); } - public static SimpleCommand getMainHelpPageCommand() { - return new SimpleCommand() { - @Override - public void execute() { - openHelpPage(HelpFile.CONTENTS); - } - }; - } @Override public void execute() { diff --git a/src/main/java/org/jabref/gui/help/NewVersionDialog.java b/src/main/java/org/jabref/gui/help/NewVersionDialog.java index 2ab73b250a5..f026d0d7295 100644 --- a/src/main/java/org/jabref/gui/help/NewVersionDialog.java +++ b/src/main/java/org/jabref/gui/help/NewVersionDialog.java @@ -7,6 +7,7 @@ import javafx.scene.control.Label; import javafx.scene.layout.VBox; +import org.jabref.gui.DialogService; import org.jabref.gui.desktop.JabRefDesktop; import org.jabref.gui.util.BaseDialog; import org.jabref.logic.l10n.Localization; @@ -14,7 +15,7 @@ public class NewVersionDialog extends BaseDialog { - public NewVersionDialog(Version currentVersion, Version latestVersion) { + public NewVersionDialog(Version currentVersion, Version latestVersion, DialogService dialogService) { this.setTitle(Localization.lang("New version available")); ButtonType btnIgnoreUpdate = new ButtonType(Localization.lang("Ignore this update"), ButtonBar.ButtonData.CANCEL_CLOSE); @@ -25,7 +26,7 @@ public NewVersionDialog(Version currentVersion, Version latestVersion) { if (button == btnIgnoreUpdate) { return false; } else if (button == btnDownloadUpdate) { - JabRefDesktop.openBrowserShowPopup(Version.JABREF_DOWNLOAD_URL); + JabRefDesktop.openBrowserShowPopup(Version.JABREF_DOWNLOAD_URL, dialogService); } return true; }); @@ -34,7 +35,7 @@ public NewVersionDialog(Version currentVersion, Version latestVersion) { Hyperlink lblMoreInformation = new Hyperlink(Localization.lang("To see what is new view the changelog.")); lblMoreInformation.setOnAction(event -> - JabRefDesktop.openBrowserShowPopup(latestVersion.getChangelogUrl()) + JabRefDesktop.openBrowserShowPopup(latestVersion.getChangelogUrl(), dialogService) ); VBox container = new VBox( diff --git a/src/main/java/org/jabref/gui/help/VersionWorker.java b/src/main/java/org/jabref/gui/help/VersionWorker.java index 66579e67a40..b4760f58c9b 100644 --- a/src/main/java/org/jabref/gui/help/VersionWorker.java +++ b/src/main/java/org/jabref/gui/help/VersionWorker.java @@ -95,7 +95,7 @@ private void showUpdateInfo(Optional newerVersion, boolean manualExecut } } else { // notify the user about a newer version - if (dialogService.showCustomDialogAndWait(new NewVersionDialog(installedVersion, newerVersion.get())).orElse(true)) { + if (dialogService.showCustomDialogAndWait(new NewVersionDialog(installedVersion, newerVersion.get(), dialogService)).orElse(true)) { internalPreferences.setIgnoredVersion(newerVersion.get()); } } diff --git a/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java b/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java index 1eed96197a6..b139a4573c4 100644 --- a/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java +++ b/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java @@ -198,7 +198,7 @@ public void resolveDuplicate(BibEntry entry) { Optional other = new DuplicateCheck(entryTypesManager).containsDuplicate(databaseContext.getDatabase(), entry, databaseContext.getMode()); if (other.isPresent()) { DuplicateResolverDialog dialog = new DuplicateResolverDialog(other.get(), - entry, DuplicateResolverDialog.DuplicateResolverType.INSPECTION, databaseContext, stateManager); + entry, DuplicateResolverDialog.DuplicateResolverType.INSPECTION, databaseContext, stateManager, dialogService); DuplicateResolverDialog.DuplicateResolverResult result = dialogService.showCustomDialogAndWait(dialog) .orElse(DuplicateResolverDialog.DuplicateResolverResult.BREAK); @@ -229,7 +229,7 @@ public void resolveDuplicate(BibEntry entry) { other = findInternalDuplicate(entry); if (other.isPresent()) { DuplicateResolverDialog diag = new DuplicateResolverDialog(entry, - other.get(), DuplicateResolverDialog.DuplicateResolverType.DUPLICATE_SEARCH, databaseContext, stateManager); + other.get(), DuplicateResolverDialog.DuplicateResolverType.DUPLICATE_SEARCH, databaseContext, stateManager, dialogService); DuplicateResolverDialog.DuplicateResolverResult answer = dialogService.showCustomDialogAndWait(diag) .orElse(DuplicateResolverDialog.DuplicateResolverResult.BREAK); diff --git a/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneView.java b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneView.java index a37a4b1f670..db0b10539fe 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneView.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneView.java @@ -30,9 +30,11 @@ public class WebSearchPaneView extends VBox { private final WebSearchPaneViewModel viewModel; private final PreferencesService preferences; + private final DialogService dialogService; public WebSearchPaneView(PreferencesService preferences, DialogService dialogService, StateManager stateManager) { this.preferences = preferences; + this.dialogService = dialogService; this.viewModel = new WebSearchPaneViewModel(preferences, dialogService, stateManager); initialize(); } @@ -51,7 +53,7 @@ private void initialize() { ActionFactory factory = new ActionFactory(preferences.getKeyBindingRepository()); EasyBind.subscribe(viewModel.selectedFetcherProperty(), fetcher -> { if ((fetcher != null) && fetcher.getHelpPage().isPresent()) { - Button helpButton = factory.createIconButton(StandardActions.HELP, new HelpAction(fetcher.getHelpPage().get())); + Button helpButton = factory.createIconButton(StandardActions.HELP, new HelpAction(fetcher.getHelpPage().get(),dialogService)); helpButtonContainer.getChildren().setAll(helpButton); } else { helpButtonContainer.getChildren().clear(); diff --git a/src/main/java/org/jabref/gui/libraryproperties/constants/ConstantsPropertiesView.java b/src/main/java/org/jabref/gui/libraryproperties/constants/ConstantsPropertiesView.java index 16f43d77a70..0e83f999963 100644 --- a/src/main/java/org/jabref/gui/libraryproperties/constants/ConstantsPropertiesView.java +++ b/src/main/java/org/jabref/gui/libraryproperties/constants/ConstantsPropertiesView.java @@ -12,6 +12,7 @@ import javafx.scene.control.Tooltip; import javafx.util.converter.DefaultStringConverter; +import org.jabref.gui.DialogService; import org.jabref.gui.icon.IconTheme; import org.jabref.gui.libraryproperties.AbstractPropertiesTabView; import org.jabref.gui.libraryproperties.PropertiesTab; @@ -33,6 +34,7 @@ public class ConstantsPropertiesView extends AbstractPropertiesTabView> allValidProperty = EasyBind.map(stringsListProperty, ConstantsItemModel::combinedValidationValidProperty); @@ -90,7 +94,7 @@ public Optional labelAlreadyExists(String label) { } public void openHelpPage() { - HelpAction.openHelpPage(HelpFile.STRING_EDITOR); + new HelpAction(HelpFile.STRING_EDITOR, dialogService).execute(); } public ListProperty stringsListProperty() { diff --git a/src/main/java/org/jabref/gui/libraryproperties/keypattern/KeyPatternPropertiesView.java b/src/main/java/org/jabref/gui/libraryproperties/keypattern/KeyPatternPropertiesView.java index a47eabc2db3..74035d4cd03 100644 --- a/src/main/java/org/jabref/gui/libraryproperties/keypattern/KeyPatternPropertiesView.java +++ b/src/main/java/org/jabref/gui/libraryproperties/keypattern/KeyPatternPropertiesView.java @@ -48,7 +48,7 @@ public void initialize() { bibtexKeyPatternTable.defaultKeyPatternProperty().bindBidirectional(viewModel.defaultKeyPatternProperty()); ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs()); - actionFactory.configureIconButton(StandardActions.HELP_KEY_PATTERNS, new HelpAction(HelpFile.CITATION_KEY_PATTERN), keyPatternHelp); + actionFactory.configureIconButton(StandardActions.HELP_KEY_PATTERNS, new HelpAction(HelpFile.CITATION_KEY_PATTERN, dialogService), keyPatternHelp); } @Override diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index 2f203cc4381..68f274e1a2d 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -119,7 +119,7 @@ public OpenOfficePanel(PreferencesService preferencesService, manualConnect.setTooltip(new Tooltip(Localization.lang("Manual connect"))); manualConnect.setMaxWidth(Double.MAX_VALUE); - help = factory.createIconButton(StandardActions.HELP, new HelpAction(HelpFile.OPENOFFICE_LIBREOFFICE)); + help = factory.createIconButton(StandardActions.HELP, new HelpAction(HelpFile.OPENOFFICE_LIBREOFFICE, dialogService)); help.setMaxWidth(Double.MAX_VALUE); selectDocument = new Button(); diff --git a/src/main/java/org/jabref/gui/preferences/citationkeypattern/CitationKeyPatternTab.java b/src/main/java/org/jabref/gui/preferences/citationkeypattern/CitationKeyPatternTab.java index 325493c520f..1b1f2838949 100644 --- a/src/main/java/org/jabref/gui/preferences/citationkeypattern/CitationKeyPatternTab.java +++ b/src/main/java/org/jabref/gui/preferences/citationkeypattern/CitationKeyPatternTab.java @@ -60,7 +60,7 @@ public void initialize() { bibtexKeyPatternTable.defaultKeyPatternProperty().bindBidirectional(viewModel.defaultKeyPatternProperty()); ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs()); - actionFactory.configureIconButton(StandardActions.HELP_KEY_PATTERNS, new HelpAction(HelpFile.CITATION_KEY_PATTERN), keyPatternHelp); + actionFactory.configureIconButton(StandardActions.HELP_KEY_PATTERNS, new HelpAction(HelpFile.CITATION_KEY_PATTERN, dialogService), keyPatternHelp); } @Override diff --git a/src/main/java/org/jabref/gui/preferences/entryeditortabs/CustomEditorFieldsTab.java b/src/main/java/org/jabref/gui/preferences/entryeditortabs/CustomEditorFieldsTab.java index f00fbe24ee8..319f4e83f02 100644 --- a/src/main/java/org/jabref/gui/preferences/entryeditortabs/CustomEditorFieldsTab.java +++ b/src/main/java/org/jabref/gui/preferences/entryeditortabs/CustomEditorFieldsTab.java @@ -37,7 +37,7 @@ public void initialize() { fieldsTextArea.textProperty().bindBidirectional(viewModel.fieldsProperty()); ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs()); - actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.GENERAL_FIELDS), generalFieldsHelp); + actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.GENERAL_FIELDS, dialogService), generalFieldsHelp); } @FXML diff --git a/src/main/java/org/jabref/gui/preferences/file/FileTab.java b/src/main/java/org/jabref/gui/preferences/file/FileTab.java index 0fd6bc201e7..f91f08650a1 100644 --- a/src/main/java/org/jabref/gui/preferences/file/FileTab.java +++ b/src/main/java/org/jabref/gui/preferences/file/FileTab.java @@ -52,7 +52,7 @@ public void initialize() { autosaveLocalLibraries.selectedProperty().bindBidirectional(viewModel.autosaveLocalLibrariesProperty()); ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs()); - actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AUTOSAVE), autosaveLocalLibrariesHelp); + actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.AUTOSAVE, dialogService), autosaveLocalLibrariesHelp); } @Override diff --git a/src/main/java/org/jabref/gui/preferences/general/GeneralTab.java b/src/main/java/org/jabref/gui/preferences/general/GeneralTab.java index 2b421129d8b..4f561b8f2a1 100644 --- a/src/main/java/org/jabref/gui/preferences/general/GeneralTab.java +++ b/src/main/java/org/jabref/gui/preferences/general/GeneralTab.java @@ -81,7 +81,7 @@ public void initialize() { addModificationDate.selectedProperty().bindBidirectional(viewModel.addModificationDateProperty()); ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs()); - actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.OWNER), markOwnerHelp); + actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.OWNER, dialogService), markOwnerHelp); validationVisualizer.setDecoration(new IconValidationDecorator()); } diff --git a/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTab.java b/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTab.java index 6c4adbbdfa9..558ac2db289 100644 --- a/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTab.java +++ b/src/main/java/org/jabref/gui/preferences/linkedfiles/LinkedFilesTab.java @@ -71,7 +71,7 @@ public void initialize() { fileDirectoryPattern.textProperty().bindBidirectional(viewModel.fileDirectoryPatternProperty()); ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs()); - actionFactory.configureIconButton(StandardActions.HELP_REGEX_SEARCH, new HelpAction(HelpFile.REGEX_SEARCH), autolinkRegexHelp); + actionFactory.configureIconButton(StandardActions.HELP_REGEX_SEARCH, new HelpAction(HelpFile.REGEX_SEARCH, dialogService), autolinkRegexHelp); validationVisualizer.setDecoration(new IconValidationDecorator()); Platform.runLater(() -> validationVisualizer.initVisualization(viewModel.mainFileDirValidationStatus(), mainFileDirectory)); diff --git a/src/main/java/org/jabref/gui/preferences/nameformatter/NameFormatterTab.java b/src/main/java/org/jabref/gui/preferences/nameformatter/NameFormatterTab.java index 03038872af2..84ccc80d80d 100644 --- a/src/main/java/org/jabref/gui/preferences/nameformatter/NameFormatterTab.java +++ b/src/main/java/org/jabref/gui/preferences/nameformatter/NameFormatterTab.java @@ -103,7 +103,7 @@ public void initialize() { }); ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs()); - actionFactory.configureIconButton(StandardActions.HELP_NAME_FORMATTER, new HelpAction(HelpFile.CUSTOM_EXPORTS_NAME_FORMATTER), formatterHelp); + actionFactory.configureIconButton(StandardActions.HELP_NAME_FORMATTER, new HelpAction(HelpFile.CUSTOM_EXPORTS_NAME_FORMATTER, dialogService), formatterHelp); } public void addFormatter() { diff --git a/src/main/java/org/jabref/gui/preferences/network/NetworkTab.java b/src/main/java/org/jabref/gui/preferences/network/NetworkTab.java index 0e7e700f074..1002f80b22e 100644 --- a/src/main/java/org/jabref/gui/preferences/network/NetworkTab.java +++ b/src/main/java/org/jabref/gui/preferences/network/NetworkTab.java @@ -110,7 +110,7 @@ public void initialize() { proxyPassword.getRight().addEventFilter(MouseEvent.MOUSE_EXITED, this::proxyPasswordMask); ActionFactory actionFactory = new ActionFactory(Globals.getKeyPrefs()); - actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.REMOTE), remoteHelp); + actionFactory.configureIconButton(StandardActions.HELP, new HelpAction(HelpFile.REMOTE, dialogService), remoteHelp); validationVisualizer.setDecoration(new IconValidationDecorator()); Platform.runLater(() -> { diff --git a/src/main/java/org/jabref/gui/preferences/table/TableTab.java b/src/main/java/org/jabref/gui/preferences/table/TableTab.java index 6014d21ae90..e3ab7004598 100644 --- a/src/main/java/org/jabref/gui/preferences/table/TableTab.java +++ b/src/main/java/org/jabref/gui/preferences/table/TableTab.java @@ -66,7 +66,7 @@ public void initialize() { setupBindings(); ActionFactory actionFactory = new ActionFactory(preferencesService.getKeyBindingRepository()); - actionFactory.configureIconButton(StandardActions.HELP_SPECIAL_FIELDS, new HelpAction(HelpFile.SPECIAL_FIELDS), specialFieldsHelp); + actionFactory.configureIconButton(StandardActions.HELP_SPECIAL_FIELDS, new HelpAction(HelpFile.SPECIAL_FIELDS, dialogService), specialFieldsHelp); } private void setupTable() { diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java index 857a410692d..43bf6f86dac 100644 --- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java +++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java @@ -184,7 +184,7 @@ private boolean openSharedDatabase(DBMSConnectionProperties connectionProperties Localization.lang("However, a new database was created alongside the pre-3.6 one."), ButtonType.OK, openHelp); - result.filter(btn -> btn.equals(openHelp)).ifPresent(btn -> HelpAction.openHelpPage(HelpFile.SQL_DATABASE_MIGRATION)); + result.filter(btn -> btn.equals(openHelp)).ifPresent(btn -> new HelpAction(HelpFile.SQL_DATABASE_MIGRATION, dialogService).execute()); result.filter(btn -> btn.equals(ButtonType.OK)).ifPresent(btn -> openSharedDatabase(connectionProperties)); } loading.set(false); diff --git a/src/test/java/org/jabref/gui/util/OpenConsoleActionTest.java b/src/test/java/org/jabref/gui/util/OpenConsoleActionTest.java index e96d8b80591..5ec37c2ee0e 100644 --- a/src/test/java/org/jabref/gui/util/OpenConsoleActionTest.java +++ b/src/test/java/org/jabref/gui/util/OpenConsoleActionTest.java @@ -31,7 +31,7 @@ public void setup() { @Test public void newActionGetsCurrentDatabase() { - OpenConsoleAction action = new OpenConsoleAction(stateManager, preferences); + OpenConsoleAction action = new OpenConsoleAction(stateManager, preferences, null); action.execute(); verify(stateManager, times(1)).getActiveDatabase(); verify(current, times(1)).getDatabasePath(); @@ -39,7 +39,7 @@ public void newActionGetsCurrentDatabase() { @Test public void newActionGetsSuppliedDatabase() { - OpenConsoleAction action = new OpenConsoleAction(() -> other, stateManager, preferences); + OpenConsoleAction action = new OpenConsoleAction(() -> other, stateManager, preferences, null); action.execute(); verify(stateManager, never()).getActiveDatabase(); verify(other, times(1)).getDatabasePath(); @@ -47,7 +47,7 @@ public void newActionGetsSuppliedDatabase() { @Test public void actionDefaultsToCurrentDatabase() { - OpenConsoleAction action = new OpenConsoleAction(() -> null, stateManager, preferences); + OpenConsoleAction action = new OpenConsoleAction(() -> null, stateManager, preferences, null); action.execute(); verify(stateManager, times(1)).getActiveDatabase(); verify(current, times(1)).getDatabasePath(); From 8d2527b596317c65fb75806a16a4ce41db85cad8 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Wed, 1 Jun 2022 22:15:55 +0200 Subject: [PATCH 07/11] fix checkstyle --- src/main/java/org/jabref/gui/desktop/os/Linux.java | 2 +- .../java/org/jabref/gui/importer/fetcher/WebSearchPaneView.java | 2 +- .../constants/ConstantsPropertiesViewModel.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/gui/desktop/os/Linux.java b/src/main/java/org/jabref/gui/desktop/os/Linux.java index 3cba7820bd9..d12eb3b4339 100644 --- a/src/main/java/org/jabref/gui/desktop/os/Linux.java +++ b/src/main/java/org/jabref/gui/desktop/os/Linux.java @@ -146,7 +146,7 @@ public void openConsole(String absolutePath, DialogService dialogService) throws cmd = new String[] {emulatorName, absolutePath}; } - ProcessBuilder builder = new ProcessBuilder(cmd); + ProcessBuilder builder = new ProcessBuilder(cmd); builder.directory(new File(absolutePath)); builder.start(); diff --git a/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneView.java b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneView.java index db0b10539fe..df252ccc8df 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneView.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneView.java @@ -53,7 +53,7 @@ private void initialize() { ActionFactory factory = new ActionFactory(preferences.getKeyBindingRepository()); EasyBind.subscribe(viewModel.selectedFetcherProperty(), fetcher -> { if ((fetcher != null) && fetcher.getHelpPage().isPresent()) { - Button helpButton = factory.createIconButton(StandardActions.HELP, new HelpAction(fetcher.getHelpPage().get(),dialogService)); + Button helpButton = factory.createIconButton(StandardActions.HELP, new HelpAction(fetcher.getHelpPage().get(), dialogService)); helpButtonContainer.getChildren().setAll(helpButton); } else { helpButtonContainer.getChildren().clear(); diff --git a/src/main/java/org/jabref/gui/libraryproperties/constants/ConstantsPropertiesViewModel.java b/src/main/java/org/jabref/gui/libraryproperties/constants/ConstantsPropertiesViewModel.java index f5ed586b365..8616f4e6b3f 100644 --- a/src/main/java/org/jabref/gui/libraryproperties/constants/ConstantsPropertiesViewModel.java +++ b/src/main/java/org/jabref/gui/libraryproperties/constants/ConstantsPropertiesViewModel.java @@ -36,7 +36,7 @@ public class ConstantsPropertiesViewModel implements PropertiesTabViewModel { public ConstantsPropertiesViewModel(BibDatabaseContext databaseContext, DialogService dialogService) { this.databaseContext = databaseContext; - this.dialogService = dialogService; + this.dialogService = dialogService; ObservableList> allValidProperty = EasyBind.map(stringsListProperty, ConstantsItemModel::combinedValidationValidProperty); From b587215df5bf22334e03ba6218c0426a6715b1e0 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Wed, 1 Jun 2022 22:24:02 +0200 Subject: [PATCH 08/11] checkstyle --- src/main/java/org/jabref/gui/desktop/os/NativeDesktop.java | 1 + src/main/java/org/jabref/gui/help/HelpAction.java | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/desktop/os/NativeDesktop.java b/src/main/java/org/jabref/gui/desktop/os/NativeDesktop.java index 8f4c4d8d985..959b6aa10fe 100644 --- a/src/main/java/org/jabref/gui/desktop/os/NativeDesktop.java +++ b/src/main/java/org/jabref/gui/desktop/os/NativeDesktop.java @@ -6,6 +6,7 @@ import org.jabref.gui.DialogService; public interface NativeDesktop { + void openFile(String filePath, String fileType) throws IOException; /** diff --git a/src/main/java/org/jabref/gui/help/HelpAction.java b/src/main/java/org/jabref/gui/help/HelpAction.java index a225685a2dd..0447f7331ed 100644 --- a/src/main/java/org/jabref/gui/help/HelpAction.java +++ b/src/main/java/org/jabref/gui/help/HelpAction.java @@ -19,13 +19,12 @@ public HelpAction(HelpFile helpPage, DialogService dialogService) { this.dialogService = dialogService; } - void openHelpPage(HelpFile helpPage) { + void openHelpPage(HelpFile helpPage) { StringBuilder sb = new StringBuilder("https://docs.jabref.org/"); sb.append(helpPage.getPageName()); JabRefDesktop.openBrowserShowPopup(sb.toString(), dialogService); } - @Override public void execute() { openHelpPage(helpPage); From f607ee99e77993b813f09a21690d2a24bf918c05 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Wed, 1 Jun 2022 22:24:29 +0200 Subject: [PATCH 09/11] remove blank line --- src/main/java/org/jabref/gui/desktop/os/NativeDesktop.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/desktop/os/NativeDesktop.java b/src/main/java/org/jabref/gui/desktop/os/NativeDesktop.java index 959b6aa10fe..349368ef3a6 100644 --- a/src/main/java/org/jabref/gui/desktop/os/NativeDesktop.java +++ b/src/main/java/org/jabref/gui/desktop/os/NativeDesktop.java @@ -39,5 +39,4 @@ public interface NativeDesktop { default Path getUserDirectory() { return Path.of(System.getProperty("user.home")); } - } From ceca3bfc127335d001e7edbbb68e5d711c2f2902 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sun, 5 Jun 2022 17:21:44 +0200 Subject: [PATCH 10/11] add missing l10n --- src/main/resources/l10n/JabRef_en.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 568136a3534..1cc2c330268 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -1303,6 +1303,7 @@ Please\ open\ %0\ manually.=Please open %0 manually. The\ link\ has\ been\ copied\ to\ the\ clipboard.=The link has been copied to the clipboard. Open\ %0\ file=Open %0 file +Could\ not\ detect\ terminal\ automatically.\ Please\ define\ a\ custom\ terminal\ in\ the\ preferences.=Could not detect terminal automatically. Please define a custom terminal in the preferences. Cannot\ delete\ file=Cannot delete file File\ permission\ error=File permission error From 7b263a63c8109f1abdba0893915efaebea4f969a Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sun, 5 Jun 2022 17:27:17 +0200 Subject: [PATCH 11/11] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index de3230689b5..e3d23b986ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Fixed +- We fixed an issue where "open folder" for linked files did not open the folder and did not select the file unter certain Linux desktop environments [#8679](https://github.com/JabRef/jabref/issues/8679), [#8849](https://github.com/JabRef/jabref/issues/8849) - We fixed an issue where the content of a big shared database library is not shown [#8788](https://github.com/JabRef/jabref/issues/8788) - We fixed the unnecessary horizontal scroll bar in group panel [#8467](https://github.com/JabRef/jabref/issues/8467) - We fixed an issue where the notification bar message, icon and actions appeared to be invisible. [#8761](https://github.com/JabRef/jabref/issues/8761)