1 | /* |
2 | * Copyright 2009, SDQ, IPD, Uni Karlsruhe (TH) |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.gmf.resource.providers; |
5 | |
6 | import java.util.ArrayList; |
7 | |
8 | import org.eclipse.core.runtime.IAdaptable; |
9 | import org.eclipse.emf.ecore.EAnnotation; |
10 | import org.eclipse.emf.ecore.EObject; |
11 | import org.eclipse.emf.ecore.EcoreFactory; |
12 | import org.eclipse.emf.transaction.util.TransactionUtil; |
13 | import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; |
14 | import org.eclipse.gmf.runtime.common.core.service.IOperation; |
15 | import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; |
16 | import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider; |
17 | import org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation; |
18 | import org.eclipse.gmf.runtime.diagram.core.services.view.CreateEdgeViewOperation; |
19 | import org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperation; |
20 | import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation; |
21 | import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewOperation; |
22 | import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; |
23 | import org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants; |
24 | import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities; |
25 | import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil; |
26 | import org.eclipse.gmf.runtime.emf.type.core.IElementType; |
27 | import org.eclipse.gmf.runtime.emf.type.core.IHintedType; |
28 | import org.eclipse.gmf.runtime.notation.Connector; |
29 | import org.eclipse.gmf.runtime.notation.DecorationNode; |
30 | import org.eclipse.gmf.runtime.notation.Diagram; |
31 | import org.eclipse.gmf.runtime.notation.Edge; |
32 | import org.eclipse.gmf.runtime.notation.FontStyle; |
33 | import org.eclipse.gmf.runtime.notation.MeasurementUnit; |
34 | import org.eclipse.gmf.runtime.notation.Node; |
35 | import org.eclipse.gmf.runtime.notation.NotationFactory; |
36 | import org.eclipse.gmf.runtime.notation.NotationPackage; |
37 | import org.eclipse.gmf.runtime.notation.RelativeBendpoints; |
38 | import org.eclipse.gmf.runtime.notation.Routing; |
39 | import org.eclipse.gmf.runtime.notation.Shape; |
40 | import org.eclipse.gmf.runtime.notation.TitleStyle; |
41 | import org.eclipse.gmf.runtime.notation.View; |
42 | import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint; |
43 | import org.eclipse.jface.preference.IPreferenceStore; |
44 | import org.eclipse.jface.preference.PreferenceConverter; |
45 | import org.eclipse.swt.SWT; |
46 | import org.eclipse.swt.graphics.FontData; |
47 | |
48 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.CommunicationLinkResourceSpecificationEditPart; |
49 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.CommunicationLinkResourceSpecificationFailureProbabilityEditPart; |
50 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.CommunicationLinkResourceSpecificationLatencyLabelEditPart; |
51 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.CommunicationLinkResourceSpecificationThroughputLabelEditPart; |
52 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.LinkingResource2EditPart; |
53 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.LinkingResourceConnectedResourceContainers_LinkingResourceEditPart; |
54 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.LinkingResourceEntityNameEditPart; |
55 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.LinkingResourceNetworkSwitchCompartmentEditPart; |
56 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ProcessingResourceSpecificationActiveResourceTypeLabelEditPart; |
57 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ProcessingResourceSpecificationEditPart; |
58 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ProcessingResourceSpecificationMTTFEditPart; |
59 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ProcessingResourceSpecificationMTTREditPart; |
60 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ProcessingResourceSpecificationNumberOfReplicasEditPart; |
61 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ProcessingResourceSpecificationProcessingResourceSpecificationCompartmentEditPart; |
62 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ProcessingResourceSpecificationSchedulingPolicyEditPart; |
63 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ResourceContainerEditPart; |
64 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ResourceContainerEntityNameEditPart; |
65 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ResourceContainerResourceContainerCompartmentEditPart; |
66 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.ResourceEnvironmentEditPart; |
67 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.WrappingLabel2EditPart; |
68 | import de.uka.ipd.sdq.pcm.gmf.resource.edit.parts.WrappingLabelEditPart; |
69 | import de.uka.ipd.sdq.pcm.gmf.resource.part.PalladioComponentModelVisualIDRegistry; |
70 | |
71 | /** |
72 | * @generated |
73 | */ |
74 | public class PalladioComponentModelViewProvider extends AbstractProvider |
75 | implements IViewProvider { |
76 | |
77 | /** |
78 | * @generated |
79 | */ |
80 | public final boolean provides(IOperation operation) { |
81 | if (operation instanceof CreateViewForKindOperation) { |
82 | return provides((CreateViewForKindOperation) operation); |
83 | } |
84 | assert operation instanceof CreateViewOperation; |
85 | if (operation instanceof CreateDiagramViewOperation) { |
86 | return provides((CreateDiagramViewOperation) operation); |
87 | } else if (operation instanceof CreateEdgeViewOperation) { |
88 | return provides((CreateEdgeViewOperation) operation); |
89 | } else if (operation instanceof CreateNodeViewOperation) { |
90 | return provides((CreateNodeViewOperation) operation); |
91 | } |
92 | return false; |
93 | } |
94 | |
95 | /** |
96 | * @generated |
97 | */ |
98 | protected boolean provides(CreateViewForKindOperation op) { |
99 | /* |
100 | if (op.getViewKind() == Node.class) |
101 | return getNodeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null; |
102 | if (op.getViewKind() == Edge.class) |
103 | return getEdgeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null; |
104 | */ |
105 | return true; |
106 | } |
107 | |
108 | /** |
109 | * @generated |
110 | */ |
111 | protected boolean provides(CreateDiagramViewOperation op) { |
112 | return ResourceEnvironmentEditPart.MODEL_ID |
113 | .equals(op.getSemanticHint()) |
114 | && PalladioComponentModelVisualIDRegistry |
115 | .getDiagramVisualID(getSemanticElement(op |
116 | .getSemanticAdapter())) != -1; |
117 | } |
118 | |
119 | /** |
120 | * @generated |
121 | */ |
122 | protected boolean provides(CreateNodeViewOperation op) { |
123 | if (op.getContainerView() == null) { |
124 | return false; |
125 | } |
126 | IElementType elementType = getSemanticElementType(op |
127 | .getSemanticAdapter()); |
128 | EObject domainElement = getSemanticElement(op.getSemanticAdapter()); |
129 | int visualID; |
130 | if (op.getSemanticHint() == null) { |
131 | // Semantic hint is not specified. Can be a result of call from CanonicalEditPolicy. |
132 | // In this situation there should be NO elementType, visualID will be determined |
133 | // by VisualIDRegistry.getNodeVisualID() for domainElement. |
134 | if (elementType != null || domainElement == null) { |
135 | return false; |
136 | } |
137 | visualID = PalladioComponentModelVisualIDRegistry.getNodeVisualID( |
138 | op.getContainerView(), domainElement); |
139 | } else { |
140 | visualID = PalladioComponentModelVisualIDRegistry.getVisualID(op |
141 | .getSemanticHint()); |
142 | if (elementType != null) { |
143 | if (!PalladioComponentModelElementTypes |
144 | .isKnownElementType(elementType) |
145 | || (!(elementType instanceof IHintedType))) { |
146 | return false; // foreign element type |
147 | } |
148 | String elementTypeHint = ((IHintedType) elementType) |
149 | .getSemanticHint(); |
150 | if (!op.getSemanticHint().equals(elementTypeHint)) { |
151 | return false; // if semantic hint is specified it should be the same as in element type |
152 | } |
153 | if (domainElement != null |
154 | && visualID != PalladioComponentModelVisualIDRegistry |
155 | .getNodeVisualID(op.getContainerView(), |
156 | domainElement)) { |
157 | return false; // visual id for node EClass should match visual id from element type |
158 | } |
159 | } else { |
160 | if (!ResourceEnvironmentEditPart.MODEL_ID |
161 | .equals(PalladioComponentModelVisualIDRegistry |
162 | .getModelID(op.getContainerView()))) { |
163 | return false; // foreign diagram |
164 | } |
165 | switch (visualID) { |
166 | case ResourceContainerEditPart.VISUAL_ID: |
167 | case LinkingResource2EditPart.VISUAL_ID: |
168 | case ProcessingResourceSpecificationEditPart.VISUAL_ID: |
169 | case CommunicationLinkResourceSpecificationEditPart.VISUAL_ID: |
170 | if (domainElement == null |
171 | || visualID != PalladioComponentModelVisualIDRegistry |
172 | .getNodeVisualID(op.getContainerView(), |
173 | domainElement)) { |
174 | return false; // visual id in semantic hint should match visual id for domain element |
175 | } |
176 | break; |
177 | default: |
178 | return false; |
179 | } |
180 | } |
181 | } |
182 | return ResourceContainerEditPart.VISUAL_ID == visualID |
183 | || LinkingResource2EditPart.VISUAL_ID == visualID |
184 | || ProcessingResourceSpecificationEditPart.VISUAL_ID == visualID |
185 | || CommunicationLinkResourceSpecificationEditPart.VISUAL_ID == visualID; |
186 | } |
187 | |
188 | /** |
189 | * @generated |
190 | */ |
191 | protected boolean provides(CreateEdgeViewOperation op) { |
192 | IElementType elementType = getSemanticElementType(op |
193 | .getSemanticAdapter()); |
194 | if (!PalladioComponentModelElementTypes.isKnownElementType(elementType) |
195 | || (!(elementType instanceof IHintedType))) { |
196 | return false; // foreign element type |
197 | } |
198 | String elementTypeHint = ((IHintedType) elementType).getSemanticHint(); |
199 | if (elementTypeHint == null |
200 | || (op.getSemanticHint() != null && !elementTypeHint.equals(op |
201 | .getSemanticHint()))) { |
202 | return false; // our hint is visual id and must be specified, and it should be the same as in element type |
203 | } |
204 | int visualID = PalladioComponentModelVisualIDRegistry |
205 | .getVisualID(elementTypeHint); |
206 | EObject domainElement = getSemanticElement(op.getSemanticAdapter()); |
207 | if (domainElement != null |
208 | && visualID != PalladioComponentModelVisualIDRegistry |
209 | .getLinkWithClassVisualID(domainElement)) { |
210 | return false; // visual id for link EClass should match visual id from element type |
211 | } |
212 | return true; |
213 | } |
214 | |
215 | /** |
216 | * @generated |
217 | */ |
218 | public Diagram createDiagram(IAdaptable semanticAdapter, |
219 | String diagramKind, PreferencesHint preferencesHint) { |
220 | Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); |
221 | diagram.getStyles().add(NotationFactory.eINSTANCE.createDiagramStyle()); |
222 | diagram.setType(ResourceEnvironmentEditPart.MODEL_ID); |
223 | diagram.setElement(getSemanticElement(semanticAdapter)); |
224 | diagram.setMeasurementUnit(MeasurementUnit.PIXEL_LITERAL); |
225 | return diagram; |
226 | } |
227 | |
228 | /** |
229 | * @generated |
230 | */ |
231 | public Node createNode(IAdaptable semanticAdapter, View containerView, |
232 | String semanticHint, int index, boolean persisted, |
233 | PreferencesHint preferencesHint) { |
234 | final EObject domainElement = getSemanticElement(semanticAdapter); |
235 | final int visualID; |
236 | if (semanticHint == null) { |
237 | visualID = PalladioComponentModelVisualIDRegistry.getNodeVisualID( |
238 | containerView, domainElement); |
239 | } else { |
240 | visualID = PalladioComponentModelVisualIDRegistry |
241 | .getVisualID(semanticHint); |
242 | } |
243 | switch (visualID) { |
244 | case ResourceContainerEditPart.VISUAL_ID: |
245 | return createResourceContainer_2001(domainElement, containerView, |
246 | index, persisted, preferencesHint); |
247 | case LinkingResource2EditPart.VISUAL_ID: |
248 | return createLinkingResource_2003(domainElement, containerView, |
249 | index, persisted, preferencesHint); |
250 | case ProcessingResourceSpecificationEditPart.VISUAL_ID: |
251 | return createProcessingResourceSpecification_3001(domainElement, |
252 | containerView, index, persisted, preferencesHint); |
253 | case CommunicationLinkResourceSpecificationEditPart.VISUAL_ID: |
254 | return createCommunicationLinkResourceSpecification_3002( |
255 | domainElement, containerView, index, persisted, |
256 | preferencesHint); |
257 | } |
258 | // can't happen, provided #provides(CreateNodeViewOperation) is correct |
259 | return null; |
260 | } |
261 | |
262 | /** |
263 | * @generated |
264 | */ |
265 | public Edge createEdge(IAdaptable semanticAdapter, View containerView, |
266 | String semanticHint, int index, boolean persisted, |
267 | PreferencesHint preferencesHint) { |
268 | IElementType elementType = getSemanticElementType(semanticAdapter); |
269 | String elementTypeHint = ((IHintedType) elementType).getSemanticHint(); |
270 | switch (PalladioComponentModelVisualIDRegistry |
271 | .getVisualID(elementTypeHint)) { |
272 | case LinkingResourceConnectedResourceContainers_LinkingResourceEditPart.VISUAL_ID: |
273 | return createLinkingResourceConnectedResourceContainers_LinkingResource_4002( |
274 | containerView, index, persisted, preferencesHint); |
275 | } |
276 | // can never happen, provided #provides(CreateEdgeViewOperation) is correct |
277 | return null; |
278 | } |
279 | |
280 | /** |
281 | * @generated |
282 | */ |
283 | public Node createResourceContainer_2001(EObject domainElement, |
284 | View containerView, int index, boolean persisted, |
285 | PreferencesHint preferencesHint) { |
286 | Shape node = NotationFactory.eINSTANCE.createShape(); |
287 | node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); |
288 | node.setType(PalladioComponentModelVisualIDRegistry |
289 | .getType(ResourceContainerEditPart.VISUAL_ID)); |
290 | ViewUtil.insertChildView(containerView, node, index, persisted); |
291 | node.setElement(domainElement); |
292 | stampShortcut(containerView, node); |
293 | // initializeFromPreferences |
294 | final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint |
295 | .getPreferenceStore(); |
296 | |
297 | org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor( |
298 | prefStore, IPreferenceConstants.PREF_LINE_COLOR); |
299 | ViewUtil.setStructuralFeatureValue(node, NotationPackage.eINSTANCE |
300 | .getLineStyle_LineColor(), FigureUtilities |
301 | .RGBToInteger(lineRGB)); |
302 | FontStyle nodeFontStyle = (FontStyle) node |
303 | .getStyle(NotationPackage.Literals.FONT_STYLE); |
304 | if (nodeFontStyle != null) { |
305 | FontData fontData = PreferenceConverter.getFontData(prefStore, |
306 | IPreferenceConstants.PREF_DEFAULT_FONT); |
307 | nodeFontStyle.setFontName(fontData.getName()); |
308 | nodeFontStyle.setFontHeight(fontData.getHeight()); |
309 | nodeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); |
310 | nodeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); |
311 | org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter |
312 | .getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR); |
313 | nodeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB) |
314 | .intValue()); |
315 | } |
316 | org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor( |
317 | prefStore, IPreferenceConstants.PREF_FILL_COLOR); |
318 | ViewUtil.setStructuralFeatureValue(node, NotationPackage.eINSTANCE |
319 | .getFillStyle_FillColor(), FigureUtilities |
320 | .RGBToInteger(fillRGB)); |
321 | Node label5001 = createLabel(node, |
322 | PalladioComponentModelVisualIDRegistry |
323 | .getType(ResourceContainerEntityNameEditPart.VISUAL_ID)); |
324 | createCompartment( |
325 | node, |
326 | PalladioComponentModelVisualIDRegistry |
327 | .getType(ResourceContainerResourceContainerCompartmentEditPart.VISUAL_ID), |
328 | false, false, true, true); |
329 | return node; |
330 | } |
331 | |
332 | /** |
333 | * @generated |
334 | */ |
335 | public Node createLinkingResource_2003(EObject domainElement, |
336 | View containerView, int index, boolean persisted, |
337 | PreferencesHint preferencesHint) { |
338 | Shape node = NotationFactory.eINSTANCE.createShape(); |
339 | node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); |
340 | node.setType(PalladioComponentModelVisualIDRegistry |
341 | .getType(LinkingResource2EditPart.VISUAL_ID)); |
342 | ViewUtil.insertChildView(containerView, node, index, persisted); |
343 | node.setElement(domainElement); |
344 | stampShortcut(containerView, node); |
345 | // initializeFromPreferences |
346 | final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint |
347 | .getPreferenceStore(); |
348 | |
349 | org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor( |
350 | prefStore, IPreferenceConstants.PREF_LINE_COLOR); |
351 | ViewUtil.setStructuralFeatureValue(node, NotationPackage.eINSTANCE |
352 | .getLineStyle_LineColor(), FigureUtilities |
353 | .RGBToInteger(lineRGB)); |
354 | FontStyle nodeFontStyle = (FontStyle) node |
355 | .getStyle(NotationPackage.Literals.FONT_STYLE); |
356 | if (nodeFontStyle != null) { |
357 | FontData fontData = PreferenceConverter.getFontData(prefStore, |
358 | IPreferenceConstants.PREF_DEFAULT_FONT); |
359 | nodeFontStyle.setFontName(fontData.getName()); |
360 | nodeFontStyle.setFontHeight(fontData.getHeight()); |
361 | nodeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); |
362 | nodeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); |
363 | org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter |
364 | .getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR); |
365 | nodeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB) |
366 | .intValue()); |
367 | } |
368 | org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor( |
369 | prefStore, IPreferenceConstants.PREF_FILL_COLOR); |
370 | ViewUtil.setStructuralFeatureValue(node, NotationPackage.eINSTANCE |
371 | .getFillStyle_FillColor(), FigureUtilities |
372 | .RGBToInteger(fillRGB)); |
373 | Node label5012 = createLabel(node, |
374 | PalladioComponentModelVisualIDRegistry |
375 | .getType(LinkingResourceEntityNameEditPart.VISUAL_ID)); |
376 | createCompartment( |
377 | node, |
378 | PalladioComponentModelVisualIDRegistry |
379 | .getType(LinkingResourceNetworkSwitchCompartmentEditPart.VISUAL_ID), |
380 | false, false, true, true); |
381 | return node; |
382 | } |
383 | |
384 | /** |
385 | * @generated |
386 | */ |
387 | public Node createProcessingResourceSpecification_3001( |
388 | EObject domainElement, View containerView, int index, |
389 | boolean persisted, PreferencesHint preferencesHint) { |
390 | Shape node = NotationFactory.eINSTANCE.createShape(); |
391 | node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); |
392 | node.setType(PalladioComponentModelVisualIDRegistry |
393 | .getType(ProcessingResourceSpecificationEditPart.VISUAL_ID)); |
394 | ViewUtil.insertChildView(containerView, node, index, persisted); |
395 | node.setElement(domainElement); |
396 | // initializeFromPreferences |
397 | final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint |
398 | .getPreferenceStore(); |
399 | |
400 | org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor( |
401 | prefStore, IPreferenceConstants.PREF_LINE_COLOR); |
402 | ViewUtil.setStructuralFeatureValue(node, NotationPackage.eINSTANCE |
403 | .getLineStyle_LineColor(), FigureUtilities |
404 | .RGBToInteger(lineRGB)); |
405 | FontStyle nodeFontStyle = (FontStyle) node |
406 | .getStyle(NotationPackage.Literals.FONT_STYLE); |
407 | if (nodeFontStyle != null) { |
408 | FontData fontData = PreferenceConverter.getFontData(prefStore, |
409 | IPreferenceConstants.PREF_DEFAULT_FONT); |
410 | nodeFontStyle.setFontName(fontData.getName()); |
411 | nodeFontStyle.setFontHeight(fontData.getHeight()); |
412 | nodeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); |
413 | nodeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); |
414 | org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter |
415 | .getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR); |
416 | nodeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB) |
417 | .intValue()); |
418 | } |
419 | org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor( |
420 | prefStore, IPreferenceConstants.PREF_FILL_COLOR); |
421 | ViewUtil.setStructuralFeatureValue(node, NotationPackage.eINSTANCE |
422 | .getFillStyle_FillColor(), FigureUtilities |
423 | .RGBToInteger(fillRGB)); |
424 | Node label5002 = createLabel( |
425 | node, |
426 | PalladioComponentModelVisualIDRegistry |
427 | .getType(ProcessingResourceSpecificationMTTFEditPart.VISUAL_ID)); |
428 | Node label5003 = createLabel( |
429 | node, |
430 | PalladioComponentModelVisualIDRegistry |
431 | .getType(ProcessingResourceSpecificationMTTREditPart.VISUAL_ID)); |
432 | Node label5004 = createLabel( |
433 | node, |
434 | PalladioComponentModelVisualIDRegistry |
435 | .getType(ProcessingResourceSpecificationSchedulingPolicyEditPart.VISUAL_ID)); |
436 | Node label5006 = createLabel( |
437 | node, |
438 | PalladioComponentModelVisualIDRegistry |
439 | .getType(ProcessingResourceSpecificationNumberOfReplicasEditPart.VISUAL_ID)); |
440 | Node label5009 = createLabel(node, |
441 | PalladioComponentModelVisualIDRegistry |
442 | .getType(WrappingLabelEditPart.VISUAL_ID)); |
443 | Node label5010 = createLabel( |
444 | node, |
445 | PalladioComponentModelVisualIDRegistry |
446 | .getType(ProcessingResourceSpecificationActiveResourceTypeLabelEditPart.VISUAL_ID)); |
447 | createCompartment( |
448 | node, |
449 | PalladioComponentModelVisualIDRegistry |
450 | .getType(ProcessingResourceSpecificationProcessingResourceSpecificationCompartmentEditPart.VISUAL_ID), |
451 | false, false, true, true); |
452 | return node; |
453 | } |
454 | |
455 | /** |
456 | * @generated |
457 | */ |
458 | public Node createCommunicationLinkResourceSpecification_3002( |
459 | EObject domainElement, View containerView, int index, |
460 | boolean persisted, PreferencesHint preferencesHint) { |
461 | Shape node = NotationFactory.eINSTANCE.createShape(); |
462 | node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); |
463 | node |
464 | .setType(PalladioComponentModelVisualIDRegistry |
465 | .getType(CommunicationLinkResourceSpecificationEditPart.VISUAL_ID)); |
466 | ViewUtil.insertChildView(containerView, node, index, persisted); |
467 | node.setElement(domainElement); |
468 | // initializeFromPreferences |
469 | final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint |
470 | .getPreferenceStore(); |
471 | |
472 | org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor( |
473 | prefStore, IPreferenceConstants.PREF_LINE_COLOR); |
474 | ViewUtil.setStructuralFeatureValue(node, NotationPackage.eINSTANCE |
475 | .getLineStyle_LineColor(), FigureUtilities |
476 | .RGBToInteger(lineRGB)); |
477 | FontStyle nodeFontStyle = (FontStyle) node |
478 | .getStyle(NotationPackage.Literals.FONT_STYLE); |
479 | if (nodeFontStyle != null) { |
480 | FontData fontData = PreferenceConverter.getFontData(prefStore, |
481 | IPreferenceConstants.PREF_DEFAULT_FONT); |
482 | nodeFontStyle.setFontName(fontData.getName()); |
483 | nodeFontStyle.setFontHeight(fontData.getHeight()); |
484 | nodeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); |
485 | nodeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); |
486 | org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter |
487 | .getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR); |
488 | nodeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB) |
489 | .intValue()); |
490 | } |
491 | org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor( |
492 | prefStore, IPreferenceConstants.PREF_FILL_COLOR); |
493 | ViewUtil.setStructuralFeatureValue(node, NotationPackage.eINSTANCE |
494 | .getFillStyle_FillColor(), FigureUtilities |
495 | .RGBToInteger(fillRGB)); |
496 | Node label5005 = createLabel( |
497 | node, |
498 | PalladioComponentModelVisualIDRegistry |
499 | .getType(CommunicationLinkResourceSpecificationFailureProbabilityEditPart.VISUAL_ID)); |
500 | Node label5007 = createLabel( |
501 | node, |
502 | PalladioComponentModelVisualIDRegistry |
503 | .getType(CommunicationLinkResourceSpecificationLatencyLabelEditPart.VISUAL_ID)); |
504 | Node label5008 = createLabel( |
505 | node, |
506 | PalladioComponentModelVisualIDRegistry |
507 | .getType(CommunicationLinkResourceSpecificationThroughputLabelEditPart.VISUAL_ID)); |
508 | Node label5011 = createLabel(node, |
509 | PalladioComponentModelVisualIDRegistry |
510 | .getType(WrappingLabel2EditPart.VISUAL_ID)); |
511 | return node; |
512 | } |
513 | |
514 | /** |
515 | * @generated not |
516 | */ |
517 | public Edge createLinkingResourceConnectedResourceContainers_LinkingResource_4002( |
518 | View containerView, int index, boolean persisted, |
519 | PreferencesHint preferencesHint) { |
520 | Connector edge = NotationFactory.eINSTANCE.createConnector(); |
521 | edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); |
522 | RelativeBendpoints bendpoints = NotationFactory.eINSTANCE |
523 | .createRelativeBendpoints(); |
524 | ArrayList points = new ArrayList(2); |
525 | points.add(new RelativeBendpoint()); |
526 | points.add(new RelativeBendpoint()); |
527 | bendpoints.setPoints(points); |
528 | edge.setBendpoints(bendpoints); |
529 | ViewUtil.insertChildView(containerView, edge, index, persisted); |
530 | edge |
531 | .setType(PalladioComponentModelVisualIDRegistry |
532 | .getType(LinkingResourceConnectedResourceContainers_LinkingResourceEditPart.VISUAL_ID)); |
533 | edge.setElement(null); |
534 | // initializePreferences |
535 | final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint |
536 | .getPreferenceStore(); |
537 | |
538 | org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor( |
539 | prefStore, IPreferenceConstants.PREF_LINE_COLOR); |
540 | ViewUtil.setStructuralFeatureValue(edge, NotationPackage.eINSTANCE |
541 | .getLineStyle_LineColor(), FigureUtilities |
542 | .RGBToInteger(lineRGB)); |
543 | FontStyle edgeFontStyle = (FontStyle) edge |
544 | .getStyle(NotationPackage.Literals.FONT_STYLE); |
545 | if (edgeFontStyle != null) { |
546 | FontData fontData = PreferenceConverter.getFontData(prefStore, |
547 | IPreferenceConstants.PREF_DEFAULT_FONT); |
548 | edgeFontStyle.setFontName(fontData.getName()); |
549 | edgeFontStyle.setFontHeight(fontData.getHeight()); |
550 | edgeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); |
551 | edgeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); |
552 | org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter |
553 | .getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR); |
554 | edgeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB) |
555 | .intValue()); |
556 | } |
557 | // Generated code removed by customization: Routing routing = |
558 | // Routing.get(prefStore.getInt(IPreferenceConstants.PREF_LINE_STYLE)); |
559 | |
560 | // Custom code: Set rectilinear routing |
561 | Routing routing = Routing.get(Routing.RECTILINEAR); |
562 | // End of custon code |
563 | if (routing != null) { |
564 | ViewUtil.setStructuralFeatureValue(edge, NotationPackage.eINSTANCE |
565 | .getRoutingStyle_Routing(), routing); |
566 | } |
567 | return edge; |
568 | } |
569 | |
570 | /** |
571 | * @generated NOT |
572 | */ |
573 | public Edge createLinkingResourceFromResourceContainer_LinkingResource_4001( |
574 | View containerView, int index, boolean persisted, |
575 | PreferencesHint preferencesHint) { |
576 | Connector edge = NotationFactory.eINSTANCE.createConnector(); |
577 | edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); |
578 | RelativeBendpoints bendpoints = NotationFactory.eINSTANCE |
579 | .createRelativeBendpoints(); |
580 | ArrayList points = new ArrayList(2); |
581 | points.add(new RelativeBendpoint()); |
582 | points.add(new RelativeBendpoint()); |
583 | bendpoints.setPoints(points); |
584 | edge.setBendpoints(bendpoints); |
585 | ViewUtil.insertChildView(containerView, edge, index, persisted); |
586 | edge |
587 | .setType(PalladioComponentModelVisualIDRegistry |
588 | .getType(LinkingResourceConnectedResourceContainers_LinkingResourceEditPart.VISUAL_ID)); |
589 | edge.setElement(null); |
590 | // initializePreferences |
591 | final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint |
592 | .getPreferenceStore(); |
593 | |
594 | org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor( |
595 | prefStore, IPreferenceConstants.PREF_LINE_COLOR); |
596 | ViewUtil.setStructuralFeatureValue(edge, NotationPackage.eINSTANCE |
597 | .getLineStyle_LineColor(), FigureUtilities |
598 | .RGBToInteger(lineRGB)); |
599 | FontStyle edgeFontStyle = (FontStyle) edge |
600 | .getStyle(NotationPackage.Literals.FONT_STYLE); |
601 | if (edgeFontStyle != null) { |
602 | FontData fontData = PreferenceConverter.getFontData(prefStore, |
603 | IPreferenceConstants.PREF_DEFAULT_FONT); |
604 | edgeFontStyle.setFontName(fontData.getName()); |
605 | edgeFontStyle.setFontHeight(fontData.getHeight()); |
606 | edgeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); |
607 | edgeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); |
608 | org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter |
609 | .getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR); |
610 | edgeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB) |
611 | .intValue()); |
612 | } |
613 | |
614 | // Generated code removed by customization: Routing routing = Routing.get(prefStore.getInt(IPreferenceConstants.PREF_LINE_STYLE)); |
615 | |
616 | // Custom code: Set rectilinear routing |
617 | Routing routing = Routing.get(Routing.RECTILINEAR); |
618 | // End of custon code |
619 | |
620 | if (routing != null) { |
621 | ViewUtil.setStructuralFeatureValue(edge, NotationPackage.eINSTANCE |
622 | .getRoutingStyle_Routing(), routing); |
623 | } |
624 | return edge; |
625 | } |
626 | |
627 | /** |
628 | * @generated |
629 | */ |
630 | private void stampShortcut(View containerView, Node target) { |
631 | if (!ResourceEnvironmentEditPart.MODEL_ID |
632 | .equals(PalladioComponentModelVisualIDRegistry |
633 | .getModelID(containerView))) { |
634 | EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE |
635 | .createEAnnotation(); |
636 | shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$ |
637 | shortcutAnnotation.getDetails().put( |
638 | "modelID", ResourceEnvironmentEditPart.MODEL_ID); //$NON-NLS-1$ |
639 | target.getEAnnotations().add(shortcutAnnotation); |
640 | } |
641 | } |
642 | |
643 | /** |
644 | * @generated |
645 | */ |
646 | private Node createLabel(View owner, String hint) { |
647 | DecorationNode rv = NotationFactory.eINSTANCE.createDecorationNode(); |
648 | rv.setType(hint); |
649 | ViewUtil.insertChildView(owner, rv, ViewUtil.APPEND, true); |
650 | return rv; |
651 | } |
652 | |
653 | /** |
654 | * @generated |
655 | */ |
656 | private Node createCompartment(View owner, String hint, |
657 | boolean canCollapse, boolean hasTitle, boolean canSort, |
658 | boolean canFilter) { |
659 | //SemanticListCompartment rv = NotationFactory.eINSTANCE.createSemanticListCompartment(); |
660 | //rv.setShowTitle(showTitle); |
661 | //rv.setCollapsed(isCollapsed); |
662 | Node rv; |
663 | if (canCollapse) { |
664 | rv = NotationFactory.eINSTANCE.createBasicCompartment(); |
665 | } else { |
666 | rv = NotationFactory.eINSTANCE.createDecorationNode(); |
667 | } |
668 | if (hasTitle) { |
669 | TitleStyle ts = NotationFactory.eINSTANCE.createTitleStyle(); |
670 | ts.setShowTitle(true); |
671 | rv.getStyles().add(ts); |
672 | } |
673 | if (canSort) { |
674 | rv.getStyles().add(NotationFactory.eINSTANCE.createSortingStyle()); |
675 | } |
676 | if (canFilter) { |
677 | rv.getStyles() |
678 | .add(NotationFactory.eINSTANCE.createFilteringStyle()); |
679 | } |
680 | rv.setType(hint); |
681 | ViewUtil.insertChildView(owner, rv, ViewUtil.APPEND, true); |
682 | return rv; |
683 | } |
684 | |
685 | /** |
686 | * @generated |
687 | */ |
688 | private EObject getSemanticElement(IAdaptable semanticAdapter) { |
689 | if (semanticAdapter == null) { |
690 | return null; |
691 | } |
692 | EObject eObject = (EObject) semanticAdapter.getAdapter(EObject.class); |
693 | if (eObject != null) { |
694 | return EMFCoreUtil.resolve(TransactionUtil |
695 | .getEditingDomain(eObject), eObject); |
696 | } |
697 | return null; |
698 | } |
699 | |
700 | /** |
701 | * @generated |
702 | */ |
703 | private IElementType getSemanticElementType(IAdaptable semanticAdapter) { |
704 | if (semanticAdapter == null) { |
705 | return null; |
706 | } |
707 | return (IElementType) semanticAdapter.getAdapter(IElementType.class); |
708 | } |
709 | } |