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/src
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/src')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/CustomClassAttributesGenerator.java11
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java19
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopFigureGenerator.java20
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java18
4 files changed, 43 insertions, 25 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/CustomClassAttributesGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/CustomClassAttributesGenerator.java
index 69138c367..d1f6ee175 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/CustomClassAttributesGenerator.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/CustomClassAttributesGenerator.java
@@ -16,7 +16,7 @@ public class CustomClassAttributesGenerator
}
protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
- protected final String TEXT_1 = NL + "\t\t{";
+ protected final String TEXT_1 = "\t\t{";
protected final String TEXT_2 = NL + "\t\t\t";
protected final String TEXT_3 = ";";
protected final String TEXT_4 = NL + "\t\t\t";
@@ -28,8 +28,9 @@ public class CustomClassAttributesGenerator
protected final String TEXT_10 = "(";
protected final String TEXT_11 = ");";
protected final String TEXT_12 = "\t";
- protected final String TEXT_13 = NL + "\t\t}" + NL;
+ protected final String TEXT_13 = NL + "\t\t}";
protected final String TEXT_14 = NL;
+ protected final String TEXT_15 = NL;
public String generate(Object argument)
{
@@ -38,8 +39,11 @@ public class CustomClassAttributesGenerator
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) {
stringBuffer.append(TEXT_1);
+ }
int attrIndex = 0;
for (Iterator attrs = instance.getAttributes().iterator(); attrs.hasNext(); attrIndex++){
@@ -80,8 +84,11 @@ for (Iterator attrs = instance.getAttributes().iterator(); attrs.hasNext(); attr
} //for
+ if (hasAttributes) {
stringBuffer.append(TEXT_13);
+ }
stringBuffer.append(TEXT_14);
+ stringBuffer.append(TEXT_15);
return stringBuffer.toString();
}
}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java
index 9bb14e158..52a77ff99 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java
@@ -31,7 +31,7 @@ public class FigureChildrenGenerator
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];
stringBuffer.append(TEXT_1);
@@ -43,34 +43,33 @@ 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++;
stringBuffer.append(TEXT_2);
- GraphDefDispatcher.Args dargs = dispatcher.create((Figure) figureMarker, figureVarName);
- GraphDefDispatcher.LayoutArgs layoutAwareArgs = dispatcher.createLayoutArgs(dargs, layoutManagerVarName, layoutDataVarName);
+ GraphDefDispatcher.LayoutArgs nextLevelArgs = dispatcher.createLayoutArgs((Figure) figureMarker, figureVarName, layoutManagerVarName, layoutDataVarName);
stringBuffer.append(TEXT_3);
- stringBuffer.append(dispatcher.dispatch("instantiate", layoutAwareArgs));
+ stringBuffer.append(dispatcher.dispatch("instantiate", nextLevelArgs));
stringBuffer.append(TEXT_4);
- stringBuffer.append(parentFigureVarName);
+ stringBuffer.append(parentArgs.getVariableName());
stringBuffer.append(TEXT_5);
stringBuffer.append(figureVarName);
stringBuffer.append(TEXT_6);
- stringBuffer.append(dispatcher.dispatch("createLayoutData", layoutAwareArgs));
+ stringBuffer.append(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/src/org/eclipse/gmf/graphdef/codegen/templates/TopFigureGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopFigureGenerator.java
index e0b79ef25..ae43904a4 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopFigureGenerator.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopFigureGenerator.java
@@ -21,10 +21,12 @@ public class TopFigureGenerator
protected final String TEXT_2 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
protected final String TEXT_3 = " extends ";
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 ";
- protected final String TEXT_5 = "() {" + NL + "\t\t";
+ protected final String TEXT_5 = "() {";
protected final String TEXT_6 = NL + "\t\t";
- 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 + "}";
- protected final String TEXT_8 = NL;
+ protected final String TEXT_7 = "\t" + NL + "\t\t";
+ protected final String TEXT_8 = NL + "\t\t";
+ 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 + "}";
+ protected final String TEXT_10 = NL;
public String generate(Object argument)
{
@@ -45,12 +47,18 @@ final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[3];
stringBuffer.append(TEXT_4);
stringBuffer.append(figure.getName());
stringBuffer.append(TEXT_5);
- stringBuffer.append(dispatcher.dispatch(figure, dispatcher.create(figure, "this")));
+
+GraphDefDispatcher.LayoutArgs dispatcherArgs = dispatcher.createLayoutArgs(figure, "this", "genLayoutManager", null);
+
stringBuffer.append(TEXT_6);
- stringBuffer.append(dispatcher.dispatch("Children", new Object[] {figure.getChildren(), dispatcher, "this"}));
+ stringBuffer.append(dispatcher.dispatch("createLayout", dispatcherArgs));
stringBuffer.append(TEXT_7);
- importManager.emitSortedImports();
+ stringBuffer.append(dispatcher.dispatch(figure, dispatcherArgs));
stringBuffer.append(TEXT_8);
+ stringBuffer.append(dispatcher.dispatch("Children", new Object[] {figure.getChildren(), dispatcher, dispatcherArgs}));
+ stringBuffer.append(TEXT_9);
+ importManager.emitSortedImports();
+ stringBuffer.append(TEXT_10);
return stringBuffer.toString();
}
}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java
index 26f5225b3..67577d724 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java
@@ -47,9 +47,10 @@ public class TopShapeGenerator
protected final String TEXT_27 = "() {";
protected final String TEXT_28 = NL;
protected final String TEXT_29 = NL;
- protected final String TEXT_30 = NL + "\t\treturn rv;" + NL + "\t}" + NL;
- 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 + "}";
- protected final String TEXT_32 = NL;
+ protected final String TEXT_30 = NL + "\t\treturn ";
+ protected final String TEXT_31 = ";" + NL + "\t}" + NL;
+ 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 + "}";
+ protected final String TEXT_33 = NL;
public String generate(Object argument)
{
@@ -124,15 +125,18 @@ for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext(); fc++)
stringBuffer.append(TEXT_26);
stringBuffer.append(next.getName());
stringBuffer.append(TEXT_27);
+ GraphDefDispatcher.LayoutArgs childFigureArgs = dispatcher.createLayoutArgs(next, next.getName(), "layoutManager" + next.getName(), null);
stringBuffer.append(TEXT_28);
- stringBuffer.append(dispatcher.dispatch("instantiate", dispatcher.create(next, "rv")));
+ stringBuffer.append(dispatcher.dispatch("instantiate", childFigureArgs));
stringBuffer.append(TEXT_29);
- stringBuffer.append(dispatcher.dispatch("Children", new Object[] {next.getChildren(), dispatcher, "rv"}));
+ stringBuffer.append(dispatcher.dispatch("Children", new Object[] {next.getChildren(), dispatcher, childFigureArgs}));
stringBuffer.append(TEXT_30);
- }
+ stringBuffer.append(next.getName());
stringBuffer.append(TEXT_31);
- importManager.emitSortedImports();
+ }
stringBuffer.append(TEXT_32);
+ importManager.emitSortedImports();
+ stringBuffer.append(TEXT_33);
return stringBuffer.toString();
}
}

Back to the top