diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/toolbox/ComponentTabbedPane.java b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/toolbox/ComponentTabbedPane.java index 6632b93f..66c73d24 100644 --- a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/toolbox/ComponentTabbedPane.java +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/toolbox/ComponentTabbedPane.java @@ -39,6 +39,8 @@ class ComponentTabbedPane extends JTabbedPane { public static int SCROLL_STEP = Presenter.ICON_SIZE + ComponentButton.MARGIN * 2 + 2; private final IPlugInPort plugInPort; + private Container recentToolbar; + private List pendingRecentComponents = null; public ComponentTabbedPane(IPlugInPort plugInPort) { super(); @@ -56,6 +58,12 @@ class ComponentTabbedPane extends JTabbedPane { @Override public void stateChanged(ChangeEvent e) { ComponentTabbedPane.this.plugInPort.setNewComponentTypeSlot(null); + // Refresh recent components if needed + if (pendingRecentComponents != null) { + refreshRecentComponentsToolbar(getRecentToolbar(), pendingRecentComponents); + getRecentToolbar().invalidate(); + pendingRecentComponents = null; + } } }); } @@ -112,6 +120,14 @@ class ComponentTabbedPane extends JTabbedPane { // scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); // return scrollPane; // } + + public Container getRecentToolbar() { + if (recentToolbar == null) { + recentToolbar = new Container(); + recentToolbar.setLayout(new BoxLayout(recentToolbar, BoxLayout.X_AXIS)); + } + return recentToolbar; + } private Component createComponentPanel(List componentTypes) { Container toolbar = new Container(); @@ -130,8 +146,7 @@ class ComponentTabbedPane extends JTabbedPane { JPanel panel = new JPanel(new BorderLayout()); panel.setOpaque(false); - final Container toolbar = new Container(); - toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS)); + final Container toolbar = getRecentToolbar(); refreshRecentComponentsToolbar(toolbar, (List) ConfigurationManager.getInstance() .readObject(IPlugInPort.RECENT_COMPONENTS_KEY, new ArrayList())); ConfigurationManager.getInstance().addConfigListener(IPlugInPort.RECENT_COMPONENTS_KEY, @@ -139,8 +154,8 @@ class ComponentTabbedPane extends JTabbedPane { @Override public void valueChanged(String key, Object value) { - refreshRecentComponentsToolbar(toolbar, (List) value); - toolbar.invalidate(); + // Cache the new list, we'll refresh when there's a chance + pendingRecentComponents = (List) value; } }); diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/update.xml b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/update.xml index 43f6a9a2..6fb1167f 100644 --- a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/update.xml +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/update.xml @@ -650,6 +650,10 @@ IMPROVEMENT Remove junk from BOM (eyelets, wires, traces) + + IMPROVEMENT + Improved "Recently Used" toolbox, doesn't jump as you click + http://code.google.com/p/diy-layout-creator/downloads/list