popUp.add(new JSeparator());  JMenuItem generateMacrosMenuItem = new JMenuItem(generateMacrosString); generateMacrosMenuItem.addActionListener(al); popUp.add(generateMacrosMenuItem);
private void showPopup(MouseEvent e){	ActionListener al = new ActionListener()	{		public void actionPerformed(ActionEvent e) {			String action = e.getActionCommand();			if (action.equals(newRecordString))				CommandManager.getInstance().execute("ShowNewDialog");			else if (action.equals(newPortString))				createPort(null);			else if (action.equals(newMacroString))				createMacro(null);			else if (action.equals(generateMacrosString))				generateMacros();			else if (action.equals(newLineString))				createLine();			else if (action.equals(newBoxString))				createBox();			else if (action.equals(newTextBoxString))				createTextBox();			else if (action.equals(templatePropertiesString))				InspectorManager.getInstance().requestInspectorFor(Group.getEditingTemplateData());			else if (action.equals(pasteString)) {				((GetGUIInterface)CommandManager.getInstance().getCommand("GetGUIMenuInterface")).getGUIMenuInterface().pasteAtPosition(pressedX, pressedY);			}			else				createTemplateInstance(null, action, true);		}		};						ActionListener al2 = new ActionListener()	{		public void actionPerformed(ActionEvent e) {			String action = e.getActionCommand();			createPort((VDBPort)Group.getEditingTemplateData().getPorts().get(action));					}		};	ActionListener al3 = new ActionListener()	{		public void actionPerformed(ActionEvent e) {			String action = e.getActionCommand();			createMacro((VDBMacro)Group.getEditingTemplateData().getMacros().get(action));					}		};	JPopupMenu popUp = new JPopupMenu();		JMenuItem item = new JMenuItem(newRecordString);	item.addActionListener(al);	popUp.add(item);		JMenu templatesMenu = new JMenu(newTemplesString);	popUp.add(templatesMenu);		// add templates	Enumeration templates = VDBData.getTemplates().keys();	while (templates.hasMoreElements())	{		String key = templates.nextElement().toString();		VDBTemplate t = (VDBTemplate)VDBData.getTemplates().get(key);		JMenuItem item2 = new JMenuItem(t.getDescription());		item2.setActionCommand(key);		item2.addActionListener(al);		templatesMenu.add(item2);			// do not allow circular dependencies		if (!templateStack.isEmpty() && templateStack.contains(t))			item2.setEnabled(false);	}			if (templatesMenu.getItemCount()==0)		templatesMenu.setEnabled(false);		if (Group.getEditingTemplateData()!=null)	{		popUp.add(new JSeparator());			// generate visual port		JMenu addPortMenu = new JMenu(addPortString);		popUp.add(addPortMenu);				// add templates		Enumeration ports = Group.getEditingTemplateData().getPortsV().elements();		while (ports.hasMoreElements())		{			VDBPort port = (VDBPort)ports.nextElement();			if (port.getVisibleObject()!=null) continue; // do not add ports with already visible rep.			JMenuItem item2 = new JMenuItem(port.getName());			item2.setActionCommand(port.getName());			item2.addActionListener(al2);			addPortMenu.add(item2);		}				if (addPortMenu.getItemCount()==0)			addPortMenu.setEnabled(false);			// generate visual MACRO		JMenu addMacroMenu = new JMenu(addMacroString);		popUp.add(addMacroMenu);				// add templates		Enumeration macros = Group.getEditingTemplateData().getMacrosV().elements();		while (macros.hasMoreElements())		{			VDBMacro macro = (VDBMacro)macros.nextElement();			if (macro.getVisibleObject()!=null) continue; // do not add macros with already visible rep.			JMenuItem item2 = new JMenuItem(macro.getName());			item2.setActionCommand(macro.getName());			item2.addActionListener(al3);			addMacroMenu.add(item2);		}				if (addMacroMenu.getItemCount()==0)			addMacroMenu.setEnabled(false);			// create port		JMenuItem portMenuItem = new JMenuItem(newPortString);		portMenuItem.addActionListener(al);		popUp.add(portMenuItem);			// create macro		JMenuItem macroMenuItem = new JMenuItem(newMacroString);		macroMenuItem.addActionListener(al);		popUp.add(macroMenuItem);	}	popUp.add(new JSeparator());		JMenuItem generateMacrosMenuItem = new JMenuItem(generateMacrosString);	generateMacrosMenuItem.addActionListener(al);	popUp.add(generateMacrosMenuItem);	popUp.add(new JSeparator());	JMenuItem lineMenuItem = new JMenuItem(newLineString);	lineMenuItem.addActionListener(al);	popUp.add(lineMenuItem);		JMenuItem boxMenuItem = new JMenuItem(newBoxString);	boxMenuItem.addActionListener(al);	popUp.add(boxMenuItem);		JMenuItem textboxMenuItem = new JMenuItem(newTextBoxString);	textboxMenuItem.addActionListener(al);	popUp.add(textboxMenuItem);	// every file is a template	//if (isTemplateMode())	{		popUp.add(new JSeparator());		JMenuItem templatePropertiesMenuItem = new JMenuItem(templatePropertiesString);		templatePropertiesMenuItem.addActionListener(al);		popUp.add(templatePropertiesMenuItem);	}		// add paste item	if (Group.getClipboard().getSubObjectsV().size() > 0) {		popUp.add(new JSeparator());		JMenuItem pasteMenuItem = new JMenuItem(pasteString);		pasteMenuItem.addActionListener(al);		popUp.add(pasteMenuItem);	}		// add plugin items	PopUpMenu.addPluginItems(popUp, null);	popUp.show(getWorkspacePanel(), e.getX(), e.getY());}