From 999bdad34ce490da13838ef7c600eae815d9a335 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Fri, 19 Aug 2011 18:10:36 +0200 Subject: [PATCH] add preferred size and few utility methods --- .../src/com/intellij/ui/ToolbarDecorator.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/platform/platform-api/src/com/intellij/ui/ToolbarDecorator.java b/platform/platform-api/src/com/intellij/ui/ToolbarDecorator.java index 69f6e07fc712..b770de236525 100644 --- a/platform/platform-api/src/com/intellij/ui/ToolbarDecorator.java +++ b/platform/platform-api/src/com/intellij/ui/ToolbarDecorator.java @@ -65,6 +65,7 @@ public class ToolbarDecorator implements DataProvider, AddRemoveUpDownPanel.List private String myRemoveName; private String myMoveUpName; private String myMoveDownName; + private Dimension myPreferredSize; private AddRemoveUpDownPanel myPanel; private JList myList; @@ -303,6 +304,12 @@ public class ToolbarDecorator implements DataProvider, AddRemoveUpDownPanel.List return this; } + public ToolbarDecorator disableUpDownActions() { + myUpActionEnabled = false; + myDownActionEnabled = false; + return this; + } + public ToolbarDecorator disableDownAction() { myDownActionEnabled = false; return this; @@ -371,6 +378,11 @@ public class ToolbarDecorator implements DataProvider, AddRemoveUpDownPanel.List return this; } + public ToolbarDecorator setPreferredSize(Dimension size) { + myPreferredSize = size; + return this; + } + public JPanel createPanel() { final AddRemoveUpDownPanel.Buttons[] buttons = getButtons(); myPanel = new AddRemoveUpDownPanel(this, @@ -381,6 +393,9 @@ public class ToolbarDecorator implements DataProvider, AddRemoveUpDownPanel.List buttons); myPanel.setBorder(myBorder); final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable == null ? myList == null ? myTree : myList : myTable); + if (myPreferredSize != null) { + scrollPane.setPreferredSize(myPreferredSize); + } scrollPane.setBorder(IdeBorderFactory.createEmptyBorder(0)); final JPanel panel = new JPanel(new BorderLayout()) { @Override