Removed
Link Here
|
1 |
<%@ jet package="org.eclipse.gmf.codegen.templates.parts" class="NodeEditPartGenerator" |
2 |
imports="java.util.* org.eclipse.emf.codegen.ecore.genmodel.* org.eclipse.gmf.codegen.gmfgen.* org.eclipse.gmf.common.codegen.*" |
3 |
skeleton="../common.skeleton"%> |
4 |
<% |
5 |
final GenNode genNode = (GenNode) ((Object[]) argument)[0]; |
6 |
final ImportAssistant importManager = (ImportAssistant) ((Object[]) argument)[1]; |
7 |
GenDiagram genDiagram = genNode.getDiagram(); |
8 |
boolean isXYLayout = ViewmapLayoutType.XY_LAYOUT_LITERAL.equals(genNode.getLayoutType()); |
9 |
|
10 |
class NodeEditPartHelper { |
11 |
private final List myInnerLabels = new LinkedList(); |
12 |
private final List myExternalLabels = new LinkedList(); |
13 |
private final List myPinnedCompartments = new LinkedList(); |
14 |
private final List myFloatingCompartments = new LinkedList(); |
15 |
private GenNodeLabel myPrimaryLabel; |
16 |
private boolean myHasChildrenInListCompartments = false; |
17 |
|
18 |
public NodeEditPartHelper(GenNode genNode){ |
19 |
myPrimaryLabel = null; |
20 |
|
21 |
for (Iterator labels = genNode.getLabels().iterator(); labels.hasNext();) { |
22 |
GenNodeLabel next = (GenNodeLabel) labels.next(); |
23 |
if (myPrimaryLabel == null){ |
24 |
myPrimaryLabel = next; |
25 |
} |
26 |
if (next instanceof GenExternalNodeLabel) { |
27 |
myExternalLabels.add(next); |
28 |
} else if (next.getViewmap() instanceof ParentAssignedViewmap) { |
29 |
myInnerLabels.add(next); |
30 |
} |
31 |
} |
32 |
|
33 |
for (Iterator compartments = genNode.getCompartments().iterator(); compartments.hasNext();){ |
34 |
GenCompartment next = (GenCompartment) compartments.next(); |
35 |
if (next.getViewmap() instanceof ParentAssignedViewmap){ |
36 |
myPinnedCompartments.add(next); |
37 |
} else { |
38 |
myFloatingCompartments.add(next); |
39 |
} |
40 |
|
41 |
myHasChildrenInListCompartments |= next.isListLayout() && !next.getChildNodes().isEmpty(); |
42 |
} |
43 |
} |
44 |
|
45 |
public boolean hasChildrenInListCompartments(){ |
46 |
return myHasChildrenInListCompartments; |
47 |
} |
48 |
|
49 |
public boolean hasInnerFixedLabels(){ |
50 |
return !myInnerLabels.isEmpty(); |
51 |
} |
52 |
|
53 |
public boolean hasPinnedCompartments(){ |
54 |
return !myPinnedCompartments.isEmpty(); |
55 |
} |
56 |
|
57 |
public boolean hasFixedChildren(){ |
58 |
return hasInnerFixedLabels() || hasPinnedCompartments(); |
59 |
} |
60 |
|
61 |
public boolean hasExternalLabels(){ |
62 |
return !myExternalLabels.isEmpty(); |
63 |
} |
64 |
|
65 |
public GenNodeLabel getPrimaryLabel(){ |
66 |
return myPrimaryLabel; |
67 |
} |
68 |
|
69 |
public Iterator getInnerFixedLabels(){ |
70 |
return myInnerLabels.iterator(); |
71 |
} |
72 |
|
73 |
public Iterator getExternalLabels(){ |
74 |
return myExternalLabels.iterator(); |
75 |
} |
76 |
|
77 |
public Iterator getPinnedCompartments(){ |
78 |
return myPinnedCompartments.iterator(); |
79 |
} |
80 |
} |
81 |
final NodeEditPartHelper myHelper = new NodeEditPartHelper(genNode); |
82 |
// [graphdef++] |
83 |
GenClass metaclass = genNode.getModelFacet().getMetaClass(); |
84 |
boolean generateSyncronizationCode = genNode.getViewmap() instanceof InnerClassViewmap && metaclass.getEcoreClass().getEAllSuperTypes().contains(metaclass.getEcoreClass().getEPackage().getEClassifier("FigureMarker")); |
85 |
// [graphdef--] |
86 |
%> |
87 |
<%@ include file="../copyright4java.jetinc"%> |
88 |
<%importManager.emitPackageStatement(stringBuffer);%> |
89 |
|
90 |
<% |
91 |
if (genNode.getViewmap() instanceof InnerClassViewmap) { |
92 |
importManager.registerInnerClass(((InnerClassViewmap) genNode.getViewmap()).getClassName()); |
93 |
} |
94 |
importManager.addImport("org.eclipse.draw2d.IFigure"); |
95 |
importManager.addImport("org.eclipse.draw2d.StackLayout"); |
96 |
importManager.addImport("org.eclipse.gef.EditPolicy"); |
97 |
importManager.addImport("org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles"); |
98 |
importManager.addImport("org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure"); |
99 |
importManager.addImport("org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure"); |
100 |
importManager.addImport("org.eclipse.gmf.runtime.notation.View"); |
101 |
importManager.markImportLocation(stringBuffer); |
102 |
%> |
103 |
|
104 |
/** |
105 |
* @generated |
106 |
*/ |
107 |
public class <%=genNode.getEditPartClassName()%> extends <%=/*[graphdef++]*/generateSyncronizationCode ? importManager.getImportedName(genDiagram.getEditPartsPackageName() + ".AbstractFigureEditPart") : importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart")/*[graphdef++]*/%> { |
108 |
<%{ |
109 |
GenCommonBase genCommonBase = genNode;%> |
110 |
<%@ include file="visualID.jetinc"%> |
111 |
<%}%> |
112 |
|
113 |
/** |
114 |
* @generated |
115 |
*/ |
116 |
protected IFigure contentPane; |
117 |
|
118 |
<% |
119 |
// [graphdef++] |
120 |
if (generateSyncronizationCode) { |
121 |
%> |
122 |
/** |
123 |
* @generated |
124 |
*/ |
125 |
private <%=((InnerClassViewmap) genNode.getViewmap()).getClassName()%> myFigure; |
126 |
|
127 |
// TODO: use myFigure? |
128 |
/** |
129 |
* @generated |
130 |
*/ |
131 |
protected <%=importManager.getImportedName("org.eclipse.draw2d.Figure")%> myNodeFigure; |
132 |
|
133 |
<% |
134 |
} |
135 |
// [graphdef--] |
136 |
%> |
137 |
/** |
138 |
* @generated |
139 |
*/ |
140 |
protected IFigure primaryShape; |
141 |
|
142 |
/** |
143 |
* @generated |
144 |
*/ |
145 |
public <%=genNode.getEditPartClassName()%>(View view) { |
146 |
super(view); |
147 |
} |
148 |
<% |
149 |
// [graphdef++] |
150 |
if (generateSyncronizationCode) { |
151 |
String modelInterfaceName = importManager.getImportedName(metaclass.getQualifiedInterfaceName()); |
152 |
%> |
153 |
|
154 |
/** |
155 |
* @generated |
156 |
*/ |
157 |
public void activate() { |
158 |
if (isActive()){ |
159 |
return; |
160 |
} |
161 |
View view = (View) getModel(); |
162 |
if (view.getElement() == null) { |
163 |
super.activate(); |
164 |
return; |
165 |
} |
166 |
|
167 |
final <%=modelInterfaceName%> modelElement = (<%=modelInterfaceName%>) view.getElement(); |
168 |
|
169 |
<% |
170 |
for (Iterator genFeatures = metaclass.getAllGenFeatures().iterator(); genFeatures.hasNext();) { |
171 |
GenFeature nextGenFeature = (GenFeature) genFeatures.next(); |
172 |
if (skip(nextGenFeature)) { |
173 |
continue; |
174 |
} |
175 |
String packageInterfaceName = metaclass.getGenPackage().getQualifiedPackageInterfaceName(); |
176 |
if (false == nextGenFeature.getTypeGenClassifier() instanceof GenDataType) { |
177 |
%> |
178 |
final <%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener")%> <%=nextGenFeature.getFeatureAccessorName()%>_PropertiesListener = new <%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener")%>() { |
179 |
public void notifyChanged(Notification notification) { |
180 |
<%=getProcessChangesCall("modelElement", nextGenFeature)%>; |
181 |
} |
182 |
}; |
183 |
<%@ include file="addFeaturePropertyChangeListeners.jetinc"%> |
184 |
<% }%> |
185 |
addListenerFilter("<%=nextGenFeature.getFeatureAccessorName()%>_Listener", new <%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener")%>() { |
186 |
public void notifyChanged(<%=importManager.getImportedName("org.eclipse.emf.common.notify.Notification")%> notification) { |
187 |
<% if (false == nextGenFeature.getTypeGenClassifier() instanceof GenDataType) { |
188 |
if (nextGenFeature.isListType()) {%> |
189 |
int listSize = modelElement.<%=nextGenFeature.getGetAccessor()%>().size(); |
190 |
if (notification.getOldValue() instanceof <%=importManager.getImportedName("java.util.Collection")%>) { |
191 |
listSize += ((<%=importManager.getImportedName("java.util.Collection")%>) notification.getOldValue()).size(); |
192 |
} else { |
193 |
listSize++; |
194 |
} |
195 |
for (int i = 0; i < listSize; i++) { |
196 |
removeListenerFilter("<%=nextGenFeature.getFeatureAccessorName()%>_PropertiesListener#" + i); |
197 |
} |
198 |
<% } else {%> |
199 |
removeListenerFilter("<%=nextGenFeature.getFeatureAccessorName()%>_PropertiesListener"); |
200 |
<% }%> |
201 |
<%@ include file="addFeaturePropertyChangeListeners.jetinc"%> |
202 |
<% }%> |
203 |
<%=getProcessChangesCall("modelElement", nextGenFeature)%>; |
204 |
} |
205 |
}, modelElement, <%=importManager.getImportedName(nextGenFeature.getGenPackage().getQualifiedPackageInterfaceName())%>.eINSTANCE.get<%=nextGenFeature.getFeatureAccessorName()%>()); |
206 |
|
207 |
<% }%> |
208 |
final <%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Bounds")%> bounds = (<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Bounds")%>) ((<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Node")%>) view).getLayoutConstraint(); |
209 |
final int sizeX; |
210 |
final int sizeY; |
211 |
if (modelElement.getPreferredSize() != null) { |
212 |
sizeX = getMapMode().DPtoLP(modelElement.getPreferredSize().getDx()); |
213 |
sizeY = getMapMode().DPtoLP(modelElement.getPreferredSize().getDy()); |
214 |
} else { |
215 |
sizeX = getMapMode().DPtoLP(20); |
216 |
sizeY = getMapMode().DPtoLP(20); |
217 |
} |
218 |
final int locationX; |
219 |
final int locationY; |
220 |
if (modelElement.getLocation() != null) { |
221 |
locationX = getMapMode().DPtoLP(modelElement.getLocation().getX()); |
222 |
locationY = getMapMode().DPtoLP(modelElement.getLocation().getY()); |
223 |
} else { |
224 |
locationX = bounds.getX(); |
225 |
locationY = bounds.getY(); |
226 |
} |
227 |
if (sizeX != bounds.getWidth() || sizeY != bounds.getHeight() || locationX != bounds.getX() || locationY != bounds.getY()) { |
228 |
try { |
229 |
new <%=importManager.getImportedName("org.eclipse.emf.workspace.AbstractEMFOperation")%>(getEditingDomain(), "Synchronizing view size with the model", <%=importManager.getImportedName("java.util.Collections")%>.singletonMap(<%=importManager.getImportedName("org.eclipse.emf.transaction.Transaction")%>.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$ |
230 |
protected <%=importManager.getImportedName("org.eclipse.core.runtime.IStatus")%> doExecute(<%=importManager.getImportedName("org.eclipse.core.runtime.IProgressMonitor")%> monitor, <%=importManager.getImportedName("org.eclipse.core.runtime.IAdaptable")%> info) throws <%=importManager.getImportedName("org.eclipse.core.commands.ExecutionException")%> { |
231 |
bounds.setX(locationX); |
232 |
bounds.setY(locationY); |
233 |
bounds.setWidth(sizeX); |
234 |
bounds.setHeight(sizeY); |
235 |
return <%=importManager.getImportedName("org.eclipse.core.runtime.Status")%>.OK_STATUS; |
236 |
} |
237 |
}.execute(new <%=importManager.getImportedName("org.eclipse.core.runtime.NullProgressMonitor")%>(), null); |
238 |
} catch (<%=importManager.getImportedName("org.eclipse.core.commands.ExecutionException")%> e) { |
239 |
<%=importManager.getImportedName(genDiagram.getEditorGen().getPlugin().getActivatorQualifiedClassName())%>.getInstance().logError("Unable to synchronize view size with the model", e); //$NON-NLS-1$ |
240 |
} |
241 |
} |
242 |
addListenerFilter("BoundsListener", new <%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener")%>() { |
243 |
public void notifyChanged(final <%=importManager.getImportedName("org.eclipse.emf.common.notify.Notification")%> notification) { |
244 |
try { |
245 |
new <%=importManager.getImportedName("org.eclipse.emf.workspace.AbstractEMFOperation")%>(getEditingDomain(), "Synchronizing model size with the view", <%=importManager.getImportedName("java.util.Collections")%>.singletonMap(<%=importManager.getImportedName("org.eclipse.emf.transaction.Transaction")%>.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$ |
246 |
protected <%=importManager.getImportedName("org.eclipse.core.runtime.IStatus")%> doExecute(<%=importManager.getImportedName("org.eclipse.core.runtime.IProgressMonitor")%> monitor, <%=importManager.getImportedName("org.eclipse.core.runtime.IAdaptable")%> info) throws <%=importManager.getImportedName("org.eclipse.core.commands.ExecutionException")%> { |
247 |
<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Bounds")%> bounds = (<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.Bounds")%>) notification.getNotifier(); |
248 |
<%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.Dimension")%> dim = modelElement.getPreferredSize(); |
249 |
if (dim == null) { |
250 |
dim = <%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.GMFGraphFactory")%>.eINSTANCE.createDimension(); |
251 |
modelElement.setPreferredSize(dim); |
252 |
} |
253 |
<%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.Point")%> location = modelElement.getLocation(); |
254 |
if (location == null) { |
255 |
location = <%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.GMFGraphFactory")%>.eINSTANCE.createPoint(); |
256 |
modelElement.setLocation(location); |
257 |
} |
258 |
|
259 |
int x = getMapMode().LPtoDP(bounds.getX()); |
260 |
int y = getMapMode().LPtoDP(bounds.getY()); |
261 |
int width = getMapMode().LPtoDP(bounds.getWidth()); |
262 |
int height = getMapMode().LPtoDP(bounds.getHeight()); |
263 |
if (location.getX() != x || location.getY() != y) { |
264 |
location.setX(x); |
265 |
location.setY(y); |
266 |
} |
267 |
if (dim.getDx() != width || dim.getDy() != height) { |
268 |
dim.setDx(width); |
269 |
dim.setDy(height); |
270 |
} |
271 |
|
272 |
myNodeFigure.setPreferredSize(bounds.getWidth(), bounds.getHeight()); |
273 |
myNodeFigure.setLocation(new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Point")%>(bounds.getX(), bounds.getY())); |
274 |
|
275 |
if (modelElement.getLayoutData() instanceof <%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.XYLayoutData")%> || (modelElement.getParent() != null && modelElement.getParent().getLayout() instanceof <%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.XYLayout")%>)) { |
276 |
<%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.XYLayoutData")%> xyLayoutData = (<%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.XYLayoutData")%>) modelElement.getLayoutData(); |
277 |
if (xyLayoutData == null) { |
278 |
xyLayoutData = <%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.GMFGraphFactory")%>.eINSTANCE.createXYLayoutData(); |
279 |
modelElement.setLayoutData(xyLayoutData); |
280 |
xyLayoutData.setTopLeft(<%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.GMFGraphFactory")%>.eINSTANCE.createPoint()); |
281 |
xyLayoutData.getTopLeft().setX(0); |
282 |
xyLayoutData.getTopLeft().setY(0); |
283 |
xyLayoutData.setSize(<%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.GMFGraphFactory")%>.eINSTANCE.createDimension()); |
284 |
xyLayoutData.getSize().setDx(40); |
285 |
xyLayoutData.getSize().setDy(40); |
286 |
} |
287 |
<%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.Point")%> topLeft; |
288 |
if (xyLayoutData.getTopLeft() != null) { |
289 |
topLeft = xyLayoutData.getTopLeft(); |
290 |
} else { |
291 |
topLeft = <%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.GMFGraphFactory")%>.eINSTANCE.createPoint(); |
292 |
xyLayoutData.setTopLeft(topLeft); |
293 |
} |
294 |
if (topLeft.getX() != location.getX() || topLeft.getY() != location.getY()) { |
295 |
topLeft.setX(location.getX()); |
296 |
topLeft.setY(location.getY()); |
297 |
} |
298 |
|
299 |
<%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.Dimension")%> size; |
300 |
if (xyLayoutData.getSize() != null) { |
301 |
size = xyLayoutData.getSize(); |
302 |
} else { |
303 |
size = <%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.GMFGraphFactory")%>.eINSTANCE.createDimension(); |
304 |
xyLayoutData.setSize(size); |
305 |
} |
306 |
if (size.getDx() != dim.getDx() || size.getDy() != dim.getDy()) { |
307 |
size.setDx(dim.getDx()); |
308 |
size.setDy(dim.getDy()); |
309 |
} |
310 |
} |
311 |
return <%=importManager.getImportedName("org.eclipse.core.runtime.Status")%>.OK_STATUS; |
312 |
} |
313 |
}.execute(new <%=importManager.getImportedName("org.eclipse.core.runtime.NullProgressMonitor")%>(), null); |
314 |
} catch (<%=importManager.getImportedName("org.eclipse.core.commands.ExecutionException")%> e) { |
315 |
<%=importManager.getImportedName(genDiagram.getEditorGen().getPlugin().getActivatorQualifiedClassName())%>.getInstance().logError("Unable to synchronize model size with the view", e); //$NON-NLS-1$ |
316 |
} |
317 |
if (getRoot() != null) { |
318 |
handleMajorSemanticChange(); |
319 |
} |
320 |
} |
321 |
}, bounds); |
322 |
|
323 |
<% |
324 |
String shapeStyleInterface = importManager.getImportedName("org.eclipse.gmf.runtime.notation.ShapeStyle"); |
325 |
String notationPackageInterfaceName = importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage"); |
326 |
%> |
327 |
final <%=shapeStyleInterface%> shapeStyle = (<%=shapeStyleInterface%>) view.getStyle(<%=notationPackageInterfaceName%>.eINSTANCE.getShapeStyle()); |
328 |
<% { |
329 |
String modelColorProperty = "Background"; |
330 |
String viewColorProperty = "Fill";%> |
331 |
<%@ include file = "setViewColor.javajet"%> |
332 |
<% }%> |
333 |
<% { |
334 |
String modelColorProperty = "Foreground"; |
335 |
String viewColorProperty = "Line";%> |
336 |
<%@ include file = "setViewColor.javajet"%> |
337 |
<% }%> |
338 |
addListenerFilter("ShapeStyleListener", new <%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener")%>() { |
339 |
public void notifyChanged(final <%=importManager.getImportedName("org.eclipse.emf.common.notify.Notification")%> notification) { |
340 |
try { |
341 |
new <%=importManager.getImportedName("org.eclipse.emf.workspace.AbstractEMFOperation")%>(getEditingDomain(), "Synchronizing model size with the view", <%=importManager.getImportedName("java.util.Collections")%>.singletonMap(<%=importManager.getImportedName("org.eclipse.emf.transaction.Transaction")%>.OPTION_UNPROTECTED, Boolean.TRUE)) { //$NON-NLS-1$ |
342 |
protected <%=importManager.getImportedName("org.eclipse.core.runtime.IStatus")%> doExecute(<%=importManager.getImportedName("org.eclipse.core.runtime.IProgressMonitor")%> monitor, <%=importManager.getImportedName("org.eclipse.core.runtime.IAdaptable")%> info) throws <%=importManager.getImportedName("org.eclipse.core.commands.ExecutionException")%> { |
343 |
<%=shapeStyleInterface%> shapeStyle = (<%=shapeStyleInterface%>) notification.getNotifier(); |
344 |
switch (notification.getFeatureID(<%=shapeStyleInterface%>.class)) { |
345 |
case <%=notationPackageInterfaceName%>.SHAPE_STYLE__FILL_COLOR: |
346 |
{ |
347 |
int color = shapeStyle.getFillColor(); |
348 |
<%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.RGBColor")%> modelColor; |
349 |
if (modelElement.getBackgroundColor() instanceof <%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.RGBColor")%>) { |
350 |
modelColor = (<%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.RGBColor")%>) modelElement.getBackgroundColor(); |
351 |
} else { |
352 |
modelColor = <%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.GMFGraphFactory")%>.eINSTANCE.createRGBColor(); |
353 |
modelElement.setBackgroundColor(modelColor); |
354 |
} |
355 |
if (modelColor.getRed() != (color & 0x000000FF) || modelColor.getGreen() != (color & 0x0000FF00) >> 8 || modelColor.getBlue() != (color & 0x00FF0000) >> 16) { |
356 |
modelColor.setRed(color & 0x000000FF); |
357 |
modelColor.setGreen((color & 0x0000FF00) >> 8); |
358 |
modelColor.setBlue((color & 0x00FF0000) >> 16); |
359 |
} |
360 |
break; |
361 |
} |
362 |
case <%=notationPackageInterfaceName%>.SHAPE_STYLE__LINE_COLOR: |
363 |
{ |
364 |
int color = shapeStyle.getLineColor(); |
365 |
<%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.RGBColor")%> modelColor; |
366 |
if (modelElement.getForegroundColor() instanceof <%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.RGBColor")%>) { |
367 |
modelColor = (<%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.RGBColor")%>) modelElement.getForegroundColor(); |
368 |
} else { |
369 |
modelColor = <%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.GMFGraphFactory")%>.eINSTANCE.createRGBColor(); |
370 |
modelElement.setForegroundColor(modelColor); |
371 |
} |
372 |
if (modelColor.getRed() != (color & 0x000000FF) || modelColor.getGreen() != (color & 0x0000FF00) >> 8 || modelColor.getBlue() != (color & 0x00FF0000) >> 16) { |
373 |
modelColor.setRed(color & 0x000000FF); |
374 |
modelColor.setGreen((color & 0x0000FF00) >> 8); |
375 |
modelColor.setBlue((color & 0x00FF0000) >> 16); |
376 |
} |
377 |
break; |
378 |
} |
379 |
} |
380 |
return <%=importManager.getImportedName("org.eclipse.core.runtime.Status")%>.OK_STATUS; |
381 |
} |
382 |
}.execute(new <%=importManager.getImportedName("org.eclipse.core.runtime.NullProgressMonitor")%>(), null); |
383 |
} catch (<%=importManager.getImportedName("org.eclipse.core.commands.ExecutionException")%> e) { |
384 |
<%=importManager.getImportedName(genDiagram.getEditorGen().getPlugin().getActivatorQualifiedClassName())%>.getInstance().logError("Unable to synchronize model size with the view", e); //$NON-NLS-1$ |
385 |
} |
386 |
} |
387 |
}, shapeStyle); |
388 |
super.activate(); |
389 |
} |
390 |
<% |
391 |
} |
392 |
// [graphdef--] |
393 |
%> |
394 |
|
395 |
/** |
396 |
* @generated |
397 |
*/ |
398 |
protected void createDefaultEditPolicies() { |
399 |
<% |
400 |
if (!genNode.getChildNodes().isEmpty() || myHelper.hasChildrenInListCompartments()) { |
401 |
%> |
402 |
installEditPolicy(EditPolicyRoles.CREATION_ROLE, new <%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy")%>() |
403 |
<% if (myHelper.hasChildrenInListCompartments()) {%> |
404 |
{ |
405 |
|
406 |
public <%=importManager.getImportedName("org.eclipse.gef.commands.Command")%> getCommand(<%=importManager.getImportedName("org.eclipse.gef.Request")%> request) { |
407 |
if (understandsRequest(request)) { |
408 |
if (request instanceof <%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest")%>) { |
409 |
<%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter")%> adapter = |
410 |
((<%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest")%>) request).getViewAndElementDescriptor().getCreateElementRequestAdapter(); |
411 |
<%=importManager.getImportedName("org.eclipse.gmf.runtime.emf.type.core.IElementType")%> type = |
412 |
(<%=importManager.getImportedName("org.eclipse.gmf.runtime.emf.type.core.IElementType")%>) adapter.getAdapter(<%=importManager.getImportedName("org.eclipse.gmf.runtime.emf.type.core.IElementType")%>.class); |
413 |
<% |
414 |
for (Iterator compartments = genNode.getCompartments().iterator(); compartments.hasNext();) { |
415 |
GenCompartment compartment = (GenCompartment) compartments.next(); |
416 |
if (compartment.isListLayout() && !compartment.getChildNodes().isEmpty()) { |
417 |
for (Iterator children = compartment.getChildNodes().iterator(); children.hasNext(); ) { |
418 |
GenNode child = (GenNode) children.next(); |
419 |
%> |
420 |
if (type == <%=importManager.getImportedName(genDiagram.getElementTypesQualifiedClassName())%>.<%=child.getUniqueIdentifier()%>) { |
421 |
<%=importManager.getImportedName("org.eclipse.gef.EditPart")%> compartmentEditPart = |
422 |
getChildBySemanticHint(<%=importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())%>.getType(<%=importManager.getImportedName(compartment.getEditPartQualifiedClassName())%>.VISUAL_ID)); |
423 |
return compartmentEditPart == null ? null : compartmentEditPart.getCommand(request); |
424 |
} |
425 |
<% |
426 |
} |
427 |
} |
428 |
} |
429 |
%> |
430 |
} |
431 |
return super.getCommand(request); |
432 |
} |
433 |
return null; |
434 |
} |
435 |
} |
436 |
<% }%> |
437 |
); |
438 |
<%}%> |
439 |
super.createDefaultEditPolicies(); |
440 |
installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new <%=importManager.getImportedName(genNode.getItemSemanticEditPolicyQualifiedClassName())%>()); |
441 |
installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new <%=importManager.getImportedName(genNode.getGraphicalNodeEditPolicyQualifiedClassName())%>()); |
442 |
<%if (!genNode.getChildNodes().isEmpty()) {%> |
443 |
installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new <%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy")%>()); |
444 |
<%} |
445 |
|
446 |
if (genDiagram.isSynchronized()) {%> |
447 |
installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new <%=importManager.getImportedName(genNode.getCanonicalEditPolicyQualifiedClassName())%>()); |
448 |
<%}%> |
449 |
installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); |
450 |
} |
451 |
|
452 |
/** |
453 |
* @generated |
454 |
*/ |
455 |
protected <%=importManager.getImportedName("org.eclipse.gef.editpolicies.LayoutEditPolicy")%> createLayoutEditPolicy() { |
456 |
<% |
457 |
final String fqnEditPart = importManager.getImportedName("org.eclipse.gef.EditPart"); |
458 |
switch(genNode.getLayoutType().getValue()){ |
459 |
case ViewmapLayoutType.XY_LAYOUT: |
460 |
%> |
461 |
<%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy")%> lep = new <%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy")%>() { |
462 |
<% if (myHelper.hasExternalLabels()) {%> |
463 |
|
464 |
protected void decorateChild(EditPart child) { |
465 |
if (isExternalLabel(child)) { |
466 |
return; |
467 |
} |
468 |
super.decorateChild(child); |
469 |
} |
470 |
<% }%> |
471 |
|
472 |
protected EditPolicy createChildEditPolicy(<%=fqnEditPart%> child) { |
473 |
EditPolicy result = super.createChildEditPolicy(child); |
474 |
if (result == null) { |
475 |
return new <%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableShapeEditPolicy")%>(); |
476 |
} |
477 |
return result; |
478 |
} |
479 |
|
480 |
<% |
481 |
// [graphdef++] |
482 |
if (generateSyncronizationCode) { |
483 |
%> |
484 |
protected <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Point")%> getLayoutOrigin() { |
485 |
return ((<%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart")%>)getHost()).getContentPane().getClientArea().getLocation(); |
486 |
} |
487 |
|
488 |
protected <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Rectangle")%> getCurrentConstraintFor(<%=importManager.getImportedName("org.eclipse.gef.GraphicalEditPart")%> child) { |
489 |
<%=importManager.getImportedName("org.eclipse.draw2d.geometry.Rectangle")%> result = super.getCurrentConstraintFor(child); |
490 |
if (result == null) { |
491 |
IFigure fig = child.getFigure(); |
492 |
result = fig.getBounds().getCopy(); |
493 |
} |
494 |
return result; |
495 |
} |
496 |
|
497 |
<% |
498 |
} |
499 |
// [graphdef--] |
500 |
%> |
501 |
}; |
502 |
<% if (myHelper.hasExternalLabels()) {%> |
503 |
<%=importManager.getImportedName(genDiagram.getExternalNodeLabelHostLayoutEditPolicyQualifiedClassName())%> xlep = new <%=importManager.getImportedName(genDiagram.getExternalNodeLabelHostLayoutEditPolicyQualifiedClassName())%>() { |
504 |
|
505 |
protected boolean isExternalLabel(EditPart editPart) { |
506 |
return <%=genNode.getEditPartClassName()%>.this.isExternalLabel(editPart); |
507 |
} |
508 |
}; |
509 |
xlep.setRealLayoutEditPolicy(lep); |
510 |
return xlep; |
511 |
<% } else {%> |
512 |
return lep; |
513 |
<% |
514 |
} |
515 |
break; |
516 |
case ViewmapLayoutType.TOOLBAR_LAYOUT: |
517 |
%> |
518 |
<%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editpolicies.ConstrainedToolbarLayoutEditPolicy")%> lep = new <%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editpolicies.ConstrainedToolbarLayoutEditPolicy")%>() { |
519 |
<% if (myHelper.hasExternalLabels()) {%> |
520 |
|
521 |
protected void decorateChild(EditPart child) { |
522 |
if (isExternalLabel(child)) { |
523 |
return; |
524 |
} |
525 |
super.decorateChild(child); |
526 |
} |
527 |
<% }%> |
528 |
|
529 |
protected EditPolicy createChildEditPolicy(<%=fqnEditPart%> child) { |
530 |
if (child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE) == null) { |
531 |
if (child instanceof <%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart")%>) { |
532 |
return new <%=importManager.getImportedName(genDiagram.getTextSelectionEditPolicyQualifiedClassName())%>(); |
533 |
} |
534 |
} |
535 |
return super.createChildEditPolicy(child); |
536 |
} |
537 |
<% |
538 |
// [graphdef++] |
539 |
if (generateSyncronizationCode) { |
540 |
%> |
541 |
protected <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Point")%> getLayoutOrigin() { |
542 |
return ((<%=importManager.getImportedName("org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart")%>)getHost()).getContentPane().getClientArea().getLocation(); |
543 |
} |
544 |
<% |
545 |
} |
546 |
// [graphdef--] |
547 |
%> |
548 |
|
549 |
}; |
550 |
<% if (myHelper.hasExternalLabels()) {%> |
551 |
<%=importManager.getImportedName(genDiagram.getExternalNodeLabelHostLayoutEditPolicyQualifiedClassName())%> xlep = new <%=importManager.getImportedName(genDiagram.getExternalNodeLabelHostLayoutEditPolicyQualifiedClassName())%>() { |
552 |
|
553 |
protected boolean isExternalLabel(EditPart editPart) { |
554 |
return <%=genNode.getEditPartClassName()%>.this.isExternalLabel(editPart); |
555 |
} |
556 |
}; |
557 |
xlep.setRealLayoutEditPolicy(lep); |
558 |
return xlep; |
559 |
<% } else {%> |
560 |
return lep; |
561 |
<% |
562 |
} |
563 |
break; |
564 |
case ViewmapLayoutType.FLOW_LAYOUT: |
565 |
%> |
566 |
<%=importManager.getImportedName("org.eclipse.gef.editpolicies.FlowLayoutEditPolicy")%> lep = new <%=importManager.getImportedName("org.eclipse.gef.editpolicies.FlowLayoutEditPolicy")%>() { |
567 |
<% if (myHelper.hasExternalLabels()) {%> |
568 |
|
569 |
protected void decorateChild(EditPart child) { |
570 |
if (isExternalLabel(child)) { |
571 |
return; |
572 |
} |
573 |
super.decorateChild(child); |
574 |
} |
575 |
<% }%> |
576 |
|
577 |
protected <%=importManager.getImportedName("org.eclipse.gef.commands.Command")%> createAddCommand(<%=fqnEditPart%> child, <%=fqnEditPart%> after) { |
578 |
return null; |
579 |
} |
580 |
|
581 |
protected <%=importManager.getImportedName("org.eclipse.gef.commands.Command")%> createMoveChildCommand(<%=fqnEditPart%> child, <%=fqnEditPart%> after) { |
582 |
return null; |
583 |
} |
584 |
|
585 |
protected <%=importManager.getImportedName("org.eclipse.gef.commands.Command")%> getCreateCommand(<%=importManager.getImportedName("org.eclipse.gef.requests.CreateRequest")%> request) { |
586 |
return null; |
587 |
} |
588 |
}; |
589 |
<% if (myHelper.hasExternalLabels()) {%> |
590 |
<%=importManager.getImportedName(genDiagram.getExternalNodeLabelHostLayoutEditPolicyQualifiedClassName())%> xlep = new <%=importManager.getImportedName(genDiagram.getExternalNodeLabelHostLayoutEditPolicyQualifiedClassName())%>() { |
591 |
|
592 |
protected boolean isExternalLabel(EditPart editPart) { |
593 |
return <%=genNode.getEditPartClassName()%>.this.isExternalLabel(editPart); |
594 |
} |
595 |
}; |
596 |
xlep.setRealLayoutEditPolicy(lep); |
597 |
return xlep; |
598 |
<% } else {%> |
599 |
return lep; |
600 |
<% |
601 |
} |
602 |
break; |
603 |
default: |
604 |
%> |
605 |
<%=importManager.getImportedName("org.eclipse.gef.editpolicies.LayoutEditPolicy")%> lep = new <%=importManager.getImportedName("org.eclipse.gef.editpolicies.LayoutEditPolicy")%>() { |
606 |
<% if (myHelper.hasExternalLabels()) {%> |
607 |
|
608 |
protected void decorateChild(EditPart child) { |
609 |
if (isExternalLabel(child)) { |
610 |
return; |
611 |
} |
612 |
super.decorateChild(child); |
613 |
} |
614 |
<% }%> |
615 |
|
616 |
protected EditPolicy createChildEditPolicy(<%=fqnEditPart%> child) { |
617 |
EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); |
618 |
if( result == null ){ |
619 |
result = new <%=importManager.getImportedName("org.eclipse.gef.editpolicies.NonResizableEditPolicy")%>(); |
620 |
} |
621 |
return result; |
622 |
} |
623 |
|
624 |
protected <%=importManager.getImportedName("org.eclipse.gef.commands.Command")%> getMoveChildrenCommand(<%=importManager.getImportedName("org.eclipse.gef.Request")%> request) { |
625 |
return null; |
626 |
} |
627 |
|
628 |
protected <%=importManager.getImportedName("org.eclipse.gef.commands.Command")%> getCreateCommand(<%=importManager.getImportedName("org.eclipse.gef.requests.CreateRequest")%> request) { |
629 |
return null; |
630 |
} |
631 |
}; |
632 |
<% if (myHelper.hasExternalLabels()) {%> |
633 |
<%=importManager.getImportedName(genDiagram.getExternalNodeLabelHostLayoutEditPolicyQualifiedClassName())%> xlep = new <%=importManager.getImportedName(genDiagram.getExternalNodeLabelHostLayoutEditPolicyQualifiedClassName())%>() { |
634 |
|
635 |
protected boolean isExternalLabel(EditPart editPart) { |
636 |
return <%=genNode.getEditPartClassName()%>.this.isExternalLabel(editPart); |
637 |
} |
638 |
}; |
639 |
xlep.setRealLayoutEditPolicy(lep); |
640 |
return xlep; |
641 |
<% } else {%> |
642 |
return lep; |
643 |
<% |
644 |
} |
645 |
} //switch |
646 |
%> |
647 |
} |
648 |
|
649 |
/** |
650 |
* @generated |
651 |
*/ |
652 |
protected IFigure createNodeShape() { |
653 |
<% |
654 |
String figureQualifiedClassName = null; |
655 |
Viewmap viewmap = genNode.getViewmap(); |
656 |
if (viewmap instanceof FigureViewmap) { |
657 |
figureQualifiedClassName = ((FigureViewmap) viewmap).getFigureQualifiedClassName(); |
658 |
if (figureQualifiedClassName == null || figureQualifiedClassName.trim().length() == 0) { |
659 |
figureQualifiedClassName = "org.eclipse.draw2d.RectangleFigure"; |
660 |
} |
661 |
figureQualifiedClassName = importManager.getImportedName(figureQualifiedClassName); |
662 |
%> |
663 |
return primaryShape = new <%=figureQualifiedClassName%>()<%if (isXYLayout) {%> { |
664 |
protected boolean useLocalCoordinates() { |
665 |
return true; |
666 |
} |
667 |
}<%} // if isXYLayout%>; |
668 |
<%} // instanceof FigureViewmap |
669 |
else if (viewmap instanceof SnippetViewmap) {%> |
670 |
return <%=((SnippetViewmap) viewmap).getBody()%>; |
671 |
<%} // instanceof SnippetViewmap; FIXME : obtain figure class name to generate getter |
672 |
else if (viewmap instanceof InnerClassViewmap) { |
673 |
figureQualifiedClassName = ((InnerClassViewmap) viewmap).getClassName(); |
674 |
%> |
675 |
<%=figureQualifiedClassName%> figure = new <%=figureQualifiedClassName%>(); |
676 |
<%if (!genNode.getChildNodes().isEmpty() && isXYLayout) { /*otherwise, leave to figure's default value*/%> |
677 |
figure.setUseLocalCoordinates(true); |
678 |
<%} |
679 |
// [graphdef++] |
680 |
if (generateSyncronizationCode) { |
681 |
String modelInterfaceName = importManager.getImportedName(metaclass.getQualifiedInterfaceName()); |
682 |
%> |
683 |
myFigure = figure; |
684 |
<%=modelInterfaceName%> modelElement = (<%=modelInterfaceName%>) ((View) getModel()).getElement(); |
685 |
if (modelElement != null) { |
686 |
<% |
687 |
for (Iterator genFeatures = metaclass.getAllGenFeatures().iterator(); genFeatures.hasNext();) { |
688 |
GenFeature nextGenFeature = (GenFeature) genFeatures.next(); |
689 |
if (skip(nextGenFeature)) { |
690 |
continue; |
691 |
} |
692 |
%> |
693 |
{ |
694 |
<%=getProcessChangesCall("modelElement", nextGenFeature)%>; |
695 |
} |
696 |
<% }%> |
697 |
} |
698 |
<% |
699 |
} |
700 |
// [graphdef--] |
701 |
%> |
702 |
return primaryShape = figure; |
703 |
<%}%> |
704 |
} |
705 |
<%if (figureQualifiedClassName != null) {%> |
706 |
|
707 |
/** |
708 |
* @generated |
709 |
*/ |
710 |
public <%=figureQualifiedClassName%> getPrimaryShape() { |
711 |
return (<%=figureQualifiedClassName%>) primaryShape; |
712 |
} |
713 |
<%}%> |
714 |
|
715 |
<% |
716 |
if (myHelper.hasFixedChildren()) { |
717 |
%> |
718 |
/** |
719 |
* @generated |
720 |
*/ |
721 |
protected boolean addFixedChild(EditPart childEditPart) { |
722 |
<% |
723 |
for (Iterator it = myHelper.getInnerFixedLabels(); it.hasNext(); ) { |
724 |
GenNodeLabel genLabel = (GenNodeLabel) it.next(); |
725 |
final String labelEditPart = importManager.getImportedName(genLabel.getEditPartQualifiedClassName()); |
726 |
final ParentAssignedViewmap childViewmap = (ParentAssignedViewmap) genLabel.getViewmap(); |
727 |
final String childSetterName = childViewmap.getSetterName() == null ? "setLabel" : childViewmap.getSetterName(); |
728 |
%> |
729 |
if (childEditPart instanceof <%=labelEditPart%>) { |
730 |
((<%=labelEditPart%>) childEditPart).<%=childSetterName%>(getPrimaryShape().<%=childViewmap.getGetterName()%>()); |
731 |
return true; |
732 |
} |
733 |
<% |
734 |
} |
735 |
|
736 |
for (Iterator it = myHelper.getPinnedCompartments(); it.hasNext(); ) { |
737 |
GenCompartment next = (GenCompartment) it.next(); |
738 |
final ParentAssignedViewmap childViewmap = (ParentAssignedViewmap) next.getViewmap(); |
739 |
String compartmentEditPartFQN = importManager.getImportedName(next.getEditPartQualifiedClassName()); |
740 |
%> |
741 |
if (childEditPart instanceof <%=compartmentEditPartFQN%>) { |
742 |
<%=importManager.getImportedName("org.eclipse.draw2d.IFigure")%> pane = getPrimaryShape().<%=childViewmap.getGetterName()%>(); |
743 |
setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way |
744 |
pane.add(((<%=compartmentEditPartFQN%>)childEditPart).getFigure()); |
745 |
return true; |
746 |
} |
747 |
<% |
748 |
} // for pinned compartments |
749 |
%> |
750 |
return false; |
751 |
} |
752 |
|
753 |
/** |
754 |
* @generated |
755 |
*/ |
756 |
protected boolean removeFixedChild(EditPart childEditPart) { |
757 |
<% |
758 |
//XXX: ignore labels assuming that they never may be removed |
759 |
for (Iterator it = myHelper.getPinnedCompartments(); it.hasNext(); ) { |
760 |
GenCompartment next = (GenCompartment) it.next(); |
761 |
final ParentAssignedViewmap childViewmap = (ParentAssignedViewmap) next.getViewmap(); |
762 |
String compartmentEditPartFQN = importManager.getImportedName(next.getEditPartQualifiedClassName()); |
763 |
%> |
764 |
if (childEditPart instanceof <%=compartmentEditPartFQN%>) { |
765 |
<%=importManager.getImportedName("org.eclipse.draw2d.IFigure")%> pane = getPrimaryShape().<%=childViewmap.getGetterName()%>(); |
766 |
pane.remove(((<%=compartmentEditPartFQN%>)childEditPart).getFigure()); |
767 |
return true; |
768 |
} |
769 |
<% |
770 |
} // for pinned compartments |
771 |
%> |
772 |
return false; |
773 |
} |
774 |
<% |
775 |
} // if myHelper.hasFixedChildren() |
776 |
%> |
777 |
|
778 |
/** |
779 |
* @generated |
780 |
*/ |
781 |
protected <%=importManager.getImportedName("org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure")%> createNodePlate() { |
782 |
<% |
783 |
int width = 40; |
784 |
int height = 40; |
785 |
DefaultSizeAttributes defSizeAttrs = (DefaultSizeAttributes) genNode.getViewmap().find(DefaultSizeAttributes.class); |
786 |
if (defSizeAttrs != null) { |
787 |
width = defSizeAttrs.getWidth(); |
788 |
height = defSizeAttrs.getHeight(); |
789 |
} |
790 |
%> |
791 |
return new <%=importManager.getImportedName("org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure")%>(getMapMode().DPtoLP(<%=width%>), getMapMode().DPtoLP(<%=height%>)); |
792 |
} |
793 |
<%if (genNode.getViewmap().find(ResizeConstraints.class) != null) { |
794 |
final ResizeConstraints rc = (ResizeConstraints) genNode.getViewmap().find(ResizeConstraints.class); |
795 |
final String draw2dPC = importManager.getImportedName("org.eclipse.draw2d.PositionConstants");%> |
796 |
|
797 |
/** |
798 |
* @generated |
799 |
*/ |
800 |
public EditPolicy getPrimaryDragEditPolicy() { |
801 |
<%=importManager.getImportedName("org.eclipse.gef.editpolicies.ResizableEditPolicy")%> ep = (<%=importManager.getImportedName("org.eclipse.gef.editpolicies.ResizableEditPolicy")%>) super.getPrimaryDragEditPolicy(); |
802 |
<%if (rc.getResizeHandleNames().isEmpty()) {%> |
803 |
ep.setResizeDirections(<%=draw2dPC%>.NONE); |
804 |
<% } else {%> |
805 |
ep.setResizeDirections(<%for (Iterator rcNamesIter = rc.getResizeHandleNames().iterator(); rcNamesIter.hasNext();) { |
806 |
String nextConstantName = (String) rcNamesIter.next();%><%=draw2dPC%>.<%=nextConstantName%><%if (rcNamesIter.hasNext()) {%> | <%}}%>); |
807 |
<%}%> |
808 |
return ep; |
809 |
} |
810 |
<%}%> |
811 |
/** |
812 |
* Creates figure for this edit part. |
813 |
* |
814 |
* Body of this method does not depend on settings in generation model |
815 |
* so you may safely remove <i>generated</i> tag and modify it. |
816 |
* |
817 |
* @generated |
818 |
*/ |
819 |
protected <%=importManager.getImportedName("org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure")%> createNodeFigure() { |
820 |
<%=importManager.getImportedName("org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure")%> figure = createNodePlate(); |
821 |
<% |
822 |
// [graphdef++] |
823 |
if (generateSyncronizationCode) { |
824 |
%> |
825 |
myNodeFigure = figure; |
826 |
<% |
827 |
} |
828 |
// [graphdef--] |
829 |
%> |
830 |
figure.setLayoutManager(new StackLayout()); |
831 |
IFigure shape = createNodeShape(); |
832 |
figure.add(shape); |
833 |
contentPane = setupContentPane(shape); |
834 |
return figure; |
835 |
} |
836 |
|
837 |
/** |
838 |
* Default implementation treats passed figure as content pane. |
839 |
* Respects layout one may have set for generated figure. |
840 |
* @param nodeShape instance of generated figure class |
841 |
* @generated |
842 |
*/ |
843 |
protected IFigure setupContentPane(IFigure nodeShape) { |
844 |
if (nodeShape.getLayoutManager() == null) { |
845 |
<% |
846 |
if (isXYLayout) { |
847 |
%> |
848 |
nodeShape.setLayoutManager(new <%=importManager.getImportedName("org.eclipse.draw2d.FreeformLayout")%>() { |
849 |
|
850 |
public Object getConstraint(IFigure figure) { |
851 |
Object result = constraints.get(figure); |
852 |
if (result == null) { |
853 |
result = new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Rectangle")%>(0, 0, -1, -1); |
854 |
} |
855 |
return result; |
856 |
} |
857 |
}); |
858 |
<%} else { |
859 |
String layoutClassName = importManager.getImportedName("org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout"); |
860 |
%> |
861 |
<%=layoutClassName%> layout = new <%=layoutClassName%>(); |
862 |
layout.setSpacing(getMapMode().DPtoLP(5)); |
863 |
nodeShape.setLayoutManager(layout); |
864 |
<%}%> |
865 |
} |
866 |
return nodeShape; // use nodeShape itself as contentPane |
867 |
} |
868 |
|
869 |
/** |
870 |
* @generated |
871 |
*/ |
872 |
public IFigure getContentPane() { |
873 |
if (contentPane != null) { |
874 |
return contentPane; |
875 |
} |
876 |
return super.getContentPane(); |
877 |
} |
878 |
<% |
879 |
if (myHelper.getPrimaryLabel() != null) { |
880 |
GenNodeLabel primaryLabel = myHelper.getPrimaryLabel(); |
881 |
%> |
882 |
|
883 |
/** |
884 |
* @generated |
885 |
*/ |
886 |
public <%=importManager.getImportedName("org.eclipse.gef.EditPart")%> getPrimaryChildEditPart() { |
887 |
return getChildBySemanticHint(<%=importManager.getImportedName(genDiagram.getVisualIDRegistryQualifiedClassName())%>.getType(<%=importManager.getImportedName(primaryLabel.getEditPartQualifiedClassName())%>.VISUAL_ID)); |
888 |
} |
889 |
<% |
890 |
} |
891 |
if (myHelper.hasExternalLabels()){ |
892 |
%> |
893 |
|
894 |
/** |
895 |
* @generated |
896 |
*/ |
897 |
protected boolean isExternalLabel(<%=importManager.getImportedName("org.eclipse.gef.EditPart")%> childEditPart) { |
898 |
<% |
899 |
for (Iterator externalLabels = myHelper.getExternalLabels(); externalLabels.hasNext();) { |
900 |
GenNodeLabel next = (GenNodeLabel) externalLabels.next(); |
901 |
%> |
902 |
if (childEditPart instanceof <%=importManager.getImportedName(next.getEditPartQualifiedClassName())%>) { |
903 |
return true; |
904 |
} |
905 |
<% }%> |
906 |
return false; |
907 |
} |
908 |
|
909 |
/** |
910 |
* @generated |
911 |
*/ |
912 |
protected IFigure getExternalLabelsContainer() { |
913 |
<%=importManager.getImportedName("org.eclipse.gef.editparts.LayerManager")%> root = (<%=importManager.getImportedName("org.eclipse.gef.editparts.LayerManager")%>) getRoot(); |
914 |
return root.getLayer(<%=importManager.getImportedName(genDiagram.getEditPartFactoryQualifiedClassName())%>.EXTERNAL_NODE_LABELS_LAYER); |
915 |
} |
916 |
|
917 |
<% |
918 |
} |
919 |
if (myHelper.hasFixedChildren() || myHelper.hasExternalLabels()) { |
920 |
%> |
921 |
|
922 |
/** |
923 |
* @generated |
924 |
*/ |
925 |
protected void addChildVisual(<%=importManager.getImportedName("org.eclipse.gef.EditPart")%> childEditPart, int index) { |
926 |
<% if (myHelper.hasExternalLabels()) {%> |
927 |
if (isExternalLabel(childEditPart)) { |
928 |
IFigure labelFigure = ((<%=importManager.getImportedName("org.eclipse.gef.GraphicalEditPart")%>) childEditPart).getFigure(); |
929 |
getExternalLabelsContainer().add(labelFigure); |
930 |
return; |
931 |
} |
932 |
<% |
933 |
} |
934 |
if (myHelper.hasFixedChildren()){ |
935 |
%> |
936 |
if (addFixedChild(childEditPart)) { |
937 |
return; |
938 |
} |
939 |
<% }%> |
940 |
super.addChildVisual(childEditPart, -1); |
941 |
} |
942 |
|
943 |
/** |
944 |
* @generated |
945 |
*/ |
946 |
protected void removeChildVisual(<%=importManager.getImportedName("org.eclipse.gef.EditPart")%> childEditPart) { |
947 |
<% if (myHelper.hasExternalLabels()) {%> |
948 |
if (isExternalLabel(childEditPart)) { |
949 |
IFigure labelFigure = ((<%=importManager.getImportedName("org.eclipse.gef.GraphicalEditPart")%>) childEditPart).getFigure(); |
950 |
getExternalLabelsContainer().remove(labelFigure); |
951 |
return; |
952 |
} |
953 |
<% |
954 |
} |
955 |
if (myHelper.hasFixedChildren()){ |
956 |
%> |
957 |
if (removeFixedChild(childEditPart)){ |
958 |
return; |
959 |
} |
960 |
<% }%> |
961 |
super.removeChildVisual(childEditPart); |
962 |
} |
963 |
<% if (myHelper.hasExternalLabels()) {%> |
964 |
|
965 |
/** |
966 |
* @generated |
967 |
*/ |
968 |
public void removeNotify() { |
969 |
for (<%=importManager.getImportedName("java.util.Iterator")%> it = getChildren().iterator(); it.hasNext();) { |
970 |
<%=importManager.getImportedName("org.eclipse.gef.EditPart")%> childEditPart = (<%=importManager.getImportedName("org.eclipse.gef.EditPart")%>) it.next(); |
971 |
if (isExternalLabel(childEditPart)) { |
972 |
IFigure labelFigure = ((<%=importManager.getImportedName("org.eclipse.gef.GraphicalEditPart")%>) childEditPart).getFigure(); |
973 |
getExternalLabelsContainer().remove(labelFigure); |
974 |
} |
975 |
} |
976 |
super.removeNotify(); |
977 |
} |
978 |
<% |
979 |
} |
980 |
} // if hasFixedChildren || hasExternalLabels |
981 |
%> |
982 |
|
983 |
<%if (genNode.getViewmap() instanceof InnerClassViewmap) {%> |
984 |
<%=((InnerClassViewmap) genNode.getViewmap()).getClassBody()%> |
985 |
<%}%> |
986 |
<% |
987 |
// [graphdef++] |
988 |
if (generateSyncronizationCode) {%> |
989 |
|
990 |
/** |
991 |
* @generated |
992 |
*/ |
993 |
protected <%=importManager.getImportedName("org.eclipse.draw2d.LayoutManager")%> getFigureLayoutManager() { |
994 |
return myFigure.getLayoutManager(); |
995 |
} |
996 |
|
997 |
/** |
998 |
* @generated |
999 |
*/ |
1000 |
protected void setFigureLayoutManager(<%=importManager.getImportedName("org.eclipse.draw2d.LayoutManager")%> layoutManager) { |
1001 |
myFigure.setLayoutManager(layoutManager); |
1002 |
} |
1003 |
|
1004 |
/** |
1005 |
* @generated |
1006 |
*/ |
1007 |
protected void refreshBounds() { |
1008 |
if (((<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.View")%>) getParent().getModel()).getElement() instanceof <%=importManager.getImportedName("org.eclipse.gmf.gmfgraph.FigureMarker")%>) { |
1009 |
int width = ((Integer) getStructuralFeatureValue(<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage")%>.eINSTANCE.getSize_Width())).intValue(); |
1010 |
int height = ((Integer) getStructuralFeatureValue(<%=importManager.getImportedName("org.eclipse.gmf.runtime.notation.NotationPackage")%>.eINSTANCE.getSize_Height())).intValue(); |
1011 |
myNodeFigure.setPreferredSize(new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%>(width, height)); |
1012 |
} else { |
1013 |
super.refreshBounds(); |
1014 |
} |
1015 |
} |
1016 |
<% |
1017 |
} |
1018 |
// [graphdef--] |
1019 |
%> |
1020 |
} |
1021 |
<%importManager.emitSortedImports();%> |