1 | /* |
2 | *Copyright 2007, IPD, SDQ, University of Karlsruhe |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.gmf.repository.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.core.runtime.IAdaptable; |
14 | import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy; |
15 | import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; |
16 | import org.eclipse.gmf.runtime.notation.View; |
17 | |
18 | import de.uka.ipd.sdq.pcm.gmf.repository.edit.parts.ResourceDemandingSEFFEditPart; |
19 | import de.uka.ipd.sdq.pcm.gmf.repository.part.PalladioComponentModelDiagramUpdater; |
20 | import de.uka.ipd.sdq.pcm.gmf.repository.part.PalladioComponentModelNodeDescriptor; |
21 | import de.uka.ipd.sdq.pcm.gmf.repository.part.PalladioComponentModelVisualIDRegistry; |
22 | import de.uka.ipd.sdq.pcm.repository.RepositoryPackage; |
23 | |
24 | /** |
25 | * @generated |
26 | */ |
27 | public class BasicComponentSEFFCompartmentCanonicalEditPolicy 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 | .getBasicComponentSEFFCompartment_7102SemanticChildren( |
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 ResourceDemandingSEFFEditPart.VISUAL_ID: |
57 | if (!semanticChildren.contains(view.getElement())) { |
58 | return true; |
59 | } |
60 | } |
61 | return false; |
62 | } |
63 | |
64 | /** |
65 | * @generated |
66 | */ |
67 | protected String getDefaultFactoryHint() { |
68 | return null; |
69 | } |
70 | |
71 | /** |
72 | * @generated |
73 | */ |
74 | protected Set getFeaturesToSynchronize() { |
75 | if (myFeaturesToSynchronize == null) { |
76 | myFeaturesToSynchronize = new HashSet(); |
77 | myFeaturesToSynchronize |
78 | .add(RepositoryPackage.eINSTANCE |
79 | .getBasicComponent_ServiceEffectSpecifications__BasicComponent()); |
80 | } |
81 | return myFeaturesToSynchronize; |
82 | } |
83 | |
84 | protected CreateViewRequest.ViewDescriptor getViewDescriptor( |
85 | IAdaptable elementAdapter, Class viewKind, String hint, int index) { |
86 | |
87 | return new CreateViewRequest.ViewDescriptor(elementAdapter, viewKind, |
88 | hint, index, true, host().getDiagramPreferencesHint()); |
89 | } |
90 | } |