1 | /* |
2 | * Copyright 2007, SDQ, IPD, U KA |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.gmf.allocation.edit.policies; |
5 | |
6 | import java.util.ArrayList; |
7 | import java.util.Collection; |
8 | import java.util.Collections; |
9 | import java.util.Iterator; |
10 | |
11 | import org.eclipse.core.commands.ExecutionException; |
12 | import org.eclipse.core.runtime.IAdaptable; |
13 | import org.eclipse.core.runtime.IProgressMonitor; |
14 | import org.eclipse.emf.ecore.EAnnotation; |
15 | import org.eclipse.emf.ecore.EObject; |
16 | import org.eclipse.emf.ecore.resource.Resource; |
17 | import org.eclipse.gef.EditPart; |
18 | import org.eclipse.gef.commands.Command; |
19 | import org.eclipse.gef.commands.CompoundCommand; |
20 | import org.eclipse.gmf.runtime.common.core.command.CommandResult; |
21 | import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper; |
22 | import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand; |
23 | import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest; |
24 | import org.eclipse.gmf.runtime.notation.Edge; |
25 | import org.eclipse.gmf.runtime.notation.Node; |
26 | import org.eclipse.gmf.runtime.notation.View; |
27 | |
28 | import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.AllocationContextEditPart; |
29 | import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.ResourceContainerAllocationCompartmentEditPart; |
30 | import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.ResourceContainerEditPart; |
31 | import de.uka.ipd.sdq.pcm.gmf.allocation.part.PalladioComponentModelVisualIDRegistry; |
32 | |
33 | /** |
34 | * @generated |
35 | */ |
36 | public class ResourceContainerItemSemanticEditPolicy extends |
37 | PalladioComponentModelBaseItemSemanticEditPolicy { |
38 | |
39 | /** |
40 | * @generated |
41 | */ |
42 | protected Command getDestroyElementCommand(DestroyElementRequest req) { |
43 | CompoundCommand cc = getDestroyEdgesCommand(); |
44 | addDestroyChildNodesCommand(cc); |
45 | addDestroyShortcutsCommand(cc); |
46 | View view = (View) getHost().getModel(); |
47 | if (view.getEAnnotation("Shortcut") != null) { //$NON-NLS-1$ |
48 | req.setElementToDestroy(view); |
49 | } |
50 | cc.add(getGEFWrapper(new DestroyElementCommand(req))); |
51 | return cc.unwrap(); |
52 | } |
53 | |
54 | /** |
55 | * @generated |
56 | */ |
57 | protected void addDestroyChildNodesCommand(CompoundCommand cmd) { |
58 | View view = (View) getHost().getModel(); |
59 | EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$ |
60 | if (annotation != null) { |
61 | return; |
62 | } |
63 | for (Iterator it = view.getChildren().iterator(); it.hasNext();) { |
64 | Node node = (Node) it.next(); |
65 | switch (PalladioComponentModelVisualIDRegistry.getVisualID(node)) { |
66 | case ResourceContainerAllocationCompartmentEditPart.VISUAL_ID: |
67 | for (Iterator cit = node.getChildren().iterator(); cit |
68 | .hasNext();) { |
69 | Node cnode = (Node) cit.next(); |
70 | switch (PalladioComponentModelVisualIDRegistry |
71 | .getVisualID(cnode)) { |
72 | case AllocationContextEditPart.VISUAL_ID: |
73 | cmd.add(getDestroyElementCommand(cnode)); |
74 | break; |
75 | } |
76 | } |
77 | break; |
78 | } |
79 | } |
80 | } |
81 | |
82 | } |