cutAction = new CutAction("Cut", selectedArray);
copyAction = new CopyAction("Copy", selectedArray);
removeAction = new RemoveModelAction("Remove", selectedModelObjects);
} else {
cutAction = new DisabledAction("Cut", "No object selected");
copyAction = new DisabledAction("Copy", "No object selected");
removeAction = new DisabledAction("Remove", "No objects to remove");
}
if (getClipboard().hasContents()) {
pasteAction = new StandardAction("Paste") {
private static final long serialVersionUID = 1L;
@Override
protected void action() {
// look for the active mouse handler. If it exists, it should contain
// the current mouse position (from the mousemoved event), so use this
// to create a new PasteEvent
PasteAction a;
MouseHandler mh = MouseHandler.getActiveMouseHandler();
if (mh != null) {
a = new PasteAction("Paste", (NodeContainer)mh.getWorld(), true);
Point2D pos = mh.getMouseMovedRelativePosition();
if (pos != null) {
a.setPosition(pos.getX(), pos.getY());
}
} else {
a = new PasteAction("Paste", NengoGraphics.getInstance(), true);
}
a.doAction();
}
};
} else {
pasteAction = new DisabledAction("Paste", "No object is in the clipboard");
}
editMenu.addAction(copyAction, KeyEvent.VK_C, KeyStroke.getKeyStroke(KeyEvent.VK_C,
MENU_SHORTCUT_KEY_MASK));
editMenu.addAction(cutAction, KeyEvent.VK_X, KeyStroke.getKeyStroke(KeyEvent.VK_X,