Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a63e8316404742bf060e9d1d449471aaccd67bee (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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
/*
 * Copyright (c) 2006, 2009 Borland Software Corporation
 * 
 * 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:
 *    Dmitry Stadnik (Borland) - initial API and implementation
 *    Alexander Shatalin (Borland) - initial API and implementation
 */

«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»
«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
«EXTENSION xpt::diagram::ViewmapAttributesUtils»
«EXTENSION xpt::diagram::editparts::Utils»
«EXTENSION xpt::diagram::Utils»


«DEFINE extendsListContents FOR gmfgen::GenNode-»
«IF hasBorderItems(self)»org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart«ELSE»org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart«ENDIF-»
«ENDDEFINE»

«DEFINE extendsListContents FOR gmfgen::GenChildSideAffixedNode-»
«IF hasBorderItems(self)»org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart«ELSE»org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderItemEditPart«ENDIF-»
«ENDDEFINE»

«DEFINE _constructor FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	public «editPartClassName»(org.eclipse.gmf.runtime.notation.View view) {
		super(view);
	}
«ENDDEFINE»

«DEFINE createDefaultEditPoliciesBody FOR gmfgen::GenNode-»
	«EXPAND installCreationRolePolicy-»
	super.createDefaultEditPolicies();
	«EXPAND installPrimaryDragEditPolicy-»
	«EXPAND xpt::diagram::editparts::Common::installSemanticEditPolicy-»
	«IF needsGraphicalNodeEditPolicy(self)-»
		installEditPolicy(org.eclipse.gef.EditPolicy.GRAPHICAL_NODE_ROLE, new «getGraphicalNodeEditPolicyQualifiedClassName()»());
	«ENDIF-»
	«IF not childNodes->isEmpty()-»
		installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.DRAG_DROP_ROLE, new org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy());
	«ENDIF-»
	«EXPAND xpt::diagram::editparts::Common::installCanonicalEditPolicy-»
	installEditPolicy(org.eclipse.gef.EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
	«EXPAND xpt::diagram::editparts::Common::behaviour FOR self-»
	// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
	// removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
«ENDDEFINE»

«DEFINE installCreationRolePolicy FOR gmfgen::GenNode-»
«IF hasChildren(self) or hasChildrenInListCompartments(self)-»
	installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE, «EXPAND _creationEditPolicyNewInstance»);
«ENDIF-»
«ENDDEFINE»

«DEFINE _creationEditPolicyNewInstance FOR gmfgen::GenNode»new org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy()«ENDDEFINE»

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

«DEFINE installPrimaryDragEditPolicy FOR gmfgen::GenChildSideAffixedNode-»
		installEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE, getPrimaryDragEditPolicy());
«ENDDEFINE»

«DEFINE createLayoutEditPolicy FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected org.eclipse.gef.editpolicies.LayoutEditPolicy createLayoutEditPolicy() {
		«EXPAND createLayoutEditPolicyBody-»
	}
«ENDDEFINE»

«DEFINE createLayoutEditPolicyBody FOR gmfgen::GenNode-»
	«IF gmfgen::ViewmapLayoutType::XY_LAYOUT = getLayoutType()-»
		org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy() {

			protected org.eclipse.gef.EditPolicy createChildEditPolicy(org.eclipse.gef.EditPart child) {
				«EXPAND borderItemSelectionEditPolicy-»
				org.eclipse.gef.EditPolicy result = super.createChildEditPolicy(child);
				if (result == null) {
					return new org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableShapeEditPolicy();
				}
				return result;
			}
		};
		return lep;
	«ELSEIF gmfgen::ViewmapLayoutType::TOOLBAR_LAYOUT = getLayoutType()»
		org.eclipse.gmf.runtime.diagram.ui.editpolicies.ConstrainedToolbarLayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.ConstrainedToolbarLayoutEditPolicy() {

			protected org.eclipse.gef.EditPolicy createChildEditPolicy(org.eclipse.gef.EditPart child) {
				«EXPAND borderItemSelectionEditPolicy-»
				if (child.getEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE) == null) {
					if (child instanceof org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart) {
						return new «getDiagram().getTextSelectionEditPolicyQualifiedClassName()»();
					}
				}
				return super.createChildEditPolicy(child);
			}
		};
		return lep;
	«ELSEIF gmfgen::ViewmapLayoutType::FLOW_LAYOUT = getLayoutType()»
		org.eclipse.gef.editpolicies.FlowLayoutEditPolicy lep = new org.eclipse.gef.editpolicies.FlowLayoutEditPolicy() {

			«IF hasBorderItems(self)-»
			protected org.eclipse.gef.EditPolicy createChildEditPolicy(org.eclipse.gef.EditPart child) {
				«EXPAND borderItemSelectionEditPolicy-»
				return super.createChildEditPolicy(child);
			}
			«ENDIF-»

			protected org.eclipse.gef.commands.Command createAddCommand(org.eclipse.gef.EditPart child, org.eclipse.gef.EditPart after) {
				return null;
			}

			protected org.eclipse.gef.commands.Command createMoveChildCommand(org.eclipse.gef.EditPart child, org.eclipse.gef.EditPart after) {
				return null;
			}

			protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gef.requests.CreateRequest request) {
				return null;
			}
		};
		return lep;
	«ELSE-»
		org.eclipse.gef.editpolicies.LayoutEditPolicy lep = new org.eclipse.gef.editpolicies.LayoutEditPolicy() {

			protected org.eclipse.gef.EditPolicy createChildEditPolicy(org.eclipse.gef.EditPart child) {
				«EXPAND borderItemSelectionEditPolicy-»
				org.eclipse.gef.EditPolicy result = child.getEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE);
				if (result == null) {
					result = new org.eclipse.gef.editpolicies.NonResizableEditPolicy();
				}
				return result;
			}

			protected org.eclipse.gef.commands.Command getMoveChildrenCommand(org.eclipse.gef.Request request) {
				return null;
			}

			protected org.eclipse.gef.commands.Command getCreateCommand(org.eclipse.gef.requests.CreateRequest request) {
				return null;
			}
		};
		return lep;
	«ENDIF-»
«ENDDEFINE»

«DEFINE 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-»
	return new org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy();
«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»

«DEFINE createNodeShape(node : gmfgen::GenNode) FOR gmfgen::Viewmap-»
	«ERROR 'Unknown viewmap: ' + self.repr()-»
«ENDDEFINE»

«DEFINE createNodeShape(node : gmfgen::GenNode) FOR gmfgen::FigureViewmap-»
	«LET (if figureQualifiedClassName = null then 'org.eclipse.draw2d.RectangleFigure' else figureQualifiedClassName endif) AS fqn-»
		«EXPAND xpt::Common::generatedMemberComment»
		protected org.eclipse.draw2d.IFigure createNodeShape() {
			return primaryShape = new «fqn»()«IF node.getLayoutType() = gmfgen::ViewmapLayoutType::XY_LAYOUT»{
				protected boolean useLocalCoordinates() {
					return true;
				}
			}«ENDIF»;
		}

		«EXPAND getPrimaryShapeMethod FOR fqn-»
	«ENDLET-»
«ENDDEFINE»

«DEFINE createNodeShape(node : gmfgen::GenNode) FOR gmfgen::SnippetViewmap-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected org.eclipse.draw2d.IFigure createNodeShape() {
		return «body»;
	}
«ENDDEFINE»

«DEFINE createNodeShape(node : gmfgen::GenNode) FOR gmfgen::InnerClassViewmap-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected org.eclipse.draw2d.IFigure createNodeShape() {
		«className» figure = new «className»();
		«IF node.childNodes->size() > 0 and node.getLayoutType() = gmfgen::ViewmapLayoutType::XY_LAYOUT-»
 		figure.setUseLocalCoordinates(true);
		«ENDIF-»
 		return primaryShape = figure;
	}

	«EXPAND getPrimaryShapeMethod FOR className-»
«ENDDEFINE»

«DEFINE getPrimaryShapeMethod FOR String-»
	«EXPAND xpt::Common::generatedMemberComment»
	public «self» getPrimaryShape() {
		return («self») primaryShape;
	}
«ENDDEFINE»

«DEFINE 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-»
		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;
		}
«ENDFOREACH-»
		return false;
	}
«ENDDEFINE»

«DEFINE removeFixedChild FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected boolean removeFixedChild(org.eclipse.gef.EditPart childEditPart) {
«FOREACH getInnerFixedLabels(self) AS label»«LET label.viewmap.oclAsType(gmfgen::ParentAssignedViewmap) AS childViewmap-»
		if (childEditPart instanceof «label.getEditPartQualifiedClassName()») {
			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.remove(((«compartment.getEditPartQualifiedClassName()») childEditPart).getFigure());
			return true;
		}	
«ENDLET»«ENDFOREACH-»
«FOREACH getSideAffixedChildren(self) AS child-»
		if (childEditPart instanceof «child.getEditPartQualifiedClassName()») {
			getBorderedFigure().getBorderItemContainer().remove(((«child.getEditPartQualifiedClassName()») childEditPart).getFigure());
			return true;
		}
«ENDFOREACH-»
		return false;
	}
«ENDDEFINE»

«DEFINE addChildVisual FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected void addChildVisual(org.eclipse.gef.EditPart childEditPart, int index) {
		if (addFixedChild(childEditPart)) {
			return;
		}
		super.addChildVisual(childEditPart, -1);
	}
«ENDDEFINE»

«DEFINE removeChildVisual FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected void removeChildVisual(org.eclipse.gef.EditPart childEditPart) {
		if (removeFixedChild(childEditPart)){
			return;
		}
		super.removeChildVisual(childEditPart);
	}
«ENDDEFINE»

«DEFINE getContentPaneFor FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected org.eclipse.draw2d.IFigure getContentPaneFor(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart editPart) {
		«REM»it is unclear what we should return for labels here«ENDREM-»
«FOREACH getPinnedCompartments(self) AS compartment»«LET compartment.viewmap.oclAsType(gmfgen::ParentAssignedViewmap) AS childViewmap-»
		if (editPart instanceof «compartment.getEditPartQualifiedClassName()») {
			return getPrimaryShape().«childViewmap.getterName»();
		}	
«ENDLET»«ENDFOREACH-»
«IF hasBorderItems(self)-»
		if (editPart instanceof org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart) {
			return getBorderedFigure().getBorderItemContainer();
		}
«ENDIF-»
		return getContentPane();
	}
«ENDDEFINE»

«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 («FOREACH getExternalLabels(self) 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 {
				super.addBorderItem(borderItemContainer, borderItemEditPart);
			}
		}
	«ENDIF-»
«ENDDEFINE»

«DEFINE createNodePlate FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure createNodePlate() {
		org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure result = new org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure(«IF getDiagram().isPixelMapMode()»«defaultSizeWidth(viewmap, 40)», «defaultSizeHeight(viewmap, 40)»«ELSE»getMapMode().DPtoLP(«defaultSizeWidth(viewmap, 40)»), getMapMode().DPtoLP(«defaultSizeHeight(viewmap, 40)»)«ENDIF»);
		«EXPAND setupNodePlate-»
		return result;
	}
«ENDDEFINE»

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

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

«DEFINE getPrimaryDragEditPolicy FOR gmfgen::GenNode-»
	«LET getResizeConstraints(viewmap) AS rc-»
		«IF null <> primaryDragEditPolicyQualifiedClassName or null <> rc-»
			«EXPAND xpt::Common::generatedMemberComment»
			public org.eclipse.gef.EditPolicy getPrimaryDragEditPolicy() {
				«IF null <> primaryDragEditPolicyQualifiedClassName-»
					return new «primaryDragEditPolicyQualifiedClassName»();
				«ELSE-»
					org.eclipse.gef.EditPolicy result = super.getPrimaryDragEditPolicy();
					if (result instanceof org.eclipse.gef.editpolicies.ResizableEditPolicy) {
						org.eclipse.gef.editpolicies.ResizableEditPolicy ep = (org.eclipse.gef.editpolicies.ResizableEditPolicy) result;
						ep.setResizeDirections(
							«IF rc.resizeHandleNames->size() > 0-»
								«FOREACH rc.resizeHandleNames->asSequence() AS name SEPARATOR ' | '»org.eclipse.draw2d.PositionConstants.«name»«ENDFOREACH-»
							«ELSE»org.eclipse.draw2d.PositionConstants.NONE«ENDIF»);
					}
					return result;
				«ENDIF-»
			}
		«ENDIF-»
	«ENDLET-»
«ENDDEFINE»

«DEFINE createFigure FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment(
		'Creates figure for this edit part.\n' + 
		'\n' + 
		'Body of this method does not depend on settings in generation model\n' + 
		'so you may safely remove <i>generated</i> tag and modify it.\n'
	)»
	protected org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure create«IF hasBorderItems(self)»Main«ELSE»Node«ENDIF»Figure() {
		org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure figure = createNodePlate();
		figure.setLayoutManager(new org.eclipse.draw2d.StackLayout());
		org.eclipse.draw2d.IFigure shape = createNodeShape();
		figure.add(shape);
		contentPane = setupContentPane(shape);
		return figure;
	}
«ENDDEFINE»

«DEFINE setupContentPane FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment(
		'Default implementation treats passed figure as content pane.\n' + 
		'Respects layout one may have set for generated figure.\n' + 
		'@param nodeShape instance of generated figure class'
	)»
	protected org.eclipse.draw2d.IFigure setupContentPane(org.eclipse.draw2d.IFigure nodeShape) {
		«IF not childNodes->isEmpty() or (not compartments->isEmpty() or not labels->-((labels)[gmfgen::GenExternalNodeLabel])->isEmpty())-»
			if (nodeShape.getLayoutManager() == null) {
				«IF getLayoutType() = gmfgen::ViewmapLayoutType::XY_LAYOUT-»
					nodeShape.setLayoutManager(new org.eclipse.draw2d.FreeformLayout() {

						public Object getConstraint(org.eclipse.draw2d.IFigure figure) {
							Object result = constraints.get(figure);
							if (result == null) {
								result = new org.eclipse.draw2d.geometry.Rectangle(0, 0, -1, -1);
							}
							return result;
						}
					});
				«ELSE-»
					org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout layout =new org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout();
					layout.setSpacing(«IF getDiagram().isPixelMapMode()»5«ELSE»getMapMode().DPtoLP(5)«ENDIF»);
					nodeShape.setLayoutManager(layout);
				«ENDIF-»
			}
		«ENDIF-»
		return nodeShape; // use nodeShape itself as contentPane
	}
«ENDDEFINE»

«DEFINE getContentPane FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	public org.eclipse.draw2d.IFigure getContentPane() {
		if (contentPane != null) {
			return contentPane;
		}
		return super.getContentPane();
	}
«ENDDEFINE»

«DEFINE setForegroundColor FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected void setForegroundColor(org.eclipse.swt.graphics.Color color) {
		if (primaryShape != null) {
			primaryShape.setForegroundColor(color);
		}
	}
«ENDDEFINE»

«DEFINE setBackgroundColor FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected void setBackgroundColor(org.eclipse.swt.graphics.Color color) {
		if (primaryShape != null) {
			primaryShape.setBackgroundColor(color);
		}
	}
«ENDDEFINE»

«DEFINE setLineWidth FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected void setLineWidth(int width) {
		if (primaryShape instanceof org.eclipse.draw2d.Shape) {
			((org.eclipse.draw2d.Shape) primaryShape).setLineWidth(«IF getDiagram().isPixelMapMode()»width«ELSE»getMapMode().DPtoLP(width)«ENDIF»);
		}
	}
«ENDDEFINE»

«DEFINE setLineStyle FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	protected void setLineType(int style) {
		if (primaryShape instanceof org.eclipse.draw2d.Shape) {
			((org.eclipse.draw2d.Shape) primaryShape).setLineStyle(style);
		}
	}
«ENDDEFINE»

«DEFINE getPrimaryChildEditPart FOR gmfgen::GenNode-»
	«IF not labels->isEmpty()-»
		«EXPAND xpt::Common::generatedMemberComment»
		public org.eclipse.gef.EditPart getPrimaryChildEditPart() {
			return getChildBySemanticHint(«EXPAND xpt::editor::VisualIDRegistry::typeMethodCall FOR labels->first().oclAsType(gmfgen::GenLabel)»);
		}
	«ENDIF-»
«ENDDEFINE»

// pre: getAssistantOutgoingLinks(this).size() > 0
«DEFINE getMARelTypesOnSource FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	public java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ getMARelTypesOnSource() {
		java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ types = new java.util.ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
		«FOREACH getAssistantOutgoingLinks(self) AS link-»
		types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR link»);
		«ENDFOREACH-»
		return types;
	}
«ENDDEFINE»

// pre: getAssistantIncomingLinks(this).size() > 0
«DEFINE getMARelTypesOnTarget FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	public java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ getMARelTypesOnTarget() {
		java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ types = new java.util.ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
		«FOREACH getAssistantIncomingLinks(self) AS link-»
		types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR link»);
		«ENDFOREACH-»
		return types;
	}
«ENDDEFINE»

// pre: getAssistantOutgoingLinks(this).size() > 0
«DEFINE getMARelTypesOnSourceAndTarget FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	public java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ getMARelTypesOnSourceAndTarget(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart targetEditPart) {
		java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ types = new java.util.ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
		«FOREACH getAssistantOutgoingLinks(self) AS link-»
			«FOREACH selectGenNodes(link.targets->asSequence()) AS target-»
		if (targetEditPart instanceof «target.getEditPartQualifiedClassName()») {
			types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR link»);
		}
			«ENDFOREACH-»
		«ENDFOREACH-»
		return types;
	}
«ENDDEFINE»

// pre: getAssistantIncomingLinks(this).size() > 0
«DEFINE getMATypesForSource FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	public java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ getMATypesForSource(org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
		java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ types = new java.util.ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
		«FOREACH getAssistantIncomingLinks(self) AS link-»
			«FOREACH selectGenNodes(link.sources->asSequence()) AS source-»
		if (relationshipType == «EXPAND xpt::providers::ElementTypes::accessElementType FOR link») {
			types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR source»);
		}
			«ENDFOREACH-»
		«ENDFOREACH-»
		return types;
	}
«ENDDEFINE»

// pre: getAssistantOutgoingLinks(this).size() > 0
«DEFINE getMATypesForTarget FOR gmfgen::GenNode-»
	«EXPAND xpt::Common::generatedMemberComment»
	public java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ getMATypesForTarget(org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
		java.util.List/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/ types = new java.util.ArrayList/*<org.eclipse.gmf.runtime.emf.type.core.IElementType>*/();
		«FOREACH getAssistantOutgoingLinks(self) AS link-»
			«FOREACH (link.targets)[gmfgen::GenNode]->asSequence() AS target-»
		if (relationshipType == «EXPAND xpt::providers::ElementTypes::accessElementType FOR link») {
			types.add(«EXPAND xpt::providers::ElementTypes::accessElementType FOR target»);
		}
			«ENDFOREACH-»
		«ENDFOREACH-»
		return types;
	}
«ENDDEFINE»

«DEFINE handleNotificationEventBody FOR gmfgen::GenTopLevelNode-»
	if (event.getNotifier() == getModel() && org.eclipse.emf.ecore.EcorePackage.eINSTANCE.getEModelElement_EAnnotations().equals(event.getFeature())) {
		handleMajorSemanticChange();
	} else {
		super.handleNotificationEvent(event);
	}
«ENDDEFINE»

«DEFINE innerClassDeclaration FOR gmfgen::Viewmap»
«ENDDEFINE»

«DEFINE innerClassDeclaration FOR gmfgen::InnerClassViewmap»
	«classBody»
«ENDDEFINE»

«DEFINE getTargetEditPartMethod FOR gmfgen::GenNode»
	«EXPAND xpt::Common::generatedMemberComment»
	public org.eclipse.gef.EditPart getTargetEditPart(org.eclipse.gef.Request request) {
		if (request instanceof org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest) {
			org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter adapter = ((org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter();
			org.eclipse.gmf.runtime.emf.type.core.IElementType type = (org.eclipse.gmf.runtime.emf.type.core.IElementType) adapter.getAdapter(org.eclipse.gmf.runtime.emf.type.core.IElementType.class);
«FOREACH compartments->asSequence() AS compartment-»
	«IF listCompartmentHasChildren(compartment)-»
		«FOREACH compartment.childNodes->asSequence() AS childNode-»
			if (type == «EXPAND xpt::providers::ElementTypes::accessElementType FOR childNode») {
				return getChildBySemanticHint(«EXPAND xpt::editor::VisualIDRegistry::typeMethodCall FOR compartment»);
			}
		«ENDFOREACH-»
	«ENDIF-»
«ENDFOREACH-»
		}
		return super.getTargetEditPart(request);
	}
«ENDDEFINE»

Back to the top