diff --git a/platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationAction.java b/platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationAction.java index 6c6b1551e84f..38dccf64ae2f 100644 --- a/platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationAction.java +++ b/platform/lang-impl/src/com/intellij/execution/actions/RunConfigurationAction.java @@ -110,16 +110,6 @@ public class RunConfigurationAction extends ComboBoxAction implements DumbAware public JComponent createCustomComponent(final Presentation presentation) { return new ComboBoxButton(presentation) { - protected void updateButtonSize() { - super.updateButtonSize(); - final Dimension preferredSize = getPreferredSize(); - final int width = preferredSize.width; - final int height = preferredSize.height; - if (width > height * 15) { - setPreferredSize(new Dimension(height * 15, height)); - } - } - public void addNotify() { super.addNotify(); //To change body of overriden methods use Options | File Templates.; final IdeFrameImpl frame = findFrame(this); diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java index b069234e1bd3..4b5ffb86864d 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/ComboBoxAction.java @@ -36,6 +36,7 @@ import java.beans.PropertyChangeListener; public abstract class ComboBoxAction extends AnAction implements CustomComponentAction { private static final Icon ARROW_ICON = IconLoader.getIcon("/general/comboArrow.png"); + private static final Icon DISABLED_ARROW_ICON = IconLoader.getDisabledIcon(ARROW_ICON); protected ComboBoxAction() { } @@ -74,7 +75,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent public ComboBoxButton(Presentation presentation) { myPresentation = presentation; setModel(new MyButtonModel()); - setHorizontalAlignment(SwingConstants.LEFT); + setHorizontalAlignment(LEFT); setFocusable(false); Insets margins = getMargin(); setMargin(new Insets(margins.top, 2, margins.bottom, 2)); @@ -196,24 +197,53 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent } } + + @Override + public Insets getInsets() { + final Insets insets = super.getInsets(); + return new Insets(insets.top, insets.left, insets.bottom, insets.right + ARROW_ICON.getIconWidth()); + } + + @Override + public Insets getInsets(Insets insets) { + final Insets result = super.getInsets(insets); + + if (UIUtil.isUnderNimbusLookAndFeel()) { + result.top += 2; + result.left += 8; + result.bottom += 2; + result.right += 4 + ARROW_ICON.getIconWidth(); + } + + return result; + } + + @Override + public Dimension getPreferredSize() { + int width = super.getPreferredSize().width; + + final String text = getText(); + if ((text == null || text.trim().length() == 0) && getIcon() == null) { + width = 10 + ARROW_ICON.getIconWidth(); + } + + return new Dimension(width, UIUtil.isUnderNimbusLookAndFeel() ? 24 : 21); + } + public final void paint(Graphics g) { super.paint(g); Dimension size = getSize(); String text = getText(); boolean isEmpty = getIcon() == null && (text == null || text.trim().length() == 0); - int x = isEmpty ? (size.width - ARROW_ICON.getIconWidth())/2 : size.width - ARROW_ICON.getIconWidth() - 2; - ARROW_ICON.paintIcon(null, g, x, (size.height - ARROW_ICON.getIconHeight()) / 2); + final Insets insets = super.getInsets(); + final Icon icon = isEnabled() ? ARROW_ICON : DISABLED_ARROW_ICON; + int x = isEmpty ? (size.width - icon.getIconWidth())/2: size.width - icon.getIconWidth() - insets.right + (UIUtil.isUnderNimbusLookAndFeel() ? -3 : 2); + icon.paintIcon(null, g, x, (size.height - icon.getIconHeight()) / 2); } protected void updateButtonSize() { - int width; - String text = getText(); - if ((text == null || text.trim().length() == 0) && getIcon() == null) { - width = ARROW_ICON.getIconWidth() + 10; - } else { - width = getUI().getPreferredSize(this).width + ARROW_ICON.getIconWidth() + 2; - } - setPreferredSize(new Dimension(width, 21)); + invalidate(); + repaint(); } } } diff --git a/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegButtonUI.java b/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegButtonUI.java index fe6a4c79a0b4..6816064f56e2 100644 --- a/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegButtonUI.java +++ b/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegButtonUI.java @@ -63,7 +63,7 @@ public class BegButtonUI extends MetalButtonUI { b.getVerticalAlignment(), b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewRect, iconRect, textRect, - b.getText() == null ? 0 : defaultTextIconGap + b.getText() == null ? 0 : b.getIconTextGap() ); clearTextShiftOffset(); diff --git a/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegMenuItemUI.java b/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegMenuItemUI.java index b6b12c27c346..bbe0575a9b7f 100644 --- a/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegMenuItemUI.java +++ b/platform/platform-impl/src/com/intellij/ui/plaf/beg/BegMenuItemUI.java @@ -58,7 +58,7 @@ public class BegMenuItemUI extends BasicMenuItemUI { @NonNls public static final String AQUA_LOOK_AND_FEEL_CLASS_NAME = "apple.laf.AquaLookAndFeel"; @NonNls public static final String GET_KEY_MODIFIERS_TEXT = "getKeyModifiersText"; - private static final Border SELECTED_BACKGROUND_PAINTER = (Border) UIManager.get("MenuItem.selectedBackgroundPainter"); + private Border myAquaSelectedBackgroundPainter; /** invoked by reflection */ public static ComponentUI createUI(JComponent component) { @@ -67,6 +67,10 @@ public class BegMenuItemUI extends BasicMenuItemUI { public BegMenuItemUI() { myMaxGutterIconWidth = 18; + + if (UIUtil.isUnderAquaLookAndFeel() && myAquaSelectedBackgroundPainter == null) { + myAquaSelectedBackgroundPainter = (Border) UIManager.get("MenuItem.selectedBackgroundPainter"); + } } protected void installDefaults() { @@ -112,7 +116,7 @@ public class BegMenuItemUI extends BasicMenuItemUI { g.fillRect(0, 0, j1, k1); if (buttonmodel.isArmed() || (comp instanceof JMenu) && buttonmodel.isSelected()){ if (UIUtil.isUnderAquaLookAndFeel()) { - SELECTED_BACKGROUND_PAINTER.paintBorder(comp, g, 0, 0, j1, k1); + myAquaSelectedBackgroundPainter.paintBorder(comp, g, 0, 0, j1, k1); } else { g.setColor(selectionBackground); if (icon2 != null){ diff --git a/platform/platform-impl/src/com/intellij/ui/plaf/beg/IdeaMenuUI.java b/platform/platform-impl/src/com/intellij/ui/plaf/beg/IdeaMenuUI.java index ffdaeccae5d9..f1dfa037ea6b 100644 --- a/platform/platform-impl/src/com/intellij/ui/plaf/beg/IdeaMenuUI.java +++ b/platform/platform-impl/src/com/intellij/ui/plaf/beg/IdeaMenuUI.java @@ -45,9 +45,9 @@ public class IdeaMenuUI extends BasicMenuUI{ private static final Rectangle ourIconRect = new Rectangle(); private static final Rectangle ourViewRect = new Rectangle(32767, 32767); - private static final Border SELECTED_BACKGROUND_PAINTER = (Border) UIManager.get("MenuItem.selectedBackgroundPainter"); - private static final Icon INVERTED_ARROW_ICON = (Icon) UIManager.get("Menu.invertedArrowIcon"); - private static final Icon DISABLED_ARROW_ICON = (Icon) UIManager.get("Menu.disabledArrowIcon"); + private Border myAquaSelectedBackgroundPainter; + private Icon myAquaInvertedArrowIcon; + private Icon myAquaDisabledArrowIcon; /** invoked by reflection */ public static ComponentUI createUI(JComponent component) { @@ -56,6 +56,12 @@ public class IdeaMenuUI extends BasicMenuUI{ public IdeaMenuUI() { myMaxGutterIconWidth = 18; + + if (UIUtil.isUnderAquaLookAndFeel()) { + if (myAquaSelectedBackgroundPainter == null) myAquaSelectedBackgroundPainter = (Border) UIManager.get("MenuItem.selectedBackgroundPainter"); + if (myAquaInvertedArrowIcon == null) myAquaInvertedArrowIcon = (Icon) UIManager.get("Menu.invertedArrowIcon"); + if (myAquaDisabledArrowIcon == null) myAquaDisabledArrowIcon = (Icon) UIManager.get("Menu.disabledArrowIcon"); + } } protected MenuKeyListener createMenuKeyListener(JComponent c){ @@ -116,7 +122,7 @@ public class IdeaMenuUI extends BasicMenuUI{ g.fillRect(0, 0, jMenu.getWidth(), jMenu.getHeight()); if (buttonmodel.isArmed() || buttonmodel.isSelected()){ if (UIUtil.isUnderAquaLookAndFeel()) { - SELECTED_BACKGROUND_PAINTER.paintBorder(comp, g, 0, 0, jMenu.getWidth(), jMenu.getHeight()); + myAquaSelectedBackgroundPainter.paintBorder(comp, g, 0, 0, jMenu.getWidth(), jMenu.getHeight()); } else { g.setColor(selectionBackground); if (allowedIcon != null) { @@ -190,10 +196,10 @@ public class IdeaMenuUI extends BasicMenuUI{ } if (useCheckAndArrow()){ try { - if (SystemInfo.isMac && INVERTED_ARROW_ICON != null && (buttonmodel.isArmed() || buttonmodel.isSelected()) && UIUtil.isUnderAquaLookAndFeel()) { - INVERTED_ARROW_ICON.paintIcon(comp, g, ourArrowIconRect.x, ourArrowIconRect.y); - } else if (SystemInfo.isMac && DISABLED_ARROW_ICON != null && !buttonmodel.isEnabled() && UIUtil.isUnderAquaLookAndFeel()) { - DISABLED_ARROW_ICON.paintIcon(comp, g, ourArrowIconRect.x, ourArrowIconRect.y); + if (SystemInfo.isMac && myAquaInvertedArrowIcon != null && (buttonmodel.isArmed() || buttonmodel.isSelected()) && UIUtil.isUnderAquaLookAndFeel()) { + myAquaInvertedArrowIcon.paintIcon(comp, g, ourArrowIconRect.x, ourArrowIconRect.y); + } else if (SystemInfo.isMac && myAquaDisabledArrowIcon != null && !buttonmodel.isEnabled() && UIUtil.isUnderAquaLookAndFeel()) { + myAquaDisabledArrowIcon.paintIcon(comp, g, ourArrowIconRect.x, ourArrowIconRect.y); } else arrowIcon.paintIcon(comp, g, ourArrowIconRect.x, ourArrowIconRect.y); } catch (NullPointerException npe) {