Mac UI fixes
authorKonstantin Bulenkov <kb@jetbrains.com>
Thu, 23 Jun 2011 16:34:48 +0000 (20:34 +0400)
committerKonstantin Bulenkov <kb@jetbrains.com>
Thu, 23 Jun 2011 16:34:48 +0000 (20:34 +0400)
platform/lang-impl/src/com/intellij/refactoring/changeSignature/ParameterTableModelBase.java
platform/lang-impl/src/com/intellij/refactoring/ui/CodeFragmentTableCellRenderer.java
platform/platform-api/src/com/intellij/ui/BooleanTableCellRenderer.java

index db574f9678fd7b2fe103034e72120b67773a5663..df588bd252de5c329a5c033b4f8cfa47edfc2443 100644 (file)
@@ -26,9 +26,12 @@ import com.intellij.refactoring.ui.StringTableCellEditor;
 import com.intellij.ui.*;
 import com.intellij.util.ui.ColumnInfo;
 import com.intellij.util.ui.ListTableModel;
+import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
+import javax.swing.border.Border;
+import javax.swing.border.LineBorder;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.TableCellEditor;
 import javax.swing.table.TableCellRenderer;
@@ -188,6 +191,9 @@ public abstract class ParameterTableModelBase<P extends ParameterInfo> extends L
       return new ColoredTableCellRenderer() {
         public void customizeCellRenderer(JTable table, Object value,
                                           boolean isSelected, boolean hasFocus, int row, int column) {
+          setBackground(table.getBackground());
+          setForeground(table.getForeground());
+
           if (value == null) return;
           append((String)value, new SimpleTextAttributes(Font.PLAIN, null));
         }
index 388efed04a1e4a008d90302e86d0978047e75eda..edb20f5e760b397413f18f65da94bc248fd983f7 100644 (file)
@@ -22,6 +22,8 @@ import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiCodeFragment;
 import com.intellij.psi.PsiDocumentManager;
 import com.intellij.ui.EditorTextField;
+import com.intellij.ui.IdeBorderFactory;
+import com.intellij.util.ui.UIUtil;
 
 import javax.swing.*;
 import javax.swing.border.EmptyBorder;
@@ -69,7 +71,10 @@ public class CodeFragmentTableCellRenderer implements TableCellRenderer {
     }
 
     editorTextField.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
-    editorTextField.setBorder(hasFocus ? BorderFactory.createLineBorder(table.getForeground()): new EmptyBorder(1, 1, 1, 1));
+    ListSelectionModel selModel = table.getSelectionModel();
+    final Color color = (selModel.getMaxSelectionIndex() - selModel.getMinSelectionIndex()) == 0
+                        ? table.getSelectionBackground() : table.getForeground();
+    editorTextField.setBorder(hasFocus ? BorderFactory.createLineBorder(color): IdeBorderFactory.createEmptyBorder(1));
     return editorTextField;
   }
 }
index 5a96c0ed05becea9ffe34c77ae9b75c14e1127bc..cd0fdc856475d0318d0f9220e9c840ae43bcdbb3 100644 (file)
  */
 
 /**
- * created at Oct 5, 2001
  * @author Jeka
+ * @author Konstantin Bulenkov
  */
 package com.intellij.ui;
 
+import com.intellij.util.ui.UIUtil;
+
 import javax.swing.*;
+import javax.swing.border.LineBorder;
 import javax.swing.table.TableCellRenderer;
 import java.awt.*;
 
 public class BooleanTableCellRenderer extends JCheckBox implements TableCellRenderer {
-  private final JPanel myPanel = new JPanel();
+  private final JPanel myPanel = new JPanel(new BorderLayout());
 
   public BooleanTableCellRenderer() {
     super();
-    setHorizontalAlignment(CENTER);
+    setBorderPainted(true);
     setVerticalAlignment(CENTER);
-    setBorder(null);
+    setHorizontalAlignment(CENTER);
   }
 
-  public Component getTableCellRendererComponent(JTable table, Object value,
-                                                 boolean isSelected, boolean hasFocus,
-                                                 int row, int column) {
-    if(value == null) {
-      if(isSelected) {
-        myPanel.setBackground(table.getSelectionBackground());
-      }
-      else {
-        myPanel.setBackground(table.getBackground());
-      }
+  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSel, boolean hasFocus, int row, int column) {
+    final Color bg = table.getBackground();
+    final Color fg = table.getForeground();
+    final Color selBg = table.getSelectionBackground();
+    final Color selFg = table.getSelectionForeground();
+
+    myPanel.setBackground(isSel ? selBg : bg);
+    if (value == null) {
       return myPanel;
     }
-    if(isSelected) {
-      setForeground(table.getSelectionForeground());
-      super.setBackground(table.getSelectionBackground());
-    }
-    else {
-      setForeground(table.getForeground());
-      setBackground(table.getBackground());
-    }
+
+    setForeground(isSel ? selFg : fg);
+    if (isSel) super.setBackground(selBg); else setBackground(bg);
+
     if (value instanceof String) {
       setSelected(Boolean.parseBoolean((String)value));
-    }
-    else {
+    } else {
       setSelected(((Boolean)value).booleanValue());
     }
+
+    setBorder(hasFocus ? UIUtil.getTableFocusCellHighlightBorder() : IdeBorderFactory.createEmptyBorder(1));
+
     setEnabled(table.isCellEditable(row, column));
+
     return this;
   }
 }