Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c18bf989e88b228353e7b70f7e128794e4a9402c (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
<%@ 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];
GraphDefDispatcher.LayoutArgs parentArgs = (GraphDefDispatcher.LayoutArgs) 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) {
		parentArgs = (GraphDefDispatcher.LayoutArgs) 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.LayoutArgs nextLevelArgs = dispatcher.createLayoutArgs((Figure) figureMarker, figureVarName, layoutManagerVarName, layoutDataVarName);%>
		<%=dispatcher.dispatch("instantiate", nextLevelArgs)%>
		<%=parentArgs.getVariableName()%>.add(<%=figureVarName%>);
		<%=dispatcher.dispatch("createLayoutData", dispatcher.createLayoutArgs(nextLevelArgs, parentArgs.getManagerVariableName(), layoutDataVarName))%>
<%
if (_nxt instanceof Figure && !((Figure) _nxt).getChildren().isEmpty()) {
	l.addFirst(marker);
	l.addAll(0, ((Figure) _nxt).getChildren());
	figureVarNamesStack.push(parentArgs);
	parentArgs = nextLevelArgs; // go on processing children of new parentFigure
} // if
} // while
%>

Back to the top