From 4c018672204ff01c4ae5f7ed99c3f51ffae72ab3 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Tue, 4 Dec 2018 17:41:32 +0300 Subject: [PATCH] IDEA-199508: remove obsolete code and deprecate corresponding methods --- .../ide/actions/SearchEverywhereAction.java | 10 -- .../src/com/intellij/ui/SearchTextField.java | 127 ++++-------------- .../options/newEditor/SettingsSearch.java | 5 - .../openapi/vcs/ui/SearchFieldAction.java | 2 - .../memory/ui/ClassesFilteredViewBase.java | 5 - 5 files changed, 23 insertions(+), 126 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java index f71fe1abaced..6f9faef961b5 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java @@ -991,16 +991,6 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA } } - @Override - protected boolean isSearchControlUISupported() { - return true; - } - - @Override - protected boolean hasIconsOutsideOfTextField() { - return false; - } - @Override protected void showPopup() { } diff --git a/platform/platform-api/src/com/intellij/ui/SearchTextField.java b/platform/platform-api/src/com/intellij/ui/SearchTextField.java index 8a8c821d8a60..fc72720a0e25 100644 --- a/platform/platform-api/src/com/intellij/ui/SearchTextField.java +++ b/platform/platform-api/src/com/intellij/ui/SearchTextField.java @@ -13,11 +13,9 @@ // limitations under the License. package com.intellij.ui; -import com.intellij.icons.AllIcons; import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.ui.JBMenuItem; import com.intellij.openapi.ui.JBPopupMenu; @@ -32,14 +30,12 @@ import com.intellij.ui.components.JBTextField; import com.intellij.util.Consumer; import com.intellij.util.ReflectionUtil; import com.intellij.util.ui.JBInsets; -import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.border.Border; -import javax.swing.border.CompoundBorder; import javax.swing.event.DocumentListener; import javax.swing.plaf.TextUI; import java.awt.*; @@ -64,8 +60,6 @@ public class SearchTextField extends JPanel { private final TextFieldWithProcessing myTextField; private JBPopup myPopup; - private JLabel myClearFieldLabel; - private JLabel myToggleHistoryLabel; private JPopupMenu myNativeSearchPopup; private JMenuItem myNoItems; private String myHistoryPropertyName; @@ -103,19 +97,6 @@ public class SearchTextField extends JPanel { super.processMouseEvent(e); } - @Override - public void setBackground(final Color bg) { - super.setBackground(bg); - if (!hasIconsOutsideOfTextField()) { - if (myClearFieldLabel != null) { - myClearFieldLabel.setBackground(bg); - } - } - if (myToggleHistoryLabel != null) { - myToggleHistoryLabel.setBackground(bg); - } - } - @Override public void setUI(TextUI ui) { if (customSetupUIAndTextField(this, textUI -> super.setUI(textUI))) return; @@ -125,12 +106,10 @@ public class SearchTextField extends JPanel { @Override protected Rectangle getEmptyTextComponentBounds(Rectangle bounds) { - if (isSearchControlUISupported()) { - Integer gap = (Integer)getClientProperty("JTextField.Search.GapEmptyText"); - if (gap != null) { - bounds.x += gap; - bounds.width -= 2 * gap; - } + Integer gap = (Integer)getClientProperty("JTextField.Search.GapEmptyText"); + if (gap != null) { + bounds.x += gap; + bounds.width -= 2 * gap; } return bounds; } @@ -157,7 +136,7 @@ public class SearchTextField extends JPanel { myTextField.getActionMap().put("showHistory", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { - if (isSearchControlUISupported() && myNativeSearchPopup != null) { + if (myNativeSearchPopup != null) { myNativeSearchPopup.show(myTextField, 5, myTextField.getHeight()); } else if (myPopup == null || !myPopup.isVisible()) { showPopup(); @@ -190,61 +169,19 @@ public class SearchTextField extends JPanel { myTextField.getInputMap().put(SHOW_HISTORY_KEYSTROKE, "showNextHistoryItem"); } - if (isSearchControlUISupported()) { - myTextField.putClientProperty("JTextField.variant", "search"); - myTextField.putClientProperty("JTextField.Search.CancelAction", (ActionListener)e -> { - myTextField.setText(""); - onFieldCleared(); - }); + myTextField.putClientProperty("JTextField.variant", "search"); + myTextField.putClientProperty("JTextField.Search.CancelAction", (ActionListener)e -> { + myTextField.setText(""); + onFieldCleared(); + }); - if (historyPopupEnabled) { - myNativeSearchPopup = new JBPopupMenu(); - myNoItems = new JBMenuItem("No recent searches"); - myNoItems.setEnabled(false); + if (historyPopupEnabled) { + myNativeSearchPopup = new JBPopupMenu(); + myNoItems = new JBMenuItem("No recent searches"); + myNoItems.setEnabled(false); - updateMenu(); - myTextField.putClientProperty("JTextField.Search.FindPopup", myNativeSearchPopup); - } - } - else { - myToggleHistoryLabel = new JLabel(AllIcons.Actions.Search); - myToggleHistoryLabel.setOpaque(true); - myToggleHistoryLabel.setToolTipText("Search History (" + KeymapUtil.getKeystrokeText(SHOW_HISTORY_KEYSTROKE)+ ")"); - myToggleHistoryLabel.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - togglePopup(); - } - }); - if (historyPopupEnabled) { - add(myToggleHistoryLabel, BorderLayout.WEST); - } - - myClearFieldLabel = new JLabel(UIUtil.isUnderDarcula() ? AllIcons.Actions.Clean : AllIcons.Actions.CleanLight); - myClearFieldLabel.setOpaque(true); - add(myClearFieldLabel, BorderLayout.EAST); - myClearFieldLabel.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - myTextField.setText(""); - onFieldCleared(); - } - }); - - if (!hasIconsOutsideOfTextField()) { - Border originalBorder = SystemInfo.isMac ? BorderFactory.createLoweredBevelBorder() : myTextField.getBorder(); - - myToggleHistoryLabel.setBackground(myTextField.getBackground()); - myClearFieldLabel.setBackground(myTextField.getBackground()); - - setBorder(new CompoundBorder(JBUI.Borders.empty(2, 0, 2, 0), originalBorder)); - - myTextField.setOpaque(true); - myTextField.setBorder(JBUI.Borders.empty(0, 5, 0, 5)); - } - else { - setBorder(JBUI.Borders.empty(2, 0, 2, 0)); - } + updateMenu(); + myTextField.putClientProperty("JTextField.Search.FindPopup", myNativeSearchPopup); } if (toClearTextOnEscape()) { @@ -285,10 +222,12 @@ public class SearchTextField extends JPanel { } } + @Deprecated protected boolean isSearchControlUISupported() { - return SystemInfo.isMacOSLeopard && UIUtil.isUnderAquaLookAndFeel() || UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF(); + return true; } + @Deprecated protected boolean hasIconsOutsideOfTextField() { return false; } @@ -326,16 +265,6 @@ public class SearchTextField extends JPanel { getTextEditor().addKeyListener(listener); } - @Override - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - if (myToggleHistoryLabel != null) { - final Color bg = enabled ? UIUtil.getTextFieldBackground() : UIUtil.getPanelBackground(); - myToggleHistoryLabel.setBackground(bg); - myClearFieldLabel.setBackground(bg); - } - } - public void setHistorySize(int historySize) { if (historySize <= 0) throw new IllegalArgumentException("history size must be a positive number"); myHistorySize = historySize; @@ -548,16 +477,7 @@ public class SearchTextField extends JPanel { } protected Component getPopupLocationComponent() { - return hasIconsOutsideOfTextField() ? myToggleHistoryLabel : this; - } - - private void togglePopup() { - if (myPopup == null) { - showPopup(); - } - else { - hidePopup(); - } + return this; } public void setSelectedItem(final String s) { @@ -586,11 +506,10 @@ public class SearchTextField extends JPanel { } return false; } - + + @Deprecated + @SuppressWarnings("unused") public void setSearchIcon(final Icon icon) { - if (! isSearchControlUISupported()) { - myToggleHistoryLabel.setIcon(icon); - } } public static final class FindAction extends DumbAwareAction { diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsSearch.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsSearch.java index f9753006d8a1..970e561aa2f9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsSearch.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/SettingsSearch.java @@ -56,11 +56,6 @@ abstract class SettingsSearch extends SearchTextField implements KeyListener { keyEventToTextField(event); } - @Override - protected boolean isSearchControlUISupported() { - return true; - } - @Override protected boolean preprocessEventForTextField(KeyEvent event) { if (!myDelegatingNow) { diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/ui/SearchFieldAction.java b/platform/vcs-api/src/com/intellij/openapi/vcs/ui/SearchFieldAction.java index 656223641bd3..251a48f50f87 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/ui/SearchFieldAction.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/ui/SearchFieldAction.java @@ -59,8 +59,6 @@ public abstract class SearchFieldAction extends AnAction implements CustomCompon else { myField.setBorder(emptyBorder); } - - myField.setSearchIcon(AllIcons.General.Filter); myComponent = new JPanel(); final BoxLayout layout = new BoxLayout(myComponent, BoxLayout.X_AXIS); myComponent.setLayout(layout); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/memory/ui/ClassesFilteredViewBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/memory/ui/ClassesFilteredViewBase.java index abf35ce4153d..328eaf70fa50 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/memory/ui/ClassesFilteredViewBase.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/memory/ui/ClassesFilteredViewBase.java @@ -284,11 +284,6 @@ public abstract class ClassesFilteredViewBase extends BorderLayoutPanel implemen @Override protected void showPopup() { } - - @Override - protected boolean hasIconsOutsideOfTextField() { - return false; - } } @Nullable