Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-05-18 19:12:35 +0000
committeratikhomirov2006-05-18 19:12:35 +0000
commit84334f4ce186342282cb5820893a3b233ced9e92 (patch)
tree7d8cc70605c5360a810de379977329dc5bf6191b /plugins/org.eclipse.gmf.graphdef.codegen/src
parent9eb98b387e47a29dfcb876ab93bc87a2e85080cd (diff)
downloadorg.eclipse.gmf-tooling-84334f4ce186342282cb5820893a3b233ced9e92.tar.gz
org.eclipse.gmf-tooling-84334f4ce186342282cb5820893a3b233ced9e92.tar.xz
org.eclipse.gmf-tooling-84334f4ce186342282cb5820893a3b233ced9e92.zip
Emitter became top-level entity (TextEmitter), oddness of JetAdapter and Emitter api were cleared.
GeneratorBase lost knowledge about JET. Parts of gmf.common made internal to avoid possible API issues. ImportAssistant refactored to know name of compilation unit to avoid problems like #134506. FigureGenerator's reuse of ImportAssistant removed. [mgolubev] Tests for #134506 and 142553
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen/src')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java42
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/GraphDefDispatcher.java12
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneEmitters.java15
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneGenerator.java58
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/ManifestMFGenerator.java2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/PluginActivatorGenerator.java2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopConnectionGenerator.java3
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopFigureGenerator.java3
8 files changed, 70 insertions, 67 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 025da6518..9bc208004 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
@@ -11,8 +11,11 @@
*/
package org.eclipse.gmf.graphdef.codegen;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.codegen.jet.JETException;
+import org.eclipse.gmf.common.UnexpectedBehaviourException;
import org.eclipse.gmf.common.codegen.ImportAssistant;
import org.eclipse.gmf.gmfgraph.BorderLayout;
import org.eclipse.gmf.gmfgraph.BorderLayoutData;
@@ -67,23 +70,22 @@ 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.eclipse.gmf.internal.common.codegen.TextEmitter;
import org.osgi.framework.Bundle;
/**
* @author artem
*
*/
-public class FigureGenerator {
- private final String packageName;
+public class FigureGenerator implements TextEmitter {
private GraphDefDispatcher myTopDispatcher;
private GraphDefDispatcher myInnerDispatcher;
- public FigureGenerator(String aPackageName, ImportAssistant importManager, FigureQualifiedNameSwitch figureNameSwitch) {
- this(aPackageName, importManager, figureNameSwitch, new MapModeCodeGenStrategy.RuntimeUnspecifiedMapMode());
+ public FigureGenerator(FigureQualifiedNameSwitch figureNameSwitch) {
+ this(figureNameSwitch, new MapModeCodeGenStrategy.RuntimeUnspecifiedMapMode());
}
- public FigureGenerator(String aPackageName, ImportAssistant importManager, FigureQualifiedNameSwitch figureNameSwitch, MapModeCodeGenStrategy mapModeStrategy) {
- packageName = aPackageName;
+ public FigureGenerator(FigureQualifiedNameSwitch figureNameSwitch, MapModeCodeGenStrategy mapModeStrategy) {
final Bundle thisBundle = Platform.getBundle("org.eclipse.gmf.graphdef.codegen");
final String[] variables = new String[] {
"org.eclipse.gmf.graphdef",
@@ -107,16 +109,9 @@ public class FigureGenerator {
};
String[] templatePath = new String[] {thisBundle.getEntry("/templates/").toString()};
EmitterFactory topFactory = new EmitterFactory(templatePath, fillTopLevel(), true, variables, true);
- myTopDispatcher = new GraphDefDispatcher(topFactory, keyMap, importManager, figureNameSwitch, mapModeStrategy);
+ myTopDispatcher = new GraphDefDispatcher(topFactory, keyMap, figureNameSwitch, mapModeStrategy);
EmitterFactory innerFactory = new EmitterFactory(templatePath, fillAttrs(), true, variables, true);
- myInnerDispatcher = new GraphDefDispatcher(innerFactory, keyMap, importManager, figureNameSwitch, mapModeStrategy);
- }
-
- /**
- * @return possibly <code>null</code>
- */
- public String getPackageStatement() {
- return packageName;
+ myInnerDispatcher = new GraphDefDispatcher(innerFactory, keyMap, figureNameSwitch, mapModeStrategy);
}
private static TemplateRegistry fillTopLevel() {
@@ -173,13 +168,22 @@ public class FigureGenerator {
return tr;
}
- public String go(Figure fig) throws JETException {
+ public String generate(IProgressMonitor monitor, Object[] arguments) throws InterruptedException, InvocationTargetException, UnexpectedBehaviourException {
+ if (arguments == null || arguments.length != 2 || false == arguments[0] instanceof Figure || false == arguments[1] instanceof ImportAssistant) {
+ throw new UnexpectedBehaviourException("Single Figure expected as argument: " + arguments);
+ }
+ return go((Figure) arguments[0], (ImportAssistant) arguments[1]);
+ }
+
+ public String go(Figure fig, ImportAssistant importManager) {
String res = null;
- Object args = new Object[] {fig, myTopDispatcher.getImportManager(), myTopDispatcher.getFQNSwitch(), myInnerDispatcher};
+ myTopDispatcher.setImportManager(importManager);
+ myInnerDispatcher.setImportManager(importManager);
+ Object args = new Object[] {fig, importManager, myTopDispatcher.getFQNSwitch(), myInnerDispatcher};
res = myTopDispatcher.dispatch(fig, args);
if (res == null) {
throw new IllegalStateException();
}
- return packageName == null ? res : "package " + packageName + ";\n" + res;
+ return res;
}
}
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
index d4a6b28c1..9eb244038 100644
--- 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
@@ -24,14 +24,13 @@ import org.eclipse.gmf.internal.codegen.dispatch.KeyMap;
* @author artem
*/
public class GraphDefDispatcher extends DispatcherImpl {
- private final ImportAssistant myImportManager;
+ private ImportAssistant myImportManager;
private final FigureQualifiedNameSwitch myFqnSwitch;
private final MapModeCodeGenStrategy myMapModeStrategy;
- public GraphDefDispatcher(EmitterFactory factory, KeyMap keyMap, ImportAssistant importManager, FigureQualifiedNameSwitch fqnSwitch, MapModeCodeGenStrategy mapModeStrategy) {
+ public GraphDefDispatcher(EmitterFactory factory, KeyMap keyMap, FigureQualifiedNameSwitch fqnSwitch, MapModeCodeGenStrategy mapModeStrategy) {
super(factory, keyMap);
assert mapModeStrategy != null;
- myImportManager = importManager;
myFqnSwitch = fqnSwitch;
myMapModeStrategy = mapModeStrategy;
}
@@ -48,6 +47,13 @@ public class GraphDefDispatcher extends DispatcherImpl {
return myImportManager;
}
+ /**
+ * Not good. Would be better to have importManager as part of Args, perhaps.
+ */
+ /*package-local*/ void setImportManager(ImportAssistant manager) {
+ myImportManager = manager;
+ }
+
public FigureQualifiedNameSwitch getFQNSwitch() {
return myFqnSwitch;
}
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 ced9d8379..215779bbf 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
@@ -12,7 +12,6 @@
package org.eclipse.gmf.graphdef.codegen;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.codegen.jet.JETEmitter;
import org.eclipse.gmf.common.UnexpectedBehaviourException;
import org.eclipse.gmf.graphdef.codegen.standalone.templates.BuildPropertiesGenerator;
import org.eclipse.gmf.graphdef.codegen.standalone.templates.ManifestMFGenerator;
@@ -22,6 +21,8 @@ import org.eclipse.gmf.internal.codegen.dispatch.EmitterFactory;
import org.eclipse.gmf.internal.codegen.dispatch.NoSuchTemplateException;
import org.eclipse.gmf.internal.codegen.dispatch.StaticTemplateRegistry;
import org.eclipse.gmf.internal.codegen.dispatch.TemplateRegistry;
+import org.eclipse.gmf.internal.common.codegen.JETEmitterAdapter;
+import org.eclipse.gmf.internal.common.codegen.TextEmitter;
public class StandaloneEmitters extends EmitterFactory {
@@ -29,25 +30,25 @@ public class StandaloneEmitters extends EmitterFactory {
super(getTemplatePath(), createTemplateRegistry());
}
- public JETEmitter getBuildPropertiesEmitter() throws UnexpectedBehaviourException {
+ public TextEmitter getBuildPropertiesEmitter() throws UnexpectedBehaviourException {
return getRegistered(BuildPropertiesGenerator.class);
}
- public JETEmitter getPluginPropertiesEmitter() throws UnexpectedBehaviourException {
+ public TextEmitter getPluginPropertiesEmitter() throws UnexpectedBehaviourException {
return getRegistered(PluginPropertiesGenerator.class);
}
- public JETEmitter getManifestMFEmitter() throws UnexpectedBehaviourException {
+ public TextEmitter getManifestMFEmitter() throws UnexpectedBehaviourException {
return getRegistered(ManifestMFGenerator.class);
}
- public JETEmitter getPluginActivatorEmitter() throws UnexpectedBehaviourException {
+ public TextEmitter getPluginActivatorEmitter() throws UnexpectedBehaviourException {
return getRegistered(PluginActivatorGenerator.class);
}
- private JETEmitter getRegistered(Class key) throws UnexpectedBehaviourException {
+ private TextEmitter getRegistered(Class key) throws UnexpectedBehaviourException {
try {
- return acquireEmitter(key);
+ return new JETEmitterAdapter(acquireEmitter(key));
} catch (NoSuchTemplateException ex) {
throw new UnexpectedBehaviourException(ex.getMessage(), ex);
}
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 515af955a..e00fd9ca2 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
@@ -21,21 +21,22 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.codegen.jet.JETException;
+import org.eclipse.emf.codegen.util.CodeGenUtil;
import org.eclipse.gmf.common.UnexpectedBehaviourException;
-import org.eclipse.gmf.common.codegen.GeneratorBase;
import org.eclipse.gmf.common.codegen.ImportAssistant;
-import org.eclipse.gmf.common.codegen.ImportUtil;
import org.eclipse.gmf.gmfgraph.Figure;
import org.eclipse.gmf.gmfgraph.FigureGallery;
import org.eclipse.gmf.gmfgraph.util.FigureQualifiedNameSwitch;
+import org.eclipse.gmf.internal.common.codegen.DelegateImportManager;
+import org.eclipse.gmf.internal.common.codegen.GeneratorBase;
+import org.eclipse.gmf.internal.common.codegen.ImportUtil;
public class StandaloneGenerator extends GeneratorBase {
private final Config myArgs;
private final FigureGallery[] myInput;
- private final Emitter myFigureGenerator;
+ private final FigureGenerator myFigureGenerator;
+ private DelegateImportManager myMapModeImportHack;
private final StandaloneEmitters myAuxiliaryGenerators;
private boolean mySkipPluginStructire;
private final FigureQualifiedNameSwitch myFigureNameSwitch;
@@ -75,12 +76,12 @@ public class StandaloneGenerator extends GeneratorBase {
}
public ConfigImpl(String pluginId, String mainPackageName, boolean useMapMode) {
- this(pluginId, mainPackageName, pluginId, "", "PluginActivator", mainPackageName + ".activator", useMapMode);
+ this(pluginId, mainPackageName, pluginId, "", "PluginActivator", (mainPackageName == null ? "" : mainPackageName + ".") + "activator", useMapMode);
}
public ConfigImpl(String pluginId, String mainPackageName, String pluginFriendlyName, String pluginProviderName, String pluginActivatorClassName, String pluginActivatorPackageName, boolean needsMapMode){
myPluginId = pluginId;
- myMainPackageName = mainPackageName;
+ myMainPackageName = mainPackageName == null ? "" : mainPackageName;
myPluginFriendlyName = pluginFriendlyName;
myPluginProviderName = pluginProviderName;
myPluginActivatorClassName = pluginActivatorClassName;
@@ -126,18 +127,16 @@ public class StandaloneGenerator extends GeneratorBase {
myArgs = config;
myInput = input;
myFigureNameSwitch = fqnSwitch;
- ImportAssistant importAssistant = new ImportUtil(getPackageName());
String pluginActivatorFQN = composePluginActivatorClassFQN(config);
MapModeCodeGenStrategy strategy;
if (config.needsMapMode()) {
- strategy = new MapModeCodeGenStrategy.RuntimeMapModeFromPluginClass(importAssistant, pluginActivatorFQN);
+ myMapModeImportHack = new DelegateImportManager();
+ strategy = new MapModeCodeGenStrategy.RuntimeMapModeFromPluginClass(myMapModeImportHack, pluginActivatorFQN);
} else {
strategy = new MapModeCodeGenStrategy.StaticIdentityMapMode();
}
- myFigureGenerator = new FigureGeneratorAdapter( //
- new FigureGenerator(getPackageName(), importAssistant, fqnSwitch, strategy)
- );
+ myFigureGenerator = new FigureGenerator(fqnSwitch, strategy);
myAuxiliaryGenerators = new StandaloneEmitters();
myGenerationInfo = new GenerationInfoImpl(myArgs);
}
@@ -181,13 +180,14 @@ public class StandaloneGenerator extends GeneratorBase {
}
private void generatePluginActivator() throws UnexpectedBehaviourException, InterruptedException{
- doGenerateJavaClass(myAuxiliaryGenerators.getPluginActivatorEmitter(), myArgs.getPluginActivatorPackageName(), myArgs.getPluginActivatorClassName(), myArgs);
+ Object[] args = new Object[] {myArgs, new ImportUtil(myArgs.getPluginActivatorPackageName(), myArgs.getPluginActivatorClassName())};
+ doGenerateJavaClass(myAuxiliaryGenerators.getPluginActivatorEmitter(), myArgs.getPluginActivatorPackageName(), myArgs.getPluginActivatorClassName(), new Object[] {args});
}
private void generatePluginStructure() throws UnexpectedBehaviourException, InterruptedException {
- doGenerateFile(myAuxiliaryGenerators.getBuildPropertiesEmitter(), new Path("build.properties"), myArgs);
- doGenerateFile(myAuxiliaryGenerators.getManifestMFEmitter(), new Path("META-INF/MANIFEST.MF"), new Object[] {myArgs, getRequiredBundles()});
- doGenerateFile(myAuxiliaryGenerators.getPluginPropertiesEmitter(), new Path("plugin.properties"), myArgs);
+ doGenerateFile(myAuxiliaryGenerators.getBuildPropertiesEmitter(), new Path("build.properties"), new Object[] { myArgs });
+ doGenerateFile(myAuxiliaryGenerators.getManifestMFEmitter(), new Path("META-INF/MANIFEST.MF"), new Object[] { new Object[] { myArgs, getRequiredBundles() } });
+ doGenerateFile(myAuxiliaryGenerators.getPluginPropertiesEmitter(), new Path("plugin.properties"), new Object[] { myArgs });
}
private String[] getRequiredBundles() {
@@ -212,10 +212,13 @@ public class StandaloneGenerator extends GeneratorBase {
}
private void visitFigure(Figure figure) throws InterruptedException {
- String packageName = getPackageName();
- String className = figure.getName();
- doGenerateJavaClass(myFigureGenerator, packageName, className, figure);
- myGenerationInfo.registerFQN(figure, composeFQN(packageName, className));
+ final ImportAssistant importAssistant = new ImportUtil(getPackageName(), CodeGenUtil.validJavaIdentifier(figure.getName()));
+ Object[] args = new Object[] { figure, importAssistant };
+ if (myMapModeImportHack != null) {
+ myMapModeImportHack.setDelegate(importAssistant);
+ }
+ doGenerateJavaClass(myFigureGenerator, getPackageName(), importAssistant.getCompilationUnitName(), args);
+ myGenerationInfo.registerFQN(figure, composeFQN(getPackageName(), importAssistant.getCompilationUnitName()));
}
private String getPackageName(){
@@ -232,21 +235,6 @@ public class StandaloneGenerator extends GeneratorBase {
return packageName == null || "".equals(packageName) ? className : packageName + "." + className;
}
- private static class FigureGeneratorAdapter implements GeneratorBase.Emitter {
- private final FigureGenerator myDelegate;
-
- public FigureGeneratorAdapter(FigureGenerator delegate){
- myDelegate = delegate;
- }
-
- public String generate(IProgressMonitor monitor, Object param) throws JETException {
- if (false == param instanceof Figure){
- throw new IllegalStateException("Figure expected: " + param);
- }
- return myDelegate.go((Figure)param);
- }
- }
-
private static class GenerationInfoImpl implements GenerationInfo {
private final Map myFigure2FQN = new IdentityHashMap();
private final Config myConfig;
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/ManifestMFGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/ManifestMFGenerator.java
index 32e85c856..84e23e007 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/ManifestMFGenerator.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/ManifestMFGenerator.java
@@ -58,7 +58,9 @@ final ListComposer listComposer = new ListComposer();
stringBuffer.append(TEXT_4);
HashSet exportedPackages = new HashSet();
+ if (config.getMainPackageName() != null && config.getMainPackageName().trim().length() > 0) {
exportedPackages.add(config.getMainPackageName());
+ }
exportedPackages.add(config.getPluginActivatorPackageName());
stringBuffer.append(TEXT_5);
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/PluginActivatorGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/PluginActivatorGenerator.java
index e7f689dc8..74e326125 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/PluginActivatorGenerator.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/PluginActivatorGenerator.java
@@ -51,7 +51,7 @@ if (config.needsMapMode()){
stringBuffer.append(TEXT_3);
importManager.markImportLocation(stringBuffer);
stringBuffer.append(TEXT_4);
- stringBuffer.append(config.getPluginActivatorClassName());
+ stringBuffer.append(importManager.getCompilationUnitName());
stringBuffer.append(TEXT_5);
if (config.needsMapMode()){
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 c85456a11..c534fc735 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
@@ -47,10 +47,11 @@ final ImportAssistant importManager = (ImportAssistant) args[1];
final FigureQualifiedNameSwitch fqnSwitch = (FigureQualifiedNameSwitch) args[2];
final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[3];
+ importManager.emitPackageStatement(stringBuffer);
stringBuffer.append(TEXT_1);
importManager.markImportLocation(stringBuffer);
stringBuffer.append(TEXT_2);
- stringBuffer.append(figure.getName());
+ stringBuffer.append(importManager.getCompilationUnitName());
stringBuffer.append(TEXT_3);
stringBuffer.append(fqnSwitch.get(figure, importManager));
stringBuffer.append(TEXT_4);
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 6f6719c35..2709ef656 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
@@ -43,10 +43,11 @@ final ImportAssistant importManager = (ImportAssistant) args[1];
final FigureQualifiedNameSwitch fqnSwitch = (FigureQualifiedNameSwitch) args[2];
final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[3];
+ importManager.emitPackageStatement(stringBuffer);
stringBuffer.append(TEXT_1);
importManager.markImportLocation(stringBuffer);
stringBuffer.append(TEXT_2);
- stringBuffer.append(figure.getName());
+ stringBuffer.append(importManager.getCompilationUnitName());
stringBuffer.append(TEXT_3);
stringBuffer.append(fqnSwitch.get(figure, importManager));
stringBuffer.append(TEXT_4);

Back to the top