Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 48265eb87a69d1f04165125d3340262e81f8cd1c (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
<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="FigureChildrenGenerator"
	imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.* java.util.*"%>
<%
Object[] args = (Object[]) argument;
List/*<Figure>*/ figureChildren = (List) args[0];
final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[1];
String parentFigureVarName = (String) args[2];
%>

<%
LinkedList l = new LinkedList();
l.addAll(figureChildren);
final Object marker = new Object();
Stack figureVarNamesStack = new Stack();
int figureCount = 0;
while (!l.isEmpty()) {
	Object _nxt = l.removeFirst();
	if (_nxt == marker) {
		parentFigureVarName = (String) figureVarNamesStack.pop();
		continue;
	}
	final FigureMarker figureMarker = (FigureMarker) _nxt;
	if (figureMarker instanceof FigureRef) {
		throw new IllegalStateException("FIXME: sorry, don't support FigureRef for a while");
	}
	final String figureVarName = "fig" + figureCount;
	final String layoutManagerVarName = "layouter" + figureCount;
	final String layoutDataVarName = "layData" + figureCount;
	figureCount++;%>
		// FIXME instantiate - FigureRef - dispatch to 'instantiate' template?
		<%GraphDefDispatcher.Args dargs = dispatcher.create((Figure) figureMarker, figureVarName);
		GraphDefDispatcher.LayoutArgs layoutAwareArgs = dispatcher.createLayoutArgs(dargs, layoutManagerVarName, layoutDataVarName);%>
		<%=dispatcher.dispatch("instantiate", layoutAwareArgs)%>
		<%=parentFigureVarName%>.add(<%=figureVarName%>);
		<%=dispatcher.dispatch("createLayoutData", layoutAwareArgs)%>
<%
if (_nxt instanceof Figure && !((Figure) _nxt).getChildren().isEmpty()) {
	l.addFirst(marker);
	l.addAll(0, ((Figure) _nxt).getChildren());
	figureVarNamesStack.push(parentFigureVarName);
	parentFigureVarName = figureVarName; // go on processing children of new parentFigure
} // if
} // while
%>

Back to the top