IDEA-142359 Find/Replace: move checkboxes back
authorVassiliy.Kudryashov <Vassiliy.Kudryashov@jetbrains.com>
Thu, 16 Jul 2015 17:24:04 +0000 (20:24 +0300)
committerVassiliy.Kudryashov <Vassiliy.Kudryashov@jetbrains.com>
Thu, 16 Jul 2015 17:25:08 +0000 (20:25 +0300)
Stage #2

platform/lang-impl/src/com/intellij/find/EditorSearchComponent.java
platform/lang-impl/src/com/intellij/find/editorHeaderActions/SwitchToReplace.java
platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java

index c78c36a8e48c7c51ba3c2aa1ad13915a447a0b0e..d3f996040689b9922f649d2c092b9fe0f6a795b8 100644 (file)
@@ -35,7 +35,10 @@ import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.SystemInfo;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.wm.IdeFocusManager;
-import com.intellij.ui.*;
+import com.intellij.ui.DocumentAdapter;
+import com.intellij.ui.LightColors;
+import com.intellij.ui.OnePixelSplitter;
+import com.intellij.ui.SearchTextField;
 import com.intellij.ui.components.JBList;
 import com.intellij.ui.components.labels.LinkLabel;
 import com.intellij.ui.components.labels.LinkListener;
@@ -118,7 +121,7 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data
     initUI();
 
     new SwitchToFind(this);
-    new SwitchToReplace(this, editor);
+    new SwitchToReplace(this);
 
     myFindModel.addObserver(new FindModel.FindModelObserver() {
       @Override
@@ -217,8 +220,9 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data
     Wrapper searchToolbarWrapper1 = new NonOpaquePanel(new BorderLayout());
     searchToolbarWrapper1.add(mySearchActionsToolbar1, BorderLayout.WEST);
     Wrapper searchToolbarWrapper2 = new Wrapper(mySearchActionsToolbar2);
+    mySearchActionsToolbar2.setBorder(JBUI.Borders.empty(0, 16, 0, 0));
     JPanel searchPair = new NonOpaquePanel(new BorderLayout()).setVerticalSizeReferent(mySearchFieldWrapper);
-    searchPair.add(mySearchActionsToolbar1, BorderLayout.WEST);
+    searchPair.add(searchToolbarWrapper1, BorderLayout.WEST);
     searchPair.add(searchToolbarWrapper2, BorderLayout.CENTER);
     JLabel closeLabel = new JLabel(null, AllIcons.Actions.Cross, SwingConstants.RIGHT);
     closeLabel.setBorder(JBUI.Borders.empty(5, 5, 5, 5));
@@ -235,6 +239,8 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data
 
     Wrapper replaceToolbarWrapper1 = new Wrapper(myReplaceActionsToolbar1).setVerticalSizeReferent(myReplaceFieldWrapper);
     Wrapper replaceToolbarWrapper2 = new Wrapper(myReplaceActionsToolbar2).setVerticalSizeReferent(myReplaceFieldWrapper);
+    myReplaceActionsToolbar2.setBorder(JBUI.Borders.empty(0, 16, 0, 0));
+
     myReplaceToolbarWrapper = new NonOpaquePanel(new BorderLayout());
     myReplaceToolbarWrapper.add(replaceToolbarWrapper1, BorderLayout.WEST);
     myReplaceToolbarWrapper.add(replaceToolbarWrapper2, BorderLayout.CENTER);
@@ -272,12 +278,7 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data
         ApplicationManager.getApplication().invokeLater(new Runnable() {
           @Override
           public void run() {
-            ApplicationManager.getApplication().invokeLater(new Runnable() {
-              @Override
-              public void run() {
-                searchFieldDocumentChanged();
-              }
-            });
+            searchFieldDocumentChanged();
           }
         });
       }
@@ -307,6 +308,7 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data
     new RestorePreviousSettingsAction(this, mySearchTextComponent);
     new VariantsCompletionAction(mySearchTextComponent); // It registers a shortcut set automatically on construction
   }
+
   private void searchFieldDocumentChanged() {
     setMatchesLimit(LivePreviewController.MATCHES_LIMIT);
     String text = mySearchTextComponent.getText();
@@ -465,6 +467,7 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data
     DefaultActionGroup actionGroup1 = new DefaultActionGroup("replace bar 1", false);
     myReplaceActionsToolbar1 = (ActionToolbarImpl)ActionManager.getInstance().createActionToolbar(ActionPlaces.EDITOR_TOOLBAR, actionGroup1, true);
     myReplaceActionsToolbar1.setForceMinimumSize(true);
+    myReplaceActionsToolbar1.setReservePlaceAutoPopupIcon(false);
     final JButton myReplaceButton = new JButton("Replace");
     myReplaceButton.setFocusable(false);
     myReplaceButton.addActionListener(new ActionListener() {
index bb472c18e03ca2512a0820a46ba73d73d1ed42f6..75b2eb782ac68fe03526542046b8c93bc3a95520 100644 (file)
@@ -7,6 +7,7 @@ import com.intellij.find.FindUtil;
 import com.intellij.openapi.actionSystem.ActionManager;
 import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.CommonDataKeys;
 import com.intellij.openapi.editor.Editor;
 
 /**
@@ -17,11 +18,9 @@ import com.intellij.openapi.editor.Editor;
 * To change this template use File | Settings | File Templates.
 */
 public class SwitchToReplace extends EditorHeaderAction {
-  private final Editor myEditor;
 
-  public SwitchToReplace(EditorSearchComponent editorSearchComponent, Editor editor) {
+  public SwitchToReplace(EditorSearchComponent editorSearchComponent) {
     super(editorSearchComponent);
-    myEditor = editor;
     AnAction replaceAction = ActionManager.getInstance().getAction("Replace");
     if (replaceAction != null) {
       registerCustomShortcutSet(replaceAction.getShortcutSet(), editorSearchComponent);
@@ -30,7 +29,8 @@ public class SwitchToReplace extends EditorHeaderAction {
 
   @Override
   public void update(AnActionEvent e) {
-    e.getPresentation().setEnabled(!ConsoleViewUtil.isConsoleViewEditor(myEditor));
+    final Editor editor = CommonDataKeys.EDITOR_EVEN_IF_INACTIVE.getData(e.getDataContext());
+    e.getPresentation().setEnabled(editor != null && !ConsoleViewUtil.isConsoleViewEditor(editor));
   }
 
   @Override
index b06001955f5895ef5285684a8e30554ba3effe44..04a2c0a6fff8857db40ab9521768c5ee20467f7e 100644 (file)
@@ -349,6 +349,9 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
       customComponent = ((CustomComponentAction)action).createCustomComponent(presentation);
       presentation.putClientProperty(CustomComponentAction.CUSTOM_COMPONENT_PROPERTY, customComponent);
     }
+    if (customComponent instanceof JCheckBox && UIUtil.isUnderWindowsLookAndFeel()) {
+      customComponent.setBorder(JBUI.Borders.empty(0, 9, 0, 0));
+    }
     tweakActionComponentUI(customComponent);
     return customComponent;
   }