IDEA-131239 "Alt F3" search in editor should have "pink" background if there are...
authorVassiliy.Kudryashov <Vassiliy.Kudryashov@jetbrains.com>
Mon, 13 Oct 2014 16:47:58 +0000 (20:47 +0400)
committerVassiliy.Kudryashov <Vassiliy.Kudryashov@jetbrains.com>
Mon, 13 Oct 2014 16:56:11 +0000 (20:56 +0400)
platform/platform-api/src/com/intellij/ui/SearchTextField.java

index c4a5551ea219ff8ca451cc46b5801b7c7910e267..d695d0dd57f7f58b61b12e90df3477b690387e98 100644 (file)
@@ -28,14 +28,17 @@ import com.intellij.openapi.ui.popup.JBPopupFactory;
 import com.intellij.openapi.util.SystemInfo;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.ui.components.JBList;
+import com.intellij.util.ReflectionUtil;
 import com.intellij.util.ui.UIUtil;
 
 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.*;
 import java.awt.event.*;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -82,6 +85,25 @@ public class SearchTextField extends JPanel {
           myToggleHistoryLabel.setBackground(bg);
         }
       }
+
+      @Override
+      public void setUI(TextUI ui) {
+        super.setUI(ui);
+        if (SystemInfo.isMac) {
+          try {
+            Class<?> uiClass = Class.forName("com.intellij.ide.ui.laf.darcula.ui.DarculaTextFieldUI");
+            Method method = ReflectionUtil.getMethod(uiClass, "createUI", JComponent.class);
+            if (method != null) {
+              super.setUI((TextUI)method.invoke(uiClass, this));
+              Class<?> borderClass = Class.forName("com.intellij.ide.ui.laf.darcula.ui.DarculaTextBorder");
+              setBorder((Border)ReflectionUtil.newInstance(borderClass));
+              setOpaque(false);
+            }
+          }
+          catch (Exception ignored) {
+          }
+        }
+      }
     };
     myTextField.setColumns(15);
     myTextField.addFocusListener(new FocusAdapter() {
@@ -161,7 +183,7 @@ public class SearchTextField extends JPanel {
         setBorder(new CompoundBorder(IdeBorderFactory.createEmptyBorder(2, 0, 2, 0), originalBorder));
 
         myTextField.setOpaque(true);
-        myTextField.setBorder(IdeBorderFactory.createEmptyBorder(0, 5, 0, 5));
+        //myTextField.setBorder(IdeBorderFactory.createEmptyBorder(0, 5, 0, 5));
       }
       else {
         setBorder(IdeBorderFactory.createEmptyBorder(2, 0, 2, 0));
@@ -375,17 +397,17 @@ public class SearchTextField extends JPanel {
     }
   }
 
-  @Override
-  public Dimension getPreferredSize() {
-    Dimension size = super.getPreferredSize();
-    Border border = super.getBorder();
-    if (border != null && UIUtil.isUnderAquaLookAndFeel()) {
-      Insets insets = border.getBorderInsets(this);
-      size.height += insets.top + insets.bottom;
-      size.width += insets.left + insets.right;
-    }
-    return size;
-  }
+  //@Override
+  //public Dimension getPreferredSize() {
+  //  Dimension size = super.getPreferredSize();
+  //  Border border = super.getBorder();
+  //  if (border != null && UIUtil.isUnderAquaLookAndFeel()) {
+  //    Insets insets = border.getBorderInsets(this);
+  //    size.height += insets.top + insets.bottom;
+  //    size.width += insets.left + insets.right;
+  //  }
+  //  return size;
+  //}
 
   protected Runnable createItemChosenCallback(final JList list) {
     return new Runnable() {