diff --git a/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java b/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java index 27625060354f..e00ecc273227 100644 --- a/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java +++ b/platform/lang-impl/src/com/intellij/application/options/InitialConfigurationDialog.java @@ -165,7 +165,7 @@ public class InitialConfigurationDialog extends DialogWrapper { private void createUIComponents() { myColorPreviewPanel = new AbstractTitledSeparatorWithIcon(IconLoader.getIcon("/general/comboArrowRight.png"), IconLoader.getIcon("/general/comboArrowDown.png"), - "Click to preview", true, false) { + "Click to preview") { private int myAddedWidth; diff --git a/platform/lvcs-impl/src/com/intellij/history/integration/ui/views/RevisionsList.java b/platform/lvcs-impl/src/com/intellij/history/integration/ui/views/RevisionsList.java index 21ea7b38aa09..17df7d096bbc 100644 --- a/platform/lvcs-impl/src/com/intellij/history/integration/ui/views/RevisionsList.java +++ b/platform/lvcs-impl/src/com/intellij/history/integration/ui/views/RevisionsList.java @@ -394,7 +394,7 @@ public class RevisionsList { @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { Graphics2D g2d = (Graphics2D)g.create(); - g2d.setColor(UIUtil.getBorderSeparatorColor()); + g2d.setColor(UIUtil.getBorderColor()); g2d.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[]{1}, 1)); g2d.drawLine(x, y, x + width, y); if (isLast) { diff --git a/platform/platform-api/src/com/intellij/openapi/ui/SimpleToolWindowPanel.java b/platform/platform-api/src/com/intellij/openapi/ui/SimpleToolWindowPanel.java index 8198230777a4..8ac88742c368 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/SimpleToolWindowPanel.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/SimpleToolWindowPanel.java @@ -18,7 +18,6 @@ package com.intellij.openapi.ui; import com.intellij.openapi.actionSystem.ActionToolbar; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.DataProvider; -import com.intellij.openapi.actionSystem.Separator; import com.intellij.openapi.util.Ref; import com.intellij.ui.switcher.QuickActionProvider; import com.intellij.util.ui.AwtVisitor; @@ -28,8 +27,8 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; -import java.awt.event.*; -import java.util.*; +import java.awt.event.ContainerAdapter; +import java.awt.event.ContainerEvent; import java.util.List; public class SimpleToolWindowPanel extends JPanel implements QuickActionProvider, DataProvider { @@ -145,7 +144,7 @@ public class SimpleToolWindowPanel extends JPanel implements QuickActionProvider super.paintComponent(g); if (myToolbar != null && myToolbar.getParent() == this && myContent != null && myContent.getParent() == this) { - g.setColor(UIUtil.getBorderSeparatorColor()); + g.setColor(UIUtil.getBorderColor()); if (myVertical) { final int y = (int)myToolbar.getBounds().getMaxY(); g.drawLine(0, y, getWidth(), y); diff --git a/platform/platform-api/src/com/intellij/ui/TitledSeparator.java b/platform/platform-api/src/com/intellij/ui/TitledSeparator.java index 6d759615473d..7773ee761c7a 100644 --- a/platform/platform-api/src/com/intellij/ui/TitledSeparator.java +++ b/platform/platform-api/src/com/intellij/ui/TitledSeparator.java @@ -54,7 +54,7 @@ public class TitledSeparator extends JPanel { public void updateUI() { super.updateUI(); if (myLabel != null) { - myLabel.setFont(UIUtil.getBorderFont(UIUtil.FontSize.SMALL, false)); + myLabel.setFont(UIUtil.getTitledBorderFont()); } } @@ -81,22 +81,4 @@ public class TitledSeparator extends JPanel { public JSeparator getSeparator() { return mySeparator; } - - @Deprecated - public boolean isBoldFont() { - return false; - } - - @Deprecated - public boolean isSmallFont() { - return true; - } - - @Deprecated - public void setBoldFont(boolean boldFont) { - } - - @Deprecated - public void setSmallFont(boolean smallFont) { - } } diff --git a/platform/platform-impl/src/com/intellij/ui/AbstractTitledSeparatorWithIcon.java b/platform/platform-impl/src/com/intellij/ui/AbstractTitledSeparatorWithIcon.java index 5a061dfef07a..44ef8f368d44 100644 --- a/platform/platform-impl/src/com/intellij/ui/AbstractTitledSeparatorWithIcon.java +++ b/platform/platform-impl/src/com/intellij/ui/AbstractTitledSeparatorWithIcon.java @@ -42,9 +42,7 @@ public abstract class AbstractTitledSeparatorWithIcon extends JPanel { public AbstractTitledSeparatorWithIcon(@NotNull final Icon icon, @NotNull final Icon iconOpen, - @NotNull final String text, - final boolean smallFont, - final boolean boldFont) { + @NotNull final String text) { myIcon = icon; myIconOpen = iconOpen; setLayout(new GridBagLayout()); @@ -59,7 +57,7 @@ public abstract class AbstractTitledSeparatorWithIcon extends JPanel { new Insets(3, 0, 0, 0), 0, 0); add(mySeparator, gb); setBorder(IdeBorderFactory.createEmptyBorder(3, 0, 5, 5)); - myLabel.setFont(UIUtil.getBorderFont(smallFont ? UIUtil.FontSize.SMALL : UIUtil.FontSize.NORMAL, boldFont)); + myLabel.setFont(UIUtil.getTitledBorderFont()); myLabel.setForeground(UIUtil.getTitledBorderTitleColor()); originalText = text; myLabel.setText(UIUtil.replaceMnemonicAmpersand(originalText)); diff --git a/platform/platform-impl/src/com/intellij/ui/HideableDetailsUnderSeparator.java b/platform/platform-impl/src/com/intellij/ui/HideableDetailsUnderSeparator.java index fb3d91012efe..1e9af99d3528 100644 --- a/platform/platform-impl/src/com/intellij/ui/HideableDetailsUnderSeparator.java +++ b/platform/platform-impl/src/com/intellij/ui/HideableDetailsUnderSeparator.java @@ -29,9 +29,8 @@ import java.awt.*; public abstract class HideableDetailsUnderSeparator extends AbstractTitledSeparatorWithIcon { public HideableDetailsUnderSeparator(@NotNull Icon icon, @NotNull Icon iconOpen, - @NotNull String text, - boolean smallFont, boolean boldFont) { - super(icon, iconOpen, text, smallFont, boldFont); + @NotNull String text) { + super(icon, iconOpen, text); } public void on() { diff --git a/platform/platform-impl/src/com/intellij/ui/HideableTitledPanel.java b/platform/platform-impl/src/com/intellij/ui/HideableTitledPanel.java new file mode 100644 index 000000000000..783c47ca8aec --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ui/HideableTitledPanel.java @@ -0,0 +1,131 @@ +package com.intellij.ui; + +import com.intellij.openapi.util.IconLoader; +import com.intellij.util.ui.UIUtil; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * @author evgeny zakrevsky + */ +public class HideableTitledPanel extends JPanel { + Icon OFF_ICON = IconLoader.getIcon("/general/comboArrow.png"); + Icon ON_ICON = IconLoader.getIcon("/general/comboUpPassive.png"); + private TitledSeparatorWithMnemonic myTitledSeparator; + private boolean myOn; + private final JComponent myContent; + private Dimension myPreviousContentSize; + + public HideableTitledPanel(String title, JComponent content, boolean on) { + super(new BorderLayout()); + myContent = content; + add(myContent, BorderLayout.CENTER); + myTitledSeparator = new TitledSeparatorWithMnemonic(title, null); + add(myTitledSeparator, BorderLayout.NORTH); + myTitledSeparator.getLabel().setIcon(OFF_ICON); + + myTitledSeparator.getLabel().addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + if (myOn) { + off(); + } + else { + on(); + } + } + + @Override + public void mouseEntered(MouseEvent e) { + setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + + @Override + public void mouseExited(MouseEvent e) { + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + } + }); + + UIUtil.setActionNameAndMnemonic(title, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + if (myOn) { + off(); + } + else { + on(); + } + } + }); + + setOn(on); + } + + public void setOn(boolean on) { + myOn = on; + if (myOn) { + on(); + } + else { + off(); + } + } + + protected void on() { + myOn = true; + myTitledSeparator.getLabel().setIcon(ON_ICON); + myContent.setVisible(true); + adjustWindow(); + invalidate(); + repaint(); + } + + private void adjustWindow() { + final Window window = SwingUtilities.getWindowAncestor(this); + if (window == null) return; + final Dimension size = window.getSize(); + final Dimension contentSize = myPreviousContentSize != null && myPreviousContentSize.width > 0 && myPreviousContentSize.height > 0 + ? myPreviousContentSize + : myContent.getPreferredSize(); + final Dimension newSize; + if (myOn) { + newSize = new Dimension(Math.max(size.width, myContent.getSize().width), size.height + contentSize.height); + } + else { + newSize = new Dimension(size.width, size.height - contentSize.height); + } + if (!newSize.equals(size)) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + if (window.isShowing()) { + window.setSize(newSize); + } + } + }); + } + } + + protected void off() { + myOn = false; + myTitledSeparator.getLabel().setIcon(OFF_ICON); + myContent.setVisible(false); + myPreviousContentSize = myContent.getSize(); + adjustWindow(); + invalidate(); + repaint(); + } + + public void setTitle(String title) { + myTitledSeparator.setText(title); + } + + @Override + public void setEnabled(boolean enabled) { + myTitledSeparator.myLabel.setForeground(enabled ? UIUtil.getActiveTextColor() : UIUtil.getInactiveTextColor()); + myContent.setEnabled(enabled); + } +} diff --git a/platform/platform-impl/src/com/intellij/ui/SplitterWithSecondHideable.java b/platform/platform-impl/src/com/intellij/ui/SplitterWithSecondHideable.java index 2b86c4af99a6..8e80795c01c6 100644 --- a/platform/platform-impl/src/com/intellij/ui/SplitterWithSecondHideable.java +++ b/platform/platform-impl/src/com/intellij/ui/SplitterWithSecondHideable.java @@ -47,7 +47,7 @@ public abstract class SplitterWithSecondHideable { public SplitterWithSecondHideable(final boolean vertical, final String separatorText, final JComponent firstComponent, - final OnOffListener listener, final boolean boldFont) { + final OnOffListener listener) { myVertical = vertical; myListener = listener; myFictivePanel = new JPanel(new BorderLayout()); @@ -56,12 +56,13 @@ public abstract class SplitterWithSecondHideable { if (vertical) { icon = IconLoader.getIcon("/general/comboArrow.png"); openIcon = IconLoader.getIcon("/general/comboUpPassive.png"); - } else { + } + else { icon = IconLoader.getIcon("/general/comboArrowRight.png"); openIcon = IconLoader.getIcon("/general/comboArrowRightPassive.png"); } - myTitledSeparator = new AbstractTitledSeparatorWithIcon(icon, openIcon, separatorText, true, true) { + myTitledSeparator = new AbstractTitledSeparatorWithIcon(icon, openIcon, separatorText) { @Override protected RefreshablePanel createPanel() { return createDetails(); @@ -89,7 +90,7 @@ public abstract class SplitterWithSecondHideable { final int firstSize = vertical ? mySplitter.getFirstComponent().getHeight() : mySplitter.getFirstComponent().getWidth(); // !! order is important! first fix mySplitter.fixFirst(); - myListener.on((int) ((1 - proportion) * firstSize / proportion)); + myListener.on((int)((1 - proportion) * firstSize / proportion)); //mySplitter.setProportion(proportion); mySplitter.setSecondComponent(myDetailsComponent.getPanel()); mySplitter.revalidate(); @@ -111,66 +112,67 @@ public abstract class SplitterWithSecondHideable { } }; mySplitter = new PseudoSplitter(vertical) { - { - myTitledSeparator.mySeparator.addMouseListener(new MouseAdapter() { - @Override - public void mouseEntered(MouseEvent e) { - myTitledSeparator.mySeparator - .setCursor(myTitledSeparator.myOn ? new Cursor(Cursor.S_RESIZE_CURSOR) : new Cursor(Cursor.DEFAULT_CURSOR)); - ((MyDivider) mySuperDivider).processMouseEvent(e); - } + { + myTitledSeparator.mySeparator.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + myTitledSeparator.mySeparator + .setCursor(myTitledSeparator.myOn ? new Cursor(Cursor.S_RESIZE_CURSOR) : new Cursor(Cursor.DEFAULT_CURSOR)); + ((MyDivider)mySuperDivider).processMouseEvent(e); + } - @Override - public void mouseExited(MouseEvent e) { - myTitledSeparator.mySeparator.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); - ((MyDivider) mySuperDivider).processMouseEvent(e); - } + @Override + public void mouseExited(MouseEvent e) { + myTitledSeparator.mySeparator.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + ((MyDivider)mySuperDivider).processMouseEvent(e); + } - @Override - public void mouseClicked(MouseEvent e) { - ((MyDivider) mySuperDivider).processMouseEvent(e); - } + @Override + public void mouseClicked(MouseEvent e) { + ((MyDivider)mySuperDivider).processMouseEvent(e); + } - @Override - public void mousePressed(MouseEvent e) { - ((MyDivider) mySuperDivider).processMouseEvent(e); - } + @Override + public void mousePressed(MouseEvent e) { + ((MyDivider)mySuperDivider).processMouseEvent(e); + } - @Override - public void mouseReleased(MouseEvent e) { - ((MyDivider) mySuperDivider).processMouseEvent(e); - } + @Override + public void mouseReleased(MouseEvent e) { + ((MyDivider)mySuperDivider).processMouseEvent(e); + } - @Override - public void mouseWheelMoved(MouseWheelEvent e) { - ((MyDivider) mySuperDivider).processMouseEvent(e); - } + @Override + public void mouseWheelMoved(MouseWheelEvent e) { + ((MyDivider)mySuperDivider).processMouseEvent(e); + } - @Override - public void mouseDragged(MouseEvent e) { - ((MyDivider) mySuperDivider).processMouseEvent(e); - } + @Override + public void mouseDragged(MouseEvent e) { + ((MyDivider)mySuperDivider).processMouseEvent(e); + } - @Override - public void mouseMoved(MouseEvent e) { - ((MyDivider) mySuperDivider).processMouseEvent(e); - } - }); + @Override + public void mouseMoved(MouseEvent e) { + ((MyDivider)mySuperDivider).processMouseEvent(e); + } + }); - myTitledSeparator.mySeparator.addMouseMotionListener(new MouseMotionListener() { - @Override - public void mouseDragged(MouseEvent e) { - ((MyDivider) mySuperDivider).processMouseMotionEvent(e); - } + myTitledSeparator.mySeparator.addMouseMotionListener(new MouseMotionListener() { + @Override + public void mouseDragged(MouseEvent e) { + ((MyDivider)mySuperDivider).processMouseMotionEvent(e); + } - @Override - public void mouseMoved(MouseEvent e) { - ((MyDivider) mySuperDivider).processMouseMotionEvent(e); - } - }); - } - @Override - protected Divider createDivider() { + @Override + public void mouseMoved(MouseEvent e) { + ((MyDivider)mySuperDivider).processMouseMotionEvent(e); + } + }); + } + + @Override + protected Divider createDivider() { mySuperDivider = new MyDivider(); mySuperDivider.add(myTitledSeparator, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, @@ -178,22 +180,22 @@ public abstract class SplitterWithSecondHideable { return mySuperDivider; } - @Override - public int getDividerWidth() { + @Override + public int getDividerWidth() { return vertical ? myTitledSeparator.getHeight() : myTitledSeparator.getWidth(); } - class MyDivider extends Divider { - @Override - public void processMouseMotionEvent(MouseEvent e) { - super.processMouseMotionEvent(e); - } - - @Override - public void processMouseEvent(MouseEvent e) { - super.processMouseEvent(e); - } + class MyDivider extends Divider { + @Override + public void processMouseMotionEvent(MouseEvent e) { + super.processMouseMotionEvent(e); } + + @Override + public void processMouseEvent(MouseEvent e) { + super.processMouseEvent(e); + } + } }; mySplitter.setDoubleBuffered(true); mySplitter.setFirstComponent(firstComponent); @@ -201,7 +203,7 @@ public abstract class SplitterWithSecondHideable { //mySplitter.setShowDividerIcon(false); mySplitter.setProportion(1.0f); } - + public void setText(final String value) { myTitledSeparator.setText(value); } @@ -215,6 +217,7 @@ public abstract class SplitterWithSecondHideable { } protected abstract RefreshablePanel createDetails(); + protected abstract float getSplitterInitialProportion(); public float getUsedProportion() { @@ -224,11 +227,11 @@ public abstract class SplitterWithSecondHideable { public void initOn() { myTitledSeparator.initOn(); } - + public void on() { myTitledSeparator.on(); } - + public void off() { myTitledSeparator.off(); } diff --git a/platform/util/src/com/intellij/openapi/ui/Splitter.java b/platform/util/src/com/intellij/openapi/ui/Splitter.java index 8e4b183ed269..a3b37c807ab5 100644 --- a/platform/util/src/com/intellij/openapi/ui/Splitter.java +++ b/platform/util/src/com/intellij/openapi/ui/Splitter.java @@ -244,8 +244,10 @@ public class Splitter extends JPanel { if (isHonorMinimumSize()) { - final double firstMinSize = getOrientation() ? myFirstComponent.getMinimumSize().getHeight() : myFirstComponent.getMinimumSize().getWidth(); - final double secondMinSize = getOrientation() ? mySecondComponent.getMinimumSize().getHeight() : mySecondComponent.getMinimumSize().getWidth(); + final double firstMinSize = + getOrientation() ? myFirstComponent.getMinimumSize().getHeight() : myFirstComponent.getMinimumSize().getWidth(); + final double secondMinSize = + getOrientation() ? mySecondComponent.getMinimumSize().getHeight() : mySecondComponent.getMinimumSize().getWidth(); if (firstComponentSize + secondComponentSize < firstMinSize + secondMinSize) { double proportion = firstMinSize / (firstMinSize + secondMinSize); @@ -269,19 +271,19 @@ public class Splitter extends JPanel { firstComponentSize = Math.floor(firstComponentSize); secondComponentSize = Math.floor(secondComponentSize); - + if (getOrientation()) { // fix flooring - secondComponentSize += (int) (height - firstComponentSize - secondComponentSize - dividerWidth); - + secondComponentSize += (int)(height - firstComponentSize - secondComponentSize - dividerWidth); + firstRect.setBounds(0, 0, (int)width, (int)firstComponentSize); dividerRect.setBounds(0, (int)firstComponentSize, (int)width, (int)dividerWidth); secondRect.setBounds(0, (int)(firstComponentSize + dividerWidth), (int)width, (int)secondComponentSize); } else { // fix flooring - secondComponentSize += (int) (width - firstComponentSize - secondComponentSize - dividerWidth); - + secondComponentSize += (int)(width - firstComponentSize - secondComponentSize - dividerWidth); + firstRect.setBounds(0, 0, (int)firstComponentSize, (int)height); dividerRect.setBounds((int)firstComponentSize, 0, (int)dividerWidth, (int)height); secondRect.setBounds((int)(firstComponentSize + dividerWidth), 0, (int)secondComponentSize, (int)height); @@ -485,16 +487,15 @@ public class Splitter extends JPanel { } Icon glueIcon = IconLoader.getIcon(isVerticalSplit ? "/general/splitGlueV.png" : "/general/splitGlueH.png"); - int leftInsetIcon = 1; - int leftInsetArrow = 0; - int glueFill = isVerticalSplit ? GridBagConstraints.VERTICAL : GridBagConstraints.HORIZONTAL; - add(new JLabel(glueIcon), new GridBagConstraints(0, 0, 1, 1, 0, 0, - GridBagConstraints.CENTER, GridBagConstraints.EAST, - new Insets(0, leftInsetIcon, 0, 0), 0, 0)); + add(new JLabel(glueIcon), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, + new Insets(0, 0, 0, 0), 0, 0)); if (myShowDividerControls && false) { + int glueFill = isVerticalSplit ? GridBagConstraints.VERTICAL : GridBagConstraints.HORIZONTAL; int xMask = isVerticalSplit ? 1 : 0; int yMask = isVerticalSplit ? 0 : 1; + int leftInsetArrow = 0; + int leftInsetIcon = 1; JLabel splitDownlabel = new JLabel(IconLoader.getIcon(isVerticalSplit ? "/general/splitDown.png" : "/general/splitRight.png")); splitDownlabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); @@ -509,7 +510,8 @@ public class Splitter extends JPanel { GridBagConstraints.NONE, new Insets(0, leftInsetArrow, 0, 0), 0, 0)); // add(new JLabel(glueIcon), - new GridBagConstraints(2 * xMask, 2 * yMask, 1, 1, 0, 0, GridBagConstraints.CENTER, glueFill, new Insets(0, leftInsetIcon, 0, 0), 0, 0)); + new GridBagConstraints(2 * xMask, 2 * yMask, 1, 1, 0, 0, GridBagConstraints.CENTER, glueFill, + new Insets(0, leftInsetIcon, 0, 0), 0, 0)); JLabel splitCenterlabel = new JLabel(IconLoader.getIcon(isVerticalSplit ? "/general/splitCenterV.png" : "/general/splitCenterH.png")); splitCenterlabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); @@ -522,7 +524,8 @@ public class Splitter extends JPanel { add(splitCenterlabel, new GridBagConstraints(3 * xMask, 3 * yMask, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, leftInsetArrow, 0, 0), 0, 0)); add(new JLabel(glueIcon), - new GridBagConstraints(4 * xMask, 4 * yMask, 1, 1, 0, 0, GridBagConstraints.CENTER, glueFill, new Insets(0, leftInsetIcon, 0, 0), 0, 0)); + new GridBagConstraints(4 * xMask, 4 * yMask, 1, 1, 0, 0, GridBagConstraints.CENTER, glueFill, + new Insets(0, leftInsetIcon, 0, 0), 0, 0)); // JLabel splitUpLabel = new JLabel(IconLoader.getIcon(isVerticalSplit ? "/general/splitUp.png" : "/general/splitLeft.png")); splitUpLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); @@ -539,7 +542,7 @@ public class Splitter extends JPanel { isVerticalSplit ? GridBagConstraints.WEST : GridBagConstraints.SOUTH, glueFill, new Insets(0, leftInsetIcon, 0, 0), 0, 0)); } - + revalidate(); repaint(); } @@ -552,13 +555,17 @@ public class Splitter extends JPanel { float proportion; if (getOrientation()) { if (getHeight() > 0) { - proportion = Math.min(1.0f, Math.max(.0f, Math.min(Math.max(getMinProportion(myFirstComponent), (float)myPoint.y / (float)Splitter.this.getHeight()), 1 - getMinProportion(mySecondComponent)))); + proportion = Math.min(1.0f, Math.max(.0f, Math + .min(Math.max(getMinProportion(myFirstComponent), (float)myPoint.y / (float)Splitter.this.getHeight()), + 1 - getMinProportion(mySecondComponent)))); setProportion(proportion); } } else { if (getWidth() > 0) { - proportion = Math.min(1.0f, Math.max(.0f, Math.min(Math.max(getMinProportion(myFirstComponent), (float)myPoint.x / (float)Splitter.this.getWidth()), 1 - getMinProportion(mySecondComponent)))); + proportion = Math.min(1.0f, Math.max(.0f, Math + .min(Math.max(getMinProportion(myFirstComponent), (float)myPoint.x / (float)Splitter.this.getWidth()), + 1 - getMinProportion(mySecondComponent)))); setProportion(proportion); } } @@ -595,9 +602,10 @@ public class Splitter extends JPanel { public void setResizeEnabled(boolean resizeEnabled) { myResizeEnabled = resizeEnabled; - if (! myResizeEnabled) { + if (!myResizeEnabled) { setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } else { + } + else { setCursor(getOrientation() ? Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR) : Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR)); diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 0a19f1839d11..89aa02faf0be 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -20,7 +20,10 @@ import com.intellij.openapi.Disposable; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.*; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.ui.*; +import com.intellij.ui.ColorUtil; +import com.intellij.ui.Gray; +import com.intellij.ui.PanelWithAnchor; +import com.intellij.ui.SideBorder; import com.intellij.util.ArrayUtil; import com.intellij.util.PairFunction; import com.intellij.util.Processor; @@ -40,15 +43,12 @@ import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; import javax.swing.plaf.ComboBoxUI; import javax.swing.plaf.ProgressBarUI; -import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicComboBoxUI; -import javax.swing.plaf.basic.BasicTreeUI; import javax.swing.plaf.basic.ComboPopup; import javax.swing.text.DefaultEditorKit; import javax.swing.text.JTextComponent; import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.StyleSheet; -import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.*; import java.awt.font.FontRenderContext; @@ -1562,26 +1562,9 @@ public class UIUtil { return BORDER_COLOR; } - public static Color getTitledBorderLineColor() { - return BORDER_COLOR; - } - public static Font getTitledBorderFont() { - return getLabelFont(); - } - - public static Font getBorderFont(@NotNull FontSize size, boolean isBold) { - Font defFont = getTitledBorderFont(); - if (size == FontSize.SMALL) { - defFont = defFont.deriveFont(Math.max(defFont.getSize() - 2f, 11f)); - } - if (size == FontSize.MINI) { - defFont = defFont.deriveFont(Math.max(defFont.getSize() - 4f, 9f)); - } - //if (isBold) { - // defFont = defFont.deriveFont(Font.BOLD); - //} - return defFont; + Font defFont = getLabelFont(); + return defFont.deriveFont(Math.max(defFont.getSize() - 2f, 11f)); } public static Color getTitledBorderTitleColor() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.java index ff9008bb46f5..801082dc1f82 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.java @@ -34,15 +34,14 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.VcsBundle; import com.intellij.openapi.vcs.VcsConfiguration; import com.intellij.openapi.vcs.changes.Change; -import com.intellij.openapi.vcs.changes.RefreshablePanel; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileWrapper; import com.intellij.openapi.vfs.encoding.EncodingManager; -import com.intellij.ui.SplitterWithSecondHideable; +import com.intellij.ui.HideableTitledPanel; import com.intellij.util.Consumer; -import com.intellij.util.OnOffListener; +import com.intellij.util.ui.FormBuilder; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -58,7 +57,7 @@ public class CreatePatchConfigurationPanel { private static final String SYSTEM_DEFAULT = IdeBundle.message("encoding.name.system.default"); public static final String ALL = "(All)"; - private JPanel myPanel; + private JPanel myMainPanel; private TextFieldWithBrowseButton myFileNameField; private JCheckBox myReversePatchCheckbox; private JComboBox myEncoding; @@ -70,17 +69,18 @@ public class CreatePatchConfigurationPanel { private List myChanges; private Collection myIncludedChanges; private SelectFilesToAddTextsToPatchPanel mySelectFilesToAddTextsToPatchPanel; - private SplitterWithSecondHideable mySplitterWithSecondHideable; + private HideableTitledPanel myHideableTitledPanel; + private JPanel myPanelWithSelectedFiles; public CreatePatchConfigurationPanel(final Project project) { myProject = project; - initUi(); + initMainPanel(); myFileNameField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final FileSaverDialog dialog = FileChooserFactory.getInstance().createSaveFileDialog( - new FileSaverDescriptor("Save patch to", ""), myPanel); + new FileSaverDescriptor("Save patch to", ""), myMainPanel); final String path = FileUtil.toSystemIndependentName(myFileNameField.getText().trim()); final int idx = path.lastIndexOf("/"); VirtualFile baseDir = idx == -1 ? project.getBaseDir() : @@ -121,27 +121,6 @@ public class CreatePatchConfigurationPanel { }); myErrorLabel.setForeground(Color.RED); checkName(); - /*new AdjustComponentWhenShown() { - @Override - protected boolean init() { - if (myPanel.isVisible()) { - IdeFocusManager.findInstanceByComponent(myPanel).requestFocus(myFileNameField.getTextField(), true); - if (myIncludeBaseRevisionTextCheckBox.isVisible()) { - // a hack =( - final JDialog dialog = getParentDialog(); - final Dimension dialogSize = dialog.getSize(); - dialog.setSize(dialogSize.width, dialogSize.height + 1); - if (dialogSize.width < 500) { - dialog.setSize(500, dialogSize.height - 1); - } else { - dialog.setSize(dialogSize.width, dialogSize.height - 1); - } - dialog.repaint(); - } - } - return false; - } - }.install(myPanel);*/ initEncodingCombo(); } @@ -165,110 +144,31 @@ public class CreatePatchConfigurationPanel { if (SYSTEM_DEFAULT.equals(selectedItem)) { return EncodingManager.getInstance().getDefaultCharset(); } - return (Charset) selectedItem; + return (Charset)selectedItem; } - private void initUi() { - myPanel = new JPanel(new GridBagLayout()); - myPanel.setMinimumSize(new Dimension(400, -1)); - final GridBagConstraints gb = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, - new Insets(1, 1, 1, 1), 0, 0); - gb.anchor = GridBagConstraints.WEST; - final JLabel createPatchLabel = new JLabel(VcsBundle.message("create.patch.file.path")); - myPanel.add(createPatchLabel, gb); - gb.anchor = GridBagConstraints.NORTHWEST; + private void initMainPanel() { myFileNameField = new TextFieldWithBrowseButton(); - ++ gb.gridx; - gb.fill = GridBagConstraints.HORIZONTAL; - gb.weightx = 1; - myPanel.add(myFileNameField, gb); - - /*gb.fill = GridBagConstraints.NONE; - gb.weightx = 0;*/ - gb.gridx = 0; - ++ gb.gridy; - gb.gridwidth = 2; myReversePatchCheckbox = new JCheckBox(VcsBundle.message("create.patch.reverse.patch.checkbox")); - ++ gb.gridy; - myPanel.add(myReversePatchCheckbox, gb); - ++ gb.gridy; - gb.gridwidth = 2; - - gb.anchor = GridBagConstraints.WEST; - myPanel.add(new JLabel("Encoding:"), gb); - ++ gb.gridx; - gb.anchor = GridBagConstraints.NORTHWEST; myEncoding = new JComboBox(); - myPanel.add(myEncoding, gb); - ++ gb.gridy; - - gb.gridx = 0; myIncludeBaseRevisionTextCheckBox = new JCheckBox("Include base revision text(s) into patch file"); - myPanel.add(myIncludeBaseRevisionTextCheckBox, gb); - ++ gb.gridy; - myErrorLabel = new JLabel(); - myPanel.add(myErrorLabel, gb); + + myMainPanel = FormBuilder.createFormBuilder() + .addLabeledComponent(VcsBundle.message("create.patch.file.path"), myFileNameField) + .addComponent(myReversePatchCheckbox) + .addLabeledComponent("Encoding:", myEncoding) + .addComponent(myIncludeBaseRevisionTextCheckBox) + .addComponent(myErrorLabel) + .getPanel(); } - private void initSplitter(Runnable inclusionListener) { + private void initPanelWithSelectedFiles(Runnable inclusionListener) { mySelectFilesToAddTextsToPatchPanel = new SelectFilesToAddTextsToPatchPanel(myProject, myChanges, myIncludedChanges, inclusionListener); - final Dimension preferredSize = myPanel.getPreferredSize(); - final JPanel wrapper = new JPanel(new BorderLayout()) { - @Override - public Dimension getPreferredSize() { - return preferredSize; - } - - @Override - public Dimension getMaximumSize() { - return preferredSize; - } - - @Override - public Dimension getMinimumSize() { - return preferredSize; - } - }; - wrapper.add(myPanel, BorderLayout.NORTH); - mySplitterWithSecondHideable = new SplitterWithSecondHideable(true, ALL, wrapper, new OnOffListener() { - @Override - public void on(Integer integer) { - VcsConfiguration.getInstance(myProject).CREATE_PATCH_EXPAND_DETAILS_DEFAULT = true; - final JDialog dialog = getParentDialog(); - final Dimension dialogSize = dialog.getSize(); - int width = dialogSize.width < 550 ? 550 : dialogSize.width; - dialog.setSize(width, dialogSize.height + integer); - dialog.repaint(); - } - - @Override - public void off(Integer integer) { - VcsConfiguration.getInstance(myProject).CREATE_PATCH_EXPAND_DETAILS_DEFAULT = false; - final JDialog dialog = getParentDialog(); - final Dimension dialogSize = dialog.getSize(); - dialog.setSize(dialogSize.width, dialogSize.height - integer); - dialog.repaint(); - } - }, false) { - @Override - protected RefreshablePanel createDetails() { - return mySelectFilesToAddTextsToPatchPanel; - } - - @Override - protected float getSplitterInitialProportion() { - return 0.3f; - } - }; - } - - private JDialog getParentDialog() { - Container parent = myPanel.getParent(); - while (! (parent instanceof JDialog)) { - parent = parent.getParent(); - } - return (JDialog)parent; + myHideableTitledPanel = new HideableTitledPanel("", mySelectFilesToAddTextsToPatchPanel.getPanel(), false); + myPanelWithSelectedFiles = new JPanel(new BorderLayout()); + myPanelWithSelectedFiles.add(myMainPanel, BorderLayout.NORTH); + myPanelWithSelectedFiles.add(myHideableTitledPanel, BorderLayout.CENTER); } public void showTextStoreOption(final boolean dvcsIsUsed) { @@ -276,29 +176,29 @@ public class CreatePatchConfigurationPanel { if (myChanges.size() > 0) { myIncludeBaseRevisionTextCheckBox.setVisible(true); - final VcsConfiguration configuration = VcsConfiguration.getInstance(myProject); - - boolean turnOn = dvcsIsUsed || configuration.INCLUDE_TEXT_INTO_PATCH; - myIncludeBaseRevisionTextCheckBox.setSelected(turnOn); - myIncludeBaseRevisionTextCheckBox.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - mySelectFilesToAddTextsToPatchPanel.setEnabled(myIncludeBaseRevisionTextCheckBox.isSelected()); - mySplitterWithSecondHideable.setEnabledColor(myIncludeBaseRevisionTextCheckBox.isSelected()); - } - }); final Runnable inclusionListener = new Runnable() { @Override public void run() { if (mySelectFilesToAddTextsToPatchPanel != null) { myIncludedChanges = mySelectFilesToAddTextsToPatchPanel.getIncludedChanges(); - mySplitterWithSecondHideable.setText("Selected: " + (myIncludedChanges.size() == myChanges.size() ? - "All" : ("" + myIncludedChanges.size() + " of " + myChanges.size()))); + myHideableTitledPanel.setTitle("Selected: " + (myIncludedChanges.size() == myChanges.size() ? + "All" : (myIncludedChanges.size() + " of " + myChanges.size()))); } } }; - initSplitter(inclusionListener); + initPanelWithSelectedFiles(inclusionListener); inclusionListener.run(); + + final VcsConfiguration configuration = VcsConfiguration.getInstance(myProject); + boolean turnOn = dvcsIsUsed || configuration.INCLUDE_TEXT_INTO_PATCH; + myIncludeBaseRevisionTextCheckBox.setSelected(turnOn); + myIncludeBaseRevisionTextCheckBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + myHideableTitledPanel.setEnabled(myIncludeBaseRevisionTextCheckBox.isSelected()); + } + }); + myHideableTitledPanel.setEnabled(myIncludeBaseRevisionTextCheckBox.isSelected()); } } @@ -306,7 +206,8 @@ public class CreatePatchConfigurationPanel { final PatchNameChecker patchNameChecker = new PatchNameChecker(myFileNameField.getText()); if (patchNameChecker.nameOk()) { myErrorLabel.setText(""); - } else { + } + else { myErrorLabel.setText(patchNameChecker.getError()); } if (myOkEnabledListener != null) { @@ -315,7 +216,7 @@ public class CreatePatchConfigurationPanel { } public void onOk() { - if (myIncludeBaseRevisionTextCheckBox.isVisible() && ! myDvcsIsUsed) { + if (myIncludeBaseRevisionTextCheckBox.isVisible() && !myDvcsIsUsed) { final VcsConfiguration vcsConfiguration = VcsConfiguration.getInstance(myProject); vcsConfiguration.INCLUDE_TEXT_INTO_PATCH = myIncludeBaseRevisionTextCheckBox.isSelected(); } @@ -330,7 +231,7 @@ public class CreatePatchConfigurationPanel { } public JComponent getPanel() { - return ! myIncludeBaseRevisionTextCheckBox.isVisible() || myChanges.isEmpty() ? myPanel : mySplitterWithSecondHideable.getComponent(); + return !myIncludeBaseRevisionTextCheckBox.isVisible() || myChanges.isEmpty() ? myMainPanel : myPanelWithSelectedFiles; } public void installOkEnabledListener(final Consumer runnable) { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java index 70779b8b6882..900ed610ff03 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitChangeListDialog.java @@ -994,7 +994,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj setSize(dialogSize.width, dialogSize.height - integer); repaint(); } - }, true) { + }) { @Override protected RefreshablePanel createDetails() { initDetails();