From 84463e7fba930d2c44e7cfb4421826b9926e0dc0 Mon Sep 17 00:00:00 2001 From: Sebastian Balzer <120449829+cardionaut@users.noreply.github.com> Date: Mon, 4 Mar 2024 12:16:47 +0100 Subject: [PATCH 01/36] Added ability to change zoom using Ctrl + Scroll in Document Viewer (#10964) * Add ability to zoom using Ctrl + Scroll in PDF Viewer * Limit zoom-out to ~1 page Observed problems with infinite zoom-out: - Occasional display errors (e.g. no text displayed for certain pages) - No content can be seen if zoomed out too far, might be unclear to user what happened and that zooming in will fix problem * Updated CHANGELOG * Remove catch newline from formatter * Update CHANGELOG.md --------- Co-authored-by: Oliver Kopp --- CHANGELOG.md | 1 + .../documentviewer/DocumentViewerControl.java | 22 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index caca9f295a7..172492abf17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We added the possibility to redownload files that had been present but are no longer in the specified location. [#10848](https://github.com/JabRef/jabref/issues/10848) - We added the citation key pattern `[camelN]`. Equivalent to the first N words of the `[camel]` pattern. - We added ability to export in CFF (Citation File Format) [#10661](https://github.com/JabRef/jabref/issues/10661). +- We added the ability to zoom in and out in the document viewer using Ctrl + Scroll. [#10964](https://github.com/JabRef/jabref/pull/10964) ### Changed diff --git a/src/main/java/org/jabref/gui/documentviewer/DocumentViewerControl.java b/src/main/java/org/jabref/gui/documentviewer/DocumentViewerControl.java index 75709e4f28b..03b46392267 100644 --- a/src/main/java/org/jabref/gui/documentviewer/DocumentViewerControl.java +++ b/src/main/java/org/jabref/gui/documentviewer/DocumentViewerControl.java @@ -14,6 +14,7 @@ import javafx.scene.control.ProgressIndicator; import javafx.scene.image.Image; import javafx.scene.image.ImageView; +import javafx.scene.input.ScrollEvent; import javafx.scene.layout.StackPane; import javafx.scene.shape.Rectangle; import javafx.util.Duration; @@ -76,6 +77,16 @@ public void show(DocumentViewModel document) { flow.estimatedScrollYProperty().addListener((observable, oldValue, newValue) -> scrollY.setValue(newValue)); scrollY.addListener((observable, oldValue, newValue) -> flow.estimatedScrollYProperty().setValue((double) newValue)); flow.totalLengthEstimateProperty().addListener((observable, oldValue, newValue) -> scrollYMax.setValue(newValue)); + flow.addEventFilter(ScrollEvent.SCROLL, (ScrollEvent event) -> { + if (event.isControlDown()) { + event.consume(); + if (event.getDeltaY() > 0) { + changePageWidth(100); + } else { + changePageWidth(-100); + } + } + }); } private void updateCurrentPage(ObservableList visiblePages) { @@ -128,7 +139,16 @@ private void updateSizeOfDisplayedPages() { public void changePageWidth(int delta) { // Assuming the current page is A4 (or has same aspect ratio) - setPageWidth(desiredPageDimension.getWidth(Math.sqrt(2)) + delta); + int newWidth = desiredPageDimension.getWidth(Math.sqrt(2)) + delta; + // Limit zoom out to ~1 page due to occasional display errors when zooming out further + int minWidth = (int) (flow.getHeight() / 2 * Math.sqrt(2)); + if (newWidth < minWidth) { + if (newWidth - delta == minWidth) { // Attempting to zoom out when already at minWidth + return; + } + newWidth = minWidth; + } + setPageWidth(newWidth); } /** From 2368786de76c1c93d9acfb963e744038403c56be Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:19:58 +0000 Subject: [PATCH 02/36] Bump org.javamodularity.moduleplugin from 1.8.13 to 1.8.14 (#10971) Bumps org.javamodularity.moduleplugin from 1.8.13 to 1.8.14. --- updated-dependencies: - dependency-name: org.javamodularity.moduleplugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3a9281c2352..21d17f4f266 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ plugins { id 'me.champeau.jmh' version '0.7.2' - id 'org.javamodularity.moduleplugin' version '1.8.13' + id 'org.javamodularity.moduleplugin' version '1.8.14' id 'org.openjfx.javafxplugin' version '0.1.0' From e470111d5ff6c34522cac8624f8e3c6040f8718e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:21:48 +0000 Subject: [PATCH 03/36] Bump org.openrewrite.rewrite from 6.8.2 to 6.8.4 (#10973) Bumps org.openrewrite.rewrite from 6.8.2 to 6.8.4. --- updated-dependencies: - dependency-name: org.openrewrite.rewrite dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 21d17f4f266..6b23be2e017 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ plugins { id 'idea' - id 'org.openrewrite.rewrite' version '6.8.2' + id 'org.openrewrite.rewrite' version '6.8.4' } // Enable following for debugging From ed64cd72b773b223d4494db404b87f7775e66cda Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:23:16 +0000 Subject: [PATCH 04/36] Bump com.dlsc.gemsfx:gemsfx from 2.0.3 to 2.2.0 (#10974) Bumps [com.dlsc.gemsfx:gemsfx](https://github.com/dlsc-software-consulting-gmbh/GemsFX) from 2.0.3 to 2.2.0. - [Release notes](https://github.com/dlsc-software-consulting-gmbh/GemsFX/releases) - [Changelog](https://github.com/dlsc-software-consulting-gmbh/GemsFX/blob/master/CHANGELOG.md) - [Commits](https://github.com/dlsc-software-consulting-gmbh/GemsFX/compare/v2.0.3...v2.2.0) --- updated-dependencies: - dependency-name: com.dlsc.gemsfx:gemsfx dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 6b23be2e017..a4baf054b6d 100644 --- a/build.gradle +++ b/build.gradle @@ -177,7 +177,7 @@ dependencies { implementation('com.tobiasdiez:easybind:2.2.1-SNAPSHOT') implementation 'org.fxmisc.flowless:flowless:0.7.2' implementation 'org.fxmisc.richtext:richtextfx:0.11.2' - implementation (group: 'com.dlsc.gemsfx', name: 'gemsfx', version: '2.0.3') { + implementation (group: 'com.dlsc.gemsfx', name: 'gemsfx', version: '2.2.0') { exclude module: 'javax.inject' // Split package, use only jakarta.inject exclude group: 'org.apache.logging.log4j' } From e9711a612de9b3a344863c4b413c798a0f38fe2d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:23:42 +0000 Subject: [PATCH 05/36] Bump org.mockito:mockito-core from 5.10.0 to 5.11.0 (#10972) Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.10.0 to 5.11.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v5.10.0...v5.11.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a4baf054b6d..7217d4cf57a 100644 --- a/build.gradle +++ b/build.gradle @@ -246,7 +246,7 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2' testImplementation 'org.junit.platform:junit-platform-launcher:1.10.2' - testImplementation 'org.mockito:mockito-core:5.10.0' + testImplementation 'org.mockito:mockito-core:5.11.0' testImplementation 'org.xmlunit:xmlunit-core:2.9.1' testImplementation 'org.xmlunit:xmlunit-matchers:2.9.1' testRuntimeOnly 'com.tngtech.archunit:archunit-junit5-engine:1.2.1' From 25137834659cd3fbef4466e90eeea61759cb7b73 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:30:06 +0000 Subject: [PATCH 06/36] Bump org.openrewrite.recipe:rewrite-recipe-bom from 2.6.4 to 2.7.1 (#10976) Bumps [org.openrewrite.recipe:rewrite-recipe-bom](https://github.com/openrewrite/rewrite-recipe-bom) from 2.6.4 to 2.7.1. - [Release notes](https://github.com/openrewrite/rewrite-recipe-bom/releases) - [Commits](https://github.com/openrewrite/rewrite-recipe-bom/compare/v2.6.4...v2.7.1) --- updated-dependencies: - dependency-name: org.openrewrite.recipe:rewrite-recipe-bom dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7217d4cf57a..146f6bfc54f 100644 --- a/build.gradle +++ b/build.gradle @@ -260,7 +260,7 @@ dependencies { xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '3.0.2' xjc group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '3.0.2' - rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.6.4")) + rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.7.1")) rewrite("org.openrewrite.recipe:rewrite-static-analysis") rewrite("org.openrewrite.recipe:rewrite-logging-frameworks") rewrite("org.openrewrite.recipe:rewrite-testing-frameworks") From 84ddaf590a76c676f5bb02750580f35dd5e9f35c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:02:29 +0000 Subject: [PATCH 07/36] Bump gittools/actions from 0.11.0 to 0.13.2 (#10978) Bumps [gittools/actions](https://github.com/gittools/actions) from 0.11.0 to 0.13.2. - [Release notes](https://github.com/gittools/actions/releases) - [Commits](https://github.com/gittools/actions/compare/v0.11.0...v0.13.2) --- updated-dependencies: - dependency-name: gittools/actions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/deployment-arm64.yml | 4 ++-- .github/workflows/deployment-jdk-ea.yml | 4 ++-- .github/workflows/deployment.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deployment-arm64.yml b/.github/workflows/deployment-arm64.yml index f4e34f09f8f..9f8f4c99917 100644 --- a/.github/workflows/deployment-arm64.yml +++ b/.github/workflows/deployment-arm64.yml @@ -66,12 +66,12 @@ jobs: submodules: 'true' show-progress: 'false' - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0.11.0 + uses: gittools/actions/gitversion/setup@v0.13.2 with: versionSpec: "5.x" - name: Run GitVersion id: gitversion - uses: gittools/actions/gitversion/execute@v0.11.0 + uses: gittools/actions/gitversion/execute@v0.13.2 - name: Setup JDK uses: actions/setup-java@v4 with: diff --git a/.github/workflows/deployment-jdk-ea.yml b/.github/workflows/deployment-jdk-ea.yml index 10f34ba4a5f..41d8d6b853a 100644 --- a/.github/workflows/deployment-jdk-ea.yml +++ b/.github/workflows/deployment-jdk-ea.yml @@ -88,12 +88,12 @@ jobs: packages: pigz version: 1.0 - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0.11.0 + uses: gittools/actions/gitversion/setup@v0.13.2 with: versionSpec: "5.x" - name: Run GitVersion id: gitversion - uses: gittools/actions/gitversion/execute@v0.11.0 + uses: gittools/actions/gitversion/execute@v0.13.2 - name: 'Set up JDK ${{ matrix.jdk }}' uses: oracle-actions/setup-java@v1 with: diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 997dc580748..02f62504013 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -79,12 +79,12 @@ jobs: packages: pigz version: 1.0 - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0.11.0 + uses: gittools/actions/gitversion/setup@v0.13.2 with: versionSpec: "5.x" - name: Run GitVersion id: gitversion - uses: gittools/actions/gitversion/execute@v0.11.0 + uses: gittools/actions/gitversion/execute@v0.13.2 - name: Setup JDK uses: actions/setup-java@v4 with: From 43eb3ef4863c94b1e060045f9ca3321a3111a834 Mon Sep 17 00:00:00 2001 From: Vlad Dobre <29517124+vladdobre@users.noreply.github.com> Date: Mon, 4 Mar 2024 20:38:26 +0100 Subject: [PATCH 08/36] Add support for TeXworks (#10953) * add TeXworks (Icon needs fixing) (#3197) Co-Authored-By: JohannBiorck <85625348+johannbiorck@users.noreply.github.com> * feat: add test for pushToTeXworks (#3197) * refactor: change icon to default icon (#3197) Co-Authored-By: JohannBiorck <85625348+johannbiorck@users.noreply.github.com> * fix: add TeXworks to applicationCommands (#3197) * doc: javadoc for PushToTeXworks (#3197) Co-Authored-By: JohannBiorck <85625348+johannbiorck@users.noreply.github.com> * Fix: find the test error + add other test (#3197) * add more tests and setCommandPath in PushToTeXworks (#3197) Co-Authored-By: JohannBiorck <85625348+johannbiorck@users.noreply.github.com> Co-Authored-By: LACHIRI ILIAS <67273129+lachiri-ilias@users.noreply.github.com> * doc: Update CHANGELOG.md #3197 Updated changelong to reflect changes. * fix: Fix Checkstyle for PushToTeXworksTest #3197 Co-Authored-By: Vlad Dobre <29517124+vladdobre@users.noreply.github.com> Co-Authored-By: Kr1st1an-F <100246316+kr1st1an-f@users.noreply.github.com> * fix: checkstyle for PushToTeXworksTest (end with newline) and openrewrite #3197 Co-Authored-By: Vlad Dobre <29517124+vladdobre@users.noreply.github.com> Co-Authored-By: Kr1st1an-F <100246316+kr1st1an-f@users.noreply.github.com> * Fix: fix suggestion for the pull request (#3197) * Update src/main/java/org/jabref/gui/push/PushToTeXworks.java * Modified tests, moved comments to interface --------- Co-authored-by: maxisr Co-authored-by: JohannBiorck <85625348+johannbiorck@users.noreply.github.com> Co-authored-by: LACHIRI Co-authored-by: LACHIRI ILIAS <67273129+lachiri-ilias@users.noreply.github.com> Co-authored-by: Kr1st1an-F <100246316+kr1st1an-f@users.noreply.github.com> Co-authored-by: Oliver Kopp Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> --- CHANGELOG.md | 1 + .../gui/push/AbstractPushToApplication.java | 14 ++- .../jabref/gui/push/PushToApplication.java | 14 +++ .../jabref/gui/push/PushToApplications.java | 2 + .../org/jabref/gui/push/PushToTeXworks.java | 37 +++++++ .../jabref/preferences/JabRefPreferences.java | 5 + .../jabref/gui/push/PushToTeXworksTest.java | 102 ++++++++++++++++++ 7 files changed, 172 insertions(+), 3 deletions(-) create mode 100644 src/main/java/org/jabref/gui/push/PushToTeXworks.java create mode 100644 src/test/java/org/jabref/gui/push/PushToTeXworksTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 172492abf17..38461b0d26b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We added the possibility to redownload files that had been present but are no longer in the specified location. [#10848](https://github.com/JabRef/jabref/issues/10848) - We added the citation key pattern `[camelN]`. Equivalent to the first N words of the `[camel]` pattern. - We added ability to export in CFF (Citation File Format) [#10661](https://github.com/JabRef/jabref/issues/10661). +- We added ability to push entries to TeXworks. [#3197](https://github.com/JabRef/jabref/issues/3197) - We added the ability to zoom in and out in the document viewer using Ctrl + Scroll. [#10964](https://github.com/JabRef/jabref/pull/10964) ### Changed diff --git a/src/main/java/org/jabref/gui/push/AbstractPushToApplication.java b/src/main/java/org/jabref/gui/push/AbstractPushToApplication.java index 3de3e190432..0c4e1b88d93 100644 --- a/src/main/java/org/jabref/gui/push/AbstractPushToApplication.java +++ b/src/main/java/org/jabref/gui/push/AbstractPushToApplication.java @@ -17,6 +17,7 @@ import org.jabref.preferences.PreferencesService; import org.jabref.preferences.PushToApplicationPreferences; +import com.google.common.annotations.VisibleForTesting; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,6 +58,11 @@ public Action getAction() { @Override public void pushEntries(BibDatabaseContext database, List entries, String keyString) { + pushEntries(database, entries, keyString, new ProcessBuilder()); + } + + @VisibleForTesting + protected void pushEntries(BibDatabaseContext database, List entries, String keyString, ProcessBuilder processBuilder) { couldNotPush = false; couldNotCall = false; notDefined = false; @@ -77,7 +83,7 @@ public void pushEntries(BibDatabaseContext database, List entries, Str LOGGER.error("Commandline does not contain enough parameters to \"push to application\""); return; } - ProcessBuilder processBuilder = new ProcessBuilder( + processBuilder.command( "open", "-a", commands[0], @@ -88,7 +94,7 @@ public void pushEntries(BibDatabaseContext database, List entries, Str ); processBuilder.start(); } else { - ProcessBuilder processBuilder = new ProcessBuilder(getCommandLine(keyString)); + processBuilder.command(getCommandLine(keyString)); processBuilder.start(); } } catch (IOException excep) { @@ -122,7 +128,9 @@ public boolean requiresCitationKeys() { } /** - * Function to get the command to be executed for pushing keys to be cited + * Constructs the command line arguments for pushing citations to the application. + * The method formats the citation key and prefixes/suffixes as per user preferences + * before invoking the application with the command to insert text. * * @param keyString String containing the Bibtex keys to be pushed to the application * @return String array with the command to call and its arguments diff --git a/src/main/java/org/jabref/gui/push/PushToApplication.java b/src/main/java/org/jabref/gui/push/PushToApplication.java index b7d5223e83d..defe018f0c1 100644 --- a/src/main/java/org/jabref/gui/push/PushToApplication.java +++ b/src/main/java/org/jabref/gui/push/PushToApplication.java @@ -13,10 +13,24 @@ */ public interface PushToApplication { + /** + * Gets the display name for the push operation. This name is used + * in the GUI to represent the push action to the user. + * + * @return The display name for the push operation. + */ String getDisplayName(); + /** + * Gets a tooltip for the push operation. + */ String getTooltip(); + /** + * Gets the icon associated with the application. + * + * @return The icon for the application. + */ JabRefIcon getApplicationIcon(); /** diff --git a/src/main/java/org/jabref/gui/push/PushToApplications.java b/src/main/java/org/jabref/gui/push/PushToApplications.java index 91d087f84fd..da229ac2c59 100644 --- a/src/main/java/org/jabref/gui/push/PushToApplications.java +++ b/src/main/java/org/jabref/gui/push/PushToApplications.java @@ -13,6 +13,7 @@ public class PushToApplications { public static final String LYX = "LyX/Kile"; public static final String TEXMAKER = "Texmaker"; public static final String TEXSTUDIO = "TeXstudio"; + public static final String TEXWORKS = "TeXworks"; public static final String VIM = "Vim"; public static final String WIN_EDT = "WinEdt"; public static final String SUBLIME_TEXT = "Sublime Text"; @@ -34,6 +35,7 @@ public static List getAllApplications(DialogService dialogSer new PushToSublimeText(dialogService, preferencesService), new PushToTexmaker(dialogService, preferencesService), new PushToTeXstudio(dialogService, preferencesService), + new PushToTeXworks(dialogService, preferencesService), new PushToVim(dialogService, preferencesService), new PushToWinEdt(dialogService, preferencesService), new PushToTexShop(dialogService, preferencesService))); diff --git a/src/main/java/org/jabref/gui/push/PushToTeXworks.java b/src/main/java/org/jabref/gui/push/PushToTeXworks.java new file mode 100644 index 00000000000..fbc052a64c7 --- /dev/null +++ b/src/main/java/org/jabref/gui/push/PushToTeXworks.java @@ -0,0 +1,37 @@ +package org.jabref.gui.push; + +import org.jabref.gui.DialogService; +import org.jabref.gui.icon.IconTheme; +import org.jabref.gui.icon.JabRefIcon; +import org.jabref.preferences.PreferencesService; + +public class PushToTeXworks extends AbstractPushToApplication { + + public static final String NAME = PushToApplications.TEXWORKS; + + /** + * Constructs a new {@code PushToTeXworks} instance. + * + * @param dialogService The dialog service for displaying messages to the user. + * @param preferencesService The service for accessing user preferences. + */ + public PushToTeXworks(DialogService dialogService, PreferencesService preferencesService) { + super(dialogService, preferencesService); + } + + @Override + public String getDisplayName() { + return NAME; + } + + @Override + public JabRefIcon getApplicationIcon() { + // TODO: replace the placeholder icon with the real one. + return IconTheme.JabRefIcons.APPLICATION_GENERIC; + } + + @Override + protected String[] getCommandLine(String keyString) { + return new String[] {commandPath, "--insert-text", "%s%s%s".formatted(getCitePrefix(), keyString, getCiteSuffix())}; + } +} diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index fe106584d86..8b881ea8b15 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -150,6 +150,7 @@ public class JabRefPreferences implements PreferencesService { public static final String PUSH_EMACS_ADDITIONAL_PARAMETERS = "emacsParameters"; public static final String PUSH_LYXPIPE = "lyxpipe"; public static final String PUSH_TEXSTUDIO_PATH = "TeXstudioPath"; + public static final String PUSH_TEXWORKS_PATH = "TeXworksPath"; public static final String PUSH_WINEDT_PATH = "winEdtPath"; public static final String PUSH_TEXMAKER_PATH = "texmakerPath"; public static final String PUSH_VIM_SERVER = "vimServer"; @@ -543,6 +544,7 @@ private JabRefPreferences() { defaults.put(PUSH_TEXMAKER_PATH, OS.getNativeDesktop().detectProgramPath("texmaker", "Texmaker")); defaults.put(PUSH_WINEDT_PATH, OS.getNativeDesktop().detectProgramPath("WinEdt", "WinEdt Team\\WinEdt")); defaults.put(PUSH_TEXSTUDIO_PATH, OS.getNativeDesktop().detectProgramPath("texstudio", "TeXstudio")); + defaults.put(PUSH_TEXWORKS_PATH, OS.getNativeDesktop().detectProgramPath("texworks", "TeXworks")); defaults.put(PUSH_SUBLIME_TEXT_PATH, OS.getNativeDesktop().detectProgramPath("subl", "Sublime")); defaults.put(PUSH_LYXPIPE, USER_HOME + File.separator + ".lyx/lyxpipe"); defaults.put(PUSH_VIM, "vim"); @@ -1783,6 +1785,7 @@ public PushToApplicationPreferences getPushToApplicationPreferences() { applicationCommands.put(PushToApplications.LYX, get(PUSH_LYXPIPE)); applicationCommands.put(PushToApplications.TEXMAKER, get(PUSH_TEXMAKER_PATH)); applicationCommands.put(PushToApplications.TEXSTUDIO, get(PUSH_TEXSTUDIO_PATH)); + applicationCommands.put(PushToApplications.TEXWORKS, get(PUSH_TEXWORKS_PATH)); applicationCommands.put(PushToApplications.VIM, get(PUSH_VIM)); applicationCommands.put(PushToApplications.WIN_EDT, get(PUSH_WINEDT_PATH)); applicationCommands.put(PushToApplications.SUBLIME_TEXT, get(PUSH_SUBLIME_TEXT_PATH)); @@ -1812,6 +1815,8 @@ private void storePushToApplicationPath(Map commandPair) { put(PUSH_TEXMAKER_PATH, value); case PushToApplications.TEXSTUDIO -> put(PUSH_TEXSTUDIO_PATH, value); + case PushToApplications.TEXWORKS -> + put(PUSH_TEXWORKS_PATH, value); case PushToApplications.VIM -> put(PUSH_VIM, value); case PushToApplications.WIN_EDT -> diff --git a/src/test/java/org/jabref/gui/push/PushToTeXworksTest.java b/src/test/java/org/jabref/gui/push/PushToTeXworksTest.java new file mode 100644 index 00000000000..4dad0b67582 --- /dev/null +++ b/src/test/java/org/jabref/gui/push/PushToTeXworksTest.java @@ -0,0 +1,102 @@ +package org.jabref.gui.push; + +import java.util.Map; + +import javafx.beans.property.SimpleMapProperty; +import javafx.collections.FXCollections; +import javafx.collections.ObservableMap; + +import org.jabref.gui.DialogService; +import org.jabref.logic.push.CitationCommandString; +import org.jabref.preferences.ExternalApplicationsPreferences; +import org.jabref.preferences.PreferencesService; +import org.jabref.preferences.PushToApplicationPreferences; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Answers; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +class PushToTeXworksTest { + + private static final String TEXWORKS_CLIENT_PATH = "/usr/bin/texworks"; + private static final String DISPLAY_NAME = "TeXworks"; + + private PushToTeXworks pushToTeXworks; + + @BeforeEach + public void setup() { + DialogService dialogService = mock(DialogService.class, Answers.RETURNS_DEEP_STUBS); + PreferencesService preferencesService = mock(PreferencesService.class); + PushToApplicationPreferences pushToApplicationPreferences = mock(PushToApplicationPreferences.class); + + // Mock the command path + Map commandPaths = Map.of(DISPLAY_NAME, TEXWORKS_CLIENT_PATH); + ObservableMap observableCommandPaths = FXCollections.observableMap(commandPaths); + when(pushToApplicationPreferences.getCommandPaths()).thenReturn(new SimpleMapProperty<>(observableCommandPaths)); + when(preferencesService.getPushToApplicationPreferences()).thenReturn(pushToApplicationPreferences); + + // Mock the return value for getCiteCommand() + ExternalApplicationsPreferences externalApplicationsPreferences = mock(ExternalApplicationsPreferences.class); + CitationCommandString mockCiteCommand = mock(CitationCommandString.class); + when(mockCiteCommand.prefix()).thenReturn(""); + when(mockCiteCommand.suffix()).thenReturn(""); + when(externalApplicationsPreferences.getCiteCommand()).thenReturn(mockCiteCommand); + when(preferencesService.getExternalApplicationsPreferences()).thenReturn(externalApplicationsPreferences); + + // Create a new instance of PushToTeXworks + pushToTeXworks = new PushToTeXworks(dialogService, preferencesService); + } + + /** + * To verify that the PushToTeXworks class correctly returns its designated display name. + * The display name is used to identify the application in the GUI. + */ + @Test + void displayName() { + assertEquals(DISPLAY_NAME, pushToTeXworks.getDisplayName()); + } + + /** + * To verify that the PushToTeXworks class correctly returns the command line for TeXworks. + * The command line is used to execute the application from the command line. + */ + @Test + void getCommandLine() { + String keyString = "TestKey"; + String[] expectedCommand = new String[] {null, "--insert-text", keyString}; // commandPath is only set in pushEntries + + String[] actualCommand = pushToTeXworks.getCommandLine(keyString); + + assertArrayEquals(expectedCommand, actualCommand); + } + + /** + * Check for the actual command and path with path is run. + */ + @Test + void pushEntries() { + ProcessBuilder processBuilder = mock(ProcessBuilder.class); + + String testKey = "TestKey"; + String[] expectedCommand = new String[] {TEXWORKS_CLIENT_PATH, "--insert-text", testKey}; + + pushToTeXworks.pushEntries(null, null, testKey, processBuilder); + + verify(processBuilder).command(expectedCommand); + } + + /** + * To verify that the PushToTeXworks class correctly returns the tooltip for TeXworks. + * The tooltip is used to display a short description of the application in the GUI. + */ + @Test + void getTooltip() { + assertEquals("Push entries to external application (TeXworks)", pushToTeXworks.getTooltip()); + } +} From 571ff708fe974649b92d6466315092aad334283a Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 4 Mar 2024 20:44:43 +0100 Subject: [PATCH 09/36] Try latest master of awalsh128/cache-apt-pkgs-action (#10981) --- .github/workflows/deployment-jdk-ea.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deployment-jdk-ea.yml b/.github/workflows/deployment-jdk-ea.yml index 41d8d6b853a..5978e568342 100644 --- a/.github/workflows/deployment-jdk-ea.yml +++ b/.github/workflows/deployment-jdk-ea.yml @@ -82,8 +82,7 @@ jobs: show-progress: 'false' - name: Install pigz and cache (linux) if: (matrix.os == 'ubuntu-latest') || (matrix.os == 'buildjet-4vcpu-ubuntu-2204-arm') - # 1.3.1 works, 1.4.1 does not (https://github.com/awalsh128/cache-apt-pkgs-action/issues/126) - uses: koppor/cache-apt-pkgs-action@add-arm64-support + uses: awalsh128/cache-apt-pkgs-action@master with: packages: pigz version: 1.0 From 8f46463f779e8cb3e8d5f9e296f7b6eb6ff6971d Mon Sep 17 00:00:00 2001 From: Abd al Rahman Gad <89566409+AbdAlRahmanGad@users.noreply.github.com> Date: Mon, 4 Mar 2024 21:45:23 +0200 Subject: [PATCH 10/36] Convert the "Custom API key" list to a table [#10926] (#10936) * Convert "Custom API keys" list to a table. * Handle if user clicked "check connection" without selecting a key. * update CHANGELOG.md * Handle if user clicked "check connection" without selecting a key in a better way. * Disable editing the "customApiKey" if "useCustomApiKey" is no cheked * Disable "Check Connection" button if no API key is selected. * add a new line to match to coding style * Bind the 'useCustomApiKey' checkbox with the emptiness of the 'customApiKey' field. * Update logic for "Custom API key" table to align with previous implementation * Add a note to guide users on how to commit changes --- CHANGELOG.md | 1 + .../preferences/websearch/WebSearchTab.fxml | 30 ++++++++--- .../preferences/websearch/WebSearchTab.java | 50 ++++++++++++------- .../logic/preferences/FetcherApiKey.java | 4 ++ 4 files changed, 59 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38461b0d26b..8ec35123236 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv ### Added +- We converted the "Custom API key" list to a table to be more accessible. [#10926](https://github.com/JabRef/jabref/issues/10926) - We added a "refresh" button for the LaTeX citations tab in the entry editor. [#10584](https://github.com/JabRef/jabref/issues/10584) - We added the possibility to show the BibTeX source in the [web search](https://docs.jabref.org/collect/import-using-online-bibliographic-database) import screen. [#560](https://github.com/koppor/jabref/issues/560) - We added a fetcher for [ISIDORE](https://isidore.science/), simply paste in the link into the text field or the last 6 digits in the link that identify that paper. [#10423](https://github.com/JabRef/jabref/issues/10423) diff --git a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.fxml b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.fxml index 06ee5a0e0dd..57cd5a4a449 100644 --- a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.fxml +++ b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.fxml @@ -2,7 +2,6 @@ - @@ -55,12 +54,29 @@