01: package org.enhydra.jawe.components.graph.actions;
02:
03: import java.awt.event.ActionEvent;
04: import java.util.ArrayList;
05: import java.util.List;
06:
07: import org.enhydra.jawe.ActionBase;
08: import org.enhydra.jawe.JaWEComponent;
09: import org.enhydra.jawe.JaWEManager;
10: import org.enhydra.jawe.components.graph.GraphController;
11:
12: /**
13: * Inserts missing start and end bubbles into graph.
14: * @author Sasa Bojanic
15: */
16: public class InsertMissingStartAndEndBubbles extends ActionBase {
17:
18: public InsertMissingStartAndEndBubbles(JaWEComponent jawecomponent) {
19: super (jawecomponent);
20: }
21:
22: public void enableDisableAction() {
23: GraphController gc = (GraphController) jawecomponent;
24: setEnabled(gc.getSelectedGraph() != null
25: && gc.getGraphSettings().shouldUseBubbles()
26: && !gc.getSelectedGraph().getXPDLObject().isReadOnly());
27: }
28:
29: public void actionPerformed(ActionEvent e) {
30: GraphController gc = (GraphController) jawecomponent;
31: if (gc.getSelectedGraph() != null) {
32: gc.setUpdateInProgress(true);
33: List easToAdd = gc.getSelectedGraph().getGraphManager()
34: .insertMissingStartEndBubbles();
35: if (easToAdd.size() > 0) {
36: JaWEManager.getInstance().getJaWEController()
37: .startUndouableChange();
38: getWorkflowProcess().getExtendedAttributes().addAll(
39: easToAdd);
40: List toSelect = new ArrayList();
41: toSelect.add(gc.getSelectedGraph().getGraphManager()
42: .getXPDLOwner());
43: JaWEManager.getInstance().getJaWEController()
44: .endUndouableChange(toSelect);
45: }
46: gc.setUpdateInProgress(false);
47: }
48: }
49: }
|