|
1 /* |
|
2 * Copyright (c) 2007, 2008 Borland Software Corporation |
|
3 * |
|
4 * All rights reserved. This program and the accompanying materials |
|
5 * are made available under the terms of the Eclipse Public License v1.0 |
|
6 * which accompanies this distribution, and is available at |
|
7 * http://www.eclipse.org/legal/epl-v10.html |
|
8 * |
|
9 * Contributors: |
|
10 * Dmitry Stadnik (Borland) - initial API and implementation |
|
11 */ |
|
12 |
|
13 «IMPORT "http://www.eclipse.org/gmf/2008/GenModel"» |
|
14 «IMPORT "http://www.eclipse.org/emf/2002/Ecore"» |
|
15 «IMPORT "http://www.eclipse.org/emf/2002/GenModel"» |
|
16 «EXTENSION xpt::diagram::ViewmapAttributesUtils» |
|
17 «EXTENSION xpt::GenModelUtils» |
|
18 |
|
19 «DEFINE updateSemanticHint FOR gmfgen::GenCommonBase-» |
|
20 if (semanticHint == null) { |
|
21 semanticHint = «getDiagram().getVisualIDRegistryQualifiedClassName()».getType( |
|
22 «getEditPartQualifiedClassName()».VISUAL_ID); |
|
23 view.setType(semanticHint); |
|
24 } |
|
25 «ENDDEFINE» |
|
26 |
|
27 «DEFINE createChildNode FOR gmfgen::GenCommonBase-» |
|
28 getViewService().createNode(eObjectAdapter, view, |
|
29 «getDiagram().getVisualIDRegistryQualifiedClassName()».getType(«getEditPartQualifiedClassName()».VISUAL_ID), |
|
30 org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.APPEND, true, getPreferencesHint()); |
|
31 «ENDDEFINE» |
|
32 |
|
33 «DEFINE domainElementAdapter(String adapterVar) FOR gmfgen::ModelFacet-» |
|
34 «ENDDEFINE» |
|
35 |
|
36 «DEFINE domainElementAdapter(String adapterVar) FOR gmfgen::TypeModelFacet-» |
|
37 org.eclipse.emf.ecore.EObject eObject = |
|
38 (org.eclipse.emf.ecore.EObject) semanticAdapter.getAdapter(org.eclipse.emf.ecore.EObject.class); |
|
39 if (eObject != null) { |
|
40 «adapterVar» = new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(eObject); |
|
41 } |
|
42 «ENDDEFINE» |
|
43 |
|
44 «DEFINE foregroundColour(String viewVar) FOR gmfgen::Viewmap-» |
|
45 «EXPAND foregroundColour(viewVar) FOREACH attributes-» |
|
46 «ENDDEFINE» |
|
47 |
|
48 «DEFINE foregroundColour(String viewVar) FOR gmfgen::Attributes-» |
|
49 «ENDDEFINE» |
|
50 |
|
51 «DEFINE foregroundColour(String viewVar) FOR gmfgen::ColorAttributes-» |
|
52 org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(«viewVar», |
|
53 org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLineStyle_LineColor(), |
|
54 org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.colorToInteger( |
|
55 org.eclipse.draw2d.ColorConstants.«foregroundColor»)); |
|
56 «ENDDEFINE» |
|
57 |
|
58 «DEFINE backgroundColour(String viewVar) FOR gmfgen::Viewmap-» |
|
59 «EXPAND backgroundColour(viewVar) FOREACH attributes-» |
|
60 «ENDDEFINE» |
|
61 |
|
62 «DEFINE backgroundColour(String viewVar) FOR gmfgen::Attributes-» |
|
63 «ENDDEFINE» |
|
64 |
|
65 «DEFINE backgroundColour(String viewVar) FOR gmfgen::ColorAttributes-» |
|
66 org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(«viewVar», |
|
67 org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getFillStyle_FillColor(), |
|
68 org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities.colorToInteger( |
|
69 org.eclipse.draw2d.ColorConstants.«backgroundColor»)); |
|
70 «ENDDEFINE» |
|
71 |
|
72 «DEFINE addShapeStyle(String stylesVar) FOR gmfgen::Viewmap-» |
|
73 «IF isFixedFont()-» |
|
74 «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDescriptionStyle()); |
|
75 «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createFillStyle()); |
|
76 «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createLineStyle()); |
|
77 «ELSE-» |
|
78 «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createShapeStyle()); |
|
79 «ENDIF-» |
|
80 «ENDDEFINE» |
|
81 |
|
82 «DEFINE addTextStyle(String stylesVar) FOR gmfgen::LabelModelFacet-» |
|
83 «ENDDEFINE» |
|
84 |
|
85 «DEFINE addTextStyle(String stylesVar) FOR gmfgen::DesignLabelModelFacet-» |
|
86 «stylesVar».add(org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createDescriptionStyle()); |
|
87 «ENDDEFINE» |
|
88 |
|
89 «DEFINE addLinkedDiagramStyle(String stylesVar) FOR gmfgen::GenCommonBase-» |
|
90 «EXPAND addLinkedDiagramStyle(stylesVar) FOREACH behaviour-» |
|
91 «ENDDEFINE» |
|
92 |
|
93 «DEFINE addLinkedDiagramStyle(String stylesVar) FOR gmfgen::Behaviour-» |
|
94 «ENDDEFINE» |
|
95 |
|
96 «DEFINE addLinkedDiagramStyle(String stylesVar) FOR gmfgen::OpenDiagramBehaviour-» |
|
97 { |
|
98 org.eclipse.gmf.runtime.notation.HintedDiagramLinkStyle diagramFacet = |
|
99 org.eclipse.gmf.runtime.notation.NotationFactory.eINSTANCE.createHintedDiagramLinkStyle(); |
|
100 «IF diagramKind != null-» |
|
101 diagramFacet.setHint("«diagramKind»"); // $NON-NLS-1$ |
|
102 «ENDIF-» |
|
103 «stylesVar».add(diagramFacet); |
|
104 } |
|
105 «ENDDEFINE» |
|
106 |
|
107 «DEFINE addCustomStyles(String stylesVar) FOR gmfgen::GenCommonBase-» |
|
108 «FOREACH styles AS style-» |
|
109 «stylesVar».add(«EXPAND MetaModel::NewInstance FOR style»); |
|
110 «ENDFOREACH-» |
|
111 «ENDDEFINE» |