Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-02-06 17:21:39 -0500
committeratikhomirov2006-02-06 17:21:39 -0500
commit192b15753755a5c87fa73705ab2b4269aa77662d (patch)
tree927782e5cab2910450ce93ac30dc64d5214b2e17 /plugins/org.eclipse.gmf.graphdef.codegen
parentab3cbec7ac30ebc2acac1565d3a11e5de969c32b (diff)
downloadorg.eclipse.gmf-tooling-192b15753755a5c87fa73705ab2b4269aa77662d.tar.gz
org.eclipse.gmf-tooling-192b15753755a5c87fa73705ab2b4269aa77662d.tar.xz
org.eclipse.gmf-tooling-192b15753755a5c87fa73705ab2b4269aa77662d.zip
refactor - moved EmitterFactory/Dispatcher infrastructure to gmf.common to enable its use in oeg.codegen
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/META-INF/MANIFEST.MF6
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/Dispatcher.java67
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java38
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/GraphDefDispatcher.java70
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureAttrGenerator.java6
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java12
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/LabelAttrGenerator.java6
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewFigureGenerator.java9
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/PolygonDecorationAttrGenerator.java6
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/PolylineAttrGenerator.java8
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/PolylineDecorationAttrGenerator.java8
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/RoundedRectAttrGenerator.java8
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/ShapeAttrGenerator.java8
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopConnectionGenerator.java12
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopFigureGenerator.java10
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java12
-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.java78
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/DynamicTemplateRegistry.java65
-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/NoSuchTemplateException.java36
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/StaticTemplateRegistry.java48
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/TemplateRegistry.java30
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/YAEmitterFactory.java160
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet6
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Label.javajet6
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylgonDecoration.javajet6
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Polyline.javajet8
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylineDecoration.javajet8
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/RoundedRectangle.javajet8
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.javajet8
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet10
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet8
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet10
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet12
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet12
38 files changed, 191 insertions, 786 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/META-INF/MANIFEST.MF b/plugins/org.eclipse.gmf.graphdef.codegen/META-INF/MANIFEST.MF
index 5780003d1..60c5f7b1b 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/META-INF/MANIFEST.MF
@@ -6,8 +6,8 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.emf.ecore,
org.eclipse.gmf.graphdef;visibility:=reexport,
- org.eclipse.emf.codegen,
- org.eclipse.gmf.common
+ org.eclipse.gmf.common,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.codegen
Export-Package: org.eclipse.gmf.graphdef.codegen
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
deleted file mode 100644
index eabbfe8fb..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/Dispatcher.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.graphdef.codegen;
-
-import org.eclipse.gmf.common.codegen.ImportAssistant;
-import org.eclipse.gmf.gmfgraph.Figure;
-import org.eclipse.gmf.gmfgraph.util.GMFGraphSwitch;
-
-/**
- * @author artem
- */
-public abstract class Dispatcher {
-
- public abstract String dispatch(Object key, Object argument);
-
- public abstract String dispatch(Object key, Args args);
-
- // TODO just keep importManager+fqnSwitch in the dispatcher (pure interface + subclass?) and shorten the list of args then
- public Args create(Figure figure, String figureVarName, ImportAssistant importManager, GMFGraphSwitch fqnSwitch) {
- return new Args(this, figure, figureVarName, importManager, fqnSwitch);
- }
-
- public class Args {
- private final String myFigureVarName;
- private final ImportAssistant myImportManager;
- private final GMFGraphSwitch myFqnSwitch;
- private final Dispatcher myOwner;
- private final Figure myFigure;
-
- public Args(Dispatcher owner, Figure figure, String figureVarName, ImportAssistant importManager, GMFGraphSwitch fqnSwitch) {
- myOwner = owner;
- myFigure = figure;
- myFigureVarName = figureVarName;
- myImportManager = importManager;
- myFqnSwitch = fqnSwitch;
- }
-
- public Figure getFigure() {
- return myFigure;
- }
-
- public String getVariableName() {
- return myFigureVarName;
- }
-
- public ImportAssistant getImportManager() {
- return myImportManager;
- }
-
- public GMFGraphSwitch getFQNSwitch() {
- return myFqnSwitch;
- }
-
- public Dispatcher getDispatcher() {
- return myOwner;
- }
- }
-}
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 71b0616a2..8128be304 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
@@ -25,6 +25,8 @@ 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.gmfgraph.util.FigureQualifiedNameSwitch;
+import org.eclipse.gmf.gmfgraph.util.GMFGraphSwitch;
import org.eclipse.gmf.graphdef.codegen.templates.FigureAttrGenerator;
import org.eclipse.gmf.graphdef.codegen.templates.FigureChildrenGenerator;
import org.eclipse.gmf.graphdef.codegen.templates.LabelAttrGenerator;
@@ -37,13 +39,12 @@ 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.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;
+import org.eclipse.gmf.internal.codegen.dispatch.EmitterFactory;
+import org.eclipse.gmf.internal.codegen.dispatch.HierarchyKeyMap;
+import org.eclipse.gmf.internal.codegen.dispatch.KeyChain;
+import org.eclipse.gmf.internal.codegen.dispatch.KeyMap;
+import org.eclipse.gmf.internal.codegen.dispatch.StaticTemplateRegistry;
+import org.eclipse.gmf.internal.codegen.dispatch.TemplateRegistry;
import org.osgi.framework.Bundle;
/**
@@ -52,14 +53,14 @@ import org.osgi.framework.Bundle;
*/
public class FigureGenerator {
private final String packageName;
- private Dispatcher myTopDispatcher;
- private Dispatcher myInnerDispatcher;
+ private GraphDefDispatcher myTopDispatcher;
+ private GraphDefDispatcher myInnerDispatcher;
public FigureGenerator() {
- this(null);
+ this(null, new NullImportAssistant(), new FigureQualifiedNameSwitch());
}
- public FigureGenerator(String aPackageName) {
+ public FigureGenerator(String aPackageName, ImportAssistant importManager, GMFGraphSwitch figureNameSwitch) {
packageName = aPackageName;
final Bundle thisBundle = Platform.getBundle("org.eclipse.gmf.graphdef.codegen");
final ArrayList variables = new ArrayList();
@@ -81,10 +82,10 @@ public class FigureGenerator {
}
}
};
- 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);
+ EmitterFactory topFactory = new EmitterFactory(thisBundle.getEntry("/"), fillTopLevel(), true, variables, true);
+ myTopDispatcher = new GraphDefDispatcher(topFactory, keyMap, importManager, figureNameSwitch);
+ EmitterFactory innerFactory = new EmitterFactory(thisBundle.getEntry("/"), fillAttrs(), true, variables, true);
+ myInnerDispatcher = new GraphDefDispatcher(innerFactory, keyMap, importManager, figureNameSwitch);
}
/**
@@ -128,12 +129,9 @@ public class FigureGenerator {
}
public String go(Figure fig) throws JETException {
- return go(fig, new NullImportAssistant());
- }
-
- public String go(Figure fig, ImportAssistant importManager) {
String res = null;
- res = myTopDispatcher.dispatch(fig, new Object[] {fig, importManager, myInnerDispatcher});
+ Object args = new Object[] {fig, myTopDispatcher.getImportManager(), myTopDispatcher.getFQNSwitch(), myInnerDispatcher};
+ res = myTopDispatcher.dispatch(fig, args);
if (res == null) {
throw new IllegalStateException();
}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/GraphDefDispatcher.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/GraphDefDispatcher.java
new file mode 100644
index 000000000..045f2df90
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/GraphDefDispatcher.java
@@ -0,0 +1,70 @@
+/*
+ * 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.graphdef.codegen;
+
+import org.eclipse.gmf.common.codegen.ImportAssistant;
+import org.eclipse.gmf.gmfgraph.Figure;
+import org.eclipse.gmf.gmfgraph.util.GMFGraphSwitch;
+import org.eclipse.gmf.internal.codegen.dispatch.DispatcherImpl;
+import org.eclipse.gmf.internal.codegen.dispatch.EmitterFactory;
+import org.eclipse.gmf.internal.codegen.dispatch.KeyMap;
+
+/**
+ * @author artem
+ */
+public class GraphDefDispatcher extends DispatcherImpl {
+ private final ImportAssistant myImportManager;
+ private final GMFGraphSwitch myFqnSwitch;
+
+ public GraphDefDispatcher(EmitterFactory factory, KeyMap keyMap, ImportAssistant importManager, GMFGraphSwitch fqnSwitch) {
+ super(factory, keyMap);
+ myImportManager = importManager;
+ myFqnSwitch = fqnSwitch;
+ }
+
+ public ImportAssistant getImportManager() {
+ return myImportManager;
+ }
+
+ public GMFGraphSwitch getFQNSwitch() {
+ return myFqnSwitch;
+ }
+
+
+ public Args create(Figure figure, String figureVarName) {
+ return new Args(this, figure, figureVarName);
+ }
+
+ public static class Args {
+ private final Figure myFigure;
+ private final String myFigureVarName;
+ private final GraphDefDispatcher myOwner;
+
+ public Args(GraphDefDispatcher owner, Figure figure, String figureVarName) {
+ myOwner = owner;
+ myFigure = figure;
+ myFigureVarName = figureVarName;
+ }
+
+ public Figure getFigure() {
+ return myFigure;
+ }
+
+ public String getVariableName() {
+ return myFigureVarName;
+ }
+
+ public GraphDefDispatcher getDispatcher() {
+ return myOwner;
+ }
+ }
+}
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
index db4ab0463..d2852b7b0 100644
--- 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
@@ -2,7 +2,7 @@ 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 org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher;
public class FigureAttrGenerator
{
@@ -43,10 +43,10 @@ public class FigureAttrGenerator
{
StringBuffer stringBuffer = new StringBuffer();
-Dispatcher.Args args = (Dispatcher.Args) argument;
+GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
final Figure figureInstance = args.getFigure();
final String figureVarName = args.getVariableName();
-final ImportAssistant importManager = args.getImportManager();
+final ImportAssistant importManager = args.getDispatcher().getImportManager();
Color colorVal;
if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java
index 890dec135..23c834123 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java
@@ -1,9 +1,7 @@
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 org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher;
import java.util.*;
public class FigureChildrenGenerator
@@ -31,10 +29,8 @@ public class FigureChildrenGenerator
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];
+final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[1];
+String parentFigureVarName = (String) args[2];
stringBuffer.append(TEXT_1);
@@ -55,7 +51,7 @@ while (!l.isEmpty()) {
}
final String figureVarName = "fig" + (figureCount++);
stringBuffer.append(TEXT_2);
- stringBuffer.append(dispatcher.dispatch("instantiate", dispatcher.create((Figure) figureMarker, figureVarName, importManager, fqnSwitch)));
+ stringBuffer.append(dispatcher.dispatch("instantiate", dispatcher.create((Figure) figureMarker, figureVarName)));
stringBuffer.append(TEXT_3);
stringBuffer.append(parentFigureVarName);
stringBuffer.append(TEXT_4);
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
index b835c2d5a..f8b15904d 100644
--- 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
@@ -1,7 +1,7 @@
package org.eclipse.gmf.graphdef.codegen.templates;
import org.eclipse.gmf.gmfgraph.*;
-import org.eclipse.gmf.graphdef.codegen.Dispatcher;
+import org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher;
public class LabelAttrGenerator
{
@@ -23,10 +23,10 @@ public class LabelAttrGenerator
{
StringBuffer stringBuffer = new StringBuffer();
-Dispatcher.Args args = (Dispatcher.Args) argument;
+GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
final Label figureInstance = (Label) args.getFigure();
final String figureVarName = args.getVariableName();
-final Dispatcher dispatcher = args.getDispatcher();
+final GraphDefDispatcher dispatcher = args.getDispatcher();
if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getLabel_Text())) {
stringBuffer.append(TEXT_1);
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
index 8a89e28fc..5d631465c 100644
--- 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
@@ -1,8 +1,7 @@
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 org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher;
public class NewFigureGenerator
{
@@ -26,11 +25,11 @@ public class NewFigureGenerator
{
StringBuffer stringBuffer = new StringBuffer();
-Dispatcher.Args args = (Dispatcher.Args) argument;
+GraphDefDispatcher.Args args = (GraphDefDispatcher.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));
+final GraphDefDispatcher dispatcher = args.getDispatcher();
+final String figureClassName = dispatcher.getImportManager().getImportedName((String) dispatcher.getFQNSwitch().doSwitch(figureInstance));
// PRODUCES instance AND (!) initializes attributes
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
index 60cb54260..1cc867f7e 100644
--- 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
@@ -1,6 +1,6 @@
package org.eclipse.gmf.graphdef.codegen.templates;
-import org.eclipse.gmf.graphdef.codegen.Dispatcher;
+import org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher;
public class PolygonDecorationAttrGenerator
{
@@ -20,8 +20,8 @@ public class PolygonDecorationAttrGenerator
{
StringBuffer stringBuffer = new StringBuffer();
-Dispatcher.Args args = (Dispatcher.Args) argument;
-final Dispatcher dispatcher = args.getDispatcher();
+GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
+final GraphDefDispatcher dispatcher = args.getDispatcher();
stringBuffer.append(TEXT_1);
stringBuffer.append(dispatcher.dispatch("PolylineDecoration", args));
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
index 7601603b3..c0fcc4782 100644
--- 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
@@ -2,7 +2,7 @@ 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 org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher;
public class PolylineAttrGenerator
{
@@ -27,11 +27,11 @@ public class PolylineAttrGenerator
{
StringBuffer stringBuffer = new StringBuffer();
-Dispatcher.Args args = (Dispatcher.Args) argument;
+GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
final Polyline figureInstance = (Polyline) args.getFigure();
final String figureVarName = args.getVariableName();
-final ImportAssistant importManager = args.getImportManager();
-final Dispatcher dispatcher = args.getDispatcher();
+final GraphDefDispatcher dispatcher = args.getDispatcher();
+final ImportAssistant importManager = dispatcher.getImportManager();
stringBuffer.append(TEXT_1);
stringBuffer.append(dispatcher.dispatch("Shape", args));
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
index 7f95c37d4..940a09698 100644
--- 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
@@ -2,7 +2,7 @@ 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 org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher;
import java.util.*;
public class PolylineDecorationAttrGenerator
@@ -34,12 +34,12 @@ public class PolylineDecorationAttrGenerator
{
StringBuffer stringBuffer = new StringBuffer();
-Dispatcher.Args args = (Dispatcher.Args) argument;
+GraphDefDispatcher.Args args = (GraphDefDispatcher.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();
+final GraphDefDispatcher dispatcher = args.getDispatcher();
+final ImportAssistant importManager = dispatcher.getImportManager();
stringBuffer.append(TEXT_1);
stringBuffer.append(TEXT_2);
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
index 76cf27418..b4682326e 100644
--- 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
@@ -2,7 +2,7 @@ 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 org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher;
public class RoundedRectAttrGenerator
{
@@ -27,11 +27,11 @@ public class RoundedRectAttrGenerator
{
StringBuffer stringBuffer = new StringBuffer();
-Dispatcher.Args args = (Dispatcher.Args) argument;
+GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
final RoundedRectangle figureInstance = (RoundedRectangle) args.getFigure();
final String figureVarName = args.getVariableName();
-final ImportAssistant importManager = args.getImportManager();
-final Dispatcher dispatcher = args.getDispatcher();
+final GraphDefDispatcher dispatcher = args.getDispatcher();
+final ImportAssistant importManager = dispatcher.getImportManager();
stringBuffer.append(TEXT_1);
stringBuffer.append(dispatcher.dispatch("Shape", args));
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
index fb351a958..26b23245f 100644
--- 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
@@ -2,7 +2,7 @@ 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 org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher;
public class ShapeAttrGenerator
{
@@ -40,11 +40,11 @@ public class ShapeAttrGenerator
{
StringBuffer stringBuffer = new StringBuffer();
-Dispatcher.Args args = (Dispatcher.Args) argument;
+GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
final Shape figureInstance = (Shape) args.getFigure();
final String figureVarName = args.getVariableName();
-final ImportAssistant importManager = args.getImportManager();
-final Dispatcher dispatcher = args.getDispatcher();
+final GraphDefDispatcher dispatcher = args.getDispatcher();
+final ImportAssistant importManager = dispatcher.getImportManager();
// PERHAPS, do this with reflection?
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
index eab82c745..2824b2c07 100644
--- 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
@@ -3,7 +3,7 @@ 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 org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher;
public class TopConnectionGenerator
{
@@ -44,8 +44,8 @@ public class TopConnectionGenerator
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];
+final GMFGraphSwitch fqnSwitch = (GMFGraphSwitch) args[2];
+final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[3];
stringBuffer.append(TEXT_1);
importManager.markImportLocation(stringBuffer);
@@ -57,7 +57,7 @@ final Dispatcher dispatcher = (Dispatcher) args[2];
stringBuffer.append(figure.getName());
stringBuffer.append(TEXT_5);
stringBuffer.append(TEXT_6);
- stringBuffer.append(dispatcher.dispatch("Shape", dispatcher.create(figure, "this", importManager, fqnSwitch)));
+ stringBuffer.append(dispatcher.dispatch("Shape", dispatcher.create(figure, "this")));
if (figure.getSourceDecoration() != null) {
stringBuffer.append(TEXT_7);
}
@@ -71,7 +71,7 @@ if (figure.getTargetDecoration() != null) {
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(dispatcher.dispatch("instantiate", dispatcher.create(figure.getSourceDecoration(), "df")));
stringBuffer.append(TEXT_13);
} /*if sourceDecoration != null */
stringBuffer.append(TEXT_14);
@@ -81,7 +81,7 @@ if (figure.getTargetDecoration() != null) {
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(dispatcher.dispatch("instantiate", dispatcher.create(figure.getTargetDecoration(), "df")));
stringBuffer.append(TEXT_18);
}
stringBuffer.append(TEXT_19);
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopFigureGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopFigureGenerator.java
index 7f4e2db48..a1aa1643e 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopFigureGenerator.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopFigureGenerator.java
@@ -3,7 +3,7 @@ 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 org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher;
public class TopFigureGenerator
{
@@ -33,8 +33,8 @@ public class TopFigureGenerator
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];
+final GMFGraphSwitch fqnSwitch = (GMFGraphSwitch) args[2];
+final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[3];
stringBuffer.append(TEXT_1);
importManager.markImportLocation(stringBuffer);
@@ -45,9 +45,9 @@ final Dispatcher dispatcher = (Dispatcher) args[2];
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(dispatcher.dispatch(figure, dispatcher.create(figure, "this")));
stringBuffer.append(TEXT_6);
- stringBuffer.append(dispatcher.dispatch("Children", new Object[] {figure.getChildren(), importManager, fqnSwitch, dispatcher, "this"}));
+ stringBuffer.append(dispatcher.dispatch("Children", new Object[] {figure.getChildren(), dispatcher, "this"}));
stringBuffer.append(TEXT_7);
importManager.emitSortedImports();
stringBuffer.append(TEXT_8);
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java
index 0d1718e26..bacc7ee17 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java
@@ -3,7 +3,7 @@ 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 org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher;
import java.util.*;
public class TopShapeGenerator
@@ -48,8 +48,8 @@ public class TopShapeGenerator
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];
+final GMFGraphSwitch fqnSwitch = (GMFGraphSwitch) args[2];
+final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[3];
stringBuffer.append(TEXT_1);
importManager.markImportLocation(stringBuffer);
@@ -60,7 +60,7 @@ final Dispatcher dispatcher = (Dispatcher) args[2];
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(dispatcher.dispatch(figure, dispatcher.create(figure, "this")));
for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext();) {
Figure next = (Figure) it.next();
@@ -91,9 +91,9 @@ for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext(); fc++)
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(dispatcher.dispatch("instantiate", dispatcher.create(next, "rv")));
stringBuffer.append(TEXT_19);
- stringBuffer.append(dispatcher.dispatch("Children", new Object[] {next.getChildren(), importManager, fqnSwitch, dispatcher, "rv"}));
+ stringBuffer.append(dispatcher.dispatch("Children", new Object[] {next.getChildren(), dispatcher, "rv"}));
stringBuffer.append(TEXT_20);
}
stringBuffer.append(TEXT_21);
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
deleted file mode 100644
index a5a39b533..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/ArrayKeyChain.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 0e22d84f0..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/DispatcherImpl.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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 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;
-
-/**
- * @author artem
- */
-public class DispatcherImpl extends Dispatcher {
-
- private final YAEmitterFactory myFactory;
-
- private final KeyMap myKeyMap;
-
- public DispatcherImpl(YAEmitterFactory factory, KeyMap keyMap) {
- myFactory = factory;
- myKeyMap = keyMap;
- }
-
- 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) {
- 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/DynamicTemplateRegistry.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/DynamicTemplateRegistry.java
deleted file mode 100644
index 4b845c648..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/DynamicTemplateRegistry.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.text.MessageFormat;
-
-/**
- * Treat key as (part of) template path to allow <%=dispatcher.dispatch("../AnotherTemplate.javajet")%> use
- * Note, braces (<em>{</em> or <em>}</em>) within keys should be escaped, see {@link MessageFormat} class for details
- * @author artem
- */
-public class DynamicTemplateRegistry implements TemplateRegistry {
- private final String myPattern;
-
- /**
- * Uses simple pattern <code>"{0}"</code> (i.e. leave key as is) to initialize instance.
- */
- public DynamicTemplateRegistry() {
- this("{0}");
- }
-
- /**
- * Allows to add some prefix/suffix to the value of passed key. E.g. <code>"/templates-new/{0}.javajet"</code>
- * @param pattern string to pass to {@link MessageFormat}
- */
- public DynamicTemplateRegistry(String pattern) {
- myPattern = pattern;
- }
-
- /**
- * Treats key as (part of) template path
- */
- public String getTemplatePath(Object key) {
- return MessageFormat.format(myPattern, new Object[] { key });
- }
-
- /**
- * @return always false
- */
- public boolean hasGeneratorClass(Object key) {
- return false;
- }
-
- /**
- * @return always <code>null</code>
- */
- public Class getGeneratorClass(Object key) {
- return null;
- }
-
- /**
- * NO-OP
- */
- public void clean() {
- }
-}
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
deleted file mode 100644
index 2c5cd0bba..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/HierarchyKeyMap.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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
deleted file mode 100644
index d189cf566..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/KeyChain.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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
deleted file mode 100644
index e87a50f44..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/KeyMap.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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/NoSuchTemplateException.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/NoSuchTemplateException.java
deleted file mode 100644
index 6c7244b73..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/NoSuchTemplateException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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;
-
-/**
- * @author artem
- */
-public class NoSuchTemplateException extends Exception {
-
- private static final long serialVersionUID = -1892646974029705702L;
-
- /**
- * @param templateName
- */
- public NoSuchTemplateException(String templateName) {
- super(templateName);
- }
-
- /**
- * @param templateName
- * @param cause
- */
- public NoSuchTemplateException(String templateName, Throwable cause) {
- super(templateName, cause);
- }
-
-}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/StaticTemplateRegistry.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/StaticTemplateRegistry.java
deleted file mode 100644
index 5e5863c09..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/StaticTemplateRegistry.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.HashMap;
-import java.util.Map;
-
-/**
- * @author artem
- */
-public class StaticTemplateRegistry implements TemplateRegistry {
- private final Map pathMap = new HashMap/*<Object, String>*/();
- private final Map classMap = new HashMap/*<Object,Class>*/();
-
- public void put(Object key, String templatePath, Class generatorClass) {
- assert key != null && templatePath != null;
- pathMap.put(key, templatePath);
- if (generatorClass != null) {
- classMap.put(key, generatorClass);
- }
- }
-
- public String getTemplatePath(Object key) {
- return (String) pathMap.get(key);
- }
-
- public boolean hasGeneratorClass(Object key) {
- return classMap.containsKey(key);
- }
-
- public Class getGeneratorClass(Object key) {
- return (Class) classMap.get(key);
- }
-
- public void clean() {
- pathMap.clear();
- classMap.clear();
- }
-}
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
deleted file mode 100644
index 1362fb8fc..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/TemplateRegistry.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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;
-
-/**
- * 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
- */
-public interface TemplateRegistry {
-
- String getTemplatePath(Object key);
-
- boolean hasGeneratorClass(Object key);
-
- Class getGeneratorClass(Object key);
-
- void clean();
-
-} \ No newline at end of file
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
deleted file mode 100644
index 9d270df99..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/YAEmitterFactory.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * 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.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.codegen.jet.JETEmitter;
-import org.eclipse.emf.codegen.jet.JETException;
-import org.eclipse.gmf.common.UnexpectedBehaviourException;
-
-/**
- * Yet Another Emitter Factory
- *
- * @author artem
- */
-public class YAEmitterFactory {
-
- private final URL myBaseURL;
-
- private final TemplateRegistry myTemplates;
-
- private final boolean myUsePrecompiled;
-
- private final List/* <String> */myVariables;
-
- private final Map myCache;
-
- /**
- * FIXME variables - either String[] or wrap as UnmodifiableList
- *
- * @param baseURL
- * @param templates
- * @param usePrecompiled
- * @param variables
- */
- public YAEmitterFactory(URL baseURL, TemplateRegistry templates, boolean usePrecompiled, List/* <String> */variables, boolean cache) {
- assert baseURL != null && templates != null;
- assert variables == null || !variables.contains(null);
- myBaseURL = baseURL;
- myTemplates = templates;
- myUsePrecompiled = usePrecompiled;
- myVariables = variables == null ? Collections.EMPTY_LIST : variables;
- if (cache) {
- myCache = createCache();
- } else {
- myCache = null;
- }
- }
-
- /**
- * Instantiates {@link HashMap} by default. NOTE, this method is invoked
- * from constructor, object may not be fully initialized, don't use this
- * method for anything but cache instantiation.
- */
- 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.
- */
- public JETEmitter acquireEmitter(Object key) throws JETException, NoSuchTemplateException, UnexpectedBehaviourException {
- JETEmitter em = checkCache(key);
- if (em != null) {
- return em;
- }
- em = newEmitter(key);
- cache(key, em);
- return em;
- }
-
- /**
- * Explicit way to produce new instance of emitter, passing over cache (if any).
- */
- public JETEmitter newEmitter(Object key) throws UnexpectedBehaviourException, NoSuchTemplateException, JETException {
- JETEmitter em;
- String fullPath = constructPath(key);
- ClassLoader cl;
- if (precompiledInUse(key)) {
- cl = myTemplates.getGeneratorClass(key).getClassLoader();
- } else {
- cl = getClass().getClassLoader();
- }
- em = new JETEmitter(fullPath, cl);
- feedVariables(em);
- initPrecompiled(key, em);
- return em;
- }
-
- private boolean precompiledInUse(Object key) {
- return myUsePrecompiled && myTemplates.hasGeneratorClass(key);
- }
-
- private void initPrecompiled(Object key, JETEmitter em) throws UnexpectedBehaviourException {
- try {
- if (precompiledInUse(key)) {
- Method m = myTemplates.getGeneratorClass(key).getMethod("generate", new Class[] { Object.class });
- em.setMethod(m);
- }
- } catch (NoSuchMethodException ex) {
- throw new UnexpectedBehaviourException("Bad template class", ex);
- }
- }
-
- private String constructPath(Object key) throws UnexpectedBehaviourException, NoSuchTemplateException {
- try {
- String path = myTemplates.getTemplatePath(key);
- if (path == null) {
- throw new NoSuchTemplateException(String.valueOf(key));
- }
- return new URL(myBaseURL, path).toString();
- } catch (MalformedURLException ex) {
- throw new UnexpectedBehaviourException(ex);
- }
- }
-
- private void feedVariables(JETEmitter em) throws JETException {
- for (Iterator it = myVariables.iterator(); it.hasNext();) {
- em.addVariable(null, (String) it.next());
- }
- }
-
- private JETEmitter checkCache(Object key) {
- if (myCache != null) {
- return (JETEmitter) myCache.get(key);
- }
- return null;
- }
-
- private void cache(Object key, JETEmitter emitter) {
- if (myCache != null) {
- myCache.put(key, emitter);
- }
- }
-}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet
index 7cd0f28ef..bf1bdab86 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet
@@ -1,10 +1,10 @@
<%@ 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"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher"%>
<%
-Dispatcher.Args args = (Dispatcher.Args) argument;
+GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
final Figure figureInstance = args.getFigure();
final String figureVarName = args.getVariableName();
-final ImportAssistant importManager = args.getImportManager();
+final ImportAssistant importManager = args.getDispatcher().getImportManager();
%>
<%Color colorVal;
if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Label.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Label.javajet
index 8d8582514..ee6031beb 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Label.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Label.javajet
@@ -1,10 +1,10 @@
<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="LabelAttrGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher"%>
<%
-Dispatcher.Args args = (Dispatcher.Args) argument;
+GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
final Label figureInstance = (Label) args.getFigure();
final String figureVarName = args.getVariableName();
-final Dispatcher dispatcher = args.getDispatcher();
+final GraphDefDispatcher dispatcher = args.getDispatcher();
%>
<%if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getLabel_Text())) {%>
<%=figureVarName%>.setText("<%=figureInstance.getText()%>");
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylgonDecoration.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylgonDecoration.javajet
index 11eec09bb..f6a79b709 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylgonDecoration.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylgonDecoration.javajet
@@ -1,7 +1,7 @@
<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="PolygonDecorationAttrGenerator"
- imports="org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
+ imports="org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher"%>
<%
-Dispatcher.Args args = (Dispatcher.Args) argument;
-final Dispatcher dispatcher = args.getDispatcher();
+GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
+final GraphDefDispatcher 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
index 497789253..2fc5a5704 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Polyline.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Polyline.javajet
@@ -1,11 +1,11 @@
<%@ 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"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher"%>
<%
-Dispatcher.Args args = (Dispatcher.Args) argument;
+GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
final Polyline figureInstance = (Polyline) args.getFigure();
final String figureVarName = args.getVariableName();
-final ImportAssistant importManager = args.getImportManager();
-final Dispatcher dispatcher = args.getDispatcher();
+final GraphDefDispatcher dispatcher = args.getDispatcher();
+final ImportAssistant importManager = dispatcher.getImportManager();
%>
<%=dispatcher.dispatch("Shape", args)%>
<%if (!figureInstance.getTemplate().isEmpty()) {
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylineDecoration.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylineDecoration.javajet
index 0a4b53871..b4edce689 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylineDecoration.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylineDecoration.javajet
@@ -1,12 +1,12 @@
<%@ 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.*"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher java.util.*"%>
<%
-Dispatcher.Args args = (Dispatcher.Args) argument;
+GraphDefDispatcher.Args args = (GraphDefDispatcher.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();
+final GraphDefDispatcher dispatcher = args.getDispatcher();
+final ImportAssistant importManager = dispatcher.getImportManager();
%>
// dispatchNext?
<%=dispatcher.dispatch("Shape", args)%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/RoundedRectangle.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/RoundedRectangle.javajet
index fd4a27459..6f470f383 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/RoundedRectangle.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/RoundedRectangle.javajet
@@ -1,11 +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"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher"%>
<%
-Dispatcher.Args args = (Dispatcher.Args) argument;
+GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
final RoundedRectangle figureInstance = (RoundedRectangle) args.getFigure();
final String figureVarName = args.getVariableName();
-final ImportAssistant importManager = args.getImportManager();
-final Dispatcher dispatcher = args.getDispatcher();
+final GraphDefDispatcher dispatcher = args.getDispatcher();
+final ImportAssistant importManager = dispatcher.getImportManager();
%>
<%=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/attr/Shape.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.javajet
index 288fe8fb7..0cca6aa6b 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.javajet
@@ -1,11 +1,11 @@
<%@ 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"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher"%>
<%
-Dispatcher.Args args = (Dispatcher.Args) argument;
+GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
final Shape figureInstance = (Shape) args.getFigure();
final String figureVarName = args.getVariableName();
-final ImportAssistant importManager = args.getImportManager();
-final Dispatcher dispatcher = args.getDispatcher();
+final GraphDefDispatcher dispatcher = args.getDispatcher();
+final ImportAssistant importManager = dispatcher.getImportManager();
%>
<%
// PERHAPS, do this with reflection?
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
index b89aa0274..f2a51c57a 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
@@ -1,12 +1,10 @@
<%@ 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.*"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher 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];
+final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[1];
+String parentFigureVarName = (String) args[2];
%>
<%
@@ -27,7 +25,7 @@ while (!l.isEmpty()) {
}
final String figureVarName = "fig" + (figureCount++);%>
// FIXME instantiate - FigureRef - dispatch to 'instantiate' template?
- <%=dispatcher.dispatch("instantiate", dispatcher.create((Figure) figureMarker, figureVarName, importManager, fqnSwitch))%>
+ <%=dispatcher.dispatch("instantiate", dispatcher.create((Figure) figureMarker, figureVarName))%>
<%=parentFigureVarName%>.add(<%=figureVarName%>);
<%
if (_nxt instanceof Figure && !((Figure) _nxt).getChildren().isEmpty()) {
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet
index 0c380c210..eecabf0fd 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet
@@ -1,11 +1,11 @@
<%@ 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"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher"%>
<%
-Dispatcher.Args args = (Dispatcher.Args) argument;
+GraphDefDispatcher.Args args = (GraphDefDispatcher.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));
+final GraphDefDispatcher dispatcher = args.getDispatcher();
+final String figureClassName = dispatcher.getImportManager().getImportedName((String) dispatcher.getFQNSwitch().doSwitch(figureInstance));
// PRODUCES instance AND (!) initializes attributes
%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
index d633f069f..61246ba1f 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
@@ -1,11 +1,11 @@
<%@ 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"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher"%>
<%
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];
+final GMFGraphSwitch fqnSwitch = (GMFGraphSwitch) args[2];
+final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[3];
%>
<%importManager.markImportLocation(stringBuffer);%>
@@ -18,7 +18,7 @@ public class <%=figure.getName()%> extends <%=importManager.getImportedName((Str
* @generated
*/
public <%=figure.getName()%>() {
- <%=dispatcher.dispatch(figure, dispatcher.create(figure, "this", importManager, fqnSwitch))%>
- <%=dispatcher.dispatch("Children", new Object[] {figure.getChildren(), importManager, fqnSwitch, dispatcher, "this"})%>
+ <%=dispatcher.dispatch(figure, dispatcher.create(figure, "this"))%>
+ <%=dispatcher.dispatch("Children", new Object[] {figure.getChildren(), dispatcher, "this"})%>
}
}<%importManager.emitSortedImports();%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet
index fdae4a8ab..c794eab65 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet
@@ -1,11 +1,11 @@
<%@ 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"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher"%>
<%
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];
+final GMFGraphSwitch fqnSwitch = (GMFGraphSwitch) args[2];
+final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[3];
%>
<%importManager.markImportLocation(stringBuffer);%>
@@ -19,7 +19,7 @@ public class <%=figure.getName()%> extends <%=importManager.getImportedName("org
* @generated
*/
public <%=figure.getName()%>() {
-<%=dispatcher.dispatch("Shape", dispatcher.create(figure, "this", importManager, fqnSwitch))%>
+<%=dispatcher.dispatch("Shape", dispatcher.create(figure, "this"))%>
<%if (figure.getSourceDecoration() != null) {%>
setSourceDecoration(createSourceDecoration());
<%}
@@ -34,7 +34,7 @@ if (figure.getTargetDecoration() != null) {%>
* @generated
*/
private <%=className%> createSourceDecoration() {
-<%=dispatcher.dispatch("instantiate", dispatcher.create(figure.getSourceDecoration(), "df", importManager, fqnSwitch))%>
+<%=dispatcher.dispatch("instantiate", dispatcher.create(figure.getSourceDecoration(), "df"))%>
return df;
}
<%} /*if sourceDecoration != null */ %>
@@ -45,7 +45,7 @@ if (figure.getTargetDecoration() != null) {%>
* @generated
*/
private <%=className%> createTargetDecoration() {
-<%=dispatcher.dispatch("instantiate", dispatcher.create(figure.getTargetDecoration(), "df", importManager, fqnSwitch))%>
+<%=dispatcher.dispatch("instantiate", dispatcher.create(figure.getTargetDecoration(), "df"))%>
return df;
}
<%}%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet
index 755205349..34d9f1df9 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet
@@ -1,11 +1,11 @@
<%@ 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.*"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher 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];
+final GMFGraphSwitch fqnSwitch = (GMFGraphSwitch) args[2];
+final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[3];
%>
<%importManager.markImportLocation(stringBuffer);%>
@@ -18,7 +18,7 @@ public class <%=figure.getName()%> extends <%=importManager.getImportedName((Str
* @generated
*/
public <%=figure.getName()%>() {
- <%=dispatcher.dispatch(figure, dispatcher.create(figure, "this", importManager, fqnSwitch))%>
+ <%=dispatcher.dispatch(figure, dispatcher.create(figure, "this"))%>
<%
for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext();) {
Figure next = (Figure) it.next();%>
@@ -52,8 +52,8 @@ for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext(); fc++)
* @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"})%>
+<%=dispatcher.dispatch("instantiate", dispatcher.create(next, "rv"))%>
+<%=dispatcher.dispatch("Children", new Object[] {next.getChildren(), dispatcher, "rv"})%>
return rv;
}

Back to the top