}
public JPopupMenu createPopupMenu() {
OMGraphic g = getCurrentEditable().getGraphic();
JPopupMenu pum = new JPopupMenu();
if ((g.getAttribute(OMGraphicConstants.CHANGE_APPEARANCE)) == null
|| ((Boolean) g.getAttribute(OMGraphicConstants.CHANGE_APPEARANCE)).booleanValue()) {
JMenuItem gui = new JMenuItem(i18n.get(OMDrawingTool.class,
"popupMenuChangeAppearance",
"Change Appearance"));
gui.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
EditableOMGraphic eomg = getCurrentEditable();
if (eomg != null) {
boolean previous = eomg.getShowGUI();
eomg.setShowGUI(true);
setVisible(true);
if (!getUseAsTool()) {
showInWindow();
}
eomg.setShowGUI(previous);
eomg.getStateMachine().setSelected();
}
}
});
if (isMask(SHOW_GUI_BEHAVIOR_MASK | GUI_VIA_POPUP_BEHAVIOR_MASK)
&& !getUseAsTool()) {
pum.add(gui);
} else {
Debug.output("Not adding Change Appearance to popup: guiViaPopup("
+ isMask(SHOW_GUI_BEHAVIOR_MASK)
+ ") isTool("
+ getUseAsTool() + ")");
}
}
if ((g.getAttribute(OMGraphicConstants.REMOVABLE)) == null
|| ((Boolean) g.getAttribute(OMGraphicConstants.REMOVABLE)).booleanValue()) {
JMenuItem delete = new JMenuItem(i18n.get(OMDrawingTool.class,
"popupMenuDelete",
"Delete"));
delete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
OMAction action = new OMAction();
action.setMask(OMGraphic.DELETE_GRAPHIC_MASK);
EditableOMGraphic eomg = getCurrentEditable();
if (eomg != null) {
OMGraphic g = eomg.getGraphic();
if (g != null) {
notifyListener(g, action);
}
}
setCurrentEditable(null);
deactivate();
}
});
pum.add(delete);
}
// JMenuItem reset = new JMenuItem("Undo Changes");
// reset.setEnabled(false);
// reset.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent ae) {
// if (currentEditable != null) {
// currentEditable.reset();
// }
// }
// });
// pum.add(reset);
return pum.getComponentCount() > 0 ? pum : null;
}