View | Details | Raw Unified | Return to bug 134097
Collapse All | Expand All

(-)src/org/eclipse/gmf/tests/gen/FigureLayoutTest.java (-23 / +65 lines)
Lines 19-24 Link Here
19
import org.eclipse.gmf.gmfgraph.BorderLayout;
19
import org.eclipse.gmf.gmfgraph.BorderLayout;
20
import org.eclipse.gmf.gmfgraph.BorderLayoutData;
20
import org.eclipse.gmf.gmfgraph.BorderLayoutData;
21
import org.eclipse.gmf.gmfgraph.CustomAttribute;
21
import org.eclipse.gmf.gmfgraph.CustomAttribute;
22
import org.eclipse.gmf.gmfgraph.CustomFigure;
22
import org.eclipse.gmf.gmfgraph.CustomLayout;
23
import org.eclipse.gmf.gmfgraph.CustomLayout;
23
import org.eclipse.gmf.gmfgraph.Dimension;
24
import org.eclipse.gmf.gmfgraph.Dimension;
24
import org.eclipse.gmf.gmfgraph.Figure;
25
import org.eclipse.gmf.gmfgraph.Figure;
Lines 31-36 Link Here
31
import org.eclipse.gmf.gmfgraph.LayoutData;
32
import org.eclipse.gmf.gmfgraph.LayoutData;
32
import org.eclipse.gmf.gmfgraph.RGBColor;
33
import org.eclipse.gmf.gmfgraph.RGBColor;
33
import org.eclipse.gmf.gmfgraph.Rectangle;
34
import org.eclipse.gmf.gmfgraph.Rectangle;
35
import org.eclipse.gmf.gmfgraph.RoundedRectangle;
34
import org.eclipse.gmf.gmfgraph.XYLayoutData;
36
import org.eclipse.gmf.gmfgraph.XYLayoutData;
35
37
36
public class FigureLayoutTest extends FigureCodegenTestBase {
38
public class FigureLayoutTest extends FigureCodegenTestBase {
Lines 58-64 Link Here
58
		for (Iterator it = children.iterator(); it.hasNext();){
60
		for (Iterator it = children.iterator(); it.hasNext();){
59
			FigureMarker next = (FigureMarker)it.next();
61
			FigureMarker next = (FigureMarker)it.next();
60
			oddChild = !oddChild;
62
			oddChild = !oddChild;
61
			LayoutData data = createLayoutDataAllProperties(oddChild);
63
			LayoutData data = createGridLayoutDataAllProperties(oddChild);
62
			next.setLayoutData(data);
64
			next.setLayoutData(data);
63
			assertEquals("data-owner relation should be bidirectional", next, data.getOwner());
65
			assertEquals("data-owner relation should be bidirectional", next, data.getOwner());
64
		}
66
		}
Lines 75-81 Link Here
75
		
77
		
76
		for (Iterator children = parent.getChildren().iterator(); children.hasNext();){
78
		for (Iterator children = parent.getChildren().iterator(); children.hasNext();){
77
			FigureMarker next = (FigureMarker)children.next();
79
			FigureMarker next = (FigureMarker)children.next();
78
			GridLayoutData data = createLayoutDataAllProperties(false);
80
			GridLayoutData data = createGridLayoutDataAllProperties(false);
79
			data.setHorizontalAlignment(Alignment.FILL_LITERAL);
81
			data.setHorizontalAlignment(Alignment.FILL_LITERAL);
80
			data.setOwner(next);
82
			data.setOwner(next);
81
			assertEquals("data-owner relation should be bidirectional", data, next.getLayoutData());
83
			assertEquals("data-owner relation should be bidirectional", data, next.getLayoutData());
Lines 91-97 Link Here
91
		for (int i = 0; i < 4; i++){
93
		for (int i = 0; i < 4; i++){
92
			next = addPairOfChildRectanglesAndReturnLeft(next);
94
			next = addPairOfChildRectanglesAndReturnLeft(next);
93
		}
95
		}
94
		performGridLayoutTests(parent);
96
		performTests(parent);
95
	}
97
	}
96
	
98
	
97
	public void testLayoutDefaults(){
99
	public void testLayoutDefaults(){
Lines 122-133 Link Here
122
		
124
		
123
		FigureRef refChildA = GMFGraphFactory.eINSTANCE.createFigureRef();
125
		FigureRef refChildA = GMFGraphFactory.eINSTANCE.createFigureRef();
124
		refChildA.setFigure(referencedFigure);
126
		refChildA.setFigure(referencedFigure);
125
		refChildA.setLayoutData(createLayoutDataAllProperties(false));
127
		refChildA.setLayoutData(createGridLayoutDataAllProperties(false));
126
		
128
		
127
		//same figure is referenced, different layout data
129
		//same figure is referenced, different layout data
128
		FigureRef refChildB = GMFGraphFactory.eINSTANCE.createFigureRef();
130
		FigureRef refChildB = GMFGraphFactory.eINSTANCE.createFigureRef();
129
		refChildB.setFigure(referencedFigure);
131
		refChildB.setFigure(referencedFigure);
130
		refChildB.setLayoutData(createLayoutDataAllProperties(true));
132
		refChildB.setLayoutData(createGridLayoutDataAllProperties(true));
131
		
133
		
132
		parent.getChildren().add(refChildA);
134
		parent.getChildren().add(refChildA);
133
		parent.getChildren().add(refChildB);
135
		parent.getChildren().add(refChildB);
Lines 142-148 Link Here
142
		
144
		
143
		Figure child = GMFGraphFactory.eINSTANCE.createRectangle();
145
		Figure child = GMFGraphFactory.eINSTANCE.createRectangle();
144
		child.setName("childWithLayoutData");
146
		child.setName("childWithLayoutData");
145
		child.setLayoutData(createLayoutDataAllProperties(false));
147
		child.setLayoutData(createGridLayoutDataAllProperties(false));
146
		
148
		
147
		parent.getChildren().add(child);
149
		parent.getChildren().add(child);
148
		
150
		
Lines 263-271 Link Here
263
	
265
	
264
	public void testXYLayout(){
266
	public void testXYLayout(){
265
		Figure group = createRGBGroup("XY");
267
		Figure group = createRGBGroup("XY");
268
		Figure left = (Figure) group.getChildren().get(0);
269
		Figure right = (Figure) group.getChildren().get(1);
270
271
		setupXYLayout(group, left, right);
272
273
		performTests(group);
274
		performTests(right);
275
		performTests(left);
276
	}
277
	
278
	public void testXYLayoutForCustomFigure(){
279
		CustomFigure group = GMFGraphFactory.eINSTANCE.createCustomFigure();
280
		group.setBundleName("org.eclipse.draw2d");
281
		group.setQualifiedClassName("org.eclipse.draw2d.Layer");
282
		group.setName("CustomLayer");
283
		
284
		Rectangle left = GMFGraphFactory.eINSTANCE.createRectangle();
285
		left.setName("Left");
286
		group.getChildren().add(left);
287
		
288
		RoundedRectangle right = GMFGraphFactory.eINSTANCE.createRoundedRectangle();
289
		right.setName("Right");
290
		group.getChildren().add(right);
291
		
292
		setupXYLayout(group, left, right);
293
294
		performTests(group);
295
	}
296
	
297
	private void setupXYLayout(final Figure group, final Figure left, final Figure right){
298
		assertTrue(group.getChildren().contains(left));
299
		assertTrue(group.getChildren().contains(right));
300
		assertNotSame(left, right);
301
266
		group.setLayout(GMFGraphFactory.eINSTANCE.createXYLayout());
302
		group.setLayout(GMFGraphFactory.eINSTANCE.createXYLayout());
267
		
303
		
268
		Figure left = (Figure) group.getChildren().get(0);
269
		XYLayoutData leftDataCorrect =  GMFGraphFactory.eINSTANCE.createXYLayoutData();
304
		XYLayoutData leftDataCorrect =  GMFGraphFactory.eINSTANCE.createXYLayoutData();
270
		leftDataCorrect.setTopLeft(GMFGraphFactory.eINSTANCE.createPoint());
305
		leftDataCorrect.setTopLeft(GMFGraphFactory.eINSTANCE.createPoint());
271
		leftDataCorrect.getTopLeft().setX(12);
306
		leftDataCorrect.getTopLeft().setX(12);
Lines 275-290 Link Here
275
		leftDataCorrect.getSize().setDy(30);
310
		leftDataCorrect.getSize().setDy(30);
276
		leftDataCorrect.setOwner(left);
311
		leftDataCorrect.setOwner(left);
277
		
312
		
278
		Figure right = (Figure) group.getChildren().get(1);
279
		XYLayoutData rightDataIncomplete =  GMFGraphFactory.eINSTANCE.createXYLayoutData();
313
		XYLayoutData rightDataIncomplete =  GMFGraphFactory.eINSTANCE.createXYLayoutData();
280
		rightDataIncomplete.setSize(GMFGraphFactory.eINSTANCE.createDimension());
314
		rightDataIncomplete.setSize(GMFGraphFactory.eINSTANCE.createDimension());
281
		rightDataIncomplete.getSize().setDx(30);
315
		rightDataIncomplete.getSize().setDx(30);
282
		rightDataIncomplete.getSize().setDy(20);
316
		rightDataIncomplete.getSize().setDy(20);
283
		right.setLayoutData(rightDataIncomplete);
317
		right.setLayoutData(rightDataIncomplete);
284
		
285
		performTests(group);
286
		performTests(right);
287
		performTests(left);
288
	}
318
	}
289
319
290
	private Figure createRGBGroup(String rootName){
320
	private Figure createRGBGroup(String rootName){
Lines 307-332 Link Here
307
	}
337
	}
308
	
338
	
309
	private Figure addPairOfChildRectanglesAndReturnLeft(Figure parent){
339
	private Figure addPairOfChildRectanglesAndReturnLeft(Figure parent){
310
		GridLayout parentLayout = createGridLayoutAllProperties();
340
		parent.setLayout(createBorderLayoutAllProperties());
311
		parentLayout.setNumColumns(2);
312
		parentLayout.setMargins(null);
313
		parentLayout.setSpacing(null);
314
		parent.setLayout(parentLayout);
315
		
341
		
316
		Rectangle left = GMFGraphFactory.eINSTANCE.createRectangle();
342
		Rectangle left = GMFGraphFactory.eINSTANCE.createRectangle();
317
		left.setName(parent.getName() + "_1");
343
		left.setName(parent.getName() + "_1");
318
		left.setLayoutData(createLayoutDataAllProperties(true));
344
		left.setLayoutData(createBorderLayoutDataAllProperties(Alignment.BEGINNING_LITERAL, false));
319
		parent.getChildren().add(left);
345
		parent.getChildren().add(left);
320
		
346
		
321
		Rectangle right = GMFGraphFactory.eINSTANCE.createRectangle();
347
		Rectangle right = GMFGraphFactory.eINSTANCE.createRectangle();
322
		right.setName(parent.getName() + "_2");
348
		right.setName(parent.getName() + "_2");
323
		right.setLayoutData(createLayoutDataAllProperties(false));
349
		right.setLayoutData(createBorderLayoutDataAllProperties(Alignment.END_LITERAL, false));
324
		parent.getChildren().add(right);
350
		parent.getChildren().add(right);
325
		
351
		
326
		return left;
352
		return left;
327
	}
353
	}
328
	
354
	
329
	private GridLayoutData createLayoutDataAllProperties(boolean horizontalBeginningNotEnd) {
355
	private GridLayoutData createGridLayoutDataAllProperties(boolean horizontalBeginningNotEnd) {
330
		GridLayoutData data = GMFGraphFactory.eINSTANCE.createGridLayoutData();
356
		GridLayoutData data = GMFGraphFactory.eINSTANCE.createGridLayoutData();
331
		data.setGrabExcessHorizontalSpace(true);
357
		data.setGrabExcessHorizontalSpace(true);
332
		data.setGrabExcessVerticalSpace(false);
358
		data.setGrabExcessVerticalSpace(false);
Lines 352-361 Link Here
352
		spacing.setDx(7);
378
		spacing.setDx(7);
353
		spacing.setDy(8);
379
		spacing.setDy(8);
354
		layout.setSpacing(spacing);
380
		layout.setSpacing(spacing);
355
		
381
356
		return layout;
382
		return layout;
357
	}
383
	}
358
	
384
	
385
	private BorderLayout createBorderLayoutAllProperties(){
386
		BorderLayout result = GMFGraphFactory.eINSTANCE.createBorderLayout();
387
		Dimension spacing = GMFGraphFactory.eINSTANCE.createDimension();
388
		spacing.setDx(11);
389
		spacing.setDy(12);
390
		result.setSpacing(spacing);
391
		return result;
392
	}
393
	
394
	private BorderLayoutData createBorderLayoutDataAllProperties(Alignment alignment, boolean isVertical){
395
		BorderLayoutData result = GMFGraphFactory.eINSTANCE.createBorderLayoutData();
396
		result.setAlignment(alignment);
397
		result.setVertical(isVertical);
398
		return result;
399
	}
400
	
359
	private Dimension createDimension(int dx, int dy){
401
	private Dimension createDimension(int dx, int dy){
360
		Dimension result = GMFGraphFactory.eINSTANCE.createDimension();
402
		Dimension result = GMFGraphFactory.eINSTANCE.createDimension();
361
		result.setDx(dx);
403
		result.setDx(dx);
Lines 379-385 Link Here
379
	}
421
	}
380
	
422
	
381
	private void performGridLayoutTests(Figure figure){
423
	private void performGridLayoutTests(Figure figure){
382
		
424
		generateAndParse(figure);
383
	}
425
	}
384
426
	
385
}
427
}
(-)templates/attr/CustomClass.javajet (-1 / +5 lines)
Lines 4-12 Link Here
4
final CustomClass instance = (CustomClass) ((Object[]) argument)[0];
4
final CustomClass instance = (CustomClass) ((Object[]) argument)[0];
5
//final GraphDefDispatcher dispatcher = (GraphDefDispatcher) ((Object[]) argument)[1];
5
//final GraphDefDispatcher dispatcher = (GraphDefDispatcher) ((Object[]) argument)[1];
6
final String varName = (String) ((Object[]) argument)[2];
6
final String varName = (String) ((Object[]) argument)[2];
7
final boolean hasAttributes = !instance.getAttributes().isEmpty();
7
%>
8
%>
8
9
<%	if (hasAttributes) {%>
9
		{
10
		{
11
<%	}%>
10
<%
12
<%
11
int attrIndex = 0;
13
int attrIndex = 0;
12
for (Iterator attrs = instance.getAttributes().iterator(); attrs.hasNext(); attrIndex++){
14
for (Iterator attrs = instance.getAttributes().iterator(); attrs.hasNext(); attrIndex++){
Lines 32-36 Link Here
32
<%
34
<%
33
} //for 
35
} //for 
34
%>
36
%>
37
<%	if (hasAttributes) {%>
35
		}
38
		}
39
<%	}%>
36
40
(-)src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java (-7 / +11 lines)
Lines 47-55 Link Here
47
  protected final String TEXT_27 = "() {";
47
  protected final String TEXT_27 = "() {";
48
  protected final String TEXT_28 = NL;
48
  protected final String TEXT_28 = NL;
49
  protected final String TEXT_29 = NL;
49
  protected final String TEXT_29 = NL;
50
  protected final String TEXT_30 = NL + "\t\treturn rv;" + NL + "\t}" + NL;
50
  protected final String TEXT_30 = NL + "\t\treturn ";
51
  protected final String TEXT_31 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected boolean useLocalCoordinates() {" + NL + "\t\treturn myUseLocalCoordinates;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void setUseLocalCoordinates(boolean useLocalCoordinates) {" + NL + "\t\tmyUseLocalCoordinates = useLocalCoordinates;" + NL + "\t}" + NL + "}";
51
  protected final String TEXT_31 = ";" + NL + "\t}" + NL;
52
  protected final String TEXT_32 = NL;
52
  protected final String TEXT_32 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected boolean useLocalCoordinates() {" + NL + "\t\treturn myUseLocalCoordinates;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void setUseLocalCoordinates(boolean useLocalCoordinates) {" + NL + "\t\tmyUseLocalCoordinates = useLocalCoordinates;" + NL + "\t}" + NL + "}";
53
  protected final String TEXT_33 = NL;
53
54
54
  public String generate(Object argument)
55
  public String generate(Object argument)
55
  {
56
  {
Lines 124-138 Link Here
124
    stringBuffer.append(TEXT_26);
125
    stringBuffer.append(TEXT_26);
125
    stringBuffer.append(next.getName());
126
    stringBuffer.append(next.getName());
126
    stringBuffer.append(TEXT_27);
127
    stringBuffer.append(TEXT_27);
128
     GraphDefDispatcher.LayoutArgs childFigureArgs = dispatcher.createLayoutArgs(next, next.getName(), "layoutManager" + next.getName(), null);
127
    stringBuffer.append(TEXT_28);
129
    stringBuffer.append(TEXT_28);
128
    stringBuffer.append(dispatcher.dispatch("instantiate", dispatcher.create(next, "rv")));
130
    stringBuffer.append(dispatcher.dispatch("instantiate", childFigureArgs));
129
    stringBuffer.append(TEXT_29);
131
    stringBuffer.append(TEXT_29);
130
    stringBuffer.append(dispatcher.dispatch("Children", new Object[] {next.getChildren(), dispatcher, "rv"}));
132
    stringBuffer.append(dispatcher.dispatch("Children", new Object[] {next.getChildren(), dispatcher, childFigureArgs}));
131
    stringBuffer.append(TEXT_30);
133
    stringBuffer.append(TEXT_30);
132
    }
134
    stringBuffer.append(next.getName());
133
    stringBuffer.append(TEXT_31);
135
    stringBuffer.append(TEXT_31);
134
    importManager.emitSortedImports();
136
    }
135
    stringBuffer.append(TEXT_32);
137
    stringBuffer.append(TEXT_32);
138
    importManager.emitSortedImports();
139
    stringBuffer.append(TEXT_33);
136
    return stringBuffer.toString();
140
    return stringBuffer.toString();
137
  }
141
  }
138
}
142
}
(-)src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java (-10 / +9 lines)
Lines 31-37 Link Here
31
Object[] args = (Object[]) argument;
31
Object[] args = (Object[]) argument;
32
List/*<Figure>*/ figureChildren = (List) args[0];
32
List/*<Figure>*/ figureChildren = (List) args[0];
33
final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[1];
33
final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[1];
34
String parentFigureVarName = (String) args[2];
34
GraphDefDispatcher.LayoutArgs parentArgs = (GraphDefDispatcher.LayoutArgs) args[2];
35
35
36
    stringBuffer.append(TEXT_1);
36
    stringBuffer.append(TEXT_1);
37
    
37
    
Lines 43-76 Link Here
43
while (!l.isEmpty()) {
43
while (!l.isEmpty()) {
44
	Object _nxt = l.removeFirst();
44
	Object _nxt = l.removeFirst();
45
	if (_nxt == marker) {
45
	if (_nxt == marker) {
46
		parentFigureVarName = (String) figureVarNamesStack.pop();
46
		parentArgs = (GraphDefDispatcher.LayoutArgs) figureVarNamesStack.pop();
47
		continue;
47
		continue;
48
	}
48
	}
49
	final FigureMarker figureMarker = (FigureMarker) _nxt;
49
	final FigureMarker figureMarker = (FigureMarker) _nxt;
50
	if (figureMarker instanceof FigureRef) {
50
	if (figureMarker instanceof FigureRef) {
51
		throw new IllegalStateException("FIXME: sorry, don't support FigureRef for a while");
51
		throw new IllegalStateException("FIXME: sorry, don't support FigureRef for a while");
52
	}
52
	}
53
	final String figureVarName = "fig" + figureCount;
53
	final String figureVarName = "fig_" + figureCount;
54
	final String layoutManagerVarName = "layouter" + figureCount;
54
	final String layoutManagerVarName = "layouter" + figureCount;
55
	final String layoutDataVarName = "layData" + figureCount;
55
	final String layoutDataVarName = "layData" + figureCount;
56
	figureCount++;
56
	figureCount++;
57
    stringBuffer.append(TEXT_2);
57
    stringBuffer.append(TEXT_2);
58
    GraphDefDispatcher.Args dargs = dispatcher.create((Figure) figureMarker, figureVarName);
58
    GraphDefDispatcher.LayoutArgs nextLevelArgs = dispatcher.createLayoutArgs((Figure) figureMarker, figureVarName, layoutManagerVarName, layoutDataVarName);
59
		GraphDefDispatcher.LayoutArgs layoutAwareArgs = dispatcher.createLayoutArgs(dargs, layoutManagerVarName, layoutDataVarName);
60
    stringBuffer.append(TEXT_3);
59
    stringBuffer.append(TEXT_3);
61
    stringBuffer.append(dispatcher.dispatch("instantiate", layoutAwareArgs));
60
    stringBuffer.append(dispatcher.dispatch("instantiate", nextLevelArgs));
62
    stringBuffer.append(TEXT_4);
61
    stringBuffer.append(TEXT_4);
63
    stringBuffer.append(parentFigureVarName);
62
    stringBuffer.append(parentArgs.getVariableName());
64
    stringBuffer.append(TEXT_5);
63
    stringBuffer.append(TEXT_5);
65
    stringBuffer.append(figureVarName);
64
    stringBuffer.append(figureVarName);
66
    stringBuffer.append(TEXT_6);
65
    stringBuffer.append(TEXT_6);
67
    stringBuffer.append(dispatcher.dispatch("createLayoutData", layoutAwareArgs));
66
    stringBuffer.append(dispatcher.dispatch("createLayoutData", dispatcher.createLayoutArgs(nextLevelArgs, parentArgs.getManagerVariableName(), layoutDataVarName)));
68
    
67
    
69
if (_nxt instanceof Figure && !((Figure) _nxt).getChildren().isEmpty()) {
68
if (_nxt instanceof Figure && !((Figure) _nxt).getChildren().isEmpty()) {
70
	l.addFirst(marker);
69
	l.addFirst(marker);
71
	l.addAll(0, ((Figure) _nxt).getChildren());
70
	l.addAll(0, ((Figure) _nxt).getChildren());
72
	figureVarNamesStack.push(parentFigureVarName);
71
	figureVarNamesStack.push(parentArgs);
73
	parentFigureVarName = figureVarName; // go on processing children of new parentFigure
72
	parentArgs = nextLevelArgs; // go on processing children of new parentFigure
74
} // if
73
} // if
75
} // while
74
} // while
76
75
(-)src/org/eclipse/gmf/graphdef/codegen/templates/TopFigureGenerator.java (-6 / +14 lines)
Lines 21-30 Link Here
21
  protected final String TEXT_2 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
21
  protected final String TEXT_2 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
22
  protected final String TEXT_3 = " extends ";
22
  protected final String TEXT_3 = " extends ";
23
  protected final String TEXT_4 = " {" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate boolean myUseLocalCoordinates;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
23
  protected final String TEXT_4 = " {" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate boolean myUseLocalCoordinates;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
24
  protected final String TEXT_5 = "() {" + NL + "\t\t";
24
  protected final String TEXT_5 = "() {";
25
  protected final String TEXT_6 = NL + "\t\t";
25
  protected final String TEXT_6 = NL + "\t\t";
26
  protected final String TEXT_7 = NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected boolean useLocalCoordinates() {" + NL + "\t\treturn myUseLocalCoordinates;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void setUseLocalCoordinates(boolean useLocalCoordinates) {" + NL + "\t\tmyUseLocalCoordinates = useLocalCoordinates;" + NL + "\t}" + NL + "" + NL + "}";
26
  protected final String TEXT_7 = "\t" + NL + "\t\t";
27
  protected final String TEXT_8 = NL;
27
  protected final String TEXT_8 = NL + "\t\t";
28
  protected final String TEXT_9 = NL + "\t}" + NL + "\t" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected boolean useLocalCoordinates() {" + NL + "\t\treturn myUseLocalCoordinates;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void setUseLocalCoordinates(boolean useLocalCoordinates) {" + NL + "\t\tmyUseLocalCoordinates = useLocalCoordinates;" + NL + "\t}" + NL + "" + NL + "}";
29
  protected final String TEXT_10 = NL;
28
30
29
  public String generate(Object argument)
31
  public String generate(Object argument)
30
  {
32
  {
Lines 45-56 Link Here
45
    stringBuffer.append(TEXT_4);
47
    stringBuffer.append(TEXT_4);
46
    stringBuffer.append(figure.getName());
48
    stringBuffer.append(figure.getName());
47
    stringBuffer.append(TEXT_5);
49
    stringBuffer.append(TEXT_5);
48
    stringBuffer.append(dispatcher.dispatch(figure, dispatcher.create(figure, "this")));
50
    
51
GraphDefDispatcher.LayoutArgs dispatcherArgs = dispatcher.createLayoutArgs(figure, "this", "genLayoutManager", null);
52
49
    stringBuffer.append(TEXT_6);
53
    stringBuffer.append(TEXT_6);
50
    stringBuffer.append(dispatcher.dispatch("Children", new Object[] {figure.getChildren(), dispatcher, "this"}));
54
    stringBuffer.append(dispatcher.dispatch("createLayout", dispatcherArgs));
51
    stringBuffer.append(TEXT_7);
55
    stringBuffer.append(TEXT_7);
52
    importManager.emitSortedImports();
56
    stringBuffer.append(dispatcher.dispatch(figure, dispatcherArgs));
53
    stringBuffer.append(TEXT_8);
57
    stringBuffer.append(TEXT_8);
58
    stringBuffer.append(dispatcher.dispatch("Children", new Object[] {figure.getChildren(), dispatcher, dispatcherArgs}));
59
    stringBuffer.append(TEXT_9);
60
    importManager.emitSortedImports();
61
    stringBuffer.append(TEXT_10);
54
    return stringBuffer.toString();
62
    return stringBuffer.toString();
55
  }
63
  }
56
}
64
}
(-)src/org/eclipse/gmf/graphdef/codegen/templates/CustomClassAttributesGenerator.java (-2 / +9 lines)
Lines 16-22 Link Here
16
  }
16
  }
17
17
18
  protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
18
  protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
19
  protected final String TEXT_1 = NL + "\t\t{";
19
  protected final String TEXT_1 = "\t\t{";
20
  protected final String TEXT_2 = NL + "\t\t\t";
20
  protected final String TEXT_2 = NL + "\t\t\t";
21
  protected final String TEXT_3 = ";";
21
  protected final String TEXT_3 = ";";
22
  protected final String TEXT_4 = NL + "\t\t\t";
22
  protected final String TEXT_4 = NL + "\t\t\t";
Lines 28-35 Link Here
28
  protected final String TEXT_10 = "(";
28
  protected final String TEXT_10 = "(";
29
  protected final String TEXT_11 = ");";
29
  protected final String TEXT_11 = ");";
30
  protected final String TEXT_12 = "\t";
30
  protected final String TEXT_12 = "\t";
31
  protected final String TEXT_13 = NL + "\t\t}" + NL;
31
  protected final String TEXT_13 = NL + "\t\t}";
32
  protected final String TEXT_14 = NL;
32
  protected final String TEXT_14 = NL;
33
  protected final String TEXT_15 = NL;
33
34
34
  public String generate(Object argument)
35
  public String generate(Object argument)
35
  {
36
  {
Lines 38-45 Link Here
38
final CustomClass instance = (CustomClass) ((Object[]) argument)[0];
39
final CustomClass instance = (CustomClass) ((Object[]) argument)[0];
39
//final GraphDefDispatcher dispatcher = (GraphDefDispatcher) ((Object[]) argument)[1];
40
//final GraphDefDispatcher dispatcher = (GraphDefDispatcher) ((Object[]) argument)[1];
40
final String varName = (String) ((Object[]) argument)[2];
41
final String varName = (String) ((Object[]) argument)[2];
42
final boolean hasAttributes = !instance.getAttributes().isEmpty();
41
43
44
    	if (hasAttributes) {
42
    stringBuffer.append(TEXT_1);
45
    stringBuffer.append(TEXT_1);
46
    	}
43
    
47
    
44
int attrIndex = 0;
48
int attrIndex = 0;
45
for (Iterator attrs = instance.getAttributes().iterator(); attrs.hasNext(); attrIndex++){
49
for (Iterator attrs = instance.getAttributes().iterator(); attrs.hasNext(); attrIndex++){
Lines 80-87 Link Here
80
    
84
    
81
} //for 
85
} //for 
82
86
87
    	if (hasAttributes) {
83
    stringBuffer.append(TEXT_13);
88
    stringBuffer.append(TEXT_13);
89
    	}
84
    stringBuffer.append(TEXT_14);
90
    stringBuffer.append(TEXT_14);
91
    stringBuffer.append(TEXT_15);
85
    return stringBuffer.toString();
92
    return stringBuffer.toString();
86
  }
93
  }
87
}
94
}
(-)templates/top/Figure.javajet (-2 / +6 lines)
Lines 24-31 Link Here
24
	 * @generated
24
	 * @generated
25
	 */
25
	 */
26
	public <%=figure.getName()%>() {
26
	public <%=figure.getName()%>() {
27
		<%=dispatcher.dispatch(figure, dispatcher.create(figure, "this"))%>
27
<%
28
		<%=dispatcher.dispatch("Children", new Object[] {figure.getChildren(), dispatcher, "this"})%>
28
GraphDefDispatcher.LayoutArgs dispatcherArgs = dispatcher.createLayoutArgs(figure, "this", "genLayoutManager", null);
29
%>
30
		<%=dispatcher.dispatch("createLayout", dispatcherArgs)%>	
31
		<%=dispatcher.dispatch(figure, dispatcherArgs)%>
32
		<%=dispatcher.dispatch("Children", new Object[] {figure.getChildren(), dispatcher, dispatcherArgs})%>
29
	}
33
	}
30
	
34
	
31
	/**
35
	/**
(-)templates/top/Shape.javajet (-3 / +4 lines)
Lines 70-78 Link Here
70
	 * @generated
70
	 * @generated
71
	 */
71
	 */
72
	private <%=nextClassName%> createFigure<%=next.getName()%>() {
72
	private <%=nextClassName%> createFigure<%=next.getName()%>() {
73
<%=dispatcher.dispatch("instantiate", dispatcher.create(next, "rv"))%>
73
<% GraphDefDispatcher.LayoutArgs childFigureArgs = dispatcher.createLayoutArgs(next, next.getName(), "layoutManager" + next.getName(), null);%>
74
<%=dispatcher.dispatch("Children", new Object[] {next.getChildren(), dispatcher, "rv"})%>
74
<%=dispatcher.dispatch("instantiate", childFigureArgs)%>
75
		return rv;
75
<%=dispatcher.dispatch("Children", new Object[] {next.getChildren(), dispatcher, childFigureArgs})%>
76
		return <%=next.getName()%>;
76
	}
77
	}
77
78
78
<%}%>
79
<%}%>
(-)templates/children/Figure.javajet (-10 / +9 lines)
Lines 4-10 Link Here
4
Object[] args = (Object[]) argument;
4
Object[] args = (Object[]) argument;
5
List/*<Figure>*/ figureChildren = (List) args[0];
5
List/*<Figure>*/ figureChildren = (List) args[0];
6
final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[1];
6
final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[1];
7
String parentFigureVarName = (String) args[2];
7
GraphDefDispatcher.LayoutArgs parentArgs = (GraphDefDispatcher.LayoutArgs) args[2];
8
%>
8
%>
9
9
10
<%
10
<%
Lines 16-44 Link Here
16
while (!l.isEmpty()) {
16
while (!l.isEmpty()) {
17
	Object _nxt = l.removeFirst();
17
	Object _nxt = l.removeFirst();
18
	if (_nxt == marker) {
18
	if (_nxt == marker) {
19
		parentFigureVarName = (String) figureVarNamesStack.pop();
19
		parentArgs = (GraphDefDispatcher.LayoutArgs) figureVarNamesStack.pop();
20
		continue;
20
		continue;
21
	}
21
	}
22
	final FigureMarker figureMarker = (FigureMarker) _nxt;
22
	final FigureMarker figureMarker = (FigureMarker) _nxt;
23
	if (figureMarker instanceof FigureRef) {
23
	if (figureMarker instanceof FigureRef) {
24
		throw new IllegalStateException("FIXME: sorry, don't support FigureRef for a while");
24
		throw new IllegalStateException("FIXME: sorry, don't support FigureRef for a while");
25
	}
25
	}
26
	final String figureVarName = "fig" + figureCount;
26
	final String figureVarName = "fig_" + figureCount;
27
	final String layoutManagerVarName = "layouter" + figureCount;
27
	final String layoutManagerVarName = "layouter" + figureCount;
28
	final String layoutDataVarName = "layData" + figureCount;
28
	final String layoutDataVarName = "layData" + figureCount;
29
	figureCount++;%>
29
	figureCount++;%>
30
		// FIXME instantiate - FigureRef - dispatch to 'instantiate' template?
30
		// FIXME instantiate - FigureRef - dispatch to 'instantiate' template?
31
		<%GraphDefDispatcher.Args dargs = dispatcher.create((Figure) figureMarker, figureVarName);
31
		<%GraphDefDispatcher.LayoutArgs nextLevelArgs = dispatcher.createLayoutArgs((Figure) figureMarker, figureVarName, layoutManagerVarName, layoutDataVarName);%>
32
		GraphDefDispatcher.LayoutArgs layoutAwareArgs = dispatcher.createLayoutArgs(dargs, layoutManagerVarName, layoutDataVarName);%>
32
		<%=dispatcher.dispatch("instantiate", nextLevelArgs)%>
33
		<%=dispatcher.dispatch("instantiate", layoutAwareArgs)%>
33
		<%=parentArgs.getVariableName()%>.add(<%=figureVarName%>);
34
		<%=parentFigureVarName%>.add(<%=figureVarName%>);
34
		<%=dispatcher.dispatch("createLayoutData", dispatcher.createLayoutArgs(nextLevelArgs, parentArgs.getManagerVariableName(), layoutDataVarName))%>
35
		<%=dispatcher.dispatch("createLayoutData", layoutAwareArgs)%>
36
<%
35
<%
37
if (_nxt instanceof Figure && !((Figure) _nxt).getChildren().isEmpty()) {
36
if (_nxt instanceof Figure && !((Figure) _nxt).getChildren().isEmpty()) {
38
	l.addFirst(marker);
37
	l.addFirst(marker);
39
	l.addAll(0, ((Figure) _nxt).getChildren());
38
	l.addAll(0, ((Figure) _nxt).getChildren());
40
	figureVarNamesStack.push(parentFigureVarName);
39
	figureVarNamesStack.push(parentArgs);
41
	parentFigureVarName = figureVarName; // go on processing children of new parentFigure
40
	parentArgs = nextLevelArgs; // go on processing children of new parentFigure
42
} // if
41
} // if
43
} // while
42
} // while
44
%>
43
%>

Return to bug 134097