}
}
private PopupMenu createActionMenu(final ViewState state) {
PopupMenu actionsMenu = new PopupMenu(ACTIONS_POP_MENU_NAME);
PopupMenu newSubMenu = new PopupMenu(NEW_SUB_POP_MENU_NAME);
MenuItem taskItem = new MenuItem(NEW_TASK_ITEM_NAME);
MenuItem condItem = new MenuItem(NEW_CONDITION_ITEM_NAME);
newSubMenu.add(taskItem);
newSubMenu.add(condItem);
newSubMenu.add(new MenuItem(NEW_PARALLEL_ITEM_NAME));
newSubMenu.add(new MenuItem(NEW_SEQUENTIAL_ITEM_NAME));
newSubMenu.addActionListener(this.myGraphListener);
actionsMenu.add(newSubMenu);
MenuItem viewReferrencedWorkflow = new MenuItem(VIEW_REF_WORKFLOW);
actionsMenu.add(viewReferrencedWorkflow);
MenuItem deleteItem = new MenuItem(DELETE_ITEM_NAME);
actionsMenu.add(deleteItem);
MenuItem formatItem = new MenuItem(FORMAT_ITEM_NAME);
actionsMenu.add(formatItem);
PopupMenu orderSubMenu = new PopupMenu(ORDER_SUB_POP_MENU_NAME);
ModelGraph modelGraph = state.getSelected();
newSubMenu.setEnabled(modelGraph == null
|| modelGraph.getModel().isParentType());
deleteItem.setEnabled(modelGraph != null);
formatItem.setEnabled(true);
if (modelGraph != null) {
viewReferrencedWorkflow.setEnabled(modelGraph.getModel().isRef());
taskItem.setEnabled(!modelGraph.isCondition());
condItem.setEnabled(modelGraph.isCondition());
orderSubMenu.setEnabled(modelGraph.getParent() != null
&& !(modelGraph.isCondition() && !modelGraph.getParent()
.isCondition()));
} else {
boolean isCondition = false;
if (state.getGraphs().size() > 0)
isCondition = state.getGraphs().get(0).isCondition();
viewReferrencedWorkflow.setEnabled(false);
taskItem.setEnabled(!isCondition);
condItem.setEnabled(isCondition);
}
actionsMenu.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(DELETE_ITEM_NAME)) {
GuiUtils.removeNode(state.getGraphs(), state.getSelected().getModel());
state.setSelected(null);
GraphView.this.notifyListeners();
} else if (e.getActionCommand().equals(FORMAT_ITEM_NAME)) {
GraphView.this.refreshView(state);
} else if (e.getActionCommand().equals(VIEW_REF_WORKFLOW)) {
scrollSelectedToVisible = true;
GraphView.this.notifyListeners(new ViewChange.VIEW_MODEL(state
.getSelected().getModel().getModelId(), GraphView.this));
}
}
});
PopupMenu edgesSubMenu = new PopupMenu(EDGES_SUB_POP_MENU_NAME);
edgesSubMenu.add(new MenuItem(TASK_LEVEL));
edgesSubMenu.add(new MenuItem(WORKFLOW_LEVEL));
actionsMenu.add(edgesSubMenu);
edgesSubMenu.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(TASK_LEVEL)) {
state.setProperty(EDGE_DISPLAY_MODE, TASK_MODE);
} else if (e.getActionCommand().equals(WORKFLOW_LEVEL)) {