Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 370d17c5bf01ffae0c9426e01bd7dae915c4fe6f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/*
 * Copyright (c) 2009 Atos Origin
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * 	  Patrick Tessier (CEA) - initial API and implementation
 *    Thibault Landre (Atos Origin) - initial API and implementation
 *    Vincent Lorenzo (CEA-LIST) - Bug 335987 [General][Enhancement] Show/Hide Connectors Labels and External Nodes Labels
 */

«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»
«IMPORT 'http://www.eclipse.org/papyrus/2009/papyrusgmfgenextension'»
«EXTENSION xpt::diagram::ViewmapAttributesUtils»
«EXTENSION xpt::diagram::editparts::Utils»
«EXTENSION xpt::diagram::Utils»
«EXTENSION xpt::EMFUtils»
«EXTENSION xpt::preferences::PrefsConstant»
«EXTENSION aspects::impl::diagram::editparts::EditPartsUtils»

«REM»-----«ENDREM»
«REM» GMF «ENDREM»
«REM»-----«ENDREM»



«DEFINE extendsListContents FOR gmfgen::GenNode-»
«REM»BEGIN: PapyrusGenCode«ENDREM»
«REM»Add own extension«ENDREM»
«IF papyrusgmfgenextension::ExtendedGenView.allInstances()->select(v:papyrusgmfgenextension::ExtendedGenView|v.genView->includes(self) and v.superOwnedEditPart<>null)->size()<>0»
	«FOREACH papyrusgmfgenextension::ExtendedGenView.allInstances()->select(v:papyrusgmfgenextension::ExtendedGenView|v.genView->includes(self) and v.superOwnedEditPart<>null) AS extendedObject»«EXPAND specifyInheritance FOR extendedObject»«ENDFOREACH-»
«REM»END: BEGIN: PapyrusGenCode«ENDREM»
«ELSE-»
	«IF hasBorderItems(self)»org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart«ELSE»org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart«ENDIF-»
«ENDIF-»
«ENDDEFINE»

«DEFINE extendsListContents FOR gmfgen::GenChildSideAffixedNode-»
«REM»BEGIN: PapyrusGenCode«ENDREM»
«REM»Add own eextension«ENDREM»
«IF papyrusgmfgenextension::ExtendedGenView.allInstances()->select(v:papyrusgmfgenextension::ExtendedGenView|v.genView->includes(self) and v.superOwnedEditPart<>null)->size()<>0»
	«FOREACH papyrusgmfgenextension::ExtendedGenView.allInstances()->select(v:papyrusgmfgenextension::ExtendedGenView|v.genView->includes(self) and v.superOwnedEditPart<>null) AS extendedObject»«EXPAND specifyInheritance FOR extendedObject»«ENDFOREACH-»
«REM»END: BEGIN: PapyrusGenCode«ENDREM»
«ELSE-»
	«IF hasBorderItems(self)»org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart«ELSE»org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderItemEditPart«ENDIF-»
«ENDIF-»
«ENDDEFINE»

«DEFINE borderItemSelectionEP FOR gmfgen::GenNode-»
new org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy() {

	protected java.util.List createSelectionHandles() {
		org.eclipse.gef.handles.MoveHandle mh = new org.eclipse.gef.handles.MoveHandle((org.eclipse.gef.GraphicalEditPart) getHost());
		mh.setBorder(null);
		return java.util.Collections.singletonList(mh);
	}
}
«ENDDEFINE»


«AROUND addFixedChild FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected boolean addFixedChild(org.eclipse.gef.EditPart childEditPart) {
«FOREACH getInnerFixedLabels(self) AS label»«LET label.viewmap.oclAsType(gmfgen::ParentAssignedViewmap) AS childViewmap-»
		if (childEditPart instanceof «label.getEditPartQualifiedClassName()») {
			((«label.getEditPartQualifiedClassName()») childEditPart).«EXPAND impl::diagram::editparts::TextAware::labelSetterName FOR childViewmap»(getPrimaryShape().«childViewmap.getterName»());
			return true;
		}
«ENDLET»«ENDFOREACH-»

«FOREACH getPinnedCompartments(self) AS compartment»«LET compartment.viewmap.oclAsType(gmfgen::ParentAssignedViewmap) AS childViewmap-»

		if (childEditPart instanceof «compartment.getEditPartQualifiedClassName()») {
			org.eclipse.draw2d.IFigure pane = getPrimaryShape().«childViewmap.getterName»();
			setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way 
			pane.add(((«compartment.getEditPartQualifiedClassName()») childEditPart).getFigure());
			return true;
		}	
«ENDLET»«ENDFOREACH-»

«FOREACH getSideAffixedChildren(self) AS child-»
	«REM»BEGIN PapyrusGencode«ENDREM»
	«REM»adding IF else end in order to take in account the case where a specific locator is added«ENDREM»
	«IF papyrusgmfgenextension::SpecificLocator.allInstances()->select(v:papyrusgmfgenextension::SpecificLocator | v.genChildSideAffixedNode->includes(child))->size()<>0»
	 «FOREACH papyrusgmfgenextension::SpecificLocator.allInstances()->select(v:papyrusgmfgenextension::SpecificLocator | v.genChildSideAffixedNode->includes(child)) AS extendedObject»
	 	«EXPAND genSpecificLocator(child) FOR extendedObject-»
	 «ENDFOREACH-»

	 «ELSE»
	 «REM»END PapyrusGencode«ENDREM»
		if (childEditPart instanceof «child.getEditPartQualifiedClassName()») {
			org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator locator = new org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator(getMainFigure(), org.eclipse.draw2d.PositionConstants.«child.preferredSideName»);
			getBorderedFigure().getBorderItemContainer().add(((«child.getEditPartQualifiedClassName()») childEditPart).getFigure(), locator);
			return true;
		}
	«REM»BEGIN PapyrusGencode«ENDREM»
	«ENDIF»
	«REM»END PapyrusGencode«ENDREM»
«ENDFOREACH-»
		return false;
	}

«ENDAROUND»


«AROUND createNodePlate FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure createNodePlate() {
		String prefElementId="«elementType.displayName»";
		org.eclipse.jface.preference.IPreferenceStore store =«getDiagram().editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getPreferenceStore();
		String preferenceConstantWitdh=org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId,  org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.WIDTH);
		String preferenceConstantHeight=org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId,  org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.HEIGHT);
		org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure result = new org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure(store.getInt(preferenceConstantWitdh), store.getInt(preferenceConstantHeight));
		
		«EXPAND setupNodePlate-»
		return result;
	}
«ENDAROUND»
«AROUND borderItemSelectionEditPolicy FOR gmfgen::GenNode-»
«IF hasBorderItems(self)-»
org.eclipse.gmf.runtime.notation.View childView = (org.eclipse.gmf.runtime.notation.View) child.getModel();
switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(childView)) {
«IF getExternalLabels(self)->size() > 0-»
«FOREACH getExternalLabels(self) AS nextLabel-»
«EXPAND xpt::Common::caseVisualID FOR nextLabel-»
«ENDFOREACH-»
	return «EXPAND borderItemSelectionEP»;
«ENDIF-»
«IF getSideAffixedChildren(self)->size() > 0-»
«FOREACH getSideAffixedChildren(self) AS nextBorderItem-»
«EXPAND xpt::Common::caseVisualID FOR nextBorderItem-»
«ENDFOREACH-»
	«REM»BEGIN PapyrusGenCode«ENDREM»
	«REM»The puRprose is to add replace GMF edit prolicy by an new editPolicy that allows to resize BorderItem«ENDREM»
	return new org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy();
	«REM»END PapyrusGenCode«ENDREM»
«ENDIF-»
}
«ENDIF-»
«ENDAROUND»

«REM»---------«ENDREM»
«REM» PAPYRUS «ENDREM»
«REM»---------«ENDREM»

«REM»BEGIN: PapyrusGenCode«ENDREM»
«REM»definition of the inheritance «ENDREM»
«DEFINE specifyInheritance FOR papyrusgmfgenextension::ExtendedGenView-»«superOwnedEditPart»«ENDDEFINE»
«REM»END: BEGIN: PapyrusGenCode«ENDREM»


«REM»BEGIN PapyrusGencode «ENDREM»
«REM» Adding line of template to manange code thanks to a spcific locator«ENDREM»
«DEFINE genSpecificLocator(gmfgen::GenChildSideAffixedNode child) FOR gmfgen::GenCommonBase-»
«ENDDEFINE»

«DEFINE genSpecificLocator(gmfgen::GenChildSideAffixedNode child) FOR gmfgen::ToolEntry-»
«ENDDEFINE»

«DEFINE genSpecificLocator(gmfgen::GenChildSideAffixedNode child) FOR gmfgen::GenNavigatorChildReference-»
«ENDDEFINE»

«DEFINE genSpecificLocator(gmfgen::GenChildSideAffixedNode child) FOR papyrusgmfgenextension::SpecificLocator-»
//Papyrus Gencode :«self.comment»
	if (childEditPart instanceof «child.getEditPartQualifiedClassName()») {
			org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator locator = new «self.classpath»(getMainFigure(), org.eclipse.draw2d.PositionConstants.«child.preferredSideName»);
			getBorderedFigure().getBorderItemContainer().add(((«child.getEditPartQualifiedClassName()») childEditPart).getFigure(), locator);
			return true;
		}
		
«ENDDEFINE»
«REM»END PapyrusGencode «ENDREM»

«REM»BEGIN PapyrusGencode «ENDREM»
«REM» Overwrite an existing method to set the preference value in the editpart«ENDREM»
«DEFINE genPreferredValue FOR gmfgen::GenNode-»

	«EXPAND xpt::Common::generatedMemberComment»
	@Override
	public Object getPreferredValue(org.eclipse.emf.ecore.EStructuralFeature feature) {
		org.eclipse.jface.preference.IPreferenceStore preferenceStore = (org.eclipse.jface.preference.IPreferenceStore) getDiagramPreferencesHint()
				.getPreferenceStore();
		Object result = null;
			
		if(feature == org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLineStyle_LineColor() || feature == org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE
					.getFontStyle_FontColor() || feature == org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE
					.getFillStyle_FillColor()){
			String prefColor = null;
			if (feature == org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getLineStyle_LineColor()) {
				prefColor = org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.getElementConstant("«elementType.displayName»", org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.COLOR_LINE);
			} else if (feature == org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE
					.getFontStyle_FontColor()) {
				prefColor = org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.getElementConstant("«elementType.displayName»", org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.COLOR_FONT);
			} else if (feature == org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE
					.getFillStyle_FillColor()) {
				prefColor = org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.getElementConstant("«elementType.displayName»", org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.COLOR_FILL);
			}
			result = org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities
						.RGBToInteger(org.eclipse.jface.preference.PreferenceConverter
								.getColor(
										(org.eclipse.jface.preference.IPreferenceStore) preferenceStore, prefColor));
		} else if (feature == org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE
					.getFillStyle_Transparency() || feature == org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE
					.getFillStyle_Gradient()) {
			String prefGradient = org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.getElementConstant("«elementType.displayName»", org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.COLOR_GRADIENT);
			org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter gradientPreferenceConverter = new org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter(
						preferenceStore.getString(prefGradient));
			if(feature == org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE
					.getFillStyle_Transparency()){
				result = new Integer(gradientPreferenceConverter
						.getTransparency());
			} else if (feature == org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE
					.getFillStyle_Gradient()){
				result = gradientPreferenceConverter.getGradientData();
			}
		}
		
		if(result == null){
			result = getStructuralFeatureValue(feature);
		}
		return result;
	}
«ENDDEFINE»
«REM»END PapyrusGencode «ENDREM»

«REM»BEGIN: PapyrusGenCode«ENDREM»
«REM»CreateGenerator to refresh figure by taking account of event of UML element or graphical element «ENDREM»
«DEFINE specificHandleNotificationEvent FOR gmfgen::GenNode-»
	«IF papyrusgmfgenextension::ExtendedGenView.allInstances()->select(v:papyrusgmfgenextension::ExtendedGenView|v.genView->includes(self))->size()<>0»
/**
*Papyrus codeGen
*@generated
**/
protected void handleNotificationEvent(org.eclipse.emf.common.notify.Notification event) {
«IF self.labels->exists(oclIsKindOf(gmfgen::GenExternalNodeLabel))-» 
	/*
	 * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart
	 * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)!
	 */
	if(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) {
		Object notifier = event.getNotifier();
		java.util.List<?> modelChildren = ((org.eclipse.gmf.runtime.notation.View)getModel()).getChildren();
		if(!(notifier instanceof org.eclipse.gmf.runtime.notation.Edge)) {
			if(modelChildren.contains(event.getNotifier())) {
				return;
			}
		}
	}
	«ENDIF-»
		super.handleNotificationEvent(event);
		«FOREACH papyrusgmfgenextension::ExtendedGenView.allInstances()->select(v:papyrusgmfgenextension::ExtendedGenView|v.genView->includes(self)) AS extendedObject»
	 		«EXPAND specificHandleNotificationEventBody FOR extendedObject.propRefreshHook-»
	 	«ENDFOREACH-»
	 	}
	«ENDIF»

«ENDDEFINE»

«DEFINE specificHandleNotificationEventBody FOR papyrusgmfgenextension::PropertyRefreshHook-»
//«self.comment»
if (resolveSemanticElement() != null) {
if(«self.triggeringCondition»){
	«self.action»;
	refreshVisuals();
}
}
«ENDDEFINE»
«REM»END: PapyrusGenCode«ENDREM»

«DEFINE addBorderItem FOR gmfgen::GenNode-»
	«IF getExternalLabels(self)->size() > 0-»
		«EXPAND xpt::Common::generatedMemberComment»
		protected void addBorderItem(org.eclipse.draw2d.IFigure borderItemContainer, org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart borderItemEditPart) {
		«IF self.getExternalLabelsWithoutSpecificLocator()->size() > 0-»	
			if («FOREACH self.getExternalLabelsWithoutSpecificLocator() AS label SEPARATOR ' || '»borderItemEditPart instanceof «label.getEditPartQualifiedClassName()»«ENDFOREACH») {
				org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator locator = new org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator(getMainFigure(), org.eclipse.draw2d.PositionConstants.SOUTH);
				locator.setBorderItemOffset(new org.eclipse.draw2d.geometry.Dimension(-20, -20));
				borderItemContainer.add(borderItemEditPart.getFigure(), locator);
			} else
		«ENDIF-»
		«FOREACH self.getExternalLabelsWithSpecificLocator() AS label-»
			if (borderItemEditPart instanceof «label.getEditPartQualifiedClassName()») {
				org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator locator = new «label.getSpecificLocator()»(getMainFigure());
				borderItemContainer.add(borderItemEditPart.getFigure(), locator);
			} else
		«ENDFOREACH-»
			{
				super.addBorderItem(borderItemContainer, borderItemEditPart);
			}
		}
	«ENDIF-»
«ENDDEFINE»

«DEFINE setupNodePlate FOR gmfgen::GenNode»«ENDDEFINE»

«DEFINE setupNodePlate FOR gmfgen::GenChildSideAffixedNode»
	//FIXME: workaround for #154536
	result.getBounds().setSize(result.getPreferredSize());
«ENDDEFINE»

Back to the top