1 | /* |
2 | *Copyright 2007, SDQ, IPD, U KA |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.gmf.allocation.view.factories; |
5 | |
6 | import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.AllocationComponentLabelEditPart; |
7 | import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.AllocationEditPart; |
8 | import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.ResourceContainerAllocationCompartmentEditPart; |
9 | import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.ResourceContainerEditPart; |
10 | import de.uka.ipd.sdq.pcm.gmf.allocation.edit.parts.ResourceContainerEntityNameEditPart; |
11 | |
12 | import de.uka.ipd.sdq.pcm.gmf.allocation.part.PalladioComponentModelVisualIDRegistry; |
13 | |
14 | import java.util.ArrayList; |
15 | import java.util.List; |
16 | |
17 | import org.eclipse.core.runtime.IAdaptable; |
18 | |
19 | import org.eclipse.emf.ecore.EAnnotation; |
20 | import org.eclipse.emf.ecore.EObject; |
21 | import org.eclipse.emf.ecore.EcoreFactory; |
22 | |
23 | import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; |
24 | |
25 | import org.eclipse.gmf.runtime.diagram.ui.view.factories.AbstractShapeViewFactory; |
26 | |
27 | import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; |
28 | import org.eclipse.gmf.runtime.notation.NotationFactory; |
29 | import org.eclipse.gmf.runtime.notation.View; |
30 | |
31 | /** |
32 | * @generated |
33 | */ |
34 | public class ResourceContainerViewFactory extends AbstractShapeViewFactory { |
35 | |
36 | /** |
37 | * @generated |
38 | */ |
39 | protected List createStyles(View view) { |
40 | List styles = new ArrayList(); |
41 | styles.add(NotationFactory.eINSTANCE.createShapeStyle()); |
42 | return styles; |
43 | } |
44 | |
45 | /** |
46 | * @generated |
47 | */ |
48 | protected void decorateView(View containerView, View view, |
49 | IAdaptable semanticAdapter, String semanticHint, int index, |
50 | boolean persisted) { |
51 | if (semanticHint == null) { |
52 | semanticHint = PalladioComponentModelVisualIDRegistry |
53 | .getType(ResourceContainerEditPart.VISUAL_ID); |
54 | view.setType(semanticHint); |
55 | } |
56 | super.decorateView(containerView, view, semanticAdapter, semanticHint, |
57 | index, persisted); |
58 | if (!AllocationEditPart.MODEL_ID |
59 | .equals(PalladioComponentModelVisualIDRegistry |
60 | .getModelID(containerView))) { |
61 | EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE |
62 | .createEAnnotation(); |
63 | shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$ |
64 | shortcutAnnotation.getDetails().put( |
65 | "modelID", AllocationEditPart.MODEL_ID); //$NON-NLS-1$ |
66 | view.getEAnnotations().add(shortcutAnnotation); |
67 | } |
68 | IAdaptable eObjectAdapter = null; |
69 | EObject eObject = (EObject) semanticAdapter.getAdapter(EObject.class); |
70 | if (eObject != null) { |
71 | eObjectAdapter = new EObjectAdapter(eObject); |
72 | } |
73 | getViewService() |
74 | .createNode( |
75 | eObjectAdapter, |
76 | view, |
77 | PalladioComponentModelVisualIDRegistry |
78 | .getType(ResourceContainerEntityNameEditPart.VISUAL_ID), |
79 | ViewUtil.APPEND, true, getPreferencesHint()); |
80 | getViewService() |
81 | .createNode( |
82 | eObjectAdapter, |
83 | view, |
84 | PalladioComponentModelVisualIDRegistry |
85 | .getType(ResourceContainerAllocationCompartmentEditPart.VISUAL_ID), |
86 | ViewUtil.APPEND, true, getPreferencesHint()); |
87 | } |
88 | |
89 | } |