1 | /* |
2 | *Copyright 2007, SDQ, IPD, University of Karlsruhe |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.gmf.usage.edit.policies; |
5 | |
6 | import java.util.Iterator; |
7 | import java.util.LinkedList; |
8 | import java.util.List; |
9 | |
10 | import org.eclipse.emf.ecore.EObject; |
11 | import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy; |
12 | import org.eclipse.gmf.runtime.notation.View; |
13 | |
14 | import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.BranchTransitionEditPart; |
15 | import de.uka.ipd.sdq.pcm.gmf.usage.part.PalladioComponentModelVisualIDRegistry; |
16 | import de.uka.ipd.sdq.pcm.usagemodel.Branch; |
17 | |
18 | /** |
19 | * @generated |
20 | */ |
21 | public class BranchCanonicalEditPolicy extends CanonicalEditPolicy { |
22 | |
23 | /** |
24 | * @generated |
25 | */ |
26 | protected List getSemanticChildrenList() { |
27 | List result = new LinkedList(); |
28 | EObject modelObject = ((View) getHost().getModel()).getElement(); |
29 | View viewObject = (View) getHost().getModel(); |
30 | EObject nextValue; |
31 | int nodeVID; |
32 | for (Iterator values = ((Branch) modelObject) |
33 | .getBranchTransitions_Branch().iterator(); values.hasNext();) { |
34 | nextValue = (EObject) values.next(); |
35 | nodeVID = PalladioComponentModelVisualIDRegistry.getNodeVisualID( |
36 | viewObject, nextValue); |
37 | if (BranchTransitionEditPart.VISUAL_ID == nodeVID) { |
38 | result.add(nextValue); |
39 | } |
40 | } |
41 | return result; |
42 | } |
43 | |
44 | /** |
45 | * @generated |
46 | */ |
47 | protected boolean shouldDeleteView(View view) { |
48 | if (view.getEAnnotation("Shortcut") != null) { //$NON-NLS-1$ |
49 | return view.isSetElement() |
50 | && (view.getElement() == null || view.getElement() |
51 | .eIsProxy()); |
52 | } |
53 | int nodeVID = PalladioComponentModelVisualIDRegistry.getVisualID(view); |
54 | switch (nodeVID) { |
55 | case BranchTransitionEditPart.VISUAL_ID: |
56 | return true; |
57 | } |
58 | return false; |
59 | } |
60 | |
61 | /** |
62 | * @generated |
63 | */ |
64 | protected String getDefaultFactoryHint() { |
65 | return null; |
66 | } |
67 | |
68 | } |