Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2007-05-17 22:14:20 +0000
committeratikhomirov2007-05-17 22:14:20 +0000
commite113c69cec70fb529429a63c19a7b7a98dbdad72 (patch)
treec840267f27cb74d586785a26ea5ce6e615da556b /plugins/org.eclipse.gmf.graphdef.codegen
parentdd02c5e5370b65118bff643741284a9915c24bbd (diff)
downloadorg.eclipse.gmf-tooling-e113c69cec70fb529429a63c19a7b7a98dbdad72.tar.gz
org.eclipse.gmf-tooling-e113c69cec70fb529429a63c19a7b7a98dbdad72.tar.xz
org.eclipse.gmf-tooling-e113c69cec70fb529429a63c19a7b7a98dbdad72.zip
moving towards not using fqnswitch and java to tell draw2d figure names; let toolsmith to control what draw2d classes are being used; fqnSwitch argument replaced with simple token indicator
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java43
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneEmitters.java9
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneGenerator.java46
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/CanvasProcessor.java13
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/GalleryProcessor.java5
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Border.xpt4
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt18
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Decoration.xpt8
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Layout.xpt16
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/LayoutData.xpt8
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Runtime.xpt72
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.ext33
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/plugin/Manifest.xpt11
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt6
14 files changed, 188 insertions, 104 deletions
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 e53ae9d75..f5f2a6814 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
@@ -21,7 +21,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.gmf.common.UnexpectedBehaviourException;
import org.eclipse.gmf.common.codegen.ImportAssistant;
import org.eclipse.gmf.gmfgraph.Figure;
-import org.eclipse.gmf.gmfgraph.util.FigureQualifiedNameSwitch;
import org.eclipse.gmf.internal.common.codegen.TextEmitter;
import org.eclipse.gmf.internal.graphdef.codegen.Activator;
import org.eclipse.gmf.internal.xpand.BufferOutput;
@@ -31,6 +30,16 @@ import org.eclipse.gmf.internal.xpand.expression.Variable;
import org.eclipse.gmf.internal.xpand.util.ContextFactory;
public class FigureGenerator implements TextEmitter {
+
+ private static final String VAR_MM_ACCESS = "mapModeAccessor";
+ private static final String VAR_OUTPUT_FIELDS = "outputStaticFields";
+ private static final String VAR_OUTPUT_METHODS = "outputAdditionalMethods";
+ private static final String VAR_PACKAGE_STMT = "packageStatement";
+ private static final String VAR_RT_TOKEN = "runtimeToken";
+
+ private static final String SLOT_FIELDS = "staticFields";
+ private static final String SLOT_METHODS = "additionalMethods";
+
private final XpandFacade xpandFacade;
private final StringBuilder result;
@@ -43,15 +52,21 @@ public class FigureGenerator implements TextEmitter {
private StringBuilder additionalFields;
- public FigureGenerator(FigureQualifiedNameSwitch fqnSwitch, boolean asInnerClass) {
- this(fqnSwitch, MapModeCodeGenStrategy.DYNAMIC, "getMapMode().", asInnerClass);
+
+ /**
+ * XXX consider using enum for runtimeToken
+ * @param runtimeToken either "full" or null to indicate full GMF runtime use, any other value is to be processed by custom templates
+ * @param asInnerClass
+ */
+ public FigureGenerator(String runtimeToken, boolean asInnerClass) {
+ this(runtimeToken, MapModeCodeGenStrategy.DYNAMIC, "getMapMode().", asInnerClass);
}
- public FigureGenerator(FigureQualifiedNameSwitch fqnSwitch, MapModeCodeGenStrategy mapModeStrategy, String mapModeAccessor, boolean asInnerClass) {
- this(fqnSwitch, mapModeStrategy, mapModeAccessor, asInnerClass, null);
+ public FigureGenerator(String runtimeToken, MapModeCodeGenStrategy mapModeStrategy, String mapModeAccessor, boolean asInnerClass) {
+ this(runtimeToken, mapModeStrategy, mapModeAccessor, asInnerClass, null);
}
- public FigureGenerator(FigureQualifiedNameSwitch fqnSwitch, MapModeCodeGenStrategy mapModeStrategy, String mapModeAccessor, boolean asInnerClass, URL[] dynamicTemplates) {
+ public FigureGenerator(String runtimeToken, MapModeCodeGenStrategy mapModeStrategy, String mapModeAccessor, boolean asInnerClass, URL[] dynamicTemplates) {
myIsInnerClassCode = asInnerClass;
if (mapModeStrategy == MapModeCodeGenStrategy.STATIC) {
if (mapModeAccessor != null && mapModeAccessor.trim().length() > 0) {
@@ -60,27 +75,29 @@ public class FigureGenerator implements TextEmitter {
}
final ArrayList<Variable> globals = new ArrayList<Variable>();
if (mapModeStrategy == MapModeCodeGenStrategy.DYNAMIC) {
- globals.add(new Variable("mapModeAccessor", mapModeAccessor == null ? "" : mapModeAccessor));
+ globals.add(new Variable(VAR_MM_ACCESS, mapModeAccessor == null ? "" : mapModeAccessor));
+ }
+ if (runtimeToken != null) {
+ globals.add(new Variable(VAR_RT_TOKEN, runtimeToken));
}
- globals.add(new Variable(FigureQualifiedNameSwitch.class.getSimpleName(), fqnSwitch));
- packageStatement = new Variable("packageStatement", "");
+ packageStatement = new Variable(VAR_PACKAGE_STMT, "");
globals.add(packageStatement);
additionalMethods = new StringBuilder();
- globals.add(new Variable("outputAdditionalMethods", "") {
+ globals.add(new Variable(VAR_OUTPUT_METHODS, "") {
public Object getValue() {
return additionalMethods.toString();
}
});
additionalFields = new StringBuilder();
- globals.add(new Variable("outputStaticFields", "") {
+ globals.add(new Variable(VAR_OUTPUT_FIELDS, "") {
public Object getValue() {
return additionalFields.toString();
}
});
result = new StringBuilder(200);
Map<String, StringBuilder> slots = new HashMap<String, StringBuilder>();
- slots.put("additionalMethods", additionalMethods);
- slots.put("staticFields", additionalFields);
+ slots.put(SLOT_METHODS, additionalMethods);
+ slots.put(SLOT_FIELDS, additionalFields);
BufferOutput bufferOutput = new BufferOutput(result, slots);
ResourceManager resourceManager = Activator.createResourceEngine(mapModeStrategy, dynamicTemplates);
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneEmitters.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneEmitters.java
index ede226eda..d3ef1940a 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneEmitters.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneEmitters.java
@@ -15,7 +15,6 @@ package org.eclipse.gmf.graphdef.codegen;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
-import java.util.LinkedList;
import java.util.List;
import org.eclipse.gmf.common.UnexpectedBehaviourException;
@@ -57,17 +56,13 @@ class StandaloneEmitters {
protected Object[] extractArguments(Object[] arguments) {
assert arguments != null && arguments.length > 1 && arguments[0] instanceof Config && arguments[1] instanceof String[];
Config config = (Config) arguments[0];
- List<String> requiredBundles = new LinkedList<String>();
- if (config.needsMapMode()) {
- requiredBundles.add("org.eclipse.gmf.runtime.draw2d.ui");
- }
- requiredBundles.addAll(Arrays.asList((String[]) arguments[1]));
List<String> exportedPackages = (config.getMainPackageName() == null || config.getMainPackageName().trim().length() == 0) ? Collections.singletonList(config.getPluginActivatorPackageName()) : Arrays.asList(config.getPluginActivatorPackageName(), config.getMainPackageName());
+ List<String> referencedBundles = Arrays.asList((String[]) arguments[1]);
return new Object[] {
config.getPluginID(),
config.getPluginActivatorPackageName() + '.' + config.getPluginActivatorClassName(),
exportedPackages,
- requiredBundles,
+ referencedBundles
};
}
};
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneGenerator.java
index f35b97b0e..26f486cf7 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneGenerator.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneGenerator.java
@@ -37,7 +37,6 @@ public class StandaloneGenerator extends GeneratorBase {
private final TextEmitter myFigureGenerator;
private final StandaloneEmitters myAuxiliaryGenerators;
private boolean mySkipPluginStructire;
- protected final FigureQualifiedNameSwitch myFigureNameSwitch;
protected Processor myProcessor;
private final Map<String, Figure> myCallbackFigures = new LinkedHashMap<String, Figure>();
@@ -49,8 +48,8 @@ public class StandaloneGenerator extends GeneratorBase {
public String getPluginActivatorClassName();
public String getPluginActivatorPackageName();
-
- public boolean needsMapMode(); // FIXME remove or (?) return MapModeCodeGenStrategy
+ public MapModeCodeGenStrategy getMapMode();
+ public String getRuntimeToken();
}
public static class ConfigImpl implements Config {
@@ -62,24 +61,26 @@ public class StandaloneGenerator extends GeneratorBase {
private final String myPluginActivatorClassName;
private final String myPluginActivatorPackageName;
- private final boolean myNeedsMapMode;
+ private final MapModeCodeGenStrategy myMapMode;
+ private final String myRuntimeToken;
public ConfigImpl(String pluginId, String mainPackageName){
- this(pluginId, mainPackageName, true);
+ this(pluginId, mainPackageName, MapModeCodeGenStrategy.DYNAMIC, null);
}
- public ConfigImpl(String pluginId, String mainPackageName, boolean useMapMode) {
- this(pluginId, mainPackageName, pluginId, "", "PluginActivator", (mainPackageName == null ? "" : mainPackageName + ".") + "activator", useMapMode);
+ public ConfigImpl(String pluginId, String mainPackageName, MapModeCodeGenStrategy mapMode, String runtimeToken) {
+ this(pluginId, mainPackageName, pluginId, "", "PluginActivator", (mainPackageName == null ? "" : mainPackageName + ".") + "activator", mapMode, null);
}
- public ConfigImpl(String pluginId, String mainPackageName, String pluginFriendlyName, String pluginProviderName, String pluginActivatorClassName, String pluginActivatorPackageName, boolean needsMapMode){
+ public ConfigImpl(String pluginId, String mainPackageName, String pluginFriendlyName, String pluginProviderName, String pluginActivatorClassName, String pluginActivatorPackageName, MapModeCodeGenStrategy mapMode, String runtimeToken){
myPluginId = pluginId;
myMainPackageName = mainPackageName == null ? "" : mainPackageName;
myPluginFriendlyName = pluginFriendlyName;
myPluginProviderName = pluginProviderName;
myPluginActivatorClassName = pluginActivatorClassName;
myPluginActivatorPackageName = pluginActivatorPackageName;
- myNeedsMapMode = needsMapMode;
+ myMapMode = mapMode;
+ myRuntimeToken = runtimeToken;
}
public String getMainPackageName() {
@@ -106,8 +107,12 @@ public class StandaloneGenerator extends GeneratorBase {
return myPluginActivatorPackageName;
}
- public boolean needsMapMode() {
- return myNeedsMapMode;
+ public MapModeCodeGenStrategy getMapMode() {
+ return myMapMode;
+ }
+
+ public String getRuntimeToken() {
+ return myRuntimeToken;
}
}
@@ -124,27 +129,26 @@ public class StandaloneGenerator extends GeneratorBase {
}
- public StandaloneGenerator(Processor p, Config config, FigureQualifiedNameSwitch fqnSwitch) {
- this(p, config, fqnSwitch, null);
+ public StandaloneGenerator(Processor p, Config config) {
+ this(p, config, null);
}
- public StandaloneGenerator(Processor p, Config config, FigureQualifiedNameSwitch fqnSwitch, URL[] dynamicTemplates) {
- assert p != null && config != null && fqnSwitch != null;
+ public StandaloneGenerator(Processor p, Config config, URL[] dynamicTemplates) {
+ assert p != null && config != null;
myArgs = config;
myProcessor = p;
- myFigureNameSwitch = fqnSwitch;
String pluginActivatorFQN = composePluginActivatorClassFQN(config);
- MapModeCodeGenStrategy strategy;
+ final MapModeCodeGenStrategy strategy;
String accessor;
- if (config.needsMapMode()) {
+ if (config.getMapMode() == MapModeCodeGenStrategy.DYNAMIC) {
strategy = MapModeCodeGenStrategy.DYNAMIC;
accessor = pluginActivatorFQN + ".getDefault().";
} else {
- strategy = MapModeCodeGenStrategy.STATIC;
+ strategy = config.getMapMode() == null ? MapModeCodeGenStrategy.STATIC : config.getMapMode();
accessor = null;
}
- myFigureGenerator = new FigureGenerator(fqnSwitch, strategy, accessor, false, dynamicTemplates);
+ myFigureGenerator = new FigureGenerator(config.getRuntimeToken(), strategy, accessor, false, dynamicTemplates);
myAuxiliaryGenerators = new StandaloneEmitters(strategy, dynamicTemplates);
}
@@ -187,7 +191,7 @@ public class StandaloneGenerator extends GeneratorBase {
protected void generatePluginStructure() throws UnexpectedBehaviourException, InterruptedException {
doGenerateFile(myAuxiliaryGenerators.getBuildPropertiesEmitter(), new Path("build.properties"), myArgs);
- doGenerateFile(myAuxiliaryGenerators.getManifestMFEmitter(), new Path("META-INF/MANIFEST.MF"), myArgs, myProcessor.getRequiredBundles(myFigureNameSwitch));
+ doGenerateFile(myAuxiliaryGenerators.getManifestMFEmitter(), new Path("META-INF/MANIFEST.MF"), myArgs, myProcessor.getRequiredBundles(null));
doGenerateFile(myAuxiliaryGenerators.getPluginPropertiesEmitter(), new Path("plugin.properties"), myArgs);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/CanvasProcessor.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/CanvasProcessor.java
index 15597c20f..ee8597578 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/CanvasProcessor.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/CanvasProcessor.java
@@ -11,8 +11,8 @@
*/
package org.eclipse.gmf.internal.graphdef.codegen;
-import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.LinkedList;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -81,9 +81,16 @@ public class CanvasProcessor extends Processor {
}
public String[] getRequiredBundles(FigureQualifiedNameSwitch fqnSwitch) {
- ArrayList<String> rv = new ArrayList<String>();
+ HashSet<String> rv = new HashSet<String>();
for (FigureGallery next : myInput.getFigures()) {
- rv.addAll(Arrays.asList(fqnSwitch.getDependencies(next)));
+ if (next.getImplementationBundle() != null && next.getImplementationBundle().trim().length() > 0) {
+ // need this for a while, though this should be done in the fqnswitch. But as I'm trying to get rid of the
+ // switch, that's a temp hack to pass through
+ rv.add(next.getImplementationBundle());
+ }
+ if (fqnSwitch != null) {
+ rv.addAll(Arrays.asList(fqnSwitch.getDependencies(next)));
+ }
}
return rv.toArray(new String[rv.size()]);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/GalleryProcessor.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/GalleryProcessor.java
index bb7d6c03e..8191de585 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/GalleryProcessor.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/GalleryProcessor.java
@@ -58,8 +58,9 @@ public class GalleryProcessor extends Processor {
if (myInput[i].getImplementationBundle() != null && myInput[i].getImplementationBundle().trim().length() > 0) {
rv.add(myInput[i].getImplementationBundle());
}
- String[] additional = fqnSwitch.getDependencies(myInput[i]);
- rv.addAll(Arrays.asList(additional));
+ if (fqnSwitch != null) {
+ rv.addAll(Arrays.asList(fqnSwitch.getDependencies(myInput[i])));
+ }
}
return rv.toArray(new String[rv.size()]);
}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Border.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Border.xpt
index 59d31bbcd..78e9f6b4b 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Border.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Border.xpt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006 Borland Software Corporation
+ * Copyright (c) 2006, 2007 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
@@ -47,7 +47,7 @@ new org.eclipse.draw2d.MarginBorder(«EXPAND MapMode::map FOR insets»)
* @generated
*/
private org.eclipse.draw2d.Border «methodName»() {
- «qualifiedClassNameGEF()» result = new «qualifiedClassNameGEF()»();
+ «EXPAND Runtime::newInstance("result")»
«EXPAND attr::CustomClass::Init("result")»
return result;
}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt
index bc3af93ea..f81dc9d14 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006 Borland Software Corporation
+ * Copyright (c) 2006, 2007 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
@@ -34,7 +34,7 @@
«DEFINE instantiate(EInt count, gmfgraph::Figure parentFigure, EString parentFigureVariable) FOR gmfgraph::Figure»
«LET figureVariableName(count) AS figureVarName»
-«EXPAND newFigureInstance(figureVarName)-»
+«EXPAND newFigureInstance(figureVarName)»
«EXPAND Attrs::Init(figureVarName)-»
«IF null == layoutData || null == parentFigure.layout-»«REM»Check for (parentLayout != null) to avoid generating data that won't be used. Not sure it's essential, but it was that way with old jet templates«ENDREM»
«parentFigureVariable».add(«figureVarName»);
@@ -47,13 +47,11 @@
«ENDLET»
«ENDDEFINE»
-«DEFINE newFigureInstance(String figureVarName) FOR gmfgraph::Figure»
-«qualifiedClassNameGEF()» «figureVarName» = new «qualifiedClassNameGEF()»();
-«ENDDEFINE»
+«DEFINE newFigureInstance(String figureVarName) FOR gmfgraph::Figure»«EXPAND Runtime::newInstance(figureVarName)»«ENDDEFINE»
-«DEFINE newFigureInstance(String figureVarName) FOR gmfgraph::ScalablePolygon»
+«DEFINE newFigureInstance(String figureVarName) FOR gmfgraph::ScalablePolygon-»
«LET figureVarName.toFirstUpper() + "Class" AS localClassName-»
-class «localClassName» extends «qualifiedClassNameGEF()» {
+class «localClassName» extends «EXPAND Runtime::fqn» {
«EXPAND xtras::ScalablePolygon::behaviour-»
};
«localClassName» «figureVarName» = new «localClassName»();
@@ -65,19 +63,19 @@ class «localClassName» extends «qualifiedClassNameGEF()» {
/**
* @generated
*/
- private «qualifiedClassNameGEF()» «figureFieldName()»;
+ private «EXPAND Runtime::fqn» «figureFieldName()»;
/**
* @generated
*/
- public «qualifiedClassNameGEF()» «figureFieldGetter()»() {
+ public «EXPAND Runtime::fqn» «figureFieldGetter()»() {
return «figureFieldName()»;
}
/**
* @generated
*/
- private void «figureFieldSetter()»(«qualifiedClassNameGEF()» fig){
+ private void «figureFieldSetter()»(«EXPAND Runtime::fqn» fig){
«figureFieldName()» = fig;
}
«ENDIF-»
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Decoration.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Decoration.xpt
index ab19dd447..f0e5e8bca 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Decoration.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Decoration.xpt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006 Borland Software Corporation
+ * Copyright (c) 2006, 2007 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
@@ -17,18 +17,18 @@
«REM»Instantiate and define attributes for DecorationFigures«ENDREM»
«DEFINE Instantiate(EString figureVarName) FOR gmfgraph::DecorationFigure-»
-«qualifiedClassNameGEF()» «figureVarName» = new «qualifiedClassNameGEF()»();
+«EXPAND Runtime::newInstance(figureVarName)»
«EXPAND Attrs::Init(figureVarName)»
«ENDDEFINE»
«REM»Guess, can't delegate to attrs through Attrs::Init because there's already Init for Polyline«ENDREM»
«DEFINE Instantiate(EString figureVarName) FOR gmfgraph::PolylineDecoration-»
-«qualifiedClassNameGEF()» «figureVarName» = new «qualifiedClassNameGEF()»();
+«EXPAND Runtime::newInstance(figureVarName)»
«EXPAND attr::Decoration::polylineAttrs(figureVarName)-»
«ENDDEFINE»
«REM»Copy of above template for PolylineDecoration, just because PolygonDecoration doesn't extend PolylineDecoration in draw2d and gmfgraph«ENDREM»
«DEFINE Instantiate(EString figureVarName) FOR gmfgraph::PolygonDecoration-»
-«qualifiedClassNameGEF()» «figureVarName» = new «qualifiedClassNameGEF()»();
+«EXPAND Runtime::newInstance(figureVarName)»
«EXPAND attr::Decoration::polylineAttrs(figureVarName)-»
«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Layout.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Layout.xpt
index f57cbd208..21e34200b 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Layout.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Layout.xpt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006 Borland Software Corporation
+ * Copyright (c) 2006, 2007 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
@@ -16,12 +16,12 @@
«EXTENSION Util»
«DEFINE Init(EString owningFigureVariable) FOR gmfgraph::Layout»
-«owningFigureVariable».setLayoutManager(new «qualifiedClassNameGEF()»());
+«owningFigureVariable».setLayoutManager(«EXPAND Runtime::newInstance»);
«ENDDEFINE»
«DEFINE Init(EString owningFigureVariable) FOR gmfgraph::BorderLayout»
«LET "layout" + owningFigureVariable.toFirstUpper() AS layoutVarName»
- «qualifiedClassNameGEF()» «layoutVarName» = new «qualifiedClassNameGEF()»();
+ «EXPAND Runtime::newInstance(layoutVarName)»
«IF null != spacing-»
«layoutVarName».setHorizontalSpacing(«spacing.dx»);// TODO mapMode?
«layoutVarName».setVerticalSpacing(«spacing.dy»);
@@ -32,7 +32,7 @@
«DEFINE Init(EString owningFigureVariable) FOR gmfgraph::GridLayout»
«LET "layout" + owningFigureVariable.toFirstUpper() AS layoutVarName»
- «qualifiedClassNameGEF()» «layoutVarName» = new «qualifiedClassNameGEF()»();
+ «EXPAND Runtime::newInstance(layoutVarName)»
«layoutVarName».numColumns = «numColumns»;
«layoutVarName».makeColumnsEqualWidth = «equalWidth»;
«IF null != spacing-»
@@ -49,14 +49,14 @@
«DEFINE Init(EString owningFigureVariable) FOR gmfgraph::FlowLayout»
«LET "layout" + owningFigureVariable.toFirstUpper() AS layoutVarName»
- «qualifiedClassNameGEF()» «layoutVarName» = new «qualifiedClassNameGEF()»();
+ «EXPAND Runtime::newInstance(layoutVarName)»
«layoutVarName».setStretchMinorAxis(«matchMinorSize»);
- «layoutVarName».setMinorAlignment(«qualifiedClassNameGEF()».«EXPAND alignment(forceSingleLine) FOR minorAlignment»);
+ «layoutVarName».setMinorAlignment(«EXPAND Runtime::fqn».«EXPAND alignment(forceSingleLine) FOR minorAlignment»);
«IF forceSingleLine»
«layoutVarName».setSpacing(«majorSpacing»);
«layoutVarName».setVertical(«vertical»);
«ELSE»
- «layoutVarName».setMajorAlignment(«qualifiedClassNameGEF()».«EXPAND alignment(forceSingleLine) FOR majorAlignment»);
+ «layoutVarName».setMajorAlignment(«EXPAND Runtime::fqn».«EXPAND alignment(forceSingleLine) FOR majorAlignment»);
«layoutVarName».setMajorSpacing(«majorSpacing»);
«layoutVarName».setMinorSpacing(«minorSpacing»);
«layoutVarName».setHorizontal(«!vertical»);
@@ -67,7 +67,7 @@
«DEFINE Init(EString owningFigureVariable) FOR gmfgraph::CustomLayout»
«LET "layout" + owningFigureVariable.toFirstUpper() AS layoutVarName»
- «qualifiedClassNameGEF()» «layoutVarName» = new «qualifiedClassNameGEF()»();
+ «EXPAND Runtime::newInstance(layoutVarName)»
«EXPAND attr::CustomClass::Init(layoutVarName)-»
«owningFigureVariable».setLayoutManager(«layoutVarName»);
«ENDLET»
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/LayoutData.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/LayoutData.xpt
index 08e95e93e..e62434e39 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/LayoutData.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/LayoutData.xpt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006 Borland Software Corporation
+ * Copyright (c) 2006, 2007 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
@@ -36,9 +36,9 @@
«DEFINE Init(EString parentFigureVariable, EString owningFigureVariable) FOR gmfgraph::GridLayoutData»
«LET "constraint" + owningFigureVariable.toFirstUpper() AS constraintVarName»
-«qualifiedClassNameGEF()» «constraintVarName» = new «qualifiedClassNameGEF()»();
-«constraintVarName».verticalAlignment = «qualifiedClassNameGEF()».«verticalAlignment.name»;«REM».literal, not .name!«ENDREM»
-«constraintVarName».horizontalAlignment = «qualifiedClassNameGEF()».«horizontalAlignment.name»;
+«EXPAND Runtime::newInstance(constraintVarName)»
+«constraintVarName».verticalAlignment = «EXPAND Runtime::fqn».«verticalAlignment.name»;«REM».literal, not .name!«ENDREM»
+«constraintVarName».horizontalAlignment = «EXPAND Runtime::fqn».«horizontalAlignment.name»;
«constraintVarName».horizontalIndent = «horizontalIndent»;
«constraintVarName».horizontalSpan = «horizontalSpan»;
«constraintVarName».verticalSpan = «verticalSpan»;
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Runtime.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Runtime.xpt
new file mode 100644
index 000000000..b66f8c80c
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Runtime.xpt
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2007 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
+ */
+
+«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
+«EXTENSION Util»
+
+«DEFINE newInstance(String figureVarName) FOR Figure»«EXPAND fqn» «figureVarName» = «EXPAND newInstance»;«ENDDEFINE»
+«DEFINE newInstance FOR Figure»new «EXPAND fqn»()«ENDDEFINE»
+
+«DEFINE newInstance(String layoutVarName) FOR Layout»«EXPAND fqn» «layoutVarName» = «EXPAND newInstance»;«ENDDEFINE»
+«DEFINE newInstance FOR Layout»new «EXPAND fqn»()«ENDDEFINE»
+
+«DEFINE newInstance(String constraintVarName) FOR LayoutData»«EXPAND fqn» «constraintVarName» = «EXPAND newInstance»;«ENDDEFINE»
+«DEFINE newInstance FOR LayoutData»new «EXPAND fqn»()«ENDDEFINE»
+
+«DEFINE newInstance(String borderVarName) FOR Border»«EXPAND fqn» «borderVarName» = «EXPAND newInstance»;«ENDDEFINE»
+«DEFINE newInstance FOR Border»new «EXPAND fqn»()«ENDDEFINE»
+
+
+«DEFINE fqn FOR Figure»«ERROR "Abstract definition fqn(Figure)"»«ENDDEFINE»
+«DEFINE fqn FOR Layout»«ERROR "Abstract definition fqn(Layout)"»«ENDDEFINE»
+«DEFINE fqn FOR LayoutData»«ERROR "Abstract definition fqn(LayoutData)"»«ENDDEFINE»
+«DEFINE fqn FOR Border»«ERROR "Abstract definition fqn(Border)"»«ENDDEFINE»
+
+////////////////////////
+«DEFINE fqn FOR CustomLayout»«qualifiedClassName»«ENDDEFINE»
+«DEFINE fqn FOR CustomBorder»«qualifiedClassName»«ENDDEFINE»
+«DEFINE fqn FOR CustomFigure»«qualifiedClassName»«ENDDEFINE»
+
+////////////////////////
+«DEFINE fqn FOR FlowLayout»«IF forceSingleLine»org.eclipse.draw2d.ToolbarLayout«ELSE»org.eclipse.draw2d.FlowLayout«ENDIF»«ENDDEFINE»
+
+«DEFINE fqn FOR XYLayout»org.eclipse.draw2d.XYLayout«ENDDEFINE»
+«DEFINE fqn FOR XYLayoutData»org.eclipse.draw2d.geometry.Rectangle«ENDDEFINE»
+
+«DEFINE fqn FOR GridLayout»org.eclipse.draw2d.GridLayout«ENDDEFINE»
+«DEFINE fqn FOR GridLayoutData»org.eclipse.draw2d.GridData«ENDDEFINE»
+
+«DEFINE fqn FOR StackLayout»org.eclipse.draw2d.StackLayout«ENDDEFINE»
+«DEFINE fqn FOR BorderLayout»org.eclipse.draw2d.BorderLayout«ENDDEFINE»
+
+////////////////////////
+«DEFINE fqn FOR Label»«IF isFullRuntime()»org.eclipse.gmf.runtime.draw2d.ui.figures.WrapLabel«ELSE»org.eclipse.draw2d.Label«ENDIF»«ENDDEFINE»
+«DEFINE fqn FOR LabeledContainer»org.eclipse.draw2d.LabeledContainer«ENDDEFINE»
+«DEFINE fqn FOR Rectangle»org.eclipse.draw2d.RectangleFigure«ENDDEFINE»
+«DEFINE fqn FOR RoundedRectangle»org.eclipse.draw2d.RoundedRectangle«ENDDEFINE»
+«DEFINE fqn FOR Ellipse»org.eclipse.draw2d.Ellipse«ENDDEFINE»
+«DEFINE fqn FOR Polygon»org.eclipse.draw2d.Polygon«ENDDEFINE»
+«REM»FIXME«ENDREM»«DEFINE fqn FOR ScalablePolygon»org.eclipse.draw2d.Shape«ENDDEFINE»
+«DEFINE fqn FOR PolygonDecoration»org.eclipse.draw2d.PolygonDecoration«ENDDEFINE»
+«DEFINE fqn FOR Polyline»org.eclipse.draw2d.Polyline«ENDDEFINE»
+«DEFINE fqn FOR PolylineDecoration»org.eclipse.draw2d.PolylineDecoration«ENDDEFINE»
+«DEFINE fqn FOR PolylineConnection»«IF isFullRuntime()»org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx«ELSE»org.eclipse.draw2d.PolylineConnection«ENDIF»«ENDDEFINE»
+
+«REM»
+to utilize around, need to fix XpandExecutionContextImpl to get aspects not only from relative aspects/ path, but from
+template file as well.
+// Full GMF Runtime
+////////////////////////
+«AROUND fqn FOR PolylineConnection»«IF isFullRuntime()»org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx«ELSE»«targetDef.proceed()»«ENDIF»«ENDAROUND»
+«AROUND fqn FOR Label»«IF isFullRuntime()»org.eclipse.gmf.runtime.draw2d.ui.figures.WrapLabel«ELSE»«targetDef.proceed()»«ENDIF»«ENDAROUND»
+«ENDREM» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.ext b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.ext
index 238c638a1..a21f4176a 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.ext
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.ext
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006 Borland Software Corporation
+ * Copyright (c) 2006, 2007 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
@@ -17,30 +17,16 @@ EString compilationUnitName(gmfgraph::Figure figure) :
figure.name.toFirstUpper()
;
-String qualifiedClassNameGEF(gmfgraph::Figure figure) :
-JAVA [FigureQualifiedNameSwitch] org.eclipse.gmf.gmfgraph.util.FigureQualifiedNameSwitch.get(org.eclipse.emf.ecore.EObject)
-;
-
-String qualifiedClassNameGEF(gmfgraph::ScalablePolygon figure) :
- "org.eclipse.draw2d.Shape"
-;
-
-String qualifiedClassNameGEF(gmfgraph::Layout layout) :
-JAVA [FigureQualifiedNameSwitch] org.eclipse.gmf.gmfgraph.util.FigureQualifiedNameSwitch.get(org.eclipse.emf.ecore.EObject)
-;
-
-String qualifiedClassNameGEF(gmfgraph::LayoutData layout) :
-JAVA [FigureQualifiedNameSwitch] org.eclipse.gmf.gmfgraph.util.FigureQualifiedNameSwitch.get(org.eclipse.emf.ecore.EObject)
-;
-
-String qualifiedClassNameGEF(gmfgraph::Border border) :
-JAVA [FigureQualifiedNameSwitch] org.eclipse.gmf.gmfgraph.util.FigureQualifiedNameSwitch.get(org.eclipse.emf.ecore.EObject)
-;
-
Boolean hasSourceDecoration(gmfgraph::PolylineConnection figure) :
null != figure.sourceDecoration
;
+List[String] requiredBundles(List[String] referencedBundles) :
+ isFullRuntime() /*&& usesLabelOrPolyline) || usesMapMode()*/ ?
+ {"org.eclipse.core.runtime","org.eclipse.draw2d", "org.eclipse.gmf.runtime.draw2d.ui"}.union(referencedBundles).toList().purgeDups() :
+ {"org.eclipse.core.runtime","org.eclipse.draw2d"}.union(referencedBundles).toList().purgeDups()
+;
+
String packageStatement() :
GLOBALVAR packageStatement
;
@@ -61,6 +47,11 @@ EBoolean hasTargetDecoration(gmfgraph::PolylineConnection figure) :
null != figure.targetDecoration
;
+cached boolean isFullRuntime() :
+ internalCheckRuntimeToken() != null ? internalCheckRuntimeToken().toLowerCase() == "full" : true
+;
+
+private String internalCheckRuntimeToken() : GLOBALVAR runtimeToken;
//nonNull(ecore::EObject obj) :
// {obj}.select(e | null != e)
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/plugin/Manifest.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/plugin/Manifest.xpt
index fd3f834f4..16fb3877c 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/plugin/Manifest.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/plugin/Manifest.xpt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006 Borland Software Corporation
+ * Copyright (c) 2006, 2007 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
@@ -9,8 +9,9 @@
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
*/
+«EXTENSION Util»
-«DEFINE Init(String pluginID, String pluginActivatorQualifiedName, List[String] exportedPackages, List[String] requiredBundles) FOR Object-»
+«DEFINE Init(String pluginID, String pluginActivatorQualifiedName, List[String] exportedPackages, List[String] referencedBundles) FOR Object-»
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
@@ -20,9 +21,7 @@ Bundle-Vendor: %providerName
Bundle-Activator: «pluginActivatorQualifiedName»
Bundle-Localization: plugin
Export-Package:«EXPAND exportPackageHeader FOR exportedPackages»
-«LET requiredBundles.union({"org.eclipse.core.runtime","org.eclipse.draw2d"}) AS s-»
-Require-Bundle:«EXPAND requireBundleHeader FOR s»
-«ENDLET-»
+Require-Bundle:«EXPAND requireBundleHeader FOR requiredBundles(referencedBundles)»
Eclipse-LazyStart: true
«EXPAND additions-»
«ENDDEFINE»
@@ -32,7 +31,7 @@ Eclipse-LazyStart: true
«ENDDEFINE»
«REM»FIXME Set[String] - improve union recognition«ENDREM»
-«DEFINE requireBundleHeader FOR Set[Object]-»
+«DEFINE requireBundleHeader FOR Collection[Object]-»
«EXPAND print FOREACH this.typeSelect(String) SEPARATOR ",\n"-»
«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt
index cb459e716..ec4062fdf 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006 Borland Software Corporation
+ * Copyright (c) 2006, 2007 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
@@ -20,7 +20,7 @@
/**
* @generated
*/
-public class «compilationUnitName()» extends «qualifiedClassNameGEF()» {
+public class «compilationUnitName()» extends «EXPAND Runtime::fqn» {
/**
* @generated
*/
@@ -52,7 +52,7 @@ public class «compilationUnitName()» extends «qualifiedClassNameGEF()» {
/**
* @generated
*/
-public class «compilationUnitName()» extends «qualifiedClassNameGEF()» {
+public class «compilationUnitName()» extends «EXPAND Runtime::fqn» {
/**
* @generated

Back to the top