Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-02-06 13:10:22 -0500
committeratikhomirov2006-02-06 13:10:22 -0500
commitab3cbec7ac30ebc2acac1565d3a11e5de969c32b (patch)
tree6975082a424975a565a3ea20368f2279f968c1c2 /plugins
parent6e7a0cab3de84e293361d07e3545872589e22f68 (diff)
downloadorg.eclipse.gmf-tooling-ab3cbec7ac30ebc2acac1565d3a11e5de969c32b.tar.gz
org.eclipse.gmf-tooling-ab3cbec7ac30ebc2acac1565d3a11e5de969c32b.tar.xz
org.eclipse.gmf-tooling-ab3cbec7ac30ebc2acac1565d3a11e5de969c32b.zip
major refactoring of gmfgraph codegen utilizing dispatcher infrastructure
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/Dispatcher.java2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java118
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ConnectionGenerator.java329
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/CustomFigureGenerator.java290
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/DecorationFigureGenerator.java182
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureAttrGenerator.java106
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java76
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/LabelAttrGenerator.java41
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/LabelGenerator.java46
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewFigureGenerator.java48
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/PolygonDecorationAttrGenerator.java30
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/PolylineAttrGenerator.java54
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/PolylineDecorationAttrGenerator.java70
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/RoundedRectAttrGenerator.java49
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ShapeAttrGenerator.java94
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ShapeAttrsGenerator.java194
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ShapeGenerator.java548
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopConnectionGenerator.java91
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopFigureGenerator.java56
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java104
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/ArrayKeyChain.java38
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/DispatcherImpl.java55
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/HierarchyKeyMap.java46
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/KeyChain.java59
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/KeyMap.java29
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/TemplateRegistry.java1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/YAEmitterFactory.java10
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/ConcreteShape.javajet67
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/DecorationFigure.javajet32
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureAttrs.jetinc11
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureChildren.jetinc27
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Label.javajet24
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet19
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Label.javajet11
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylgonDecoration.javajet7
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Polyline.javajet16
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylineDecoration.javajet21
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/RoundedRectangle.javajet11
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.javajet (renamed from plugins/org.eclipse.gmf.graphdef.codegen/templates/ShapeAttrs.javajet)14
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet40
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/decoration.jetinc20
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/instantiate.jetinc20
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet13
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet (renamed from plugins/org.eclipse.gmf.graphdef.codegen/templates/CustomFigure.javajet)16
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet (renamed from plugins/org.eclipse.gmf.graphdef.codegen/templates/PolylineConnection.javajet)26
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet61
47 files changed, 1343 insertions, 1881 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/Dispatcher.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/Dispatcher.java
index d4d6dd5af..eabbfe8fb 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/Dispatcher.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/Dispatcher.java
@@ -20,7 +20,7 @@ import org.eclipse.gmf.gmfgraph.util.GMFGraphSwitch;
*/
public abstract class Dispatcher {
- public abstract String dispatch(Object arg, Object[] orginalArgs);
+ public abstract String dispatch(Object key, Object argument);
public abstract String dispatch(Object key, Args args);
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java
index 7fd87ed08..71b0616a2 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java
@@ -14,25 +14,33 @@ package org.eclipse.gmf.graphdef.codegen;
import java.util.ArrayList;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.codegen.jet.JETEmitter;
import org.eclipse.emf.codegen.jet.JETException;
-import org.eclipse.emf.common.util.BasicMonitor;
-import org.eclipse.gmf.common.UnexpectedBehaviourException;
+import org.eclipse.gmf.common.codegen.ImportAssistant;
import org.eclipse.gmf.common.codegen.NullImportAssistant;
-import org.eclipse.gmf.gmfgraph.CustomFigure;
-import org.eclipse.gmf.gmfgraph.DecorationFigure;
import org.eclipse.gmf.gmfgraph.Figure;
import org.eclipse.gmf.gmfgraph.Label;
+import org.eclipse.gmf.gmfgraph.PolygonDecoration;
+import org.eclipse.gmf.gmfgraph.Polyline;
import org.eclipse.gmf.gmfgraph.PolylineConnection;
+import org.eclipse.gmf.gmfgraph.PolylineDecoration;
+import org.eclipse.gmf.gmfgraph.RoundedRectangle;
import org.eclipse.gmf.gmfgraph.Shape;
-import org.eclipse.gmf.graphdef.codegen.templates.ConnectionGenerator;
-import org.eclipse.gmf.graphdef.codegen.templates.CustomFigureGenerator;
-import org.eclipse.gmf.graphdef.codegen.templates.DecorationFigureGenerator;
-import org.eclipse.gmf.graphdef.codegen.templates.LabelGenerator;
-import org.eclipse.gmf.graphdef.codegen.templates.ShapeAttrsGenerator;
-import org.eclipse.gmf.graphdef.codegen.templates.ShapeGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.FigureAttrGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.FigureChildrenGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.LabelAttrGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.NewFigureGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.PolygonDecorationAttrGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.PolylineAttrGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.PolylineDecorationAttrGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.RoundedRectAttrGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.ShapeAttrGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.TopConnectionGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.TopFigureGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.TopShapeGenerator;
import org.eclipse.gmf.internal.graphdef.codegen.DispatcherImpl;
-import org.eclipse.gmf.internal.graphdef.codegen.NoSuchTemplateException;
+import org.eclipse.gmf.internal.graphdef.codegen.HierarchyKeyMap;
+import org.eclipse.gmf.internal.graphdef.codegen.KeyChain;
+import org.eclipse.gmf.internal.graphdef.codegen.KeyMap;
import org.eclipse.gmf.internal.graphdef.codegen.StaticTemplateRegistry;
import org.eclipse.gmf.internal.graphdef.codegen.TemplateRegistry;
import org.eclipse.gmf.internal.graphdef.codegen.YAEmitterFactory;
@@ -44,8 +52,8 @@ import org.osgi.framework.Bundle;
*/
public class FigureGenerator {
private final String packageName;
- private YAEmitterFactory myFactory;
- private Dispatcher myDispatcher;
+ private Dispatcher myTopDispatcher;
+ private Dispatcher myInnerDispatcher;
public FigureGenerator() {
this(null);
@@ -61,8 +69,22 @@ public class FigureGenerator {
variables.add("org.eclipse.gmf.common");
variables.add("org.eclipse.gmf.graphdef.codegen");
- myFactory = new YAEmitterFactory(thisBundle.getEntry("/"), fill(), true, variables, true);
- myDispatcher = new DispatcherImpl(myFactory);
+ KeyMap keyMap = new HierarchyKeyMap() {
+ /*
+ * Capture knowledge that we use classes and strings as keys
+ */
+ public KeyChain map(Object key) {
+ if (key instanceof String) {
+ return super.map(key);
+ } else {
+ return super.map(key.getClass());
+ }
+ }
+ };
+ YAEmitterFactory topFactory = new YAEmitterFactory(thisBundle.getEntry("/"), fillTopLevel(), true, variables, true);
+ myTopDispatcher = new DispatcherImpl(topFactory, keyMap);
+ YAEmitterFactory innerFactory = new YAEmitterFactory(thisBundle.getEntry("/"), fillAttrs(), true, variables, true);
+ myInnerDispatcher = new DispatcherImpl(innerFactory, keyMap);
}
/**
@@ -72,45 +94,49 @@ public class FigureGenerator {
return packageName;
}
- private static TemplateRegistry fill() {
+ private static TemplateRegistry fillTopLevel() {
StaticTemplateRegistry tr = new StaticTemplateRegistry();
- tr.put(PolylineConnection.class, "/templates/PolylineConnection.javajet", ConnectionGenerator.class);
- tr.put(DecorationFigure.class, "/templates/DecorationFigure.javajet", DecorationFigureGenerator.class);
- tr.put(Shape.class, "/templates/ConcreteShape.javajet", ShapeGenerator.class);
- tr.put(Label.class, "/templates/Label.javajet", LabelGenerator.class);
- tr.put(CustomFigure.class, "/templates/CustomFigure.javajet", CustomFigureGenerator.class);
- tr.put("ShapeAttrs", "/templates/ShapeAttrs.javajet", ShapeAttrsGenerator.class);
+ tr.put(PolylineConnection.class, "/templates/PolylineConnection.javajet", TopConnectionGenerator.class);
+ tr.put(Shape.class, "/templates/top/Shape.javajet", TopShapeGenerator.class);
+ tr.put(Figure.class, "/templates/top/Figure.javajet", TopFigureGenerator.class);
+ return tr;
+ }
+
+ // XXX NOTE, the fact we use "instantiate" and "Children" strings
+ // helps us to postpone resolution of the next problem (one we make these twwo overridable):
+ // it's not possible to tell from single dispatcher.dispatch(Figure, args) what's the intention -
+ // whether to instantiate, look for children or initialize attributes
+ // Perhaps, we should have distinct methods in the Dispatcher, or add "hint" as another argument
+ private static TemplateRegistry fillAttrs() {
+ StaticTemplateRegistry tr = new StaticTemplateRegistry();
+ tr.put(Figure.class, "/templates/attr/Figure.javajet", FigureAttrGenerator.class);
+ tr.put(Shape.class, "/templates/attr/Shape.javajet", ShapeAttrGenerator.class);
+ tr.put(Label.class, "/templates/attr/Label.javajet", LabelAttrGenerator.class);
+ tr.put(Polyline.class, "/templates/attr/Polyline.javajet", PolylineAttrGenerator.class);
+ tr.put(RoundedRectangle.class, "/templates/attr/RoundedRectangle.javajet", RoundedRectAttrGenerator.class);
+ tr.put(PolygonDecoration.class, "/templates/attr/PolygonDecoration.javajet", PolygonDecorationAttrGenerator.class);
+ tr.put(PolylineDecoration.class, "/templates/attr/PolylineDecoration.javajet", PolylineDecorationAttrGenerator.class);
+ // instantiation templates - only single one now. FIXME - make it overridable
+ tr.put("instantiate", "/templates/new/Figure.javajet", NewFigureGenerator.class);
+ // children templates - only single one now. FIXME - make it overridable
+ tr.put("Children", "/templates/children/Figure.javajet", FigureChildrenGenerator.class);
+ // FIXME same template is registered twice
+ tr.put("Shape", "/templates/attr/Shape.javajet", ShapeAttrGenerator.class);
+ tr.put("Figure", "/templates/attr/Figure.javajet", FigureAttrGenerator.class);
+ tr.put("PolylineDecoration", "/templates/attr/PolylineDecoration.javajet", PolylineDecorationAttrGenerator.class);
return tr;
}
public String go(Figure fig) throws JETException {
+ return go(fig, new NullImportAssistant());
+ }
+
+ public String go(Figure fig, ImportAssistant importManager) {
String res = null;
- try {
- if (fig instanceof PolylineConnection) {
- res = generate(fig, myFactory.acquireEmitter(PolylineConnection.class));
- } else if (fig instanceof DecorationFigure) {
- res = generate(fig, myFactory.acquireEmitter(DecorationFigure.class));
- } else if (fig instanceof Shape) {
- res = generate(fig, myFactory.acquireEmitter(Shape.class));
- } else if (fig instanceof CustomFigure) {
- res = generate(fig, myFactory.acquireEmitter(CustomFigure.class));
- } else if (fig instanceof Label) {
- res = generate(fig, myFactory.acquireEmitter(Label.class));
- }
-// TODO: } else if (fig instanceof LabeledContainer) {
+ res = myTopDispatcher.dispatch(fig, new Object[] {fig, importManager, myInnerDispatcher});
if (res == null) {
throw new IllegalStateException();
}
- } catch (UnexpectedBehaviourException ex) {
- throw new IllegalStateException(ex);
- } catch (NoSuchTemplateException ex) {
- throw new IllegalStateException(ex);
- }
return packageName == null ? res : "package " + packageName + ";\n" + res;
}
-
- private String generate(Figure fig, JETEmitter emitter) throws JETException {
- Object argument = new Object[] {fig, new NullImportAssistant(), myDispatcher};
- return emitter.generate(new BasicMonitor.Printing(System.out), new Object[] {argument});
- }
}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ConnectionGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ConnectionGenerator.java
deleted file mode 100644
index c26dee0b5..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ConnectionGenerator.java
+++ /dev/null
@@ -1,329 +0,0 @@
-package org.eclipse.gmf.graphdef.codegen.templates;
-
-import org.eclipse.gmf.gmfgraph.*;
-import org.eclipse.gmf.gmfgraph.util.*;
-import org.eclipse.gmf.common.codegen.*;
-import org.eclipse.gmf.graphdef.codegen.Dispatcher;
-import java.util.*;
-
-public class ConnectionGenerator
-{
- protected static String nl;
- public static synchronized ConnectionGenerator create(String lineSeparator)
- {
- nl = lineSeparator;
- ConnectionGenerator result = new ConnectionGenerator();
- nl = null;
- return result;
- }
-
- protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
- protected final String TEXT_1 = "";
- protected final String TEXT_2 = NL;
- protected final String TEXT_3 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
- protected final String TEXT_4 = " extends ";
- protected final String TEXT_5 = " {" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
- protected final String TEXT_6 = "() {";
- protected final String TEXT_7 = NL;
- protected final String TEXT_8 = NL + "\t\tsetSourceDecoration(createSourceDecoration());";
- protected final String TEXT_9 = NL + "\t\tsetTargetDecoration(createTargetDecoration());";
- protected final String TEXT_10 = NL + "\t}" + NL;
- protected final String TEXT_11 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ";
- protected final String TEXT_12 = " createSourceDecoration() {";
- protected final String TEXT_13 = NL;
- protected final String TEXT_14 = "\t\t";
- protected final String TEXT_15 = " ";
- protected final String TEXT_16 = " = new ";
- protected final String TEXT_17 = "();";
- protected final String TEXT_18 = NL;
- protected final String TEXT_19 = NL + "\t\t";
- protected final String TEXT_20 = ".setForegroundColor(";
- protected final String TEXT_21 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_22 = ", ";
- protected final String TEXT_23 = ", ";
- protected final String TEXT_24 = ")";
- protected final String TEXT_25 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_26 = ");";
- protected final String TEXT_27 = NL + "\t\t";
- protected final String TEXT_28 = ".setBackgroundColor(";
- protected final String TEXT_29 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_30 = ", ";
- protected final String TEXT_31 = ", ";
- protected final String TEXT_32 = ")";
- protected final String TEXT_33 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_34 = ");";
- protected final String TEXT_35 = NL + "\t\t";
- protected final String TEXT_36 = ".setPreferredSize(getMapMode().DPtoLP(";
- protected final String TEXT_37 = "), getMapMode().DPtoLP(";
- protected final String TEXT_38 = "));";
- protected final String TEXT_39 = NL + "\t\torg.eclipse.draw2d.geometry.PointList pl = new org.eclipse.draw2d.geometry.PointList();";
- protected final String TEXT_40 = NL + "\t\tpl.addPoint(";
- protected final String TEXT_41 = ", ";
- protected final String TEXT_42 = ");";
- protected final String TEXT_43 = NL + "\t\t";
- protected final String TEXT_44 = ".setTemplate(pl);";
- protected final String TEXT_45 = NL + "\t\t";
- protected final String TEXT_46 = ".setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));";
- protected final String TEXT_47 = NL + "\t\treturn ";
- protected final String TEXT_48 = ";" + NL + "\t}";
- protected final String TEXT_49 = NL;
- protected final String TEXT_50 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ";
- protected final String TEXT_51 = " createTargetDecoration() {";
- protected final String TEXT_52 = NL;
- protected final String TEXT_53 = "\t\t";
- protected final String TEXT_54 = " ";
- protected final String TEXT_55 = " = new ";
- protected final String TEXT_56 = "();";
- protected final String TEXT_57 = NL;
- protected final String TEXT_58 = NL + "\t\t";
- protected final String TEXT_59 = ".setForegroundColor(";
- protected final String TEXT_60 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_61 = ", ";
- protected final String TEXT_62 = ", ";
- protected final String TEXT_63 = ")";
- protected final String TEXT_64 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_65 = ");";
- protected final String TEXT_66 = NL + "\t\t";
- protected final String TEXT_67 = ".setBackgroundColor(";
- protected final String TEXT_68 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_69 = ", ";
- protected final String TEXT_70 = ", ";
- protected final String TEXT_71 = ")";
- protected final String TEXT_72 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_73 = ");";
- protected final String TEXT_74 = NL + "\t\t";
- protected final String TEXT_75 = ".setPreferredSize(getMapMode().DPtoLP(";
- protected final String TEXT_76 = "), getMapMode().DPtoLP(";
- protected final String TEXT_77 = "));";
- protected final String TEXT_78 = NL + "\t\torg.eclipse.draw2d.geometry.PointList pl = new org.eclipse.draw2d.geometry.PointList();";
- protected final String TEXT_79 = NL + "\t\tpl.addPoint(";
- protected final String TEXT_80 = ", ";
- protected final String TEXT_81 = ");";
- protected final String TEXT_82 = NL + "\t\t";
- protected final String TEXT_83 = ".setTemplate(pl);";
- protected final String TEXT_84 = NL + "\t\t";
- protected final String TEXT_85 = ".setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));";
- protected final String TEXT_86 = NL + "\t\treturn ";
- protected final String TEXT_87 = ";" + NL + "\t}";
- protected final String TEXT_88 = NL + "}";
-
- public String generate(Object argument)
- {
- StringBuffer stringBuffer = new StringBuffer();
- stringBuffer.append(TEXT_1);
-
-Object[] args = (Object[]) argument;
-PolylineConnection figure = (PolylineConnection) args[0];
-final ImportAssistant importManager = (ImportAssistant) args[1];
-final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
-final Dispatcher dispatcher = (Dispatcher) args[2];
-
- stringBuffer.append(TEXT_2);
- importManager.markImportLocation(stringBuffer);
- stringBuffer.append(TEXT_3);
- stringBuffer.append(figure.getName());
- stringBuffer.append(TEXT_4);
- stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx"));
- stringBuffer.append(TEXT_5);
- stringBuffer.append(figure.getName());
- stringBuffer.append(TEXT_6);
- stringBuffer.append(TEXT_7);
- stringBuffer.append(dispatcher.dispatch("ShapeAttrs", dispatcher.create(figure, "this", importManager, fqnSwitch)));
- if (figure.getSourceDecoration() != null) {
- stringBuffer.append(TEXT_8);
- }
-if (figure.getTargetDecoration() != null) {
- stringBuffer.append(TEXT_9);
- }
- stringBuffer.append(TEXT_10);
- String decFigVarName = "df";
-if (figure.getSourceDecoration() != null) {
-DecorationFigure df = figure.getSourceDecoration();
- stringBuffer.append(TEXT_11);
- stringBuffer.append(fqnSwitch.doSwitch(df));
- stringBuffer.append(TEXT_12);
- stringBuffer.append(TEXT_13);
- stringBuffer.append(TEXT_14);
- stringBuffer.append(fqnSwitch.doSwitch(df));
- stringBuffer.append(TEXT_15);
- stringBuffer.append(decFigVarName);
- stringBuffer.append(TEXT_16);
- stringBuffer.append(fqnSwitch.doSwitch(df));
- stringBuffer.append(TEXT_17);
- { // scope
-Figure figureInstance = df;
-String figureVarName = decFigVarName;
-
- stringBuffer.append(TEXT_18);
- Color colorVal;
-if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
- colorVal = figureInstance.getForegroundColor();
- stringBuffer.append(TEXT_19);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_20);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_21);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_22);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_23);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_24);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_25);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_26);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
- colorVal = figureInstance.getBackgroundColor();
- stringBuffer.append(TEXT_27);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_28);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_29);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_30);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_31);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_32);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_33);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_34);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) {
- Dimension d = figureInstance.getPreferredSize();
- stringBuffer.append(TEXT_35);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_36);
- stringBuffer.append(d.getDx());
- stringBuffer.append(TEXT_37);
- stringBuffer.append(d.getDy());
- stringBuffer.append(TEXT_38);
- }
- } // scope
- /*include FigureChildren*/
-
-if ((df instanceof PolylineDecoration || df instanceof PolygonDecoration)) {
- if (!((Polyline) df).getTemplate().isEmpty()) {
-
- stringBuffer.append(TEXT_39);
- for (Iterator pointIt = ((Polyline) df).getTemplate().iterator(); pointIt.hasNext(); ) {
- Point p = (Point) pointIt.next();
- stringBuffer.append(TEXT_40);
- stringBuffer.append(p.getX());
- stringBuffer.append(TEXT_41);
- stringBuffer.append(p.getY());
- stringBuffer.append(TEXT_42);
- } /*for*/
- stringBuffer.append(TEXT_43);
- stringBuffer.append(decFigVarName);
- stringBuffer.append(TEXT_44);
- } /*!if getTemplate().isEmpty()*/
- stringBuffer.append(TEXT_45);
- stringBuffer.append(decFigVarName);
- stringBuffer.append(TEXT_46);
- } /*if instanceof */
- stringBuffer.append(TEXT_47);
- stringBuffer.append(decFigVarName);
- stringBuffer.append(TEXT_48);
- } /*if sourceDecoration != null */
- stringBuffer.append(TEXT_49);
- if (figure.getTargetDecoration() != null) {
-DecorationFigure df = figure.getTargetDecoration();
- stringBuffer.append(TEXT_50);
- stringBuffer.append(fqnSwitch.doSwitch(df));
- stringBuffer.append(TEXT_51);
- stringBuffer.append(TEXT_52);
- stringBuffer.append(TEXT_53);
- stringBuffer.append(fqnSwitch.doSwitch(df));
- stringBuffer.append(TEXT_54);
- stringBuffer.append(decFigVarName);
- stringBuffer.append(TEXT_55);
- stringBuffer.append(fqnSwitch.doSwitch(df));
- stringBuffer.append(TEXT_56);
- { // scope
-Figure figureInstance = df;
-String figureVarName = decFigVarName;
-
- stringBuffer.append(TEXT_57);
- Color colorVal;
-if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
- colorVal = figureInstance.getForegroundColor();
- stringBuffer.append(TEXT_58);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_59);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_60);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_61);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_62);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_63);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_64);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_65);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
- colorVal = figureInstance.getBackgroundColor();
- stringBuffer.append(TEXT_66);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_67);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_68);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_69);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_70);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_71);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_72);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_73);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) {
- Dimension d = figureInstance.getPreferredSize();
- stringBuffer.append(TEXT_74);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_75);
- stringBuffer.append(d.getDx());
- stringBuffer.append(TEXT_76);
- stringBuffer.append(d.getDy());
- stringBuffer.append(TEXT_77);
- }
- } // scope
- /*include FigureChildren*/
-
-if ((df instanceof PolylineDecoration || df instanceof PolygonDecoration)) {
- if (!((Polyline) df).getTemplate().isEmpty()) {
-
- stringBuffer.append(TEXT_78);
- for (Iterator pointIt = ((Polyline) df).getTemplate().iterator(); pointIt.hasNext(); ) {
- Point p = (Point) pointIt.next();
- stringBuffer.append(TEXT_79);
- stringBuffer.append(p.getX());
- stringBuffer.append(TEXT_80);
- stringBuffer.append(p.getY());
- stringBuffer.append(TEXT_81);
- } /*for*/
- stringBuffer.append(TEXT_82);
- stringBuffer.append(decFigVarName);
- stringBuffer.append(TEXT_83);
- } /*!if getTemplate().isEmpty()*/
- stringBuffer.append(TEXT_84);
- stringBuffer.append(decFigVarName);
- stringBuffer.append(TEXT_85);
- } /*if instanceof */
- stringBuffer.append(TEXT_86);
- stringBuffer.append(decFigVarName);
- stringBuffer.append(TEXT_87);
- }
- stringBuffer.append(TEXT_88);
- importManager.emitSortedImports();
- return stringBuffer.toString();
- }
-}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/CustomFigureGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/CustomFigureGenerator.java
deleted file mode 100644
index 2dcd49580..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/CustomFigureGenerator.java
+++ /dev/null
@@ -1,290 +0,0 @@
-package org.eclipse.gmf.graphdef.codegen.templates;
-
-import org.eclipse.gmf.gmfgraph.*;
-import org.eclipse.gmf.gmfgraph.util.*;
-import org.eclipse.gmf.common.codegen.*;
-import org.eclipse.gmf.graphdef.codegen.Dispatcher;
-import java.util.*;
-
-public class CustomFigureGenerator
-{
- protected static String nl;
- public static synchronized CustomFigureGenerator create(String lineSeparator)
- {
- nl = lineSeparator;
- CustomFigureGenerator result = new CustomFigureGenerator();
- nl = null;
- return result;
- }
-
- protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
- protected final String TEXT_1 = "";
- 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 + "\tpublic ";
- protected final String TEXT_5 = "() {" + NL + "\t\t// TODO - process custom properties here";
- protected final String TEXT_6 = NL;
- protected final String TEXT_7 = NL;
- protected final String TEXT_8 = NL + "\t\t";
- protected final String TEXT_9 = " ";
- protected final String TEXT_10 = " = new ";
- protected final String TEXT_11 = "();";
- protected final String TEXT_12 = NL;
- protected final String TEXT_13 = NL + "\t\t";
- protected final String TEXT_14 = ".setForegroundColor(";
- protected final String TEXT_15 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_16 = ", ";
- protected final String TEXT_17 = ", ";
- protected final String TEXT_18 = ")";
- protected final String TEXT_19 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_20 = ");";
- protected final String TEXT_21 = NL + "\t\t";
- protected final String TEXT_22 = ".setBackgroundColor(";
- protected final String TEXT_23 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_24 = ", ";
- protected final String TEXT_25 = ", ";
- protected final String TEXT_26 = ")";
- protected final String TEXT_27 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_28 = ");";
- protected final String TEXT_29 = NL + "\t\t";
- protected final String TEXT_30 = ".setPreferredSize(getMapMode().DPtoLP(";
- protected final String TEXT_31 = "), getMapMode().DPtoLP(";
- protected final String TEXT_32 = "));";
- protected final String TEXT_33 = NL + "\t\t";
- protected final String TEXT_34 = " ";
- protected final String TEXT_35 = " = new ";
- protected final String TEXT_36 = "();";
- protected final String TEXT_37 = NL;
- protected final String TEXT_38 = NL + "\t\torg.eclipse.draw2d.IFigure ";
- protected final String TEXT_39 = " = new ";
- protected final String TEXT_40 = "();";
- protected final String TEXT_41 = NL + "\t\t";
- protected final String TEXT_42 = " ";
- protected final String TEXT_43 = " = new ";
- protected final String TEXT_44 = "();" + NL + "\t\t";
- protected final String TEXT_45 = ".setText(\"";
- protected final String TEXT_46 = "\");";
- protected final String TEXT_47 = NL;
- protected final String TEXT_48 = NL + "\t\t";
- protected final String TEXT_49 = ".setForegroundColor(";
- protected final String TEXT_50 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_51 = ", ";
- protected final String TEXT_52 = ", ";
- protected final String TEXT_53 = ")";
- protected final String TEXT_54 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_55 = ");";
- protected final String TEXT_56 = NL + "\t\t";
- protected final String TEXT_57 = ".setBackgroundColor(";
- protected final String TEXT_58 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_59 = ", ";
- protected final String TEXT_60 = ", ";
- protected final String TEXT_61 = ")";
- protected final String TEXT_62 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_63 = ");";
- protected final String TEXT_64 = NL + "\t\t";
- protected final String TEXT_65 = ".setPreferredSize(getMapMode().DPtoLP(";
- protected final String TEXT_66 = "), getMapMode().DPtoLP(";
- protected final String TEXT_67 = "));";
- protected final String TEXT_68 = NL + "\t\t";
- protected final String TEXT_69 = ".add(";
- protected final String TEXT_70 = ");";
- protected final String TEXT_71 = NL + "\t}" + NL + "}";
-
- public String generate(Object argument)
- {
- StringBuffer stringBuffer = new StringBuffer();
-
-Object[] args = (Object[]) argument;
-CustomFigure figure = (CustomFigure) args[0];
-final ImportAssistant importManager = (ImportAssistant) args[1];
-final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
-final Dispatcher dispatcher = (Dispatcher) args[2];
-
- stringBuffer.append(TEXT_1);
- importManager.markImportLocation(stringBuffer);
- stringBuffer.append(TEXT_2);
- stringBuffer.append(figure.getName());
- stringBuffer.append(TEXT_3);
- stringBuffer.append(importManager.getImportedName(figure.getQualifiedClassName()));
- stringBuffer.append(TEXT_4);
- stringBuffer.append(figure.getName());
- stringBuffer.append(TEXT_5);
- String parentFigureVarName = "this";
- stringBuffer.append(TEXT_6);
-
-LinkedList l = new LinkedList();
-l.addAll(figure.getChildren());
-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;
- }
- FigureMarker figureMarker = (FigureMarker) _nxt;
- String figureVarName = "fig" + (figureCount++);
- stringBuffer.append(TEXT_7);
-
-// FigureMarker: figureMarker
-// String: figureVarName
-if (figureMarker instanceof CustomFigure) {
- CustomFigure figureInstance = (CustomFigure) figureMarker;
-
- stringBuffer.append(TEXT_8);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_9);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_10);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_11);
- stringBuffer.append(TEXT_12);
- Color colorVal;
-if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
- colorVal = figureInstance.getForegroundColor();
- stringBuffer.append(TEXT_13);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_14);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_15);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_16);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_17);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_18);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_19);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_20);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
- colorVal = figureInstance.getBackgroundColor();
- stringBuffer.append(TEXT_21);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_22);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_23);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_24);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_25);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_26);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_27);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_28);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) {
- Dimension d = figureInstance.getPreferredSize();
- stringBuffer.append(TEXT_29);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_30);
- stringBuffer.append(d.getDx());
- stringBuffer.append(TEXT_31);
- stringBuffer.append(d.getDy());
- stringBuffer.append(TEXT_32);
- }
- } else if (figureMarker instanceof Shape) {
-Shape figureInstance = (Shape) figureMarker;
- stringBuffer.append(TEXT_33);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_34);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_35);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_36);
- stringBuffer.append(TEXT_37);
- stringBuffer.append(dispatcher.dispatch("ShapeAttrs", dispatcher.create(figureInstance, figureVarName, importManager, fqnSwitch)));
- } else if (figureMarker instanceof FigureRef) {
- stringBuffer.append(TEXT_38);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_39);
- stringBuffer.append(((FigureRef) figureMarker).getFigure().getName());
- stringBuffer.append(TEXT_40);
- } else if (figureMarker instanceof Label) {
- Label figureInstance = (Label) figureMarker;
-
- stringBuffer.append(TEXT_41);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_42);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_43);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_44);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_45);
- stringBuffer.append(((Label) figureMarker).getText());
- stringBuffer.append(TEXT_46);
- stringBuffer.append(TEXT_47);
- Color colorVal;
-if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
- colorVal = figureInstance.getForegroundColor();
- stringBuffer.append(TEXT_48);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_49);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_50);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_51);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_52);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_53);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_54);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_55);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
- colorVal = figureInstance.getBackgroundColor();
- stringBuffer.append(TEXT_56);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_57);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_58);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_59);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_60);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_61);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_62);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_63);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) {
- Dimension d = figureInstance.getPreferredSize();
- stringBuffer.append(TEXT_64);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_65);
- stringBuffer.append(d.getDx());
- stringBuffer.append(TEXT_66);
- stringBuffer.append(d.getDy());
- stringBuffer.append(TEXT_67);
- }
- }
- stringBuffer.append(TEXT_68);
- stringBuffer.append(parentFigureVarName);
- stringBuffer.append(TEXT_69);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_70);
-
-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
-}
-
-
-} // while
-
- stringBuffer.append(TEXT_71);
- importManager.emitSortedImports();
- return stringBuffer.toString();
- }
-}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/DecorationFigureGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/DecorationFigureGenerator.java
deleted file mode 100644
index 82b990513..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/DecorationFigureGenerator.java
+++ /dev/null
@@ -1,182 +0,0 @@
-package org.eclipse.gmf.graphdef.codegen.templates;
-
-import org.eclipse.gmf.gmfgraph.*;
-import org.eclipse.gmf.gmfgraph.util.*;
-import org.eclipse.gmf.common.codegen.*;
-import java.util.*;
-
-public class DecorationFigureGenerator
-{
- protected static String nl;
- public static synchronized DecorationFigureGenerator create(String lineSeparator)
- {
- nl = lineSeparator;
- DecorationFigureGenerator result = new DecorationFigureGenerator();
- nl = null;
- return result;
- }
-
- protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
- protected final String TEXT_1 = "";
- protected final String TEXT_2 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "class ";
- protected final String TEXT_3 = " extends ";
- protected final String TEXT_4 = " {" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
- protected final String TEXT_5 = "() {";
- protected final String TEXT_6 = NL;
- protected final String TEXT_7 = "\t\t";
- protected final String TEXT_8 = " ";
- protected final String TEXT_9 = " = new ";
- protected final String TEXT_10 = "();";
- protected final String TEXT_11 = NL;
- protected final String TEXT_12 = NL + "\t\t";
- protected final String TEXT_13 = ".setForegroundColor(";
- protected final String TEXT_14 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_15 = ", ";
- protected final String TEXT_16 = ", ";
- protected final String TEXT_17 = ")";
- protected final String TEXT_18 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_19 = ");";
- protected final String TEXT_20 = NL + "\t\t";
- protected final String TEXT_21 = ".setBackgroundColor(";
- protected final String TEXT_22 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_23 = ", ";
- protected final String TEXT_24 = ", ";
- protected final String TEXT_25 = ")";
- protected final String TEXT_26 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_27 = ");";
- protected final String TEXT_28 = NL + "\t\t";
- protected final String TEXT_29 = ".setPreferredSize(getMapMode().DPtoLP(";
- protected final String TEXT_30 = "), getMapMode().DPtoLP(";
- protected final String TEXT_31 = "));";
- protected final String TEXT_32 = NL + "\t\torg.eclipse.draw2d.geometry.PointList pl = new org.eclipse.draw2d.geometry.PointList();";
- protected final String TEXT_33 = NL + "\t\tpl.addPoint(";
- protected final String TEXT_34 = ", ";
- protected final String TEXT_35 = ");";
- protected final String TEXT_36 = NL + "\t\t";
- protected final String TEXT_37 = ".setTemplate(pl);";
- protected final String TEXT_38 = NL + "\t\t";
- protected final String TEXT_39 = ".setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));";
- protected final String TEXT_40 = NL + "\t\tsetScale(";
- protected final String TEXT_41 = ", ";
- protected final String TEXT_42 = ");";
- protected final String TEXT_43 = NL + "\t}" + NL + "}";
-
- public String generate(Object argument)
- {
- StringBuffer stringBuffer = new StringBuffer();
-
-Object[] args = (Object[]) argument;
-DecorationFigure figure = (DecorationFigure) args[0];
-final ImportAssistant importManager = (ImportAssistant) args[1];
-assert false == figure instanceof CustomFigure;
-final Point scale;
-scale = null; //XXX
-final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
-
- stringBuffer.append(TEXT_1);
- importManager.markImportLocation(stringBuffer);
- stringBuffer.append(TEXT_2);
- stringBuffer.append(figure.getName());
- stringBuffer.append(TEXT_3);
- stringBuffer.append(importManager.getImportedName((String) fqnSwitch.doSwitch(figure)));
- stringBuffer.append(TEXT_4);
- stringBuffer.append(figure.getName());
- stringBuffer.append(TEXT_5);
-
-DecorationFigure df = figure;
-String decFigVarName = "this";
- stringBuffer.append(TEXT_6);
- stringBuffer.append(TEXT_7);
- stringBuffer.append(fqnSwitch.doSwitch(df));
- stringBuffer.append(TEXT_8);
- stringBuffer.append(decFigVarName);
- stringBuffer.append(TEXT_9);
- stringBuffer.append(fqnSwitch.doSwitch(df));
- stringBuffer.append(TEXT_10);
- { // scope
-Figure figureInstance = df;
-String figureVarName = decFigVarName;
-
- stringBuffer.append(TEXT_11);
- Color colorVal;
-if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
- colorVal = figureInstance.getForegroundColor();
- stringBuffer.append(TEXT_12);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_13);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_14);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_15);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_16);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_17);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_18);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_19);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
- colorVal = figureInstance.getBackgroundColor();
- stringBuffer.append(TEXT_20);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_21);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_22);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_23);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_24);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_25);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_26);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_27);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) {
- Dimension d = figureInstance.getPreferredSize();
- stringBuffer.append(TEXT_28);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_29);
- stringBuffer.append(d.getDx());
- stringBuffer.append(TEXT_30);
- stringBuffer.append(d.getDy());
- stringBuffer.append(TEXT_31);
- }
- } // scope
- /*include FigureChildren*/
-
-if ((df instanceof PolylineDecoration || df instanceof PolygonDecoration)) {
- if (!((Polyline) df).getTemplate().isEmpty()) {
-
- stringBuffer.append(TEXT_32);
- for (Iterator pointIt = ((Polyline) df).getTemplate().iterator(); pointIt.hasNext(); ) {
- Point p = (Point) pointIt.next();
- stringBuffer.append(TEXT_33);
- stringBuffer.append(p.getX());
- stringBuffer.append(TEXT_34);
- stringBuffer.append(p.getY());
- stringBuffer.append(TEXT_35);
- } /*for*/
- stringBuffer.append(TEXT_36);
- stringBuffer.append(decFigVarName);
- stringBuffer.append(TEXT_37);
- } /*!if getTemplate().isEmpty()*/
- stringBuffer.append(TEXT_38);
- stringBuffer.append(decFigVarName);
- stringBuffer.append(TEXT_39);
- } /*if instanceof */
- if (scale != null) {
- stringBuffer.append(TEXT_40);
- stringBuffer.append(scale.getX());
- stringBuffer.append(TEXT_41);
- stringBuffer.append(scale.getY());
- stringBuffer.append(TEXT_42);
- }
- stringBuffer.append(TEXT_43);
- importManager.emitSortedImports();
- return stringBuffer.toString();
- }
-}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureAttrGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureAttrGenerator.java
new file mode 100644
index 000000000..db4ab0463
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureAttrGenerator.java
@@ -0,0 +1,106 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.common.codegen.*;
+import org.eclipse.gmf.graphdef.codegen.Dispatcher;
+
+public class FigureAttrGenerator
+{
+ protected static String nl;
+ public static synchronized FigureAttrGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ FigureAttrGenerator result = new FigureAttrGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "\t\t";
+ protected final String TEXT_2 = ".setForegroundColor(";
+ protected final String TEXT_3 = "new ";
+ protected final String TEXT_4 = "(null, ";
+ protected final String TEXT_5 = ", ";
+ protected final String TEXT_6 = ", ";
+ protected final String TEXT_7 = ")";
+ protected final String TEXT_8 = ".";
+ protected final String TEXT_9 = ");";
+ protected final String TEXT_10 = NL + "\t\t";
+ protected final String TEXT_11 = ".setBackgroundColor(";
+ protected final String TEXT_12 = "new ";
+ protected final String TEXT_13 = "(null, ";
+ protected final String TEXT_14 = ", ";
+ protected final String TEXT_15 = ", ";
+ protected final String TEXT_16 = ")";
+ protected final String TEXT_17 = ".";
+ protected final String TEXT_18 = ");";
+ protected final String TEXT_19 = NL + "\t\t";
+ protected final String TEXT_20 = ".setPreferredSize(getMapMode().DPtoLP(";
+ protected final String TEXT_21 = "), getMapMode().DPtoLP(";
+ protected final String TEXT_22 = "));";
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final Figure figureInstance = args.getFigure();
+final String figureVarName = args.getVariableName();
+final ImportAssistant importManager = args.getImportManager();
+
+ Color colorVal;
+if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
+ colorVal = figureInstance.getForegroundColor();
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_2);
+ if (colorVal instanceof RGBColor) {
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.swt.graphics.Color"));
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(((RGBColor) colorVal).getRed());
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(((RGBColor) colorVal).getGreen());
+ stringBuffer.append(TEXT_6);
+ stringBuffer.append(((RGBColor) colorVal).getBlue());
+ stringBuffer.append(TEXT_7);
+ } else if (colorVal instanceof ConstantColor) {
+ stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.ColorConstants"));
+ stringBuffer.append(TEXT_8);
+ stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
+ }
+ stringBuffer.append(TEXT_9);
+ } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
+ colorVal = figureInstance.getBackgroundColor();
+ stringBuffer.append(TEXT_10);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_11);
+ if (colorVal instanceof RGBColor) {
+ stringBuffer.append(TEXT_12);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.swt.graphics.Color"));
+ stringBuffer.append(TEXT_13);
+ stringBuffer.append(((RGBColor) colorVal).getRed());
+ stringBuffer.append(TEXT_14);
+ stringBuffer.append(((RGBColor) colorVal).getGreen());
+ stringBuffer.append(TEXT_15);
+ stringBuffer.append(((RGBColor) colorVal).getBlue());
+ stringBuffer.append(TEXT_16);
+ } else if (colorVal instanceof ConstantColor) {
+ stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.ColorConstants"));
+ stringBuffer.append(TEXT_17);
+ stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
+ }
+ stringBuffer.append(TEXT_18);
+ } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) {
+ Dimension d = figureInstance.getPreferredSize();
+ stringBuffer.append(TEXT_19);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_20);
+ stringBuffer.append(d.getDx());
+ stringBuffer.append(TEXT_21);
+ stringBuffer.append(d.getDy());
+ stringBuffer.append(TEXT_22);
+ }
+ 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
new file mode 100644
index 000000000..890dec135
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java
@@ -0,0 +1,76 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.gmfgraph.util.*;
+import org.eclipse.gmf.common.codegen.*;
+import org.eclipse.gmf.graphdef.codegen.Dispatcher;
+import java.util.*;
+
+public class FigureChildrenGenerator
+{
+ protected static String nl;
+ public static synchronized FigureChildrenGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ FigureChildrenGenerator result = new FigureChildrenGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL + "\t\t// FIXME instantiate - FigureRef - dispatch to 'instantiate' template?" + NL + "\t\t";
+ protected final String TEXT_3 = NL + "\t\t";
+ protected final String TEXT_4 = ".add(";
+ protected final String TEXT_5 = ");";
+ protected final String TEXT_6 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+Object[] args = (Object[]) argument;
+List/*<Figure>*/ figureChildren = (List) args[0];
+final ImportAssistant importManager = (ImportAssistant) args[1];
+final GMFGraphSwitch fqnSwitch = (GMFGraphSwitch) args[2];
+final Dispatcher dispatcher = (Dispatcher) args[3];
+String parentFigureVarName = (String) args[4];
+
+ stringBuffer.append(TEXT_1);
+
+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++);
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(dispatcher.dispatch("instantiate", dispatcher.create((Figure) figureMarker, figureVarName, importManager, fqnSwitch)));
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(parentFigureVarName);
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_5);
+
+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
+
+ stringBuffer.append(TEXT_6);
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/LabelAttrGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/LabelAttrGenerator.java
new file mode 100644
index 000000000..b835c2d5a
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/LabelAttrGenerator.java
@@ -0,0 +1,41 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.graphdef.codegen.Dispatcher;
+
+public class LabelAttrGenerator
+{
+ protected static String nl;
+ public static synchronized LabelAttrGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ LabelAttrGenerator result = new LabelAttrGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = ".setText(\"";
+ protected final String TEXT_3 = "\");";
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final Label figureInstance = (Label) args.getFigure();
+final String figureVarName = args.getVariableName();
+final Dispatcher dispatcher = args.getDispatcher();
+
+ if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getLabel_Text())) {
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(figureInstance.getText());
+ stringBuffer.append(TEXT_3);
+ }
+ stringBuffer.append(dispatcher.dispatch("Figure", args));
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/LabelGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/LabelGenerator.java
deleted file mode 100644
index a976bfe5e..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/LabelGenerator.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.eclipse.gmf.graphdef.codegen.templates;
-
-import org.eclipse.gmf.gmfgraph.*;
-import org.eclipse.gmf.common.codegen.*;
-
-public class LabelGenerator
-{
- protected static String nl;
- public static synchronized LabelGenerator create(String lineSeparator)
- {
- nl = lineSeparator;
- LabelGenerator result = new LabelGenerator();
- nl = null;
- return result;
- }
-
- protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
- protected final String TEXT_1 = "";
- protected final String TEXT_2 = NL;
- protected final String TEXT_3 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
- protected final String TEXT_4 = " extends ";
- protected final String TEXT_5 = " {" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
- protected final String TEXT_6 = "() {" + NL + "\t\tsuper();" + NL + "\t}" + NL + "" + NL + "}";
-
- public String generate(Object argument)
- {
- StringBuffer stringBuffer = new StringBuffer();
- stringBuffer.append(TEXT_1);
-
-Object[] args = (Object[]) argument;
-Label figure = (Label) args[0];
-final ImportAssistant importManager = (ImportAssistant) args[1];
-
- stringBuffer.append(TEXT_2);
- importManager.markImportLocation(stringBuffer);
- stringBuffer.append(TEXT_3);
- stringBuffer.append(figure.getName());
- stringBuffer.append(TEXT_4);
- stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.Label"));
- stringBuffer.append(TEXT_5);
- stringBuffer.append(figure.getName());
- stringBuffer.append(TEXT_6);
- importManager.emitSortedImports();
- return stringBuffer.toString();
- }
-}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewFigureGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewFigureGenerator.java
new file mode 100644
index 000000000..8a89e28fc
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewFigureGenerator.java
@@ -0,0 +1,48 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.common.codegen.*;
+import org.eclipse.gmf.graphdef.codegen.Dispatcher;
+
+public class NewFigureGenerator
+{
+ protected static String nl;
+ public static synchronized NewFigureGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ NewFigureGenerator result = new NewFigureGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = " ";
+ protected final String TEXT_3 = " = new ";
+ protected final String TEXT_4 = "();";
+ protected final String TEXT_5 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final Figure figureInstance = args.getFigure();
+final String figureVarName = args.getVariableName();
+final ImportAssistant importManager = args.getImportManager();
+final String figureClassName = importManager.getImportedName((String) args.getFQNSwitch().doSwitch(figureInstance));
+
+// PRODUCES instance AND (!) initializes attributes
+
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(figureClassName);
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(figureClassName);
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(args.getDispatcher().dispatch(figureInstance, args));
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/PolygonDecorationAttrGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/PolygonDecorationAttrGenerator.java
new file mode 100644
index 000000000..60cb54260
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/PolygonDecorationAttrGenerator.java
@@ -0,0 +1,30 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.graphdef.codegen.Dispatcher;
+
+public class PolygonDecorationAttrGenerator
+{
+ protected static String nl;
+ public static synchronized PolygonDecorationAttrGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ PolygonDecorationAttrGenerator result = new PolygonDecorationAttrGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final Dispatcher dispatcher = args.getDispatcher();
+
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(dispatcher.dispatch("PolylineDecoration", args));
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/PolylineAttrGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/PolylineAttrGenerator.java
new file mode 100644
index 000000000..7601603b3
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/PolylineAttrGenerator.java
@@ -0,0 +1,54 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.common.codegen.*;
+import org.eclipse.gmf.graphdef.codegen.Dispatcher;
+
+public class PolylineAttrGenerator
+{
+ protected static String nl;
+ public static synchronized PolylineAttrGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ PolylineAttrGenerator result = new PolylineAttrGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL + "\t\t";
+ protected final String TEXT_3 = ".addPoint(new ";
+ protected final String TEXT_4 = "(";
+ protected final String TEXT_5 = ", ";
+ protected final String TEXT_6 = "));";
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final Polyline figureInstance = (Polyline) args.getFigure();
+final String figureVarName = args.getVariableName();
+final ImportAssistant importManager = args.getImportManager();
+final Dispatcher dispatcher = args.getDispatcher();
+
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(dispatcher.dispatch("Shape", args));
+ if (!figureInstance.getTemplate().isEmpty()) {
+ final String pointClassName = importManager.getImportedName("org.eclipse.draw2d.geometry.Point");
+ for (java.util.Iterator pointIt = figureInstance.getTemplate().iterator(); pointIt.hasNext(); ) {
+ Point p = (Point) pointIt.next();
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(pointClassName);
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(p.getX());
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(p.getY());
+ stringBuffer.append(TEXT_6);
+ }}
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/PolylineDecorationAttrGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/PolylineDecorationAttrGenerator.java
new file mode 100644
index 000000000..7f95c37d4
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/PolylineDecorationAttrGenerator.java
@@ -0,0 +1,70 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.common.codegen.*;
+import org.eclipse.gmf.graphdef.codegen.Dispatcher;
+import java.util.*;
+
+public class PolylineDecorationAttrGenerator
+{
+ protected static String nl;
+ public static synchronized PolylineDecorationAttrGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ PolylineDecorationAttrGenerator result = new PolylineDecorationAttrGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "// dispatchNext?";
+ protected final String TEXT_2 = NL;
+ protected final String TEXT_3 = NL + "\t\t";
+ protected final String TEXT_4 = " pl = new ";
+ protected final String TEXT_5 = "();";
+ protected final String TEXT_6 = NL + "\t\tpl.addPoint(";
+ protected final String TEXT_7 = ", ";
+ protected final String TEXT_8 = ");";
+ protected final String TEXT_9 = NL + "\t\t";
+ protected final String TEXT_10 = ".setTemplate(pl);" + NL + "\t\t";
+ protected final String TEXT_11 = ".setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));";
+ protected final String TEXT_12 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+Dispatcher.Args args = (Dispatcher.Args) argument;
+// not PolylineDecoration, as we use same template from PolygonDecoration
+final Polyline figureInstance = (Polyline) args.getFigure();
+final String figureVarName = args.getVariableName();
+final ImportAssistant importManager = args.getImportManager();
+final Dispatcher dispatcher = args.getDispatcher();
+
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(dispatcher.dispatch("Shape", args));
+ if (!figureInstance.getTemplate().isEmpty()) {
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.PointList"));
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.PointList"));
+ stringBuffer.append(TEXT_5);
+ for (Iterator pointIt = figureInstance.getTemplate().iterator(); pointIt.hasNext(); ) {
+ Point p = (Point) pointIt.next();
+ stringBuffer.append(TEXT_6);
+ stringBuffer.append(p.getX());
+ stringBuffer.append(TEXT_7);
+ stringBuffer.append(p.getY());
+ stringBuffer.append(TEXT_8);
+ } /*for*/
+ stringBuffer.append(TEXT_9);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_10);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_11);
+ } /*!if getTemplate().isEmpty()*/
+ stringBuffer.append(TEXT_12);
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/RoundedRectAttrGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/RoundedRectAttrGenerator.java
new file mode 100644
index 000000000..76cf27418
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/RoundedRectAttrGenerator.java
@@ -0,0 +1,49 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.common.codegen.*;
+import org.eclipse.gmf.graphdef.codegen.Dispatcher;
+
+public class RoundedRectAttrGenerator
+{
+ protected static String nl;
+ public static synchronized RoundedRectAttrGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ RoundedRectAttrGenerator result = new RoundedRectAttrGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL;
+ protected final String TEXT_3 = ".setCornerDimensions(new ";
+ protected final String TEXT_4 = "(getMapMode().DPtoLP(";
+ protected final String TEXT_5 = "), getMapMode().DPtoLP(";
+ protected final String TEXT_6 = ")));";
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final RoundedRectangle figureInstance = (RoundedRectangle) args.getFigure();
+final String figureVarName = args.getVariableName();
+final ImportAssistant importManager = args.getImportManager();
+final Dispatcher dispatcher = args.getDispatcher();
+
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(dispatcher.dispatch("Shape", args));
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension"));
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(figureInstance.getCornerWidth());
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(figureInstance.getCornerHeight());
+ stringBuffer.append(TEXT_6);
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ShapeAttrGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ShapeAttrGenerator.java
new file mode 100644
index 000000000..fb351a958
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ShapeAttrGenerator.java
@@ -0,0 +1,94 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.common.codegen.*;
+import org.eclipse.gmf.graphdef.codegen.Dispatcher;
+
+public class ShapeAttrGenerator
+{
+ protected static String nl;
+ public static synchronized ShapeAttrGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ ShapeAttrGenerator result = new ShapeAttrGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "\t\t";
+ protected final String TEXT_2 = ".setFill(";
+ protected final String TEXT_3 = ");";
+ protected final String TEXT_4 = NL + "\t\t";
+ protected final String TEXT_5 = ".setOutline(";
+ protected final String TEXT_6 = ");";
+ protected final String TEXT_7 = NL + "\t\t";
+ protected final String TEXT_8 = ".setLineWidth(";
+ protected final String TEXT_9 = ");";
+ protected final String TEXT_10 = NL + "\t\t";
+ protected final String TEXT_11 = ".setLineStyle(";
+ protected final String TEXT_12 = ".";
+ protected final String TEXT_13 = ");";
+ protected final String TEXT_14 = NL + "\t\t";
+ protected final String TEXT_15 = ".setFillXOR(";
+ protected final String TEXT_16 = ");";
+ protected final String TEXT_17 = NL + "\t\t";
+ protected final String TEXT_18 = ".setOutlineXOR(";
+ protected final String TEXT_19 = ");";
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final Shape figureInstance = (Shape) args.getFigure();
+final String figureVarName = args.getVariableName();
+final ImportAssistant importManager = args.getImportManager();
+final Dispatcher dispatcher = args.getDispatcher();
+
+
+// PERHAPS, do this with reflection?
+
+ if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_Fill())) {
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(figureInstance.isFill());
+ stringBuffer.append(TEXT_3);
+ } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_Outline())) {
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(figureInstance.isOutline());
+ stringBuffer.append(TEXT_6);
+ } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_LineWidth())) {
+ stringBuffer.append(TEXT_7);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_8);
+ stringBuffer.append(figureInstance.getLineWidth());
+ stringBuffer.append(TEXT_9);
+ } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_LineKind())) {
+ stringBuffer.append(TEXT_10);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_11);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.Graphics"));
+ stringBuffer.append(TEXT_12);
+ stringBuffer.append(figureInstance.getLineKind().getName());
+ stringBuffer.append(TEXT_13);
+ } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_XorFill())) {
+ stringBuffer.append(TEXT_14);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_15);
+ stringBuffer.append(figureInstance.isXorFill());
+ stringBuffer.append(TEXT_16);
+ } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_XorOutline())) {
+ stringBuffer.append(TEXT_17);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_18);
+ stringBuffer.append(figureInstance.isXorOutline());
+ stringBuffer.append(TEXT_19);
+ }
+ stringBuffer.append(dispatcher.dispatch("Figure", args));
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ShapeAttrsGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ShapeAttrsGenerator.java
deleted file mode 100644
index c2cc5fd69..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ShapeAttrsGenerator.java
+++ /dev/null
@@ -1,194 +0,0 @@
-package org.eclipse.gmf.graphdef.codegen.templates;
-
-import org.eclipse.gmf.gmfgraph.*;
-import org.eclipse.gmf.common.codegen.*;
-import java.util.*;
-import org.eclipse.gmf.graphdef.codegen.Dispatcher;
-
-public class ShapeAttrsGenerator
-{
- protected static String nl;
- public static synchronized ShapeAttrsGenerator create(String lineSeparator)
- {
- nl = lineSeparator;
- ShapeAttrsGenerator result = new ShapeAttrsGenerator();
- nl = null;
- return result;
- }
-
- protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
- protected final String TEXT_1 = "\t\t";
- protected final String TEXT_2 = ".setFill(";
- protected final String TEXT_3 = ");";
- protected final String TEXT_4 = NL + "\t\t";
- protected final String TEXT_5 = ".setOutline(";
- protected final String TEXT_6 = ");";
- protected final String TEXT_7 = NL + "\t\t";
- protected final String TEXT_8 = ".setLineWidth(";
- protected final String TEXT_9 = ");";
- protected final String TEXT_10 = NL + "\t\t";
- protected final String TEXT_11 = ".setLineStyle(";
- protected final String TEXT_12 = ".";
- protected final String TEXT_13 = ");";
- protected final String TEXT_14 = NL + "\t\t";
- protected final String TEXT_15 = ".setFillXOR(";
- protected final String TEXT_16 = ");";
- protected final String TEXT_17 = NL + "\t\t";
- protected final String TEXT_18 = ".setOutlineXOR(";
- protected final String TEXT_19 = ");";
- protected final String TEXT_20 = NL + "\t\t";
- protected final String TEXT_21 = ".addPoint(new ";
- protected final String TEXT_22 = "(";
- protected final String TEXT_23 = ", ";
- protected final String TEXT_24 = "));";
- protected final String TEXT_25 = NL + "\t\t";
- protected final String TEXT_26 = ".setCornerDimensions(new ";
- protected final String TEXT_27 = "(getMapMode().DPtoLP(";
- protected final String TEXT_28 = "), getMapMode().DPtoLP(";
- protected final String TEXT_29 = ")));";
- protected final String TEXT_30 = NL + "\t\t";
- protected final String TEXT_31 = ".setForegroundColor(";
- protected final String TEXT_32 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_33 = ", ";
- protected final String TEXT_34 = ", ";
- protected final String TEXT_35 = ")";
- protected final String TEXT_36 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_37 = ");";
- protected final String TEXT_38 = NL + "\t\t";
- protected final String TEXT_39 = ".setBackgroundColor(";
- protected final String TEXT_40 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_41 = ", ";
- protected final String TEXT_42 = ", ";
- protected final String TEXT_43 = ")";
- protected final String TEXT_44 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_45 = ");";
- protected final String TEXT_46 = NL + "\t\t";
- protected final String TEXT_47 = ".setPreferredSize(getMapMode().DPtoLP(";
- protected final String TEXT_48 = "), getMapMode().DPtoLP(";
- protected final String TEXT_49 = "));";
-
- public String generate(Object argument)
- {
- StringBuffer stringBuffer = new StringBuffer();
-
-Dispatcher.Args args = (Dispatcher.Args) argument;
-final Shape figureInstance = (Shape) args.getFigure();
-final String figureVarName = args.getVariableName();
-final ImportAssistant importManager = args.getImportManager();
-
-
-// PERHAPS, do this with reflection?
-
- if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_Fill())) {
- stringBuffer.append(TEXT_1);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_2);
- stringBuffer.append(figureInstance.isFill());
- stringBuffer.append(TEXT_3);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_Outline())) {
- stringBuffer.append(TEXT_4);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_5);
- stringBuffer.append(figureInstance.isOutline());
- stringBuffer.append(TEXT_6);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_LineWidth())) {
- stringBuffer.append(TEXT_7);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_8);
- stringBuffer.append(figureInstance.getLineWidth());
- stringBuffer.append(TEXT_9);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_LineKind())) {
- stringBuffer.append(TEXT_10);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_11);
- stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.Graphics"));
- stringBuffer.append(TEXT_12);
- stringBuffer.append(figureInstance.getLineKind().getName());
- stringBuffer.append(TEXT_13);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_XorFill())) {
- stringBuffer.append(TEXT_14);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_15);
- stringBuffer.append(figureInstance.isXorFill());
- stringBuffer.append(TEXT_16);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_XorOutline())) {
- stringBuffer.append(TEXT_17);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_18);
- stringBuffer.append(figureInstance.isXorOutline());
- stringBuffer.append(TEXT_19);
- } if (figureInstance instanceof Polyline && !((Polyline) figureInstance).getTemplate().isEmpty()) {
- for (Iterator pointIt = ((Polyline) figureInstance).getTemplate().iterator(); pointIt.hasNext(); ) {
- Point p = (Point) pointIt.next();
- stringBuffer.append(TEXT_20);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_21);
- stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.Point"));
- stringBuffer.append(TEXT_22);
- stringBuffer.append(p.getX());
- stringBuffer.append(TEXT_23);
- stringBuffer.append(p.getY());
- stringBuffer.append(TEXT_24);
- }
- } else if (figureInstance instanceof RoundedRectangle) {
- RoundedRectangle rrFigure = (RoundedRectangle) figureInstance;
- stringBuffer.append(TEXT_25);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_26);
- stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension"));
- stringBuffer.append(TEXT_27);
- stringBuffer.append(rrFigure.getCornerWidth());
- stringBuffer.append(TEXT_28);
- stringBuffer.append(rrFigure.getCornerHeight());
- stringBuffer.append(TEXT_29);
- }
- Color colorVal;
-if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
- colorVal = figureInstance.getForegroundColor();
- stringBuffer.append(TEXT_30);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_31);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_32);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_33);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_34);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_35);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_36);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_37);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
- colorVal = figureInstance.getBackgroundColor();
- stringBuffer.append(TEXT_38);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_39);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_40);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_41);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_42);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_43);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_44);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_45);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) {
- Dimension d = figureInstance.getPreferredSize();
- stringBuffer.append(TEXT_46);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_47);
- stringBuffer.append(d.getDx());
- stringBuffer.append(TEXT_48);
- stringBuffer.append(d.getDy());
- stringBuffer.append(TEXT_49);
- }
- return stringBuffer.toString();
- }
-}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ShapeGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ShapeGenerator.java
deleted file mode 100644
index 96f10f442..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ShapeGenerator.java
+++ /dev/null
@@ -1,548 +0,0 @@
-package org.eclipse.gmf.graphdef.codegen.templates;
-
-import org.eclipse.gmf.gmfgraph.*;
-import org.eclipse.gmf.gmfgraph.util.*;
-import org.eclipse.gmf.common.codegen.*;
-import org.eclipse.gmf.graphdef.codegen.Dispatcher;
-import java.util.*;
-
-public class ShapeGenerator
-{
- protected static String nl;
- public static synchronized ShapeGenerator create(String lineSeparator)
- {
- nl = lineSeparator;
- ShapeGenerator result = new ShapeGenerator();
- nl = null;
- return result;
- }
-
- protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
- protected final String TEXT_1 = "";
- 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 + "\tpublic ";
- protected final String TEXT_5 = "() {";
- protected final String TEXT_6 = NL;
- protected final String TEXT_7 = NL + "\t\tsetFigure";
- protected final String TEXT_8 = "(createFigure";
- protected final String TEXT_9 = "());" + NL + "\t\tadd(getFigure";
- protected final String TEXT_10 = "());";
- protected final String TEXT_11 = NL + "\t}" + NL;
- protected final String TEXT_12 = NL + NL + "\tprivate IFigure f";
- protected final String TEXT_13 = "; " + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic IFigure getFigure";
- protected final String TEXT_14 = "() {" + NL + "\t\treturn f";
- protected final String TEXT_15 = ";" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void setFigure";
- protected final String TEXT_16 = "(IFigure figure) {" + NL + "\t\tf";
- protected final String TEXT_17 = " = figure;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate IFigure createFigure";
- protected final String TEXT_18 = "() {";
- protected final String TEXT_19 = NL;
- protected final String TEXT_20 = NL + "\t\t";
- protected final String TEXT_21 = " ";
- protected final String TEXT_22 = " = new ";
- protected final String TEXT_23 = "();";
- protected final String TEXT_24 = NL;
- protected final String TEXT_25 = NL + "\t\t";
- protected final String TEXT_26 = ".setForegroundColor(";
- protected final String TEXT_27 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_28 = ", ";
- protected final String TEXT_29 = ", ";
- protected final String TEXT_30 = ")";
- protected final String TEXT_31 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_32 = ");";
- protected final String TEXT_33 = NL + "\t\t";
- protected final String TEXT_34 = ".setBackgroundColor(";
- protected final String TEXT_35 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_36 = ", ";
- protected final String TEXT_37 = ", ";
- protected final String TEXT_38 = ")";
- protected final String TEXT_39 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_40 = ");";
- protected final String TEXT_41 = NL + "\t\t";
- protected final String TEXT_42 = ".setPreferredSize(getMapMode().DPtoLP(";
- protected final String TEXT_43 = "), getMapMode().DPtoLP(";
- protected final String TEXT_44 = "));";
- protected final String TEXT_45 = NL + "\t\t";
- protected final String TEXT_46 = " ";
- protected final String TEXT_47 = " = new ";
- protected final String TEXT_48 = "();";
- protected final String TEXT_49 = NL;
- protected final String TEXT_50 = NL + "\t\torg.eclipse.draw2d.IFigure ";
- protected final String TEXT_51 = " = new ";
- protected final String TEXT_52 = "();";
- protected final String TEXT_53 = NL + "\t\t";
- protected final String TEXT_54 = " ";
- protected final String TEXT_55 = " = new ";
- protected final String TEXT_56 = "();" + NL + "\t\t";
- protected final String TEXT_57 = ".setText(\"";
- protected final String TEXT_58 = "\");";
- protected final String TEXT_59 = NL;
- protected final String TEXT_60 = NL + "\t\t";
- protected final String TEXT_61 = ".setForegroundColor(";
- protected final String TEXT_62 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_63 = ", ";
- protected final String TEXT_64 = ", ";
- protected final String TEXT_65 = ")";
- protected final String TEXT_66 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_67 = ");";
- protected final String TEXT_68 = NL + "\t\t";
- protected final String TEXT_69 = ".setBackgroundColor(";
- protected final String TEXT_70 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_71 = ", ";
- protected final String TEXT_72 = ", ";
- protected final String TEXT_73 = ")";
- protected final String TEXT_74 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_75 = ");";
- protected final String TEXT_76 = NL + "\t\t";
- protected final String TEXT_77 = ".setPreferredSize(getMapMode().DPtoLP(";
- protected final String TEXT_78 = "), getMapMode().DPtoLP(";
- protected final String TEXT_79 = "));";
- protected final String TEXT_80 = NL;
- protected final String TEXT_81 = NL;
- protected final String TEXT_82 = NL + "\t\t";
- protected final String TEXT_83 = " ";
- protected final String TEXT_84 = " = new ";
- protected final String TEXT_85 = "();";
- protected final String TEXT_86 = NL;
- protected final String TEXT_87 = NL + "\t\t";
- protected final String TEXT_88 = ".setForegroundColor(";
- protected final String TEXT_89 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_90 = ", ";
- protected final String TEXT_91 = ", ";
- protected final String TEXT_92 = ")";
- protected final String TEXT_93 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_94 = ");";
- protected final String TEXT_95 = NL + "\t\t";
- protected final String TEXT_96 = ".setBackgroundColor(";
- protected final String TEXT_97 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_98 = ", ";
- protected final String TEXT_99 = ", ";
- protected final String TEXT_100 = ")";
- protected final String TEXT_101 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_102 = ");";
- protected final String TEXT_103 = NL + "\t\t";
- protected final String TEXT_104 = ".setPreferredSize(getMapMode().DPtoLP(";
- protected final String TEXT_105 = "), getMapMode().DPtoLP(";
- protected final String TEXT_106 = "));";
- protected final String TEXT_107 = NL + "\t\t";
- protected final String TEXT_108 = " ";
- protected final String TEXT_109 = " = new ";
- protected final String TEXT_110 = "();";
- protected final String TEXT_111 = NL;
- protected final String TEXT_112 = NL + "\t\torg.eclipse.draw2d.IFigure ";
- protected final String TEXT_113 = " = new ";
- protected final String TEXT_114 = "();";
- protected final String TEXT_115 = NL + "\t\t";
- protected final String TEXT_116 = " ";
- protected final String TEXT_117 = " = new ";
- protected final String TEXT_118 = "();" + NL + "\t\t";
- protected final String TEXT_119 = ".setText(\"";
- protected final String TEXT_120 = "\");";
- protected final String TEXT_121 = NL;
- protected final String TEXT_122 = NL + "\t\t";
- protected final String TEXT_123 = ".setForegroundColor(";
- protected final String TEXT_124 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_125 = ", ";
- protected final String TEXT_126 = ", ";
- protected final String TEXT_127 = ")";
- protected final String TEXT_128 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_129 = ");";
- protected final String TEXT_130 = NL + "\t\t";
- protected final String TEXT_131 = ".setBackgroundColor(";
- protected final String TEXT_132 = "new org.eclipse.swt.graphics.Color(null, ";
- protected final String TEXT_133 = ", ";
- protected final String TEXT_134 = ", ";
- protected final String TEXT_135 = ")";
- protected final String TEXT_136 = "org.eclipse.draw2d.ColorConstants.";
- protected final String TEXT_137 = ");";
- protected final String TEXT_138 = NL + "\t\t";
- protected final String TEXT_139 = ".setPreferredSize(getMapMode().DPtoLP(";
- protected final String TEXT_140 = "), getMapMode().DPtoLP(";
- protected final String TEXT_141 = "));";
- protected final String TEXT_142 = NL + "\t\t";
- protected final String TEXT_143 = ".add(";
- protected final String TEXT_144 = ");";
- protected final String TEXT_145 = NL + "\t\treturn ";
- protected final String TEXT_146 = ";" + NL + "\t}" + NL;
- protected final String TEXT_147 = NL + "}";
-
- public String generate(Object argument)
- {
- StringBuffer stringBuffer = new StringBuffer();
-
-Object[] args = (Object[]) argument;
-Shape shapeFig = (Shape) args[0];
-final ImportAssistant importManager = (ImportAssistant) args[1];
-final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
-final Dispatcher dispatcher = (Dispatcher) args[2];
-
- stringBuffer.append(TEXT_1);
- importManager.markImportLocation(stringBuffer);
- stringBuffer.append(TEXT_2);
- stringBuffer.append(shapeFig.getName());
- stringBuffer.append(TEXT_3);
- stringBuffer.append(importManager.getImportedName((String) fqnSwitch.doSwitch(shapeFig)));
- stringBuffer.append(TEXT_4);
- stringBuffer.append(shapeFig.getName());
- stringBuffer.append(TEXT_5);
- stringBuffer.append(TEXT_6);
- stringBuffer.append(dispatcher.dispatch("ShapeAttrs", dispatcher.create(shapeFig, "this", importManager, fqnSwitch)));
-
-for (Iterator it = shapeFig.getResolvedChildren().iterator(); it.hasNext();) {
- Figure next = (Figure) it.next();
- stringBuffer.append(TEXT_7);
- stringBuffer.append(next.getName());
- stringBuffer.append(TEXT_8);
- stringBuffer.append(next.getName());
- stringBuffer.append(TEXT_9);
- stringBuffer.append(next.getName());
- stringBuffer.append(TEXT_10);
- }
- stringBuffer.append(TEXT_11);
-
-int fc = 0;
-for (Iterator it = shapeFig.getResolvedChildren().iterator(); it.hasNext(); fc++) {
- Figure figure = (Figure) it.next();
- stringBuffer.append(TEXT_12);
- stringBuffer.append(figure.getName());
- stringBuffer.append(TEXT_13);
- stringBuffer.append(figure.getName());
- stringBuffer.append(TEXT_14);
- stringBuffer.append(figure.getName());
- stringBuffer.append(TEXT_15);
- stringBuffer.append(figure.getName());
- stringBuffer.append(TEXT_16);
- stringBuffer.append(figure.getName());
- stringBuffer.append(TEXT_17);
- stringBuffer.append(figure.getName());
- stringBuffer.append(TEXT_18);
-
-String parentFigureVarName = "rv" + fc;
-{ // scope
-FigureMarker figureMarker = figure;
-String figureVarName = parentFigureVarName;
- stringBuffer.append(TEXT_19);
-
-// FigureMarker: figureMarker
-// String: figureVarName
-if (figureMarker instanceof CustomFigure) {
- CustomFigure figureInstance = (CustomFigure) figureMarker;
-
- stringBuffer.append(TEXT_20);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_21);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_22);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_23);
- stringBuffer.append(TEXT_24);
- Color colorVal;
-if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
- colorVal = figureInstance.getForegroundColor();
- stringBuffer.append(TEXT_25);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_26);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_27);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_28);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_29);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_30);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_31);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_32);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
- colorVal = figureInstance.getBackgroundColor();
- stringBuffer.append(TEXT_33);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_34);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_35);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_36);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_37);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_38);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_39);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_40);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) {
- Dimension d = figureInstance.getPreferredSize();
- stringBuffer.append(TEXT_41);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_42);
- stringBuffer.append(d.getDx());
- stringBuffer.append(TEXT_43);
- stringBuffer.append(d.getDy());
- stringBuffer.append(TEXT_44);
- }
- } else if (figureMarker instanceof Shape) {
-Shape figureInstance = (Shape) figureMarker;
- stringBuffer.append(TEXT_45);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_46);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_47);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_48);
- stringBuffer.append(TEXT_49);
- stringBuffer.append(dispatcher.dispatch("ShapeAttrs", dispatcher.create(figureInstance, figureVarName, importManager, fqnSwitch)));
- } else if (figureMarker instanceof FigureRef) {
- stringBuffer.append(TEXT_50);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_51);
- stringBuffer.append(((FigureRef) figureMarker).getFigure().getName());
- stringBuffer.append(TEXT_52);
- } else if (figureMarker instanceof Label) {
- Label figureInstance = (Label) figureMarker;
-
- stringBuffer.append(TEXT_53);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_54);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_55);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_56);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_57);
- stringBuffer.append(((Label) figureMarker).getText());
- stringBuffer.append(TEXT_58);
- stringBuffer.append(TEXT_59);
- Color colorVal;
-if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
- colorVal = figureInstance.getForegroundColor();
- stringBuffer.append(TEXT_60);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_61);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_62);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_63);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_64);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_65);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_66);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_67);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
- colorVal = figureInstance.getBackgroundColor();
- stringBuffer.append(TEXT_68);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_69);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_70);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_71);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_72);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_73);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_74);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_75);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) {
- Dimension d = figureInstance.getPreferredSize();
- stringBuffer.append(TEXT_76);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_77);
- stringBuffer.append(d.getDx());
- stringBuffer.append(TEXT_78);
- stringBuffer.append(d.getDy());
- stringBuffer.append(TEXT_79);
- }
- }
- }
- stringBuffer.append(TEXT_80);
-
-LinkedList l = new LinkedList();
-l.addAll(figure.getChildren());
-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;
- }
- FigureMarker figureMarker = (FigureMarker) _nxt;
- String figureVarName = "fig" + (figureCount++);
- stringBuffer.append(TEXT_81);
-
-// FigureMarker: figureMarker
-// String: figureVarName
-if (figureMarker instanceof CustomFigure) {
- CustomFigure figureInstance = (CustomFigure) figureMarker;
-
- stringBuffer.append(TEXT_82);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_83);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_84);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_85);
- stringBuffer.append(TEXT_86);
- Color colorVal;
-if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
- colorVal = figureInstance.getForegroundColor();
- stringBuffer.append(TEXT_87);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_88);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_89);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_90);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_91);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_92);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_93);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_94);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
- colorVal = figureInstance.getBackgroundColor();
- stringBuffer.append(TEXT_95);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_96);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_97);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_98);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_99);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_100);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_101);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_102);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) {
- Dimension d = figureInstance.getPreferredSize();
- stringBuffer.append(TEXT_103);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_104);
- stringBuffer.append(d.getDx());
- stringBuffer.append(TEXT_105);
- stringBuffer.append(d.getDy());
- stringBuffer.append(TEXT_106);
- }
- } else if (figureMarker instanceof Shape) {
-Shape figureInstance = (Shape) figureMarker;
- stringBuffer.append(TEXT_107);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_108);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_109);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_110);
- stringBuffer.append(TEXT_111);
- stringBuffer.append(dispatcher.dispatch("ShapeAttrs", dispatcher.create(figureInstance, figureVarName, importManager, fqnSwitch)));
- } else if (figureMarker instanceof FigureRef) {
- stringBuffer.append(TEXT_112);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_113);
- stringBuffer.append(((FigureRef) figureMarker).getFigure().getName());
- stringBuffer.append(TEXT_114);
- } else if (figureMarker instanceof Label) {
- Label figureInstance = (Label) figureMarker;
-
- stringBuffer.append(TEXT_115);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_116);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_117);
- stringBuffer.append(fqnSwitch.doSwitch(figureMarker));
- stringBuffer.append(TEXT_118);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_119);
- stringBuffer.append(((Label) figureMarker).getText());
- stringBuffer.append(TEXT_120);
- stringBuffer.append(TEXT_121);
- Color colorVal;
-if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
- colorVal = figureInstance.getForegroundColor();
- stringBuffer.append(TEXT_122);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_123);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_124);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_125);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_126);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_127);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_128);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_129);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
- colorVal = figureInstance.getBackgroundColor();
- stringBuffer.append(TEXT_130);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_131);
- if (colorVal instanceof RGBColor) {
- stringBuffer.append(TEXT_132);
- stringBuffer.append(((RGBColor) colorVal).getRed());
- stringBuffer.append(TEXT_133);
- stringBuffer.append(((RGBColor) colorVal).getGreen());
- stringBuffer.append(TEXT_134);
- stringBuffer.append(((RGBColor) colorVal).getBlue());
- stringBuffer.append(TEXT_135);
- } else if (colorVal instanceof ConstantColor) {
- stringBuffer.append(TEXT_136);
- stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral());
- }
- stringBuffer.append(TEXT_137);
- } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) {
- Dimension d = figureInstance.getPreferredSize();
- stringBuffer.append(TEXT_138);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_139);
- stringBuffer.append(d.getDx());
- stringBuffer.append(TEXT_140);
- stringBuffer.append(d.getDy());
- stringBuffer.append(TEXT_141);
- }
- }
- stringBuffer.append(TEXT_142);
- stringBuffer.append(parentFigureVarName);
- stringBuffer.append(TEXT_143);
- stringBuffer.append(figureVarName);
- stringBuffer.append(TEXT_144);
-
-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
-}
-
-
-} // while
-
- stringBuffer.append(TEXT_145);
- stringBuffer.append(parentFigureVarName);
- stringBuffer.append(TEXT_146);
- }
- stringBuffer.append(TEXT_147);
- importManager.emitSortedImports();
- return stringBuffer.toString();
- }
-}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopConnectionGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopConnectionGenerator.java
new file mode 100644
index 000000000..eab82c745
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopConnectionGenerator.java
@@ -0,0 +1,91 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.gmfgraph.util.*;
+import org.eclipse.gmf.common.codegen.*;
+import org.eclipse.gmf.graphdef.codegen.Dispatcher;
+
+public class TopConnectionGenerator
+{
+ protected static String nl;
+ public static synchronized TopConnectionGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ TopConnectionGenerator result = new TopConnectionGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ 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 + "\tpublic ";
+ protected final String TEXT_5 = "() {";
+ protected final String TEXT_6 = NL;
+ protected final String TEXT_7 = NL + "\t\tsetSourceDecoration(createSourceDecoration());";
+ protected final String TEXT_8 = NL + "\t\tsetTargetDecoration(createTargetDecoration());";
+ protected final String TEXT_9 = NL + "\t}" + NL;
+ protected final String TEXT_10 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ";
+ protected final String TEXT_11 = " createSourceDecoration() {";
+ protected final String TEXT_12 = NL;
+ protected final String TEXT_13 = NL + "\t\treturn df;" + NL + "\t}";
+ protected final String TEXT_14 = NL;
+ protected final String TEXT_15 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate ";
+ protected final String TEXT_16 = " createTargetDecoration() {";
+ protected final String TEXT_17 = NL;
+ protected final String TEXT_18 = NL + "\t\treturn df;" + NL + "\t}";
+ protected final String TEXT_19 = NL + "}";
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+Object[] args = (Object[]) argument;
+PolylineConnection figure = (PolylineConnection) args[0];
+final ImportAssistant importManager = (ImportAssistant) args[1];
+final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
+final Dispatcher dispatcher = (Dispatcher) args[2];
+
+ stringBuffer.append(TEXT_1);
+ importManager.markImportLocation(stringBuffer);
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(figure.getName());
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(importManager.getImportedName("org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx"));
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(figure.getName());
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(TEXT_6);
+ stringBuffer.append(dispatcher.dispatch("Shape", dispatcher.create(figure, "this", importManager, fqnSwitch)));
+ if (figure.getSourceDecoration() != null) {
+ stringBuffer.append(TEXT_7);
+ }
+if (figure.getTargetDecoration() != null) {
+ stringBuffer.append(TEXT_8);
+ }
+ stringBuffer.append(TEXT_9);
+ if (figure.getSourceDecoration() != null) {
+ final String className = importManager.getImportedName((String) fqnSwitch.doSwitch(figure.getSourceDecoration()));
+ stringBuffer.append(TEXT_10);
+ stringBuffer.append(className);
+ stringBuffer.append(TEXT_11);
+ stringBuffer.append(TEXT_12);
+ stringBuffer.append(dispatcher.dispatch("instantiate", dispatcher.create(figure.getSourceDecoration(), "df", importManager, fqnSwitch)));
+ stringBuffer.append(TEXT_13);
+ } /*if sourceDecoration != null */
+ stringBuffer.append(TEXT_14);
+ if (figure.getTargetDecoration() != null) {
+ final String className = importManager.getImportedName((String) fqnSwitch.doSwitch(figure.getTargetDecoration()));
+ stringBuffer.append(TEXT_15);
+ stringBuffer.append(className);
+ stringBuffer.append(TEXT_16);
+ stringBuffer.append(TEXT_17);
+ stringBuffer.append(dispatcher.dispatch("instantiate", dispatcher.create(figure.getTargetDecoration(), "df", importManager, fqnSwitch)));
+ stringBuffer.append(TEXT_18);
+ }
+ stringBuffer.append(TEXT_19);
+ importManager.emitSortedImports();
+ return stringBuffer.toString();
+ }
+}
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
new file mode 100644
index 000000000..7f4e2db48
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopFigureGenerator.java
@@ -0,0 +1,56 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.gmfgraph.util.*;
+import org.eclipse.gmf.common.codegen.*;
+import org.eclipse.gmf.graphdef.codegen.Dispatcher;
+
+public class TopFigureGenerator
+{
+ protected static String nl;
+ public static synchronized TopFigureGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ TopFigureGenerator result = new TopFigureGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ 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 + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
+ protected final String TEXT_5 = "() {" + NL + "\t\t";
+ protected final String TEXT_6 = NL + "\t\t";
+ protected final String TEXT_7 = NL + "\t}" + NL + "}";
+ protected final String TEXT_8 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+Object[] args = (Object[]) argument;
+Figure figure = (Figure) args[0];
+final ImportAssistant importManager = (ImportAssistant) args[1];
+final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
+final Dispatcher dispatcher = (Dispatcher) args[2];
+
+ stringBuffer.append(TEXT_1);
+ importManager.markImportLocation(stringBuffer);
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(figure.getName());
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(importManager.getImportedName((String) fqnSwitch.doSwitch(figure)));
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(figure.getName());
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(dispatcher.dispatch(figure, dispatcher.create(figure, "this", importManager, fqnSwitch)));
+ stringBuffer.append(TEXT_6);
+ stringBuffer.append(dispatcher.dispatch("Children", new Object[] {figure.getChildren(), importManager, fqnSwitch, dispatcher, "this"}));
+ stringBuffer.append(TEXT_7);
+ importManager.emitSortedImports();
+ stringBuffer.append(TEXT_8);
+ 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
new file mode 100644
index 000000000..0d1718e26
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java
@@ -0,0 +1,104 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.gmfgraph.util.*;
+import org.eclipse.gmf.common.codegen.*;
+import org.eclipse.gmf.graphdef.codegen.Dispatcher;
+import java.util.*;
+
+public class TopShapeGenerator
+{
+ protected static String nl;
+ public static synchronized TopShapeGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ TopShapeGenerator result = new TopShapeGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ 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 + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
+ protected final String TEXT_5 = "() {" + NL + "\t\t";
+ protected final String TEXT_6 = NL + "\t\tsetFigure";
+ protected final String TEXT_7 = "(createFigure";
+ protected final String TEXT_8 = "());" + NL + "\t\tadd(getFigure";
+ protected final String TEXT_9 = "());";
+ protected final String TEXT_10 = NL + "\t}" + NL;
+ protected final String TEXT_11 = NL + NL + "\tprivate IFigure f";
+ protected final String TEXT_12 = "; " + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic IFigure getFigure";
+ protected final String TEXT_13 = "() {" + NL + "\t\treturn f";
+ protected final String TEXT_14 = ";" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void setFigure";
+ protected final String TEXT_15 = "(IFigure figure) {" + NL + "\t\tf";
+ protected final String TEXT_16 = " = figure;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate IFigure createFigure";
+ protected final String TEXT_17 = "() {";
+ protected final String TEXT_18 = NL;
+ protected final String TEXT_19 = NL;
+ protected final String TEXT_20 = NL + "\t\treturn rv;" + NL + "\t}" + NL;
+ protected final String TEXT_21 = NL + "}";
+ protected final String TEXT_22 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+Object[] args = (Object[]) argument;
+Shape figure = (Shape) args[0];
+final ImportAssistant importManager = (ImportAssistant) args[1];
+final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
+final Dispatcher dispatcher = (Dispatcher) args[2];
+
+ stringBuffer.append(TEXT_1);
+ importManager.markImportLocation(stringBuffer);
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(figure.getName());
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(importManager.getImportedName((String) fqnSwitch.doSwitch(figure)));
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(figure.getName());
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(dispatcher.dispatch(figure, dispatcher.create(figure, "this", importManager, fqnSwitch)));
+
+for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext();) {
+ Figure next = (Figure) it.next();
+ stringBuffer.append(TEXT_6);
+ stringBuffer.append(next.getName());
+ stringBuffer.append(TEXT_7);
+ stringBuffer.append(next.getName());
+ stringBuffer.append(TEXT_8);
+ stringBuffer.append(next.getName());
+ stringBuffer.append(TEXT_9);
+ }
+ stringBuffer.append(TEXT_10);
+
+int fc = 0;
+for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext(); fc++) {
+ Figure next = (Figure) it.next();
+ stringBuffer.append(TEXT_11);
+ stringBuffer.append(next.getName());
+ stringBuffer.append(TEXT_12);
+ stringBuffer.append(next.getName());
+ stringBuffer.append(TEXT_13);
+ stringBuffer.append(next.getName());
+ stringBuffer.append(TEXT_14);
+ stringBuffer.append(next.getName());
+ stringBuffer.append(TEXT_15);
+ stringBuffer.append(next.getName());
+ stringBuffer.append(TEXT_16);
+ stringBuffer.append(next.getName());
+ stringBuffer.append(TEXT_17);
+ stringBuffer.append(TEXT_18);
+ stringBuffer.append(dispatcher.dispatch("instantiate", dispatcher.create(next, "rv", importManager, fqnSwitch)));
+ stringBuffer.append(TEXT_19);
+ stringBuffer.append(dispatcher.dispatch("Children", new Object[] {next.getChildren(), importManager, fqnSwitch, dispatcher, "rv"}));
+ stringBuffer.append(TEXT_20);
+ }
+ stringBuffer.append(TEXT_21);
+ importManager.emitSortedImports();
+ stringBuffer.append(TEXT_22);
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/ArrayKeyChain.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/ArrayKeyChain.java
new file mode 100644
index 000000000..a5a39b533
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/ArrayKeyChain.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2006 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.internal.graphdef.codegen;
+
+/**
+ * Although it's more straightforward just to override hasNext/next then to perform checks in advance,
+ * did it that way for now to verify implementation in super. FIXME - refactor.
+ * @author artem
+ */
+public class ArrayKeyChain extends KeyChain {
+ private final Object[] myKeys;
+ private int myIndex = 0;
+
+ public ArrayKeyChain(Object origin, Object singleKey) {
+ this(origin, new Object[] {singleKey});
+ }
+
+ public ArrayKeyChain(Object origin, Object[] mappedKeys) {
+ super(origin);
+ myKeys = mappedKeys;
+ }
+
+ protected Object advance() {
+ if (myIndex < myKeys.length) {
+ return myKeys[myIndex++];
+ }
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/DispatcherImpl.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/DispatcherImpl.java
index 32b5bfeed..0e22d84f0 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/DispatcherImpl.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/DispatcherImpl.java
@@ -11,8 +11,13 @@
*/
package org.eclipse.gmf.internal.graphdef.codegen;
+import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
import org.eclipse.emf.codegen.jet.JETEmitter;
+import org.eclipse.emf.codegen.jet.JETException;
+import org.eclipse.gmf.common.UnexpectedBehaviourException;
import org.eclipse.gmf.graphdef.codegen.Dispatcher;
/**
@@ -22,20 +27,52 @@ public class DispatcherImpl extends Dispatcher {
private final YAEmitterFactory myFactory;
- public DispatcherImpl(YAEmitterFactory factory) {
+ private final KeyMap myKeyMap;
+
+ public DispatcherImpl(YAEmitterFactory factory, KeyMap keyMap) {
myFactory = factory;
+ myKeyMap = keyMap;
}
- public String dispatch(Object arg, Object[] orginalArgs) {
- return "asdasdasd";
+ public String dispatch(Object key, Object argument) {
+ final String pluginID = "org.eclipse.gmf.graphdef.codegen";
+ final ILog traceFacility = Platform.getLog(Platform.getBundle(pluginID));
+ try {
+ StringBuffer errors = new StringBuffer();
+ for (KeyChain it = myKeyMap.map(key); it.hasNext();) {
+ Object nextKey = it.next();
+ if (myFactory.checkEmitter(nextKey)) {
+ try {
+ JETEmitter em = myFactory.acquireEmitter(nextKey);
+ return em.generate(new NullProgressMonitor(), new Object[] {argument});
+ } catch (NoSuchTemplateException ex) {
+ traceFacility.log(new Status(Status.ERROR, pluginID, 0, "Template for key '" + nextKey + "' failed", ex));
+ errors.append(formatError(ex));
+ errors.append("\n");
+ } catch (UnexpectedBehaviourException ex) {
+ traceFacility.log(new Status(Status.ERROR, pluginID, 0, "Template for key '" + nextKey + "' failed", ex));
+ errors.append(formatError(ex));
+ errors.append("\n");
+ }
+ }
+ }
+ if (errors.length() == 0) {
+ // TODO option silent?
+ return "// no suitable template found for '" + key + "'";
+ } else {
+ return errors.toString();
+ }
+ } catch (JETException ex) {
+ traceFacility.log(new Status(Status.ERROR, pluginID, 0, ex.getMessage(), ex));
+ return "ERROR: " + formatError(ex);
+ }
}
public String dispatch(Object key, Args args) {
- try {
- JETEmitter em = myFactory.acquireEmitter(key);
- return em.generate(new NullProgressMonitor(), new Object[] {args});
- } catch (Exception ex) {
- return "// " + ex.getClass().getSimpleName() + ": " + ex.getMessage();
- }
+ return dispatch(key, (Object) args);
+ }
+
+ private static String formatError(Exception ex) {
+ return ex.getClass().getSimpleName() + ": " + ex.getMessage();
}
}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/HierarchyKeyMap.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/HierarchyKeyMap.java
new file mode 100644
index 000000000..2c5cd0bba
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/HierarchyKeyMap.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2006 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.internal.graphdef.codegen;
+
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+
+/**
+ * XXX cache hierarchies?
+ * @author artem
+ */
+public class HierarchyKeyMap extends KeyMap {
+
+ public HierarchyKeyMap() {
+ }
+
+ /**
+ * Processes instances of {@link java.lang.Class} only, delegates to superclass otherwise
+ */
+ public KeyChain map(Object key) {
+ if (false == key instanceof Class) {
+ return super.map(key);
+ }
+ Class keyClass = (Class) key;
+ Class[] immediateInterfaces = keyClass.getInterfaces();
+ // make sure immediate interfaces are considered first in the key chain
+ LinkedHashSet result = new LinkedHashSet(Arrays.asList(immediateInterfaces));
+ LinkedList l = new LinkedList(result);
+ while (!l.isEmpty()) {
+ Class iface = (Class) l.removeFirst();
+ result.add(iface);
+ l.addAll(0, Arrays.asList(iface.getInterfaces()));
+ }
+ return new ArrayKeyChain(keyClass, result.toArray());
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/KeyChain.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/KeyChain.java
new file mode 100644
index 000000000..d189cf566
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/KeyChain.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2006 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.internal.graphdef.codegen;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * Key extraction and prioritization. <code>null</code> keys are not supported (useing null as eol indicator)
+ * TODO add absract #reset()?
+ * @author artem
+ */
+public abstract class KeyChain/*<T>*/ implements Iterator/*<E>*/ {
+ private final Object/*<T>*/ myOrigin;
+ private Object/*<E>*/ myNextValue;
+ private boolean myIsInitialized = false;
+
+ public KeyChain(Object origin) {
+ myOrigin = origin;
+ }
+
+ public final Object getOrigin() {
+ return myOrigin;
+ }
+
+ public boolean hasNext() {
+ if (!myIsInitialized) {
+ myNextValue = advance();
+ myIsInitialized = true;
+ }
+ return myNextValue != null;
+ }
+
+ /**
+ * @return <code>null</code> to indicate EOL
+ */
+ protected abstract Object/*<E>*/ advance();
+
+ public Object next() {
+ if (hasNext()) {
+ myIsInitialized = false;
+ return myNextValue;
+ }
+ throw new NoSuchElementException();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/KeyMap.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/KeyMap.java
new file mode 100644
index 000000000..e87a50f44
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/KeyMap.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2006 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.internal.graphdef.codegen;
+
+/**
+ * Logic of key extraction and prioritization.
+ * @author artem
+ * @see KeyChain
+ */
+public class KeyMap/*<T,E>*/ {
+
+ /**
+ * Default implementation just returns the key itself as sole item in the chain
+ * @param key
+ * @return key chain with sole item that is key itself.
+ */
+ public KeyChain/*<T,E>*/ map(Object/*<T>*/ key) {
+ return new ArrayKeyChain(key, key);
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/TemplateRegistry.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/TemplateRegistry.java
index 3904813f1..1362fb8fc 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/TemplateRegistry.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/TemplateRegistry.java
@@ -12,6 +12,7 @@
package org.eclipse.gmf.internal.graphdef.codegen;
/**
+ * XXX hm, it's possible to have only one JETEmitter per key. What if we'd like to reference same emitter with different keys?
* TODO CompositeTemplateRegistry?
* TODO move to gmf.common
* @author artem
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/YAEmitterFactory.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/YAEmitterFactory.java
index acc8a1911..9d270df99 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/YAEmitterFactory.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/YAEmitterFactory.java
@@ -68,11 +68,19 @@ public class YAEmitterFactory {
* from constructor, object may not be fully initialized, don't use this
* method for anything but cache instantiation.
*/
- protected Map/* <Object, JETEmitter> */createCache() {
+ protected Map/*<Object, JETEmitter>*/ createCache() {
return new HashMap();
}
/**
+ * @param key
+ * @return <code>true</code> if template for the key passes is known to this factory
+ */
+ public boolean checkEmitter(Object key) {
+ return checkCache(key) != null || myTemplates.getTemplatePath(key) != null;
+ }
+
+ /**
* This is primary way to get emitters from this factory.
* Checks cache (if there's one) first. Produces new emitter (with {@link #newEmitter(Object)}), caches and returns its outcome.
*/
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc
index 08bcde1e4..9ed864a0e 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc
@@ -1 +1 @@
-<%if (colorVal instanceof RGBColor) {%>new org.eclipse.swt.graphics.Color(null, <%=((RGBColor) colorVal).getRed()%>, <%=((RGBColor) colorVal).getGreen()%>, <%=((RGBColor) colorVal).getBlue()%>)<%} else if (colorVal instanceof ConstantColor) {%>org.eclipse.draw2d.ColorConstants.<%=((ConstantColor) colorVal).getValue().getLiteral()%><%}%> \ No newline at end of file
+<%if (colorVal instanceof RGBColor) {%>new <%=importManager.getImportedName("org.eclipse.swt.graphics.Color")%>(null, <%=((RGBColor) colorVal).getRed()%>, <%=((RGBColor) colorVal).getGreen()%>, <%=((RGBColor) colorVal).getBlue()%>)<%} else if (colorVal instanceof ConstantColor) {%><%=importManager.getImportedName("org.eclipse.draw2d.ColorConstants")%>.<%=((ConstantColor) colorVal).getValue().getLiteral()%><%}%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/ConcreteShape.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/ConcreteShape.javajet
deleted file mode 100644
index 448a04e09..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/ConcreteShape.javajet
+++ /dev/null
@@ -1,67 +0,0 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="ShapeGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher java.util.*"%>
-<%
-Object[] args = (Object[]) argument;
-Shape shapeFig = (Shape) args[0];
-final ImportAssistant importManager = (ImportAssistant) args[1];
-final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
-final Dispatcher dispatcher = (Dispatcher) args[2];
-%>
-
-<%importManager.markImportLocation(stringBuffer);%>
-
-/**
- * @generated
- */
-public class <%=shapeFig.getName()%> extends <%=importManager.getImportedName((String) fqnSwitch.doSwitch(shapeFig))%> {
-
- /**
- * @generated
- */
- public <%=shapeFig.getName()%>() {
-<%=dispatcher.dispatch("ShapeAttrs", dispatcher.create(shapeFig, "this", importManager, fqnSwitch))%>
-<%
-for (Iterator it = shapeFig.getResolvedChildren().iterator(); it.hasNext();) {
- Figure next = (Figure) it.next();%>
- setFigure<%=next.getName()%>(createFigure<%=next.getName()%>());
- add(getFigure<%=next.getName()%>());
-<%}%>
- }
-
-<%
-int fc = 0;
-for (Iterator it = shapeFig.getResolvedChildren().iterator(); it.hasNext(); fc++) {
- Figure figure = (Figure) it.next();%>
-
- private IFigure f<%=figure.getName()%>;
-
- /**
- * @generated
- */
- public IFigure getFigure<%=figure.getName()%>() {
- return f<%=figure.getName()%>;
- }
-
- /**
- * @generated
- */
- protected void setFigure<%=figure.getName()%>(IFigure figure) {
- f<%=figure.getName()%> = figure;
- }
-
- /**
- * @generated
- */
- private IFigure createFigure<%=figure.getName()%>() {
-<%
-String parentFigureVarName = "rv" + fc;
-{ // scope
-FigureMarker figureMarker = figure;
-String figureVarName = parentFigureVarName;%>
-<%@ include file="instantiate.jetinc" %><%}%>
-<%@ include file="FigureChildren.jetinc" %>
- return <%=parentFigureVarName%>;
- }
-
-<%}%>
-}<%importManager.emitSortedImports();%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/DecorationFigure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/DecorationFigure.javajet
deleted file mode 100644
index ca932986c..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/DecorationFigure.javajet
+++ /dev/null
@@ -1,32 +0,0 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="DecorationFigureGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* java.util.*"%>
-<%
-Object[] args = (Object[]) argument;
-DecorationFigure figure = (DecorationFigure) args[0];
-final ImportAssistant importManager = (ImportAssistant) args[1];
-assert false == figure instanceof CustomFigure;
-final Point scale;
-scale = null; //XXX
-final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
-%>
-
-<%importManager.markImportLocation(stringBuffer);%>
-
-/**
- * @generated
- */
-class <%=figure.getName()%> extends <%=importManager.getImportedName((String) fqnSwitch.doSwitch(figure))%> {
-
- /**
- * @generated
- */
- public <%=figure.getName()%>() {
-<%
-DecorationFigure df = figure;
-String decFigVarName = "this";%>
-<%@ include file="decoration.jetinc" %>
-<%if (scale != null) {%>
- setScale(<%=scale.getX()%>, <%=scale.getY()%>);
-<%}%>
- }
-}<%importManager.emitSortedImports();%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureAttrs.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureAttrs.jetinc
deleted file mode 100644
index b16cc7aaa..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureAttrs.jetinc
+++ /dev/null
@@ -1,11 +0,0 @@
-<%Color colorVal;
-if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
- colorVal = figureInstance.getForegroundColor();%>
- <%=figureVarName%>.setForegroundColor(<%@ include file="Color.jetinc"%>);
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
- colorVal = figureInstance.getBackgroundColor();%>
- <%=figureVarName%>.setBackgroundColor(<%@ include file="Color.jetinc"%>);
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) {
- Dimension d = figureInstance.getPreferredSize();%>
- <%=figureVarName%>.setPreferredSize(getMapMode().DPtoLP(<%=d.getDx()%>), getMapMode().DPtoLP(<%=d.getDy()%>));
-<%}%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureChildren.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureChildren.jetinc
deleted file mode 100644
index b00f8055f..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureChildren.jetinc
+++ /dev/null
@@ -1,27 +0,0 @@
-<%
-LinkedList l = new LinkedList();
-l.addAll(figure.getChildren());
-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;
- }
- FigureMarker figureMarker = (FigureMarker) _nxt;
- String figureVarName = "fig" + (figureCount++);%>
-<%@ include file="instantiate.jetinc" %>
- <%=parentFigureVarName%>.add(<%=figureVarName%>);
-<%
-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
-}
-%>
-<%
-} // while
-%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Label.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Label.javajet
deleted file mode 100644
index ecbd3eb02..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Label.javajet
+++ /dev/null
@@ -1,24 +0,0 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="LabelGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.*"%>
-
-<%
-Object[] args = (Object[]) argument;
-Label figure = (Label) args[0];
-final ImportAssistant importManager = (ImportAssistant) args[1];
-%>
-
-<%importManager.markImportLocation(stringBuffer);%>
-
-/**
- * @generated
- */
-public class <%=figure.getName()%> extends <%=importManager.getImportedName("org.eclipse.draw2d.Label")%> {
-
- /**
- * @generated
- */
- public <%=figure.getName()%>() {
- super();
- }
-
-}<%importManager.emitSortedImports();%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet
new file mode 100644
index 000000000..7cd0f28ef
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet
@@ -0,0 +1,19 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="FigureAttrGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
+<%
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final Figure figureInstance = args.getFigure();
+final String figureVarName = args.getVariableName();
+final ImportAssistant importManager = args.getImportManager();
+%>
+<%Color colorVal;
+if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
+ colorVal = figureInstance.getForegroundColor();%>
+ <%=figureVarName%>.setForegroundColor(<%@ include file="../Color.jetinc"%>);
+<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
+ colorVal = figureInstance.getBackgroundColor();%>
+ <%=figureVarName%>.setBackgroundColor(<%@ include file="../Color.jetinc"%>);
+<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) {
+ Dimension d = figureInstance.getPreferredSize();%>
+ <%=figureVarName%>.setPreferredSize(getMapMode().DPtoLP(<%=d.getDx()%>), getMapMode().DPtoLP(<%=d.getDy()%>));
+<%}%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Label.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Label.javajet
new file mode 100644
index 000000000..8d8582514
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Label.javajet
@@ -0,0 +1,11 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="LabelAttrGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
+<%
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final Label figureInstance = (Label) args.getFigure();
+final String figureVarName = args.getVariableName();
+final Dispatcher dispatcher = args.getDispatcher();
+%>
+<%if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getLabel_Text())) {%>
+<%=figureVarName%>.setText("<%=figureInstance.getText()%>");
+<%}%><%=dispatcher.dispatch("Figure", args)%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylgonDecoration.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylgonDecoration.javajet
new file mode 100644
index 000000000..11eec09bb
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylgonDecoration.javajet
@@ -0,0 +1,7 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="PolygonDecorationAttrGenerator"
+ imports="org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
+<%
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final Dispatcher dispatcher = args.getDispatcher();
+%>
+<%=dispatcher.dispatch("PolylineDecoration", args)%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Polyline.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Polyline.javajet
new file mode 100644
index 000000000..497789253
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Polyline.javajet
@@ -0,0 +1,16 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="PolylineAttrGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
+<%
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final Polyline figureInstance = (Polyline) args.getFigure();
+final String figureVarName = args.getVariableName();
+final ImportAssistant importManager = args.getImportManager();
+final Dispatcher dispatcher = args.getDispatcher();
+%>
+<%=dispatcher.dispatch("Shape", args)%>
+<%if (!figureInstance.getTemplate().isEmpty()) {
+ final String pointClassName = importManager.getImportedName("org.eclipse.draw2d.geometry.Point");
+ for (java.util.Iterator pointIt = figureInstance.getTemplate().iterator(); pointIt.hasNext(); ) {
+ Point p = (Point) pointIt.next();%>
+ <%=figureVarName%>.addPoint(new <%=pointClassName%>(<%=p.getX()%>, <%=p.getY()%>));
+<%}}%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylineDecoration.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylineDecoration.javajet
new file mode 100644
index 000000000..0a4b53871
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylineDecoration.javajet
@@ -0,0 +1,21 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="PolylineDecorationAttrGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher java.util.*"%>
+<%
+Dispatcher.Args args = (Dispatcher.Args) argument;
+// not PolylineDecoration, as we use same template from PolygonDecoration
+final Polyline figureInstance = (Polyline) args.getFigure();
+final String figureVarName = args.getVariableName();
+final ImportAssistant importManager = args.getImportManager();
+final Dispatcher dispatcher = args.getDispatcher();
+%>
+// dispatchNext?
+<%=dispatcher.dispatch("Shape", args)%>
+<%if (!figureInstance.getTemplate().isEmpty()) {%>
+ <%=importManager.getImportedName("org.eclipse.draw2d.geometry.PointList")%> pl = new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.PointList")%>();
+<% for (Iterator pointIt = figureInstance.getTemplate().iterator(); pointIt.hasNext(); ) {
+ Point p = (Point) pointIt.next();%>
+ pl.addPoint(<%=p.getX()%>, <%=p.getY()%>);
+<% } /*for*/ %>
+ <%=figureVarName%>.setTemplate(pl);
+ <%=figureVarName%>.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));
+<% } /*!if getTemplate().isEmpty()*/ %>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/RoundedRectangle.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/RoundedRectangle.javajet
new file mode 100644
index 000000000..fd4a27459
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/RoundedRectangle.javajet
@@ -0,0 +1,11 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="RoundedRectAttrGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
+<%
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final RoundedRectangle figureInstance = (RoundedRectangle) args.getFigure();
+final String figureVarName = args.getVariableName();
+final ImportAssistant importManager = args.getImportManager();
+final Dispatcher dispatcher = args.getDispatcher();
+%>
+<%=dispatcher.dispatch("Shape", args)%>
+<%=figureVarName%>.setCornerDimensions(new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%>(getMapMode().DPtoLP(<%=figureInstance.getCornerWidth()%>), getMapMode().DPtoLP(<%=figureInstance.getCornerHeight()%>))); \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/ShapeAttrs.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.javajet
index 815afd334..288fe8fb7 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/ShapeAttrs.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.javajet
@@ -1,10 +1,11 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="ShapeAttrsGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* java.util.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="ShapeAttrGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
<%
Dispatcher.Args args = (Dispatcher.Args) argument;
final Shape figureInstance = (Shape) args.getFigure();
final String figureVarName = args.getVariableName();
final ImportAssistant importManager = args.getImportManager();
+final Dispatcher dispatcher = args.getDispatcher();
%>
<%
// PERHAPS, do this with reflection?
@@ -20,11 +21,4 @@ final ImportAssistant importManager = args.getImportManager();
<%=figureVarName%>.setFillXOR(<%=figureInstance.isXorFill()%>);
<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_XorOutline())) {%>
<%=figureVarName%>.setOutlineXOR(<%=figureInstance.isXorOutline()%>);
-<%} if (figureInstance instanceof Polyline && !((Polyline) figureInstance).getTemplate().isEmpty()) {
- for (Iterator pointIt = ((Polyline) figureInstance).getTemplate().iterator(); pointIt.hasNext(); ) {
- Point p = (Point) pointIt.next();%>
- <%=figureVarName%>.addPoint(new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Point")%>(<%=p.getX()%>, <%=p.getY()%>));
-<%}%><%} else if (figureInstance instanceof RoundedRectangle) {
- RoundedRectangle rrFigure = (RoundedRectangle) figureInstance;%>
- <%=figureVarName%>.setCornerDimensions(new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%>(getMapMode().DPtoLP(<%=rrFigure.getCornerWidth()%>), getMapMode().DPtoLP(<%=rrFigure.getCornerHeight()%>)));
-<%}%><%@ include file="FigureAttrs.jetinc"%> \ No newline at end of file
+<%}%><%=dispatcher.dispatch("Figure", args)%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
new file mode 100644
index 000000000..b89aa0274
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
@@ -0,0 +1,40 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="FigureChildrenGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher java.util.*"%>
+<%
+Object[] args = (Object[]) argument;
+List/*<Figure>*/ figureChildren = (List) args[0];
+final ImportAssistant importManager = (ImportAssistant) args[1];
+final GMFGraphSwitch fqnSwitch = (GMFGraphSwitch) args[2];
+final Dispatcher dispatcher = (Dispatcher) args[3];
+String parentFigureVarName = (String) args[4];
+%>
+
+<%
+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++);%>
+ // FIXME instantiate - FigureRef - dispatch to 'instantiate' template?
+ <%=dispatcher.dispatch("instantiate", dispatcher.create((Figure) figureMarker, figureVarName, importManager, fqnSwitch))%>
+ <%=parentFigureVarName%>.add(<%=figureVarName%>);
+<%
+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
+%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/decoration.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/decoration.jetinc
deleted file mode 100644
index be64196f9..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/decoration.jetinc
+++ /dev/null
@@ -1,20 +0,0 @@
- <%=fqnSwitch.doSwitch(df)%> <%=decFigVarName%> = new <%=fqnSwitch.doSwitch(df)%>();
-<% { // scope
-Figure figureInstance = df;
-String figureVarName = decFigVarName;
-%>
-<%@ include file="FigureAttrs.jetinc"%><%} // scope %>
-<% /*include FigureChildren*/ %>
-<%
-if ((df instanceof PolylineDecoration || df instanceof PolygonDecoration)) {
- if (!((Polyline) df).getTemplate().isEmpty()) {
-%>
- org.eclipse.draw2d.geometry.PointList pl = new org.eclipse.draw2d.geometry.PointList();
-<% for (Iterator pointIt = ((Polyline) df).getTemplate().iterator(); pointIt.hasNext(); ) {
- Point p = (Point) pointIt.next();%>
- pl.addPoint(<%=p.getX()%>, <%=p.getY()%>);
-<% } /*for*/ %>
- <%=decFigVarName%>.setTemplate(pl);
-<% } /*!if getTemplate().isEmpty()*/ %>
- <%=decFigVarName%>.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));
-<%} /*if instanceof */ %>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/instantiate.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/instantiate.jetinc
deleted file mode 100644
index 99cc56df9..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/instantiate.jetinc
+++ /dev/null
@@ -1,20 +0,0 @@
-<%
-// FigureMarker: figureMarker
-// String: figureVarName
-if (figureMarker instanceof CustomFigure) {
- CustomFigure figureInstance = (CustomFigure) figureMarker;
-%>
- <%=fqnSwitch.doSwitch(figureMarker)%> <%=figureVarName%> = new <%=fqnSwitch.doSwitch(figureMarker)%>();
-<%@ include file="FigureAttrs.jetinc"%>
-<%} else if (figureMarker instanceof Shape) {
-Shape figureInstance = (Shape) figureMarker;%>
- <%=fqnSwitch.doSwitch(figureMarker)%> <%=figureVarName%> = new <%=fqnSwitch.doSwitch(figureMarker)%>();
-<%=dispatcher.dispatch("ShapeAttrs", dispatcher.create(figureInstance, figureVarName, importManager, fqnSwitch))%>
-<%} else if (figureMarker instanceof FigureRef) {%>
- org.eclipse.draw2d.IFigure <%=figureVarName%> = new <%=((FigureRef) figureMarker).getFigure().getName()%>();
-<%} else if (figureMarker instanceof Label) {
- Label figureInstance = (Label) figureMarker;
-%>
- <%=fqnSwitch.doSwitch(figureMarker)%> <%=figureVarName%> = new <%=fqnSwitch.doSwitch(figureMarker)%>();
- <%=figureVarName%>.setText("<%=((Label) figureMarker).getText()%>");
-<%@ include file="FigureAttrs.jetinc"%><%}%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet
new file mode 100644
index 000000000..0c380c210
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet
@@ -0,0 +1,13 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="NewFigureGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
+<%
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final Figure figureInstance = args.getFigure();
+final String figureVarName = args.getVariableName();
+final ImportAssistant importManager = args.getImportManager();
+final String figureClassName = importManager.getImportedName((String) args.getFQNSwitch().doSwitch(figureInstance));
+
+// PRODUCES instance AND (!) initializes attributes
+%>
+<%=figureClassName%> <%=figureVarName%> = new <%=figureClassName%>();
+<%=args.getDispatcher().dispatch(figureInstance, args)%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/CustomFigure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
index 981d23bae..d633f069f 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/CustomFigure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
@@ -1,8 +1,8 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="CustomFigureGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher java.util.*"%>
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="TopFigureGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
<%
Object[] args = (Object[]) argument;
-CustomFigure figure = (CustomFigure) args[0];
+Figure figure = (Figure) args[0];
final ImportAssistant importManager = (ImportAssistant) args[1];
final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
final Dispatcher dispatcher = (Dispatcher) args[2];
@@ -13,14 +13,12 @@ final Dispatcher dispatcher = (Dispatcher) args[2];
/**
* @generated
*/
-public class <%=figure.getName()%> extends <%=importManager.getImportedName(figure.getQualifiedClassName())%> {
-
+public class <%=figure.getName()%> extends <%=importManager.getImportedName((String) fqnSwitch.doSwitch(figure))%> {
/**
* @generated
*/
public <%=figure.getName()%>() {
- // TODO - process custom properties here
-<%String parentFigureVarName = "this";%>
-<%@ include file="FigureChildren.jetinc" %>
+ <%=dispatcher.dispatch(figure, dispatcher.create(figure, "this", importManager, fqnSwitch))%>
+ <%=dispatcher.dispatch("Children", new Object[] {figure.getChildren(), importManager, fqnSwitch, dispatcher, "this"})%>
}
-}<%importManager.emitSortedImports();%> \ No newline at end of file
+}<%importManager.emitSortedImports();%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/PolylineConnection.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet
index ca11d4de0..fdae4a8ab 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/PolylineConnection.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet
@@ -1,6 +1,5 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="ConnectionGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher java.util.*"%>
-
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="TopConnectionGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
<%
Object[] args = (Object[]) argument;
PolylineConnection figure = (PolylineConnection) args[0];
@@ -20,7 +19,7 @@ public class <%=figure.getName()%> extends <%=importManager.getImportedName("org
* @generated
*/
public <%=figure.getName()%>() {
-<%=dispatcher.dispatch("ShapeAttrs", dispatcher.create(figure, "this", importManager, fqnSwitch))%>
+<%=dispatcher.dispatch("Shape", dispatcher.create(figure, "this", importManager, fqnSwitch))%>
<%if (figure.getSourceDecoration() != null) {%>
setSourceDecoration(createSourceDecoration());
<%}
@@ -29,26 +28,25 @@ if (figure.getTargetDecoration() != null) {%>
<%}%>
}
-<%String decFigVarName = "df";
-if (figure.getSourceDecoration() != null) {
-DecorationFigure df = figure.getSourceDecoration();%>
+<%if (figure.getSourceDecoration() != null) {
+ final String className = importManager.getImportedName((String) fqnSwitch.doSwitch(figure.getSourceDecoration()));%>
/**
* @generated
*/
- private <%=fqnSwitch.doSwitch(df)%> createSourceDecoration() {
-<%@ include file="decoration.jetinc" %>
- return <%=decFigVarName%>;
+ private <%=className%> createSourceDecoration() {
+<%=dispatcher.dispatch("instantiate", dispatcher.create(figure.getSourceDecoration(), "df", importManager, fqnSwitch))%>
+ return df;
}
<%} /*if sourceDecoration != null */ %>
<%if (figure.getTargetDecoration() != null) {
-DecorationFigure df = figure.getTargetDecoration();%>
+ final String className = importManager.getImportedName((String) fqnSwitch.doSwitch(figure.getTargetDecoration()));%>
/**
* @generated
*/
- private <%=fqnSwitch.doSwitch(df)%> createTargetDecoration() {
-<%@ include file="decoration.jetinc" %>
- return <%=decFigVarName%>;
+ private <%=className%> createTargetDecoration() {
+<%=dispatcher.dispatch("instantiate", dispatcher.create(figure.getTargetDecoration(), "df", importManager, fqnSwitch))%>
+ return df;
}
<%}%>
}<%importManager.emitSortedImports();%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet
new file mode 100644
index 000000000..755205349
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet
@@ -0,0 +1,61 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="TopShapeGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher java.util.*"%>
+<%
+Object[] args = (Object[]) argument;
+Shape figure = (Shape) args[0];
+final ImportAssistant importManager = (ImportAssistant) args[1];
+final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
+final Dispatcher dispatcher = (Dispatcher) args[2];
+%>
+
+<%importManager.markImportLocation(stringBuffer);%>
+
+/**
+ * @generated
+ */
+public class <%=figure.getName()%> extends <%=importManager.getImportedName((String) fqnSwitch.doSwitch(figure))%> {
+ /**
+ * @generated
+ */
+ public <%=figure.getName()%>() {
+ <%=dispatcher.dispatch(figure, dispatcher.create(figure, "this", importManager, fqnSwitch))%>
+<%
+for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext();) {
+ Figure next = (Figure) it.next();%>
+ setFigure<%=next.getName()%>(createFigure<%=next.getName()%>());
+ add(getFigure<%=next.getName()%>());
+<%}%>
+ }
+
+<%
+int fc = 0;
+for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext(); fc++) {
+ Figure next = (Figure) it.next();%>
+
+ private IFigure f<%=next.getName()%>;
+
+ /**
+ * @generated
+ */
+ public IFigure getFigure<%=next.getName()%>() {
+ return f<%=next.getName()%>;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setFigure<%=next.getName()%>(IFigure figure) {
+ f<%=next.getName()%> = figure;
+ }
+
+ /**
+ * @generated
+ */
+ private IFigure createFigure<%=next.getName()%>() {
+<%=dispatcher.dispatch("instantiate", dispatcher.create(next, "rv", importManager, fqnSwitch))%>
+<%=dispatcher.dispatch("Children", new Object[] {next.getChildren(), importManager, fqnSwitch, dispatcher, "rv"})%>
+ return rv;
+ }
+
+<%}%>
+}<%importManager.emitSortedImports();%>

Back to the top