01: /**
02: *
03: */package diagram.commands;
04:
05: import newprocess.Actor;
06: import newprocess.AsyncActivity;
07: import newprocess.Condition;
08: import newprocess.Event;
09: import newprocess.Listener;
10: import newprocess.Loader;
11: import newprocess.SyncActivity;
12: import newprocess.diagram.edit.parts.ActorEditPart;
13: import newprocess.diagram.edit.parts.AsyncActivity2EditPart;
14: import newprocess.diagram.edit.parts.AsyncActivityEditPart;
15: import newprocess.diagram.edit.parts.ConditionEditPart;
16: import newprocess.diagram.edit.parts.EventEditPart;
17: import newprocess.diagram.edit.parts.ListenerEditPart;
18: import newprocess.diagram.edit.parts.LoaderEditPart;
19: import newprocess.diagram.edit.parts.ProcessEditPart;
20: import newprocess.diagram.edit.parts.SyncActivityEditPart;
21:
22: import org.eclipse.emf.common.util.EList;
23: import org.eclipse.gef.EditPart;
24: import org.eclipse.gmf.runtime.notation.Diagram;
25: import org.eclipse.gmf.runtime.notation.Node;
26:
27: /**
28: * Reads the EnvEntries of the selected EditPart
29: *
30: * @author sh
31: */
32: public class ReadCommand {
33:
34: /**
35: * Returns the list of EnvEntries for the given EditPart.
36: *
37: * @param selectedEditPart the EditPart containing the EnvEntries.
38: *
39: * @return a list of EnvEntries.
40: */
41: public EList getValues(EditPart selectedEditPart) {
42: if (selectedEditPart instanceof ActorEditPart)
43: return ((Actor) ((Node) selectedEditPart.getModel())
44: .getElement()).getHasEnvEntries();
45: if (selectedEditPart instanceof ProcessEditPart)
46: return ((newprocess.Process) ((Diagram) selectedEditPart
47: .getModel()).getElement()).getHasEnvEntries();
48: if (selectedEditPart instanceof LoaderEditPart)
49: return ((Loader) ((Node) selectedEditPart.getModel())
50: .getElement()).getHasEnvEntries();
51: if (selectedEditPart instanceof ConditionEditPart)
52: return ((Condition) ((Node) selectedEditPart.getModel())
53: .getElement()).getHasEnvEntries();
54: if (selectedEditPart instanceof SyncActivityEditPart)
55: return ((SyncActivity) ((Node) selectedEditPart.getModel())
56: .getElement()).getHasEnvEntries();
57: if (selectedEditPart instanceof AsyncActivityEditPart
58: || selectedEditPart instanceof AsyncActivity2EditPart)
59: return ((AsyncActivity) ((Node) selectedEditPart.getModel())
60: .getElement()).getHasEnvEntries();
61: if (selectedEditPart instanceof EventEditPart)
62: return ((Event) ((Node) selectedEditPart.getModel())
63: .getElement()).getHasEnvEntries();
64: if (selectedEditPart instanceof ListenerEditPart)
65: return ((Listener) ((Node) selectedEditPart.getModel())
66: .getElement()).getHasEnvEntries();
67: return null;
68: }
69: }
|