diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/.classpath b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/.classpath index c49d0a29..97231114 100644 --- a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/.classpath +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/.classpath @@ -10,6 +10,9 @@ + + + diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/lib/diylc-core.jar b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/lib/diylc-core.jar index 9a7df7f2..5eb70340 100644 Binary files a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/lib/diylc-core.jar and b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/lib/diylc-core.jar differ diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/lib/org-openide-awt.jar b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/lib/org-openide-awt.jar new file mode 100644 index 00000000..0adcff51 Binary files /dev/null and b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/lib/org-openide-awt.jar differ diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/lib/org-openide-util-lookup.jar b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/lib/org-openide-util-lookup.jar new file mode 100644 index 00000000..c9a082b2 Binary files /dev/null and b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/lib/org-openide-util-lookup.jar differ diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/lib/org-openide-util.jar b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/lib/org-openide-util.jar new file mode 100644 index 00000000..a61c4d44 Binary files /dev/null and b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/lib/org-openide-util.jar differ diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/lib/swing-framework.jar b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/lib/swing-framework.jar deleted file mode 100644 index 0a66901d..00000000 Binary files a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/lib/swing-framework.jar and /dev/null differ diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/library/main.jar b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/library/main.jar index ba3219a2..2182dc14 100644 Binary files a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/library/main.jar and b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/library/main.jar differ diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/images/IconLoader.java b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/images/IconLoader.java index f2034622..5d92148a 100644 --- a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/images/IconLoader.java +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/images/IconLoader.java @@ -32,7 +32,7 @@ public enum IconLoader { "icon_medium.png"), IconSmall("icon_small.png"), DocumentEdit("document_edit.png"), EditComponent( "edit_component.png"), Size("size.png"), Front("front.png"), Back("back.png"), Pens( "pens.png"), Sort("sort.png"), ElementsSelection("elements_selection.png"), BranchAdd( - "branch_add.png"); + "branch_add.png"), Briefcase_Add("briefcase_add.png"); protected String name; diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/ActionFactory.java b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/ActionFactory.java index 0e407d89..95db8722 100644 --- a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/ActionFactory.java +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/ActionFactory.java @@ -10,6 +10,7 @@ import java.util.ArrayList; import java.util.List; import javax.swing.AbstractAction; +import javax.swing.JOptionPane; import javax.swing.KeyStroke; import org.apache.log4j.Logger; @@ -131,6 +132,11 @@ public class ActionFactory { return new DeleteSelectionAction(plugInPort); } + public SaveAsTemplateAction createSaveAsTemplateAction( + IPlugInPort plugInPort) { + return new SaveAsTemplateAction(plugInPort); + } + public ExpandSelectionAction createExpandSelectionAction( IPlugInPort plugInPort, ExpansionMode expansionMode) { return new ExpandSelectionAction(plugInPort, expansionMode); @@ -804,6 +810,32 @@ public class ActionFactory { } } + public static class SaveAsTemplateAction extends AbstractAction { + + private static final long serialVersionUID = 1L; + + private IPlugInPort plugInPort; + + public SaveAsTemplateAction(IPlugInPort plugInPort) { + super(); + this.plugInPort = plugInPort; + putValue(AbstractAction.NAME, "Save as Template"); + putValue(AbstractAction.SMALL_ICON, IconLoader.Briefcase_Add + .getIcon()); + } + + @Override + public void actionPerformed(ActionEvent e) { + LOG.info("Save as template triggered"); + String templateName = JOptionPane.showInputDialog(null, + "Template name:", "Save as Template", + JOptionPane.PLAIN_MESSAGE); + if (templateName != null && !templateName.trim().isEmpty()) { + plugInPort.saveSelectedComponentAsTemplate(templateName); + } + } + } + public static class ExpandSelectionAction extends AbstractAction { private static final long serialVersionUID = 1L; diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPanel.java b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPanel.java index 489a04d6..52364121 100644 --- a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPanel.java +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPanel.java @@ -93,7 +93,7 @@ class CanvasPanel extends JComponent implements Autoscroll { @Override public void actionPerformed(ActionEvent e) { - CanvasPanel.this.plugInPort.setNewComponentTypeSlot(null); + CanvasPanel.this.plugInPort.setNewComponentTypeSlot(null, null); } }); } diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java index e20c5fb0..a542427e 100644 --- a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/canvas/CanvasPlugin.java @@ -59,6 +59,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner { private ActionFactory.PasteAction pasteAction; private ActionFactory.EditSelectionAction editSelectionAction; private ActionFactory.DeleteSelectionAction deleteSelectionAction; + private ActionFactory.SaveAsTemplateAction saveAsTemplateAction; private ActionFactory.GroupAction groupAction; private ActionFactory.UngroupAction ungroupAction; private ActionFactory.SendToBackAction sendToBackAction; @@ -101,7 +102,8 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner { @Override public void mouseReleased(MouseEvent e) { - if (plugInPort.getNewComponentTypeSlot() == null && e.isPopupTrigger()) { + if (plugInPort.getNewComponentTypeSlot() == null + && e.isPopupTrigger()) { // Enable actions. boolean enabled = !plugInPort.getSelectedComponents() .isEmpty(); @@ -125,6 +127,9 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner { getSendToBackAction().setEnabled(enabled); getBringToFrontAction().setEnabled(enabled); + getSaveAsTemplateAction().setEnabled( + plugInPort.getSelectedComponents().size() == 1); + showPopupAt(e.getX(), e.getY()); } } @@ -220,6 +225,7 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner { popupMenu.addSeparator(); popupMenu.add(getEditSelectionAction()); popupMenu.add(getDeleteSelectionAction()); + popupMenu.add(getSaveAsTemplateAction()); popupMenu.add(getGroupAction()); popupMenu.add(getUngroupAction()); popupMenu.add(getSendToBackAction()); @@ -311,6 +317,14 @@ public class CanvasPlugin implements IPlugIn, ClipboardOwner { return deleteSelectionAction; } + public ActionFactory.SaveAsTemplateAction getSaveAsTemplateAction() { + if (saveAsTemplateAction == null) { + saveAsTemplateAction = ActionFactory.getInstance() + .createSaveAsTemplateAction(plugInPort); + } + return saveAsTemplateAction; + } + public ActionFactory.GroupAction getGroupAction() { if (groupAction == null) { groupAction = ActionFactory.getInstance().createGroupAction( diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/toolbox/ComponentButton.java b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/toolbox/ComponentButton.java deleted file mode 100644 index ac212fcc..00000000 --- a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/toolbox/ComponentButton.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.diylc.swing.plugins.toolbox; - -import java.awt.Insets; -import java.awt.dnd.DnDConstants; -import java.awt.dnd.DragSource; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.JButton; - -import org.diylc.common.ComponentType; -import org.diylc.common.IPlugInPort; -import org.diylc.core.IDIYComponent; - -/** - * {@link JButton} that displays component type icon and instantiates the - * component when clicked. - * - * @author Branislav Stojkovic - */ -class ComponentButton extends JButton { - - private static final long serialVersionUID = 1L; - - public static int MARGIN = 2; - - private IPlugInPort plugInPort; - private ComponentType componentType; - - public ComponentButton(final IPlugInPort plugInPort, final ComponentType componentType) { - super(componentType.getIcon()); - this.plugInPort = plugInPort; - this.componentType = componentType; - - setMargin(new Insets(MARGIN, MARGIN, MARGIN, MARGIN)); - - setToolTipText("" + componentType.getName() + "
" - + componentType.getDescription() + "
Author: " + componentType.getAuthor() - + "

Right click to select all components of this type" - + ""); - // initializeDnD(); - addMouseListener(new MouseAdapter() { - - @Override - public void mousePressed(MouseEvent e) { - if (e.getButton() == MouseEvent.BUTTON1) { - plugInPort.setNewComponentTypeSlot(componentType); - } else { - List> components = plugInPort.getCurrentProject().getComponents(); - List> newSelection = new ArrayList>(); - for (IDIYComponent component : components) { - if (componentType.getInstanceClass().equals(component.getClass())) { - newSelection.add(component); - } - } - plugInPort.updateSelection(newSelection); - plugInPort.setNewComponentTypeSlot(null); - plugInPort.refresh(); - } - } - }); -// addActionListener(new ActionListener() { -// -// @Override -// public void actionPerformed(ActionEvent e) { -// // plugInPort.setCursorIcon(componentType.getIcon()); -// plugInPort.setNewComponentTypeSlot(componentType); -// // try { -// // plugInPort.instantiateComponent(componentType -// // .getComponentInstanceClass(), null); -// // } catch (Exception e1) { -// // e1.printStackTrace(); -// // } -// } -// }); - addKeyListener(new KeyAdapter() { - - @Override - public void keyPressed(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_DELETE) { - plugInPort.deleteSelectedComponents(); - } - } - }); - // addKeyListener(new KeyAdapter() { - // - // @Override - // public void keyPressed(KeyEvent e) { - // if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - // plugInPort.setNewComponentSlot(null); - // } - // } - // }); - } - - private void initializeDnD() { - // Initialize drag source recognizer. - DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(this, - DnDConstants.ACTION_MOVE, - new ToolboxGestureListener(plugInPort, componentType.getInstanceClass().getName())); - } -} diff --git a/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/toolbox/ComponentButtonFactory.java b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/toolbox/ComponentButtonFactory.java new file mode 100644 index 00000000..4698699e --- /dev/null +++ b/ diy-layout-creator --username bancika@gmail.com/diylc-swing/src/org/diylc/swing/plugins/toolbox/ComponentButtonFactory.java @@ -0,0 +1,169 @@ +package org.diylc.swing.plugins.toolbox; + +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; + +import org.diylc.common.ComponentType; +import org.diylc.common.IPlugInPort; +import org.diylc.core.IDIYComponent; +import org.diylc.core.Template; +import org.diylc.images.IconLoader; +import org.openide.awt.DropDownButtonFactory; + +/** + * {@link JButton} that displays component type icon and instantiates the + * component when clicked. + * + * @author Branislav Stojkovic + */ +class ComponentButtonFactory { + + private static final long serialVersionUID = 1L; + + public static int MARGIN = 4; + + public static JButton create(final IPlugInPort plugInPort, + final ComponentType componentType, final JPopupMenu menu) { + JButton button = DropDownButtonFactory.createDropDownButton( + componentType.getIcon(), menu); + + button.setBorder(BorderFactory.createEmptyBorder(MARGIN, MARGIN, + MARGIN, MARGIN)); + + // mainButton.setBorder(BorderFactory.createEmptyBorder()); + // dropDownButton.setBorder(BorderFactory.createEmptyBorder()); + // setBorder(BorderFactory.createLineBorder(Color.gray)); + + button.setToolTipText("" + componentType.getName() + + "
" + componentType.getDescription() + "
Author: " + + componentType.getAuthor() + + "

Right click to select all components of this type" + + ""); + // initializeDnD(); + button.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + plugInPort.setNewComponentTypeSlot(componentType, null); + } + }); + + button.addMouseListener(new MouseAdapter() { + + @Override + public void mousePressed(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON3) { + List> components = plugInPort + .getCurrentProject().getComponents(); + List> newSelection = new ArrayList>(); + for (IDIYComponent component : components) { + if (componentType.getInstanceClass().equals( + component.getClass())) { + newSelection.add(component); + } + } + plugInPort.updateSelection(newSelection); + plugInPort.setNewComponentTypeSlot(null, null); + plugInPort.refresh(); + } + } + }); + // addActionListener(new ActionListener() { + // + // @Override + // public void actionPerformed(ActionEvent e) { + // // plugInPort.setCursorIcon(componentType.getIcon()); + // plugInPort.setNewComponentTypeSlot(componentType); + // // try { + // // plugInPort.instantiateComponent(componentType + // // .getComponentInstanceClass(), null); + // // } catch (Exception e1) { + // // e1.printStackTrace(); + // // } + // } + // }); + button.addKeyListener(new KeyAdapter() { + + @Override + public void keyPressed(KeyEvent e) { + plugInPort.keyPressed(e.getKeyCode(), e.isControlDown(), e + .isShiftDown(), e.isAltDown()); + } + }); + // addKeyListener(new KeyAdapter() { + // + // @Override + // public void keyPressed(KeyEvent e) { + // if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + // plugInPort.setNewComponentSlot(null); + // } + // } + // }); + return button; + } + + // private void initializeDnD() { + // // Initialize drag source recognizer. + // DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer( + // this, + // DnDConstants.ACTION_MOVE, + // new ToolboxGestureListener(plugInPort, componentType + // .getInstanceClass().getName())); + // } + + public static JMenuItem createTemplateItem(final IPlugInPort plugInPort, + final Template template, final ComponentType componentType) { + final JMenuItem item = new JMenuItem(template.getName()) { + + private static final long serialVersionUID = 1L; + + // Customize item size to fit the delete button + public java.awt.Dimension getPreferredSize() { + Dimension d = super.getPreferredSize(); + return new Dimension(d.width + 18, d.height); + } + }; + item.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + plugInPort.setNewComponentTypeSlot(componentType, template); + } + }); + JLabel label = new JLabel(IconLoader.Garbage.getIcon()); + label.setToolTipText("Delete template"); + label.addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent e) { + plugInPort.deleteTemplate(componentType.getCategory(), + componentType.getName(), template.getName()); + e.consume(); + // Hide the menu + Container c = item.getParent(); + if (c != null && c instanceof JPopupMenu) { + JPopupMenu m = (JPopupMenu) c; + m.setVisible(false); + } + } + }); + item.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); + item.add(label); + return item; + } +} 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 66c73d24..607e714e 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 @@ -9,11 +9,14 @@ import java.util.List; import java.util.Map; import javax.swing.BoxLayout; -import javax.swing.JButton; +import javax.swing.JMenuItem; import javax.swing.JPanel; +import javax.swing.JPopupMenu; import javax.swing.JTabbedPane; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; import org.apache.log4j.Logger; import org.diylc.appframework.miscutils.ConfigurationManager; @@ -21,6 +24,7 @@ import org.diylc.appframework.miscutils.IConfigListener; import org.diylc.common.ComponentType; import org.diylc.common.IPlugInPort; import org.diylc.core.IDIYComponent; +import org.diylc.core.Template; import org.diylc.presenter.ComparatorFactory; import org.diylc.presenter.ComponentProcessor; import org.diylc.presenter.Presenter; @@ -34,9 +38,11 @@ class ComponentTabbedPane extends JTabbedPane { private static final long serialVersionUID = 1L; - private static final Logger LOG = Logger.getLogger(ComponentTabbedPane.class); + private static final Logger LOG = Logger + .getLogger(ComponentTabbedPane.class); - public static int SCROLL_STEP = Presenter.ICON_SIZE + ComponentButton.MARGIN * 2 + 2; + public static int SCROLL_STEP = Presenter.ICON_SIZE + + ComponentButtonFactory.MARGIN * 2 + 2; private final IPlugInPort plugInPort; private Container recentToolbar; @@ -46,7 +52,8 @@ class ComponentTabbedPane extends JTabbedPane { super(); this.plugInPort = plugInPort; addTab("Recently Used", createRecentComponentsPanel()); - Map> componentTypes = plugInPort.getComponentTypes(); + Map> componentTypes = plugInPort + .getComponentTypes(); List categories = new ArrayList(componentTypes.keySet()); Collections.sort(categories); for (String category : categories) { @@ -57,10 +64,12 @@ class ComponentTabbedPane extends JTabbedPane { @Override public void stateChanged(ChangeEvent e) { - ComponentTabbedPane.this.plugInPort.setNewComponentTypeSlot(null); + ComponentTabbedPane.this.plugInPort.setNewComponentTypeSlot( + null, null); // Refresh recent components if needed - if (pendingRecentComponents != null) { - refreshRecentComponentsToolbar(getRecentToolbar(), pendingRecentComponents); + if (pendingRecentComponents != null) { + refreshRecentComponentsToolbar(getRecentToolbar(), + pendingRecentComponents); getRecentToolbar().invalidate(); pendingRecentComponents = null; } @@ -120,11 +129,12 @@ 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)); + recentToolbar.setLayout(new BoxLayout(recentToolbar, + BoxLayout.X_AXIS)); } return recentToolbar; } @@ -135,7 +145,8 @@ class ComponentTabbedPane extends JTabbedPane { .getComponentTypeComparator()); toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.X_AXIS)); for (ComponentType componentType : componentTypes) { - JButton button = new ComponentButton(plugInPort, componentType); + Component button = ComponentButtonFactory.create(plugInPort, + componentType, createTemplatePopup(componentType)); toolbar.add(button); } @@ -146,15 +157,18 @@ class ComponentTabbedPane extends JTabbedPane { JPanel panel = new JPanel(new BorderLayout()); panel.setOpaque(false); - final Container toolbar = getRecentToolbar(); - refreshRecentComponentsToolbar(toolbar, (List) ConfigurationManager.getInstance() - .readObject(IPlugInPort.RECENT_COMPONENTS_KEY, new ArrayList())); - ConfigurationManager.getInstance().addConfigListener(IPlugInPort.RECENT_COMPONENTS_KEY, - new IConfigListener() { + final Container toolbar = getRecentToolbar(); + refreshRecentComponentsToolbar(toolbar, + (List) ConfigurationManager.getInstance().readObject( + IPlugInPort.RECENT_COMPONENTS_KEY, + new ArrayList())); + ConfigurationManager.getInstance().addConfigListener( + IPlugInPort.RECENT_COMPONENTS_KEY, new IConfigListener() { @Override public void valueChanged(String key, Object value) { - // Cache the new list, we'll refresh when there's a chance + // Cache the new list, we'll refresh when there's a + // chance pendingRecentComponents = (List) value; } }); @@ -170,13 +184,52 @@ class ComponentTabbedPane extends JTabbedPane { for (String componentClassName : recentComponentClassList) { ComponentType componentType; try { - componentType = ComponentProcessor.getInstance().extractComponentTypeFrom( - (Class>) Class.forName(componentClassName)); - JButton button = new ComponentButton(plugInPort, componentType); + componentType = ComponentProcessor.getInstance() + .extractComponentTypeFrom( + (Class>) Class + .forName(componentClassName)); + Component button = ComponentButtonFactory.create(plugInPort, + componentType, createTemplatePopup(componentType)); toolbar.add(button); } catch (ClassNotFoundException e) { - LOG.error("Could not create recent component button for " + componentClassName, e); + LOG.error("Could not create recent component button for " + + componentClassName, e); } } } + + private JPopupMenu createTemplatePopup(final ComponentType componentType) { + final JPopupMenu templatePopup = new JPopupMenu(); + templatePopup.add("Loading..."); + templatePopup.addPopupMenuListener(new PopupMenuListener() { + + @Override + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + templatePopup.removeAll(); + List