Skip to main content
aboutsummaryrefslogblamecommitdiffstats
blob: 48265eb87a69d1f04165125d3340262e81f8cd1c (plain) (tree)
1
2
3
4
5
6
7
                                                                                            
                                                                                             


                                                 

                                                                   

















                                                                                                     
                                                         
                                                                     

                                                                 
                                                                                      


                                                                                                                                              
                                                                 
                                                                             








                                                                                             
<%@ 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