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.Collection; |
7 | import java.util.HashSet; |
8 | import java.util.Iterator; |
9 | import java.util.LinkedList; |
10 | import java.util.List; |
11 | import java.util.Set; |
12 | |
13 | import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy; |
14 | import org.eclipse.gmf.runtime.notation.View; |
15 | |
16 | import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.ClosedWorkloadEditPart; |
17 | import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.OpenWorkloadEditPart; |
18 | import de.uka.ipd.sdq.pcm.gmf.usage.edit.parts.ScenarioBehaviourEditPart; |
19 | import de.uka.ipd.sdq.pcm.gmf.usage.part.PalladioComponentModelDiagramUpdater; |
20 | import de.uka.ipd.sdq.pcm.gmf.usage.part.PalladioComponentModelNodeDescriptor; |
21 | import de.uka.ipd.sdq.pcm.gmf.usage.part.PalladioComponentModelVisualIDRegistry; |
22 | import de.uka.ipd.sdq.pcm.usagemodel.UsagemodelPackage; |
23 | |
24 | /** |
25 | * @generated |
26 | */ |
27 | public class UsageScenarioUsageScenarioCompartmentCanonicalEditPolicy extends |
28 | CanonicalEditPolicy { |
29 | |
30 | /** |
31 | * @generated |
32 | */ |
33 | Set myFeaturesToSynchronize; |
34 | |
35 | /** |
36 | * @generated |
37 | */ |
38 | protected List getSemanticChildrenList() { |
39 | View viewObject = (View) getHost().getModel(); |
40 | List result = new LinkedList(); |
41 | for (Iterator it = PalladioComponentModelDiagramUpdater |
42 | .getUsageScenarioUsageScenarioCompartment_7012SemanticChildren( |
43 | viewObject).iterator(); it.hasNext();) { |
44 | result.add(((PalladioComponentModelNodeDescriptor) it.next()) |
45 | .getModelElement()); |
46 | } |
47 | return result; |
48 | } |
49 | |
50 | /** |
51 | * @generated |
52 | */ |
53 | protected boolean isOrphaned(Collection semanticChildren, final View view) { |
54 | int visualID = PalladioComponentModelVisualIDRegistry.getVisualID(view); |
55 | switch (visualID) { |
56 | case ScenarioBehaviourEditPart.VISUAL_ID: |
57 | case ClosedWorkloadEditPart.VISUAL_ID: |
58 | case OpenWorkloadEditPart.VISUAL_ID: |
59 | if (!semanticChildren.contains(view.getElement())) { |
60 | return true; |
61 | } |
62 | } |
63 | return false; |
64 | } |
65 | |
66 | /** |
67 | * @generated |
68 | */ |
69 | protected String getDefaultFactoryHint() { |
70 | return null; |
71 | } |
72 | |
73 | /** |
74 | * @generated |
75 | */ |
76 | protected Set getFeaturesToSynchronize() { |
77 | if (myFeaturesToSynchronize == null) { |
78 | myFeaturesToSynchronize = new HashSet(); |
79 | myFeaturesToSynchronize.add(UsagemodelPackage.eINSTANCE |
80 | .getUsageScenario_ScenarioBehaviour_UsageScenario()); |
81 | myFeaturesToSynchronize.add(UsagemodelPackage.eINSTANCE |
82 | .getUsageScenario_Workload_UsageScenario()); |
83 | } |
84 | return myFeaturesToSynchronize; |
85 | } |
86 | |
87 | } |