From bcd1870f63c152f5b32a6e51da55354c50304949 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Wed, 7 Feb 2018 17:50:14 +0100 Subject: [PATCH 1/3] Try to change color of magnifier icon --- src/main/java/org/jabref/gui/IconTheme.java | 1 + .../org/jabref/gui/search/GlobalSearchBar.java | 1 + .../org/jabref/gui/search/SearchTextField.java | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/IconTheme.java b/src/main/java/org/jabref/gui/IconTheme.java index 0b78c7cd09e..ad99a9b6543 100644 --- a/src/main/java/org/jabref/gui/IconTheme.java +++ b/src/main/java/org/jabref/gui/IconTheme.java @@ -198,6 +198,7 @@ public enum JabRefIcon { REFRESH(MaterialDesignIcon.REFRESH), DELETE_ENTRY(MaterialDesignIcon.DELETE), SEARCH(MaterialDesignIcon.MAGNIFY), + ADVANCED_SEARCH(Color.ORANGE, MaterialDesignIcon.MAGNIFY), PREFERENCES(MaterialDesignIcon.SETTINGS), HELP(MaterialDesignIcon.HELP_CIRCLE), UP(MaterialDesignIcon.CHEVRON_UP), diff --git a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java index 4d12cb41cd7..a25a646ed57 100644 --- a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java +++ b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java @@ -391,6 +391,7 @@ public void updateResults(int matched, TextFlow description, boolean grammarBase currentResults.setText(Localization.lang("Found %0 results.", String.valueOf(matched))); searchField.pseudoClassStateChanged(CLASS_RESULTS_FOUND, true); } + SearchTextField.switchSearchColor(searchField, grammarBasedSearch); Tooltip tooltip = new Tooltip(); tooltip.setContentDisplay(ContentDisplay.GRAPHIC_ONLY); tooltip.setGraphic(description); diff --git a/src/main/java/org/jabref/gui/search/SearchTextField.java b/src/main/java/org/jabref/gui/search/SearchTextField.java index e018ac2efd9..e0f9f9f686a 100644 --- a/src/main/java/org/jabref/gui/search/SearchTextField.java +++ b/src/main/java/org/jabref/gui/search/SearchTextField.java @@ -1,8 +1,10 @@ package org.jabref.gui.search; +import javafx.scene.Node; import javafx.scene.control.TextField; import org.jabref.gui.IconTheme; +import org.jabref.gui.util.DefaultTaskExecutor; import org.jabref.logic.l10n.Localization; import org.controlsfx.control.textfield.CustomTextField; @@ -13,7 +15,21 @@ public class SearchTextField { public static TextField create() { CustomTextField textField = (CustomTextField) TextFields.createClearableTextField(); textField.setPromptText(Localization.lang("Search") + "..."); - textField.setLeft(IconTheme.JabRefIcon.SEARCH.getGraphicNode()); + Node node = IconTheme.JabRefIcon.SEARCH.getGraphicNode(); + node.setStyle("-fx-text-fill: #00ffff"); + textField.setLeft(node); return textField; } + + public static void switchSearchColor(TextField textField, boolean grammarBasedSearch) { + if (grammarBasedSearch) { + DefaultTaskExecutor.runInJavaFXThread(() -> + ((CustomTextField) textField).setLeft(IconTheme.JabRefIcon.ADVANCED_SEARCH.getGraphicNode())); + } else { + DefaultTaskExecutor.runInJavaFXThread(() -> + ((CustomTextField) textField).setLeft(IconTheme.JabRefIcon.SEARCH.getGraphicNode())); + } + } + + } From a5bede1f56f86dfc57e4ee0d9cd03b9c9b14d418 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Tue, 13 Feb 2018 16:22:57 +0100 Subject: [PATCH 2/3] Migrate magnifier icon back to Swing --- src/main/java/org/jabref/gui/IconTheme.java | 2 +- .../org/jabref/gui/search/GlobalSearchBar.java | 10 +++++++++- .../org/jabref/gui/search/SearchTextField.java | 17 ----------------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/jabref/gui/IconTheme.java b/src/main/java/org/jabref/gui/IconTheme.java index ad99a9b6543..249e40ccc3f 100644 --- a/src/main/java/org/jabref/gui/IconTheme.java +++ b/src/main/java/org/jabref/gui/IconTheme.java @@ -198,7 +198,7 @@ public enum JabRefIcon { REFRESH(MaterialDesignIcon.REFRESH), DELETE_ENTRY(MaterialDesignIcon.DELETE), SEARCH(MaterialDesignIcon.MAGNIFY), - ADVANCED_SEARCH(Color.ORANGE, MaterialDesignIcon.MAGNIFY), + ADVANCED_SEARCH(Color.CYAN, MaterialDesignIcon.MAGNIFY), PREFERENCES(MaterialDesignIcon.SETTINGS), HELP(MaterialDesignIcon.HELP_CIRCLE), UP(MaterialDesignIcon.CHEVRON_UP), diff --git a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java index a25a646ed57..fcec6fbc2fc 100644 --- a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java +++ b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java @@ -22,6 +22,7 @@ import javafx.css.PseudoClass; import javafx.embed.swing.JFXPanel; +import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.ContentDisplay; import javafx.scene.control.TextField; @@ -78,6 +79,8 @@ public class GlobalSearchBar extends JPanel { private SearchDisplayMode searchDisplayMode; + private JLabel searchIcon = new JLabel(IconTheme.JabRefIcon.SEARCH.getIcon()); + /** * if this flag is set the searchbar won't be selected after the next search */ @@ -195,6 +198,7 @@ public void actionPerformed(ActionEvent e) { setLayout(new FlowLayout(FlowLayout.RIGHT)); JToolBar toolBar = new OSXCompatibleToolbar(); toolBar.setFloatable(false); + toolBar.add(searchIcon); toolBar.add(container); toolBar.add(openCurrentResultsInDialog); toolBar.addSeparator(); @@ -391,7 +395,11 @@ public void updateResults(int matched, TextFlow description, boolean grammarBase currentResults.setText(Localization.lang("Found %0 results.", String.valueOf(matched))); searchField.pseudoClassStateChanged(CLASS_RESULTS_FOUND, true); } - SearchTextField.switchSearchColor(searchField, grammarBasedSearch); + if (grammarBasedSearch) { + searchIcon.setIcon(IconTheme.JabRefIcon.ADVANCED_SEARCH.getIcon()); + } else { + searchIcon.setIcon(IconTheme.JabRefIcon.SEARCH.getIcon()); + } Tooltip tooltip = new Tooltip(); tooltip.setContentDisplay(ContentDisplay.GRAPHIC_ONLY); tooltip.setGraphic(description); diff --git a/src/main/java/org/jabref/gui/search/SearchTextField.java b/src/main/java/org/jabref/gui/search/SearchTextField.java index e0f9f9f686a..334b5a751aa 100644 --- a/src/main/java/org/jabref/gui/search/SearchTextField.java +++ b/src/main/java/org/jabref/gui/search/SearchTextField.java @@ -1,10 +1,7 @@ package org.jabref.gui.search; -import javafx.scene.Node; import javafx.scene.control.TextField; -import org.jabref.gui.IconTheme; -import org.jabref.gui.util.DefaultTaskExecutor; import org.jabref.logic.l10n.Localization; import org.controlsfx.control.textfield.CustomTextField; @@ -15,21 +12,7 @@ public class SearchTextField { public static TextField create() { CustomTextField textField = (CustomTextField) TextFields.createClearableTextField(); textField.setPromptText(Localization.lang("Search") + "..."); - Node node = IconTheme.JabRefIcon.SEARCH.getGraphicNode(); - node.setStyle("-fx-text-fill: #00ffff"); - textField.setLeft(node); return textField; } - public static void switchSearchColor(TextField textField, boolean grammarBasedSearch) { - if (grammarBasedSearch) { - DefaultTaskExecutor.runInJavaFXThread(() -> - ((CustomTextField) textField).setLeft(IconTheme.JabRefIcon.ADVANCED_SEARCH.getGraphicNode())); - } else { - DefaultTaskExecutor.runInJavaFXThread(() -> - ((CustomTextField) textField).setLeft(IconTheme.JabRefIcon.SEARCH.getGraphicNode())); - } - } - - } From 89b3aa0d7fdbe16cd2e6e142baf42fbd6b85a420 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Tue, 13 Feb 2018 16:26:57 +0100 Subject: [PATCH 3/3] Fix imports --- src/main/java/org/jabref/gui/search/GlobalSearchBar.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java index fcec6fbc2fc..7ffc8cc100e 100644 --- a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java +++ b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java @@ -22,7 +22,6 @@ import javafx.css.PseudoClass; import javafx.embed.swing.JFXPanel; -import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.ContentDisplay; import javafx.scene.control.TextField;