01: /**
02: *
03: */package model;
04:
05: import newprocess.Element;
06: import newprocess.diagram.edit.parts.ActorEditPart;
07: import newprocess.diagram.edit.parts.AsyncActivity2EditPart;
08: import newprocess.diagram.edit.parts.AsyncActivityEditPart;
09: import newprocess.diagram.edit.parts.ConditionEditPart;
10: import newprocess.diagram.edit.parts.EventEditPart;
11: import newprocess.diagram.edit.parts.ListenerEditPart;
12: import newprocess.diagram.edit.parts.LoaderEditPart;
13: import newprocess.diagram.edit.parts.ProcessEditPart;
14: import newprocess.diagram.edit.parts.SyncActivityEditPart;
15:
16: import org.eclipse.emf.ecore.EObject;
17: import org.eclipse.gef.EditPart;
18: import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
19: import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
20: import org.eclipse.gmf.runtime.notation.Diagram;
21: import org.eclipse.gmf.runtime.notation.Node;
22:
23: /**
24: * @author sh
25: *
26: */
27: public class PropertyUtil {
28: /**
29: * This utility method is used to refactor a
30: * model element. It checks if the selected
31: * EditPart is defined for refactoring.
32: *
33: * @param editPart the EditPart to check
34: * @return true if the given EditPart is accepted
35: */
36: public static boolean isEditPartSupported(EditPart editPart) {
37: if (editPart instanceof ActorEditPart
38: || editPart instanceof ProcessEditPart
39: || editPart instanceof LoaderEditPart
40: || editPart instanceof ConditionEditPart
41: || editPart instanceof AsyncActivityEditPart
42: || editPart instanceof AsyncActivity2EditPart
43: || editPart instanceof SyncActivityEditPart
44: || editPart instanceof EventEditPart
45: || editPart instanceof ListenerEditPart)
46: return true;
47: return false;
48: }
49:
50: /**
51: * Returs the implementation value for the given EditPart
52: *
53: * @param editPart the EditPart containing the implementation
54: * @return the implementation value
55: */
56: public static String getImplementation(EditPart editPart) {
57: EObject modelElement = null;
58: if (editPart instanceof ShapeNodeEditPart) {
59: modelElement = ((Node) editPart.getModel()).getElement();
60: } else if (editPart instanceof DiagramEditPart) {
61: modelElement = ((Diagram) editPart.getModel()).getElement();
62: }
63:
64: if (modelElement instanceof Element == false)
65: return null;
66: return ((Element) modelElement).getImplementation();
67: }
68: }
|