diff --git a/CHANGELOG.md b/CHANGELOG.md index 5254da0d2e5..73b7b325491 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We added an option in the settings to set the default action in JabRef when right clicking on any entry in any database and selecting "Open folder". [#4763](https://github.com/JabRef/jabref/issues/4763) - The Medline fetcher now normalizes the author names according to the BibTeX-Standard [#4345](https://github.com/JabRef/jabref/issues/4345) - We added an option on the Linked File Viewer to rename the attached file of an entry directly on the JabRef. [#4844](https://github.com/JabRef/jabref/issues/4844) +- We added an option in the preference dialog box that allows user to enable helpful tooltips.[#3599](https://github.com/JabRef/jabref/issues/3599) ### Fixed diff --git a/src/main/java/org/jabref/gui/preferences/AdvancedTab.java b/src/main/java/org/jabref/gui/preferences/AdvancedTab.java index 829b1a8e97e..b1889a16786 100644 --- a/src/main/java/org/jabref/gui/preferences/AdvancedTab.java +++ b/src/main/java/org/jabref/gui/preferences/AdvancedTab.java @@ -56,11 +56,13 @@ public AdvancedTab(DialogService dialogService, JabRefPreferences prefs) { Label remoteOperation = new Label(Localization.lang("Remote operation")); remoteOperation.getStyleClass().add("sectionHeader"); builder.add(remoteOperation, 2, 1); - Text textRemote = new Text(Localization.lang("This feature lets new files be opened or imported into an already running instance of JabRef " + - "instead of opening a new instance. For instance, this is useful when you open a file in JabRef " + - "from your web browser. Note that this will prevent you from running more than one instance of JabRef at a time.")); - textRemote.setWrappingWidth(600); - builder.add(textRemote, 2, 4); + if (Globals.prefs.getBoolean(JabRefPreferences.SHOW_ADVANCED_HINTS)) { + Text textRemote = new Text(Localization.lang("This feature lets new files be opened or imported into an already running instance of JabRef " + + "instead of opening a new instance. For instance, this is useful when you open a file in JabRef " + + "from your web browser. Note that this will prevent you from running more than one instance of JabRef at a time.")); + textRemote.setWrappingWidth(600); + builder.add(textRemote, 2, 4); + } HBox p = new HBox(); p.setSpacing(8); diff --git a/src/main/java/org/jabref/gui/preferences/GeneralTab.java b/src/main/java/org/jabref/gui/preferences/GeneralTab.java index d39715dd410..4c76449acdb 100644 --- a/src/main/java/org/jabref/gui/preferences/GeneralTab.java +++ b/src/main/java/org/jabref/gui/preferences/GeneralTab.java @@ -40,6 +40,7 @@ class GeneralTab extends Pane implements PrefsTab { private final CheckBox confirmDelete; private final CheckBox memoryStick; private final CheckBox inspectionWarnDupli; + private final CheckBox showAdvancedHints; private final CheckBox useTimeStamp; private final CheckBox updateTimeStamp; private final CheckBox overwriteTimeStamp; @@ -77,6 +78,7 @@ public GeneralTab(DialogService dialogService, JabRefPreferences prefs) { timeStampFormat = new TextField(); timeStampField = new TextField(); inspectionWarnDupli = new CheckBox(Localization.lang("Warn about unresolved duplicates when closing inspection window")); + showAdvancedHints = new CheckBox(Localization.lang("Show advanced hints (i.e. helpful tooltips, suggestions and explanation)")); shouldCollectTelemetry = new CheckBox(Localization.lang("Collect and share telemetry data to help improve JabRef.")); encodings = new ComboBox<>(FXCollections.observableArrayList(Encodings.ENCODINGS)); @@ -135,6 +137,8 @@ public GeneralTab(DialogService dialogService, JabRefPreferences prefs) { Label defaultBibliographyMode = new Label(Localization.lang("Default bibliography mode")); biblioBox.getChildren().addAll(defaultBibliographyMode, biblatexMode); builder.add(biblioBox, 1, 29); + + builder.add(showAdvancedHints,1,30); } @Override @@ -164,6 +168,7 @@ public void setValues() { } encodings.setValue(prefs.getDefaultEncoding()); languageSelection.setValue(prefs.getLanguage()); + showAdvancedHints.setSelected(prefs.getBoolean(JabRefPreferences.SHOW_ADVANCED_HINTS)); } @Override @@ -181,6 +186,7 @@ public void storeSettings() { + " rename or remove the jabref.xml file in the same folder as JabRef.")); } prefs.putBoolean(JabRefPreferences.MEMORY_STICK_MODE, memoryStick.isSelected()); + prefs.putBoolean(JabRefPreferences.SHOW_ADVANCED_HINTS, showAdvancedHints.isSelected()); prefs.putBoolean(JabRefPreferences.CONFIRM_DELETE, confirmDelete.isSelected()); prefs.putBoolean(JabRefPreferences.WARN_ABOUT_DUPLICATES_IN_INSPECTION, inspectionWarnDupli.isSelected()); String owner = defOwnerField.getText().trim(); diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialog.java b/src/main/java/org/jabref/gui/preferences/PreferencesDialog.java index 7145caa3ed7..4814e1b4165 100644 --- a/src/main/java/org/jabref/gui/preferences/PreferencesDialog.java +++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialog.java @@ -246,6 +246,7 @@ private void storeAllSettings() { GUIGlobals.updateEntryEditorColors(); frame.setupAllTables(); + frame.getGlobalSearchBar().updateHintVisibility(); dialogService.notify(Localization.lang("Preferences recorded.")); } diff --git a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java index 8426b3fb290..60a46a783ca 100644 --- a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java +++ b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java @@ -1,6 +1,7 @@ package org.jabref.gui.search; import java.lang.reflect.Field; +import java.util.List; import java.util.Objects; import java.util.Optional; @@ -27,6 +28,7 @@ import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; +import javafx.scene.text.Text; import javafx.scene.text.TextFlow; import javafx.util.Duration; @@ -43,10 +45,12 @@ import org.jabref.gui.keyboard.KeyBindingRepository; import org.jabref.gui.maintable.MainTable; import org.jabref.gui.util.DefaultTaskExecutor; +import org.jabref.gui.util.TooltipTextUtil; import org.jabref.logic.l10n.Localization; import org.jabref.logic.search.SearchQuery; import org.jabref.logic.search.SearchQueryHighlightObservable; import org.jabref.model.entry.Author; +import org.jabref.preferences.JabRefPreferences; import org.jabref.preferences.SearchPreferences; import impl.org.controlsfx.skin.AutoCompletePopup; @@ -72,6 +76,7 @@ public class GlobalSearchBar extends HBox { private final ToggleButton regularExp; private final Button searchModeButton = new Button(); private final Label currentResults = new Label(""); + private final Tooltip tooltip = new Tooltip(); private final SearchQueryHighlightObservable searchQueryHighlightObservable = new SearchQueryHighlightObservable(); private SearchWorker searchWorker; @@ -86,6 +91,11 @@ public GlobalSearchBar(JabRefFrame frame) { // fits the standard "found x entries"-message thus hinders the searchbar to jump around while searching if the frame width is too small currentResults.setPrefWidth(150); + tooltip.setContentDisplay(ContentDisplay.GRAPHIC_ONLY); + tooltip.setMaxHeight(10); + searchField.setTooltip(null); + updateHintVisibility(); + KeyBindingRepository keyBindingRepository = Globals.getKeyPrefs(); searchField.addEventFilter(KeyEvent.KEY_PRESSED, event -> { Optional keyBinding = keyBindingRepository.mapToKeyBinding(event); @@ -188,6 +198,7 @@ public void focus() { private void clearSearch() { currentResults.setText(""); searchField.setText(""); + setHintTooltip(null); searchQueryHighlightObservable.reset(); Globals.stateManager.clearSearchQuery(); @@ -284,11 +295,35 @@ public void updateResults(int matched, TextFlow description, boolean grammarBase // TODO: switch Icon color //searchIcon.setIcon(IconTheme.JabRefIcon.SEARCH.getIcon()); } - Tooltip tooltip = new Tooltip(); - tooltip.setContentDisplay(ContentDisplay.GRAPHIC_ONLY); - tooltip.setGraphic(description); - tooltip.setMaxHeight(10); - searchField.setTooltip(tooltip); + + setHintTooltip(description); + } + + private void setHintTooltip(TextFlow description) { + if (Globals.prefs.getBoolean(JabRefPreferences.SHOW_ADVANCED_HINTS)) { + String genericDescription = Localization.lang("Hint: To search specific fields only, enter for example:

author=smith and title=electrical"); + genericDescription = genericDescription.replace("

", "\n"); + List genericDescriptionTexts = TooltipTextUtil.formatToTexts(genericDescription, new TooltipTextUtil.TextReplacement("author=smith and title=electrical", "author=smith and title=electrical", TooltipTextUtil.TextType.MONOSPACED)); + + if (description != null) { + description.getChildren().add(new Text("\n\n")); + description.getChildren().addAll(genericDescriptionTexts); + tooltip.setGraphic(description); + } else { + TextFlow emptyHintTooltip = new TextFlow(); + emptyHintTooltip.getChildren().setAll(genericDescriptionTexts); + tooltip.setGraphic(emptyHintTooltip); + } + } + } + + public void updateHintVisibility() { + if (Globals.prefs.getBoolean(JabRefPreferences.SHOW_ADVANCED_HINTS)) { + searchField.setTooltip(tooltip); + } else { + searchField.setTooltip(null); + } + setHintTooltip(null); } public void setSearchTerm(String searchTerm) { diff --git a/src/main/java/org/jabref/gui/search/rules/describer/ContainsAndRegexBasedSearchRuleDescriber.java b/src/main/java/org/jabref/gui/search/rules/describer/ContainsAndRegexBasedSearchRuleDescriber.java index ab9503659fb..4ff85ca09ee 100644 --- a/src/main/java/org/jabref/gui/search/rules/describer/ContainsAndRegexBasedSearchRuleDescriber.java +++ b/src/main/java/org/jabref/gui/search/rules/describer/ContainsAndRegexBasedSearchRuleDescriber.java @@ -39,12 +39,7 @@ public TextFlow getDescription() { } } - String genericDescription = "\n\n" + Localization.lang("Hint: To search specific fields only, enter for example:

author=smith and title=electrical"); - genericDescription = genericDescription.replace("

", "\n"); - List genericDescriptionTexts = TooltipTextUtil.formatToTexts(genericDescription, new TooltipTextUtil.TextReplacement("author=smith and title=electrical", "author=smith and title=electrical", TooltipTextUtil.TextType.MONOSPACED)); textList.add(getCaseSensitiveDescription()); - textList.addAll(genericDescriptionTexts); - TextFlow searchDescription = new TextFlow(); searchDescription.getChildren().setAll(textList); return searchDescription; diff --git a/src/main/java/org/jabref/preferences/JabRefPreferences.java b/src/main/java/org/jabref/preferences/JabRefPreferences.java index 6e41ae34352..8ea32b20878 100644 --- a/src/main/java/org/jabref/preferences/JabRefPreferences.java +++ b/src/main/java/org/jabref/preferences/JabRefPreferences.java @@ -224,6 +224,7 @@ public class JabRefPreferences implements PreferencesService { public static final String RECENT_DATABASES = "recentDatabases"; public static final String RENAME_ON_MOVE_FILE_TO_FILE_DIR = "renameOnMoveFileToFileDir"; public static final String MEMORY_STICK_MODE = "memoryStickMode"; + public static final String SHOW_ADVANCED_HINTS = "showAdvancedHints"; public static final String DEFAULT_OWNER = "defaultOwner"; public static final String DEFAULT_ENCODING = "defaultEncoding"; public static final String TOOLBAR_VISIBLE = "toolbarVisible"; @@ -590,6 +591,7 @@ private JabRefPreferences() { defaults.put(DEFAULT_ENCODING, StandardCharsets.UTF_8.name()); defaults.put(DEFAULT_OWNER, System.getProperty("user.name")); defaults.put(MEMORY_STICK_MODE, Boolean.FALSE); + defaults.put(SHOW_ADVANCED_HINTS, Boolean.TRUE); defaults.put(RENAME_ON_MOVE_FILE_TO_FILE_DIR, Boolean.TRUE); defaults.put(FONT_STYLE, Font.PLAIN); diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 46610be5394..58822acd1ce 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -530,6 +530,8 @@ Link=Link Listen\ for\ remote\ operation\ on\ port=Listen for remote operation on port Load\ and\ Save\ preferences\ from/to\ jabref.xml\ on\ start-up\ (memory\ stick\ mode)=Load and Save preferences from/to jabref.xml on start-up (memory stick mode) +Show\ advanced\ hints\ (i.e.\ helpful\ tooltips,\ suggestions\ and\ explanation)=Show advanced hints (i.e. helpful tooltips, suggestions and explanation) + Main\ file\ directory=Main file directory Manage\ custom\ exports=Manage custom exports