Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-03-30 22:39:09 +0000
committeratikhomirov2006-03-30 22:39:09 +0000
commitdb90f31eb82df700d5759efae2142c6576e7dbf9 (patch)
treee277968672b43fbd079503c10e92f3114c40734e /plugins/org.eclipse.gmf.graphdef.codegen/templates
parent20861a6d1d320dbdd070f125e24d7ad25c32c321 (diff)
downloadorg.eclipse.gmf-tooling-db90f31eb82df700d5759efae2142c6576e7dbf9.tar.gz
org.eclipse.gmf-tooling-db90f31eb82df700d5759efae2142c6576e7dbf9.tar.xz
org.eclipse.gmf-tooling-db90f31eb82df700d5759efae2142c6576e7dbf9.zip
[mgolubev] #134097 Invalid code is generated for the node figure with XYLayout
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen/templates')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet6
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet19
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet8
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet7
4 files changed, 24 insertions, 16 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet
index 5d7424e22..fa176f2d8 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet
@@ -4,9 +4,11 @@
final CustomClass instance = (CustomClass) ((Object[]) argument)[0];
//final GraphDefDispatcher dispatcher = (GraphDefDispatcher) ((Object[]) argument)[1];
final String varName = (String) ((Object[]) argument)[2];
+final boolean hasAttributes = !instance.getAttributes().isEmpty();
%>
-
+<% if (hasAttributes) {%>
{
+<% }%>
<%
int attrIndex = 0;
for (Iterator attrs = instance.getAttributes().iterator(); attrs.hasNext(); attrIndex++){
@@ -32,5 +34,7 @@ for (Iterator attrs = instance.getAttributes().iterator(); attrs.hasNext(); attr
<%
} //for
%>
+<% if (hasAttributes) {%>
}
+<% }%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
index 48265eb87..c18bf989e 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
@@ -4,7 +4,7 @@
Object[] args = (Object[]) argument;
List/*<Figure>*/ figureChildren = (List) args[0];
final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[1];
-String parentFigureVarName = (String) args[2];
+GraphDefDispatcher.LayoutArgs parentArgs = (GraphDefDispatcher.LayoutArgs) args[2];
%>
<%
@@ -16,29 +16,28 @@ int figureCount = 0;
while (!l.isEmpty()) {
Object _nxt = l.removeFirst();
if (_nxt == marker) {
- parentFigureVarName = (String) figureVarNamesStack.pop();
+ 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 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)%>
+ <%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(parentFigureVarName);
- parentFigureVarName = figureVarName; // go on processing children of new parentFigure
+ figureVarNamesStack.push(parentArgs);
+ parentArgs = nextLevelArgs; // go on processing children of new parentFigure
} // if
} // while
%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
index c362d4848..9233982ca 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
@@ -24,8 +24,12 @@ public class <%=figure.getName()%> extends <%=fqnSwitch.get(figure, importManage
* @generated
*/
public <%=figure.getName()%>() {
- <%=dispatcher.dispatch(figure, dispatcher.create(figure, "this"))%>
- <%=dispatcher.dispatch("Children", new Object[] {figure.getChildren(), dispatcher, "this"})%>
+<%
+GraphDefDispatcher.LayoutArgs dispatcherArgs = dispatcher.createLayoutArgs(figure, "this", "genLayoutManager", null);
+%>
+ <%=dispatcher.dispatch("createLayout", dispatcherArgs)%>
+ <%=dispatcher.dispatch(figure, dispatcherArgs)%>
+ <%=dispatcher.dispatch("Children", new Object[] {figure.getChildren(), dispatcher, dispatcherArgs})%>
}
/**
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet
index 096ea145a..4213475b4 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet
@@ -70,9 +70,10 @@ for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext(); fc++)
* @generated
*/
private <%=nextClassName%> createFigure<%=next.getName()%>() {
-<%=dispatcher.dispatch("instantiate", dispatcher.create(next, "rv"))%>
-<%=dispatcher.dispatch("Children", new Object[] {next.getChildren(), dispatcher, "rv"})%>
- return rv;
+<% GraphDefDispatcher.LayoutArgs childFigureArgs = dispatcher.createLayoutArgs(next, next.getName(), "layoutManager" + next.getName(), null);%>
+<%=dispatcher.dispatch("instantiate", childFigureArgs)%>
+<%=dispatcher.dispatch("Children", new Object[] {next.getChildren(), dispatcher, childFigureArgs})%>
+ return <%=next.getName()%>;
}
<%}%>

Back to the top