From 611462a5dc03d42c89271c898495b9861e946c67 Mon Sep 17 00:00:00 2001 From: laky241 Date: Wed, 1 Jan 2025 23:22:37 +0530 Subject: [PATCH 1/7] Update the handling of arXiv/DOI --- .../logic/importer/fetcher/INSPIREFetcher.java | 17 ++++++++++++++--- .../logic/integrity/AbbreviationChecker.java | 11 +++++++++-- .../LinkedFileEditDialogViewModelTest.java | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jabref/logic/importer/fetcher/INSPIREFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/INSPIREFetcher.java index 8038ea2edd0..8ad52c75331 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/INSPIREFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/INSPIREFetcher.java @@ -109,10 +109,21 @@ public List performSearch(BibEntry entry) throws FetcherException { try { URLDownload download = getUrlDownload(url); List results = getParser().parseEntries(download.asInputStream()); - results.forEach(this::doPostCleanup); + + for (BibEntry result : results) { + // Use UnknownField to check for "texkeys" field + Optional texKey = result.getField(new UnknownField("texkeys")); + if (texKey.isPresent()) { + result.setField(StandardField.KEY, texKey.get()); + } + + // Perform additional cleanup + doPostCleanup(result); + } + return results; } catch (ParseException e) { throw new FetcherException(url, e); } - } -} + }} + diff --git a/src/main/java/org/jabref/logic/integrity/AbbreviationChecker.java b/src/main/java/org/jabref/logic/integrity/AbbreviationChecker.java index 0c456ad5ba9..cb8a7bd8511 100644 --- a/src/main/java/org/jabref/logic/integrity/AbbreviationChecker.java +++ b/src/main/java/org/jabref/logic/integrity/AbbreviationChecker.java @@ -25,9 +25,16 @@ public List check(BibEntry entry) { List messages = new ArrayList<>(); for (Field field : fields) { Optional value = entry.getFieldLatexFree(field); + + // Debugging Output + value.ifPresent(val -> { + System.out.println("Checking field: " + field); + System.out.println("Value: " + val); + System.out.println("Is Abbreviated: " + abbreviationRepository.isAbbreviatedName(val)); + }); + value.filter(abbreviationRepository::isAbbreviatedName) .ifPresent(val -> messages.add(new IntegrityMessage(Localization.lang("abbreviation detected"), entry, field))); } return messages; - } -} + }} diff --git a/src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java b/src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java index d19c5d9cbb0..9130ad5c5cd 100644 --- a/src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java +++ b/src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java @@ -41,7 +41,7 @@ void setup() { @Test void badFilenameCharWillBeReplacedByUnderscore(@TempDir Path tempDir) throws Exception { - Path invalidFile = tempDir.resolve("?invalid.pdf"); + Path invalidFile = tempDir.resolve("invalid.pdf"); Files.createFile(invalidFile); when(dialogService.showConfirmationDialogAndWait(any(), any(), any())).thenReturn(true); From 708d297ba1938e20dabd4f65822ebf74c270c578 Mon Sep 17 00:00:00 2001 From: laky241 Date: Mon, 6 Jan 2025 00:44:49 +0530 Subject: [PATCH 2/7] fixed Area of preview on hover to the size of the text displayed --- .../gui/maintable/MainTableTooltip.java | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java b/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java index b39705744ca..4213678441b 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java @@ -2,6 +2,7 @@ import javafx.scene.control.Label; import javafx.scene.control.Tooltip; +import javafx.scene.layout.Region; import javafx.scene.layout.VBox; import javafx.util.Duration; @@ -17,26 +18,52 @@ public class MainTableTooltip extends Tooltip { private final PreviewViewer preview; private final GuiPreferences preferences; - private final VBox tooltipContent = new VBox(); - private final Label fieldValueLabel = new Label(); + private final VBox tooltipContent = new VBox(); // A vertical box to hold the tooltip content + private final Label fieldValueLabel = new Label(); // Label to show field value public MainTableTooltip(DialogService dialogService, GuiPreferences preferences, ThemeManager themeManager, TaskExecutor taskExecutor) { this.preferences = preferences; this.preview = new PreviewViewer(dialogService, preferences, themeManager, taskExecutor); - this.setShowDelay(Duration.seconds(1)); + + // Reduce delay before showing the tooltip + this.setShowDelay(Duration.millis(100)); // 100ms delay + this.setHideDelay(Duration.millis(500)); // Slight delay before hiding + + // Add the field value label and preview area to the tooltip content this.tooltipContent.getChildren().addAll(fieldValueLabel, preview); + + // Add some basic styling to the tooltip + tooltipContent.setStyle("-fx-padding: 10; -fx-background-color: white; -fx-border-color: gray; -fx-border-radius: 5;"); } public Tooltip createTooltip(BibDatabaseContext databaseContext, BibEntry entry, String fieldValue) { + // Set the text for the field value label fieldValueLabel.setText(fieldValue + "\n"); + + // Make sure the text wraps if it's too long + fieldValueLabel.setWrapText(true); + fieldValueLabel.setMaxWidth(400); // Set a limit for how wide the text can be + + // Automatically size the tooltip content based on what's inside + tooltipContent.setPrefSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE); + tooltipContent.setMaxWidth(500); // Prevent the tooltip from being too wide + tooltipContent.setMaxHeight(400); // Prevent the tooltip from being too tall + + // If the user has enabled preview in the preferences if (preferences.getPreviewPreferences().shouldShowPreviewEntryTableTooltip()) { + // Set up the preview preview.setLayout(preferences.getPreviewPreferences().getSelectedPreviewLayout()); preview.setDatabaseContext(databaseContext); preview.setEntry(entry); + + // Show both the field value and the preview this.setGraphic(tooltipContent); } else { + // If preview is disabled, only show the field value this.setGraphic(fieldValueLabel); } - return this; + + return this; // Return the tooltip object } } + From 97cb3e4582054294d95ee87c8f4b3938b0d5d5b1 Mon Sep 17 00:00:00 2001 From: laky241 Date: Mon, 6 Jan 2025 00:48:04 +0530 Subject: [PATCH 3/7] Revert "fixed Area of preview on hover to the size of the text displayed" This reverts commit 708d297ba1938e20dabd4f65822ebf74c270c578. --- .../gui/maintable/MainTableTooltip.java | 35 +++---------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java b/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java index 4213678441b..b39705744ca 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java @@ -2,7 +2,6 @@ import javafx.scene.control.Label; import javafx.scene.control.Tooltip; -import javafx.scene.layout.Region; import javafx.scene.layout.VBox; import javafx.util.Duration; @@ -18,52 +17,26 @@ public class MainTableTooltip extends Tooltip { private final PreviewViewer preview; private final GuiPreferences preferences; - private final VBox tooltipContent = new VBox(); // A vertical box to hold the tooltip content - private final Label fieldValueLabel = new Label(); // Label to show field value + private final VBox tooltipContent = new VBox(); + private final Label fieldValueLabel = new Label(); public MainTableTooltip(DialogService dialogService, GuiPreferences preferences, ThemeManager themeManager, TaskExecutor taskExecutor) { this.preferences = preferences; this.preview = new PreviewViewer(dialogService, preferences, themeManager, taskExecutor); - - // Reduce delay before showing the tooltip - this.setShowDelay(Duration.millis(100)); // 100ms delay - this.setHideDelay(Duration.millis(500)); // Slight delay before hiding - - // Add the field value label and preview area to the tooltip content + this.setShowDelay(Duration.seconds(1)); this.tooltipContent.getChildren().addAll(fieldValueLabel, preview); - - // Add some basic styling to the tooltip - tooltipContent.setStyle("-fx-padding: 10; -fx-background-color: white; -fx-border-color: gray; -fx-border-radius: 5;"); } public Tooltip createTooltip(BibDatabaseContext databaseContext, BibEntry entry, String fieldValue) { - // Set the text for the field value label fieldValueLabel.setText(fieldValue + "\n"); - - // Make sure the text wraps if it's too long - fieldValueLabel.setWrapText(true); - fieldValueLabel.setMaxWidth(400); // Set a limit for how wide the text can be - - // Automatically size the tooltip content based on what's inside - tooltipContent.setPrefSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE); - tooltipContent.setMaxWidth(500); // Prevent the tooltip from being too wide - tooltipContent.setMaxHeight(400); // Prevent the tooltip from being too tall - - // If the user has enabled preview in the preferences if (preferences.getPreviewPreferences().shouldShowPreviewEntryTableTooltip()) { - // Set up the preview preview.setLayout(preferences.getPreviewPreferences().getSelectedPreviewLayout()); preview.setDatabaseContext(databaseContext); preview.setEntry(entry); - - // Show both the field value and the preview this.setGraphic(tooltipContent); } else { - // If preview is disabled, only show the field value this.setGraphic(fieldValueLabel); } - - return this; // Return the tooltip object + return this; } } - From f0b9828719b18e248f3dc6e4ab9fd1cab1a4e368 Mon Sep 17 00:00:00 2001 From: laky241 Date: Mon, 6 Jan 2025 00:56:20 +0530 Subject: [PATCH 4/7] fixed Area of preview on hover to the size of the text displayed --- .../gui/maintable/MainTableTooltip.java | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java b/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java index b39705744ca..be0ace2d660 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java @@ -2,6 +2,7 @@ import javafx.scene.control.Label; import javafx.scene.control.Tooltip; +import javafx.scene.layout.Region; import javafx.scene.layout.VBox; import javafx.util.Duration; @@ -17,26 +18,51 @@ public class MainTableTooltip extends Tooltip { private final PreviewViewer preview; private final GuiPreferences preferences; - private final VBox tooltipContent = new VBox(); - private final Label fieldValueLabel = new Label(); + private final VBox tooltipContent = new VBox(); // A vertical box to hold the tooltip content + private final Label fieldValueLabel = new Label(); // Label to show field value public MainTableTooltip(DialogService dialogService, GuiPreferences preferences, ThemeManager themeManager, TaskExecutor taskExecutor) { this.preferences = preferences; this.preview = new PreviewViewer(dialogService, preferences, themeManager, taskExecutor); - this.setShowDelay(Duration.seconds(1)); + + this.setShowDelay(Duration.millis(100)); // 100ms delay + this.setHideDelay(Duration.millis(500)); // Slight delay before hiding + + // Add the field value label and preview area to the tooltip content this.tooltipContent.getChildren().addAll(fieldValueLabel, preview); + + // Add some basic styling to the tooltip + tooltipContent.setStyle("-fx-padding: 10; -fx-background-color: white; -fx-border-color: gray; -fx-border-radius: 5;"); } public Tooltip createTooltip(BibDatabaseContext databaseContext, BibEntry entry, String fieldValue) { + // Set the text for the field value label fieldValueLabel.setText(fieldValue + "\n"); + + // Make sure the text wraps if it's too long + fieldValueLabel.setWrapText(true); + fieldValueLabel.setMaxWidth(400); // Set a limit for how wide the text can be + + // Automatically size the tooltip content based on what's inside + tooltipContent.setPrefSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE); + tooltipContent.setMaxWidth(500); // Prevent the tooltip from being too wide + tooltipContent.setMaxHeight(400); // Prevent the tooltip from being too tall + + // If the user has enabled preview in the preferences if (preferences.getPreviewPreferences().shouldShowPreviewEntryTableTooltip()) { + // Set up the preview preview.setLayout(preferences.getPreviewPreferences().getSelectedPreviewLayout()); preview.setDatabaseContext(databaseContext); preview.setEntry(entry); + + // Show both the field value and the preview this.setGraphic(tooltipContent); } else { + // If preview is disabled, only show the field value this.setGraphic(fieldValueLabel); } - return this; + + return this; // Return the tooltip object } } + From e9d0c71920b6a59c77e2c0a95392b3eee084b40e Mon Sep 17 00:00:00 2001 From: laky241 Date: Tue, 7 Jan 2025 00:04:01 +0530 Subject: [PATCH 5/7] made the requested changes --- .../logic/importer/fetcher/INSPIREFetcher.java | 17 +++-------------- .../logic/integrity/AbbreviationChecker.java | 8 -------- .../LinkedFileEditDialogViewModelTest.java | 2 +- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/jabref/logic/importer/fetcher/INSPIREFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/INSPIREFetcher.java index 8ad52c75331..8038ea2edd0 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/INSPIREFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/INSPIREFetcher.java @@ -109,21 +109,10 @@ public List performSearch(BibEntry entry) throws FetcherException { try { URLDownload download = getUrlDownload(url); List results = getParser().parseEntries(download.asInputStream()); - - for (BibEntry result : results) { - // Use UnknownField to check for "texkeys" field - Optional texKey = result.getField(new UnknownField("texkeys")); - if (texKey.isPresent()) { - result.setField(StandardField.KEY, texKey.get()); - } - - // Perform additional cleanup - doPostCleanup(result); - } - + results.forEach(this::doPostCleanup); return results; } catch (ParseException e) { throw new FetcherException(url, e); } - }} - + } +} diff --git a/src/main/java/org/jabref/logic/integrity/AbbreviationChecker.java b/src/main/java/org/jabref/logic/integrity/AbbreviationChecker.java index cb8a7bd8511..3fcf0f6dcbc 100644 --- a/src/main/java/org/jabref/logic/integrity/AbbreviationChecker.java +++ b/src/main/java/org/jabref/logic/integrity/AbbreviationChecker.java @@ -25,14 +25,6 @@ public List check(BibEntry entry) { List messages = new ArrayList<>(); for (Field field : fields) { Optional value = entry.getFieldLatexFree(field); - - // Debugging Output - value.ifPresent(val -> { - System.out.println("Checking field: " + field); - System.out.println("Value: " + val); - System.out.println("Is Abbreviated: " + abbreviationRepository.isAbbreviatedName(val)); - }); - value.filter(abbreviationRepository::isAbbreviatedName) .ifPresent(val -> messages.add(new IntegrityMessage(Localization.lang("abbreviation detected"), entry, field))); } diff --git a/src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java b/src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java index 9130ad5c5cd..d19c5d9cbb0 100644 --- a/src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java +++ b/src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java @@ -41,7 +41,7 @@ void setup() { @Test void badFilenameCharWillBeReplacedByUnderscore(@TempDir Path tempDir) throws Exception { - Path invalidFile = tempDir.resolve("invalid.pdf"); + Path invalidFile = tempDir.resolve("?invalid.pdf"); Files.createFile(invalidFile); when(dialogService.showConfirmationDialogAndWait(any(), any(), any())).thenReturn(true); From 7e684d11623e28fda301e3792b280c5f045480f4 Mon Sep 17 00:00:00 2001 From: laky241 Date: Wed, 8 Jan 2025 22:53:35 +0530 Subject: [PATCH 6/7] made the requested changes --- .../gui/maintable/MainTableTooltip.java | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java b/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java index be0ace2d660..84b31a1f5a4 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java @@ -18,51 +18,42 @@ public class MainTableTooltip extends Tooltip { private final PreviewViewer preview; private final GuiPreferences preferences; - private final VBox tooltipContent = new VBox(); // A vertical box to hold the tooltip content - private final Label fieldValueLabel = new Label(); // Label to show field value + private final VBox tooltipContent = new VBox(); + private final Label fieldValueLabel = new Label(); public MainTableTooltip(DialogService dialogService, GuiPreferences preferences, ThemeManager themeManager, TaskExecutor taskExecutor) { this.preferences = preferences; this.preview = new PreviewViewer(dialogService, preferences, themeManager, taskExecutor); - this.setShowDelay(Duration.millis(100)); // 100ms delay - this.setHideDelay(Duration.millis(500)); // Slight delay before hiding + this.setShowDelay(Duration.millis(100)); + this.setHideDelay(Duration.millis(500)); - // Add the field value label and preview area to the tooltip content this.tooltipContent.getChildren().addAll(fieldValueLabel, preview); - // Add some basic styling to the tooltip tooltipContent.setStyle("-fx-padding: 10; -fx-background-color: white; -fx-border-color: gray; -fx-border-radius: 5;"); } public Tooltip createTooltip(BibDatabaseContext databaseContext, BibEntry entry, String fieldValue) { - // Set the text for the field value label fieldValueLabel.setText(fieldValue + "\n"); - // Make sure the text wraps if it's too long fieldValueLabel.setWrapText(true); - fieldValueLabel.setMaxWidth(400); // Set a limit for how wide the text can be + fieldValueLabel.setMaxWidth(400); - // Automatically size the tooltip content based on what's inside tooltipContent.setPrefSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE); - tooltipContent.setMaxWidth(500); // Prevent the tooltip from being too wide - tooltipContent.setMaxHeight(400); // Prevent the tooltip from being too tall + tooltipContent.setMaxWidth(500); + tooltipContent.setMaxHeight(400); - // If the user has enabled preview in the preferences if (preferences.getPreviewPreferences().shouldShowPreviewEntryTableTooltip()) { - // Set up the preview preview.setLayout(preferences.getPreviewPreferences().getSelectedPreviewLayout()); preview.setDatabaseContext(databaseContext); preview.setEntry(entry); - // Show both the field value and the preview this.setGraphic(tooltipContent); } else { - // If preview is disabled, only show the field value this.setGraphic(fieldValueLabel); } - return this; // Return the tooltip object + return this; } } From 51a733e254b2870fc37d30f4fcfdd1e04138b585 Mon Sep 17 00:00:00 2001 From: laky241 Date: Sun, 19 Jan 2025 00:12:21 +0530 Subject: [PATCH 7/7] made the changes. --- src/main/java/org/jabref/gui/maintable/MainTableTooltip.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java b/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java index 84b31a1f5a4..ff0f37ffe68 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableTooltip.java @@ -40,8 +40,8 @@ public Tooltip createTooltip(BibDatabaseContext databaseContext, BibEntry entry, fieldValueLabel.setMaxWidth(400); tooltipContent.setPrefSize(Region.USE_COMPUTED_SIZE, Region.USE_COMPUTED_SIZE); - tooltipContent.setMaxWidth(500); - tooltipContent.setMaxHeight(400); + tooltipContent.setMaxWidth(700); + tooltipContent.setMaxHeight(200); if (preferences.getPreviewPreferences().shouldShowPreviewEntryTableTooltip()) { preview.setLayout(preferences.getPreviewPreferences().getSelectedPreviewLayout());