diff --git a/platform/core-api/src/com/intellij/util/IconUtil.java b/platform/core-api/src/com/intellij/util/IconUtil.java index c8be32c8e0f1..f00a90b7b51f 100644 --- a/platform/core-api/src/com/intellij/util/IconUtil.java +++ b/platform/core-api/src/com/intellij/util/IconUtil.java @@ -272,4 +272,50 @@ public class IconUtil { private static String getToolbarDecoratorIconsFolder() { return "/toolbarDecorator/" + (SystemInfo.isMac ? "mac/" : ""); } + + /** + * Result icons look like original but have equal (maximum) size + */ + public static Icon[] getEqualSizedIcons(@NotNull Icon... icons) { + Icon[] result = new Icon[icons.length]; + int width = 0; + int height = 0; + for (Icon icon : icons) { + width = Math.max(width, icon.getIconWidth()); + height = Math.max(height, icon.getIconHeight()); + } + for (int i = 0; i < icons.length; i++) { + result[i] = new IconSizeWrapper(icons[i], width, height); + } + return result; + } + + private static class IconSizeWrapper implements Icon { + private final Icon myIcon; + private final int myWidth; + private final int myHeight; + + private IconSizeWrapper(Icon icon, int width, int height) { + myIcon = icon; + myWidth = width; + myHeight = height; + } + + @Override + public void paintIcon(Component c, Graphics g, int x, int y) { + x += (myWidth - myIcon.getIconWidth()) / 2; + y += (myHeight - myIcon.getIconHeight()) / 2; + myIcon.paintIcon(c, g, x, y); + } + + @Override + public int getIconWidth() { + return myWidth; + } + + @Override + public int getIconHeight() { + return myHeight; + } + } } diff --git a/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java b/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java index ac6634241050..9fc3bc46a051 100644 --- a/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java +++ b/platform/lang-api/src/com/intellij/execution/configurations/RunConfigurationBase.java @@ -269,6 +269,6 @@ public abstract class RunConfigurationBase extends UserDataHolderBase implements @Override public String toString() { - return getType() + ": " + getName(); + return getType().getDisplayName() + ": " + getName(); } } diff --git a/platform/lang-impl/src/com/intellij/execution/impl/BeforeRunStepsPanel.java b/platform/lang-impl/src/com/intellij/execution/impl/BeforeRunStepsPanel.java index 86c62b76301d..8a2ccac06586 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/BeforeRunStepsPanel.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/BeforeRunStepsPanel.java @@ -21,6 +21,7 @@ import com.intellij.execution.ExecutionBundle; import com.intellij.execution.RunnerAndConfigurationSettings; import com.intellij.execution.configurations.RunConfiguration; import com.intellij.execution.configurations.UnknownRunConfiguration; +import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.DefaultActionGroup; @@ -35,9 +36,12 @@ import com.intellij.openapi.util.SystemInfo; import com.intellij.ui.*; import com.intellij.ui.components.JBList; import com.intellij.util.containers.hash.HashSet; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; import java.awt.*; @@ -50,6 +54,8 @@ import java.util.List; * @author Vassiliy Kudryashov */ class BeforeRunStepsPanel extends DropDownPanel { + @NonNls private static final String EXPAND_PROPERTY_KEY = "ExpandBeforeRunStepsPanel"; + private final JCheckBox myShowSettingsBeforeRunCheckBox; private final JBList myList; private final CollectionListModel myModel; @@ -143,6 +149,13 @@ class BeforeRunStepsPanel extends DropDownPanel { wrapper.add(myShowSettingsBeforeRunCheckBox, BorderLayout.NORTH); wrapper.add(myPanel, BorderLayout.CENTER); setContent(wrapper); + setExpanded(PropertiesComponent.getInstance().getBoolean(EXPAND_PROPERTY_KEY, false)); + addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + PropertiesComponent.getInstance().setValue(EXPAND_PROPERTY_KEY, String.valueOf(isExpanded())); + } + }); } @Nullable @@ -160,11 +173,13 @@ class BeforeRunStepsPanel extends DropDownPanel { myRunConfiguration = settings.getConfiguration(); originalTasks.clear(); - originalTasks.addAll(RunManagerImpl.getInstanceImpl(myRunConfiguration.getProject()).getBeforeRunTasks(myRunConfiguration)); + RunManagerImpl runManager = RunManagerImpl.getInstanceImpl(myRunConfiguration.getProject()); + originalTasks.addAll(runManager.getBeforeRunTasks(myRunConfiguration)); myModel.replaceAll(originalTasks); myShowSettingsBeforeRunCheckBox.setSelected(settings.isEditBeforeRun()); myShowSettingsBeforeRunCheckBox.setEnabled(!(isUnknown())); myPanel.setVisible(checkBeforeRunTasksAbility(false)); + updateText(); } private void updateText() { diff --git a/platform/platform-impl/src/com/intellij/ui/DropDownPanel.java b/platform/platform-impl/src/com/intellij/ui/DropDownPanel.java index 26497c04b55b..04a2bb42d635 100644 --- a/platform/platform-impl/src/com/intellij/ui/DropDownPanel.java +++ b/platform/platform-impl/src/com/intellij/ui/DropDownPanel.java @@ -19,32 +19,36 @@ import com.intellij.icons.AllIcons; import com.intellij.openapi.actionSystem.ActionButtonComponent; import com.intellij.openapi.actionSystem.ex.ActionButtonLook; import com.intellij.util.IconUtil; -import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import javax.swing.border.Border; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import java.awt.*; import java.awt.event.MouseEvent; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; /** * User: Vassiliy.Kudryashov */ public class DropDownPanel extends JPanel { - private static final Icon DOWN = AllIcons.General.ComboArrow; - private static final Icon UP = IconUtil.flip(AllIcons.General.ComboArrow, false); + private static final Icon[] WRAPPERS = IconUtil.getEqualSizedIcons(AllIcons.General.ComboArrowRight, AllIcons.General.ComboArrow); + private static final Icon DOWN = WRAPPERS[0]; + private static final Icon UP = WRAPPERS[1]; - private final JLabel myLabel; + private final ButtonLabel myLabel; private @Nullable JComponent myContent; private boolean myExpanded = true; + private final List myListeners = new CopyOnWriteArrayList(); public DropDownPanel() { - this(null, null, true); + this(null, null); } - public DropDownPanel(@Nullable String title, @Nullable JComponent content, boolean withSeparatorLine) { + public DropDownPanel(@Nullable String title, @Nullable JComponent content) { super(new BorderLayout()); - myLabel = new ButtonLabel(withSeparatorLine); + myLabel = new ButtonLabel(); add(myLabel, BorderLayout.NORTH); setTitle(title); setContent(content); @@ -71,7 +75,7 @@ public class DropDownPanel extends JPanel { if (myExpanded == expanded) { return; } - myLabel.setIcon(expanded ? UP : DOWN); + myLabel.getLabel().setIcon(expanded ? UP : DOWN); if (myContent != null) { if (expanded) { add(myContent, BorderLayout.CENTER); @@ -83,42 +87,42 @@ public class DropDownPanel extends JPanel { myExpanded = expanded; revalidate(); repaint(); + ChangeEvent changeEvent = new ChangeEvent(this); + for (ChangeListener listener : myListeners) { + listener.stateChanged(changeEvent); + } } public boolean isExpanded() { return myExpanded; } - private class ButtonLabel extends JLabel implements ActionButtonComponent { + public void addChangeListener(ChangeListener listener) { + if (listener != null) { + myListeners.add(listener); + } + } + public void removeChangeListener(ChangeListener listener) { + if (listener != null) { + myListeners.remove(listener); + } + } + + private class ButtonLabel extends TitledSeparator implements ActionButtonComponent { private boolean myMouseDown; private boolean myRollover; - private final boolean myLine; - private ButtonLabel(boolean withSeparatorLine) { - myLine = withSeparatorLine; - setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); - setIconTextGap(2); + private ButtonLabel() { + setBorder(BorderFactory.createEmptyBorder(4, 0, 4, 0)); + myLabel.setIconTextGap(2); enableEvents(AWTEvent.MOUSE_EVENT_MASK); } @Override public void paintComponent(Graphics g) { + super.paintComponent(g); ActionButtonLook.IDEA_LOOK.paintBackground(g, this); ActionButtonLook.IDEA_LOOK.paintBorder(g, this); - super.paintComponent(g); - if (myLine) { - g.setColor(GroupedElementsRenderer.POPUP_SEPARATOR_FOREGROUND); - Icon icon = getIcon(); - final FontMetrics fm = getFontMetrics(getFont()); - String text = getText(); - Border border = getBorder(); - Insets insets = border != null ? border.getBorderInsets(this) : new Insets(0, 0, 0, 0); - int width = (icon != null ? icon.getIconWidth() : 0) - + (text != null ? getIconTextGap() + fm.stringWidth(text) : 0) - + insets.left; - final int lineY = (UIUtil.isUnderNativeMacLookAndFeel() ? 1 : 3) + fm.getHeight() / 2; - g.drawLine(width + 3, lineY, getWidth() - 3 - insets.right, lineY); - } } @Override diff --git a/platform/platform-resources-en/src/messages/ExecutionBundle.properties b/platform/platform-resources-en/src/messages/ExecutionBundle.properties index a0d9889ec8fd..f2b6b490fbd1 100644 --- a/platform/platform-resources-en/src/messages/ExecutionBundle.properties +++ b/platform/platform-resources-en/src/messages/ExecutionBundle.properties @@ -278,7 +278,7 @@ show.swing.inspector=&Enable capturing form snapshots show.swing.inspector.disabled=&Enable capturing form snapshots (requires JRE 5.0 or higher) before.run.property.make=Make run.configuration.store.place.option=&Share -run.configuration.singleton=Single instance allowed +run.configuration.singleton=Single instance only run.configuration.default.type.description=configuration #GeneralCommandLine