Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-03-02 13:16:15 +0000
committeratikhomirov2006-03-02 13:16:15 +0000
commit1e39c59995ac3431357387f1fccc937d2839d981 (patch)
tree9ae1febddb30c5293cf15630261516c650d4c545 /plugins/org.eclipse.gmf.graphdef.codegen/src
parente8480b6522d370b673e9481a690ea7048c7638cf (diff)
downloadorg.eclipse.gmf-tooling-1e39c59995ac3431357387f1fccc937d2839d981.tar.gz
org.eclipse.gmf-tooling-1e39c59995ac3431357387f1fccc937d2839d981.tar.xz
org.eclipse.gmf-tooling-1e39c59995ac3431357387f1fccc937d2839d981.zip
[mgolubev] #128779 generate figures as standalone plugin
#129362 - respect plug-in dependencies imposed by figure fqn switch
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/StandaloneEmitters.java77
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneGenerator.java212
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/BuildPropertiesGenerator.java25
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/ManifestMFGenerator.java77
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/PluginActivatorGenerator.java84
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/PluginPropertiesGenerator.java34
6 files changed, 509 insertions, 0 deletions
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
new file mode 100644
index 000000000..3530d65ba
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneEmitters.java
@@ -0,0 +1,77 @@
+/*
+ * 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:
+ * Michael Golubev (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.graphdef.codegen;
+
+import org.eclipse.core.runtime.Platform;
+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.standalone.templates.BuildPropertiesGenerator;
+import org.eclipse.gmf.graphdef.codegen.standalone.templates.ManifestMFGenerator;
+import org.eclipse.gmf.graphdef.codegen.standalone.templates.PluginActivatorGenerator;
+import org.eclipse.gmf.graphdef.codegen.standalone.templates.PluginPropertiesGenerator;
+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;
+
+public class StandaloneEmitters extends EmitterFactory {
+
+ public StandaloneEmitters(){
+ super(getTemplatePath(), createTemplateRegistry());
+ }
+
+ public JETEmitter getBuildPropertiesEmitter() throws JETException {
+ return getRegistered(BuildPropertiesGenerator.class);
+ }
+
+ public JETEmitter getPluginPropertiesEmitter() throws JETException {
+ return getRegistered(PluginPropertiesGenerator.class);
+ }
+
+ public JETEmitter getManifestMFEmitter() throws JETException {
+ return getRegistered(ManifestMFGenerator.class);
+ }
+
+ public JETEmitter getPluginActivatorEmitter() throws JETException {
+ return getRegistered(PluginActivatorGenerator.class);
+ }
+
+ private JETEmitter getRegistered(Class key) throws JETException {
+ try {
+ return acquireEmitter(key);
+ } catch (NoSuchTemplateException ex) {
+ throw new JETException(ex.getClass().getName(), ex);
+ } catch (UnexpectedBehaviourException ex) {
+ throw new JETException(ex.getClass().getName(), ex);
+ }
+ }
+
+ private static String[] getTemplatePath() {
+ // XXX for precompiled templates we use at the moment, there's no much value
+ return new String[] { Platform.getBundle("org.eclipse.gmf.graphdef.codegen").getEntry("/templates").toString() };
+ }
+
+ private static TemplateRegistry createTemplateRegistry() {
+ StaticTemplateRegistry result = new StaticTemplateRegistry(StandaloneEmitters.class.getClassLoader());
+ registerTemplate(result, BuildPropertiesGenerator.class, "/plugin/build.propertiesjet");
+ registerTemplate(result, ManifestMFGenerator.class, "/plugin/manifest.mfjet");
+ registerTemplate(result, PluginPropertiesGenerator.class, "/plugin/plugin.propertiesjet");
+ registerTemplate(result, PluginActivatorGenerator.class, "/plugin/plugin.javajet");
+ return result;
+ }
+
+ private static void registerTemplate(StaticTemplateRegistry registry, Class compiled, String path){
+ registry.put(compiled, path, compiled);
+ }
+
+}
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
new file mode 100644
index 000000000..551f2269c
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneGenerator.java
@@ -0,0 +1,212 @@
+/*
+ * 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:
+ * Michael Golubev (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.graphdef.codegen;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.codegen.jet.JETException;
+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;
+
+public class StandaloneGenerator extends GeneratorBase {
+ private final Config myArgs;
+ private final FigureGallery myInput;
+ private final Emitter myFigureGenerator;
+ private final StandaloneEmitters myAuxiliaryGenerators;
+ private boolean mySkipPluginStructire;
+ private final FigureQualifiedNameSwitch myFigureNameSwitch;
+
+ public interface Config {
+ public String getPluginID();
+ public String getPluginFriendlyName();
+ public String getPluginProviderName();
+ public String getMainPackageName();
+
+ public String getPluginActivatorClassName();
+ public String getPluginActivatorPackageName();
+
+ public boolean needsMapMode();
+ }
+
+ public static class ConfigImpl implements Config {
+ private final String myPluginId;
+ private final String myMainPackageName;
+ private final String myPluginFriendlyName;
+ private final String myPluginProviderName;
+
+ private final String myPluginActivatorClassName;
+ private final String myPluginActivatorPackageName;
+
+ private final boolean myNeedsMapMode;
+
+ public ConfigImpl(String pluginId, String mainPackageName){
+ this(pluginId, mainPackageName, pluginId, "", "PluginActivator", mainPackageName + ".activator", true);
+ }
+
+ public ConfigImpl(String pluginId, String mainPackageName, String pluginFriendlyName, String pluginProviderName, String pluginActivatorClassName, String pluginActivatorPackageName, boolean needsMapMode){
+ myPluginId = pluginId;
+ myMainPackageName = mainPackageName;
+ myPluginFriendlyName = pluginFriendlyName;
+ myPluginProviderName = pluginProviderName;
+ myPluginActivatorClassName = pluginActivatorClassName;
+ myPluginActivatorPackageName = pluginActivatorPackageName;
+ myNeedsMapMode = needsMapMode;
+ }
+
+ public String getMainPackageName() {
+ return myMainPackageName;
+ }
+
+ public String getPluginFriendlyName() {
+ return myPluginFriendlyName;
+ }
+
+ public String getPluginID() {
+ return myPluginId;
+ }
+
+ public String getPluginProviderName() {
+ return myPluginProviderName;
+ }
+
+ public String getPluginActivatorClassName() {
+ return myPluginActivatorClassName;
+ }
+
+ public String getPluginActivatorPackageName() {
+ return myPluginActivatorPackageName;
+ }
+
+ public boolean needsMapMode() {
+ return myNeedsMapMode;
+ }
+ }
+
+ public StandaloneGenerator(FigureGallery input, Config config, FigureQualifiedNameSwitch fqnSwitch){
+ assert input != null && config != null && fqnSwitch != null;
+ myArgs = config;
+ myInput = input;
+ myFigureNameSwitch = fqnSwitch;
+ ImportAssistant importAssistant = new ImportUtil(getPackageName());
+ String pluginActivatorFQN = composePluginActivatorClassFQN(config);
+ MapModeCodeGenStrategy strategy = new MapModeCodeGenStrategy.RuntimeMapModeFromPluginClass( //
+ importAssistant, pluginActivatorFQN);
+
+ myFigureGenerator = new FigureGeneratorAdapter( //
+ new FigureGenerator(getPackageName(), importAssistant, fqnSwitch, strategy)
+ );
+ myAuxiliaryGenerators = new StandaloneEmitters();
+ }
+
+ /**
+ * Allows clients to skip generating of manifest.mf, pligin and build properties files.
+ * "New-plugin-by-template" generator uses this feature because it delegates this generation to PDE defaults.
+ */
+ public void setSkipPluginStructure(boolean skipManifest){
+ mySkipPluginStructire = skipManifest;
+ }
+
+ private static String composePluginActivatorClassFQN(Config config) {
+ String packageName = config.getPluginActivatorPackageName();
+ String className = config.getPluginActivatorClassName();
+ return packageName == null || "".equals(packageName) ? className : packageName + "." + className;
+ }
+
+ protected void setupProgressMonitor() {
+ //setupProgressMonitor("Generating GMFGraph plugin", 100);
+ }
+
+ protected URL getJMergeControlFile() {
+ return null;
+ }
+
+ protected List createReferencedProjectsList() {
+ return Collections.EMPTY_LIST;
+ }
+
+ protected void customRun() throws InterruptedException, JETException, UnexpectedBehaviourException {
+ initializeEditorProject(myArgs.getPluginID(), createReferencedProjectsList());
+
+ if (!mySkipPluginStructire){
+ generatePluginStructure();
+ }
+ try {
+ generatePluginActivator();
+ generateTopLevelFigures();
+ } catch (IllegalStateException e){
+ throw new UnexpectedBehaviourException(e);
+ }
+ }
+
+ private void generatePluginActivator() throws JETException, InterruptedException{
+ doGenerateJavaClass(myAuxiliaryGenerators.getPluginActivatorEmitter(), myArgs.getPluginActivatorPackageName(), myArgs.getPluginActivatorClassName(), myArgs);
+ }
+
+ private void generatePluginStructure() throws JETException, 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);
+ }
+
+ private String[] getRequiredBundles() {
+ HashSet rv = new HashSet();
+ if (myInput.getImplementationBundle() != null && myInput.getImplementationBundle().trim().length() > 0) {
+ rv.add(myInput.getImplementationBundle());
+ }
+ String[] additional = (String[]) myFigureNameSwitch.doSwitch(myInput);
+ rv.addAll(Arrays.asList(additional));
+ return (String[]) rv.toArray(new String[rv.size()]);
+ }
+
+ private void generateTopLevelFigures() throws InterruptedException {
+ for (Iterator it = myInput.getFigures().iterator(); it.hasNext();){
+ Figure next = (Figure) it.next();
+ visitFigure(next);
+ }
+ }
+
+ private void visitFigure(Figure figure) throws InterruptedException {
+ doGenerateJavaClass(myFigureGenerator, getPackageName(), figure.getName(), figure);
+ }
+
+ private String getPackageName(){
+ return myArgs.getMainPackageName();
+ }
+
+ 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);
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/BuildPropertiesGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/BuildPropertiesGenerator.java
new file mode 100644
index 000000000..f5d8da7a2
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/BuildPropertiesGenerator.java
@@ -0,0 +1,25 @@
+package org.eclipse.gmf.graphdef.codegen.standalone.templates;
+
+public class BuildPropertiesGenerator
+{
+ protected static String nl;
+ public static synchronized BuildPropertiesGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ BuildPropertiesGenerator result = new BuildPropertiesGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "source.. = src/" + NL + "output.. = bin/" + NL + "bin.includes = META-INF/,\\";
+ protected final String TEXT_2 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(TEXT_2);
+ return stringBuffer.toString();
+ }
+}
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
new file mode 100644
index 000000000..e3ba402d3
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/ManifestMFGenerator.java
@@ -0,0 +1,77 @@
+package org.eclipse.gmf.graphdef.codegen.standalone.templates;
+
+import java.util.*;
+import org.eclipse.gmf.graphdef.codegen.*;
+
+public class ManifestMFGenerator
+{
+ protected static String nl;
+ public static synchronized ManifestMFGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ ManifestMFGenerator result = new ManifestMFGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "Manifest-Version: 1.0" + NL + "Bundle-ManifestVersion: 2" + NL + "Bundle-Name: %pluginName" + NL + "Bundle-SymbolicName: ";
+ protected final String TEXT_2 = "; singleton:=true" + NL + "Bundle-Version: 1.0.0" + NL + "Bundle-Vendor: %providerName" + NL + "Bundle-Localization: plugin";
+ protected final String TEXT_3 = NL + "Export-Package: ";
+ protected final String TEXT_4 = NL + "Require-Bundle: ";
+ protected final String TEXT_5 = NL + "Eclipse-LazyStart: true";
+ protected final String TEXT_6 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+final Object[] passedArgs = (Object[]) argument;
+final StandaloneGenerator.Config config = (StandaloneGenerator.Config) passedArgs[0];
+final String[] requiredBundles = (String[]) passedArgs[1];
+
+
+class ListComposer {
+ public String composeList(Collection strings){
+ StringBuffer result = new StringBuffer();
+ for (Iterator it = strings.iterator(); it.hasNext();){
+ result.append(" "); //do not miss required space here
+ result.append(it.next());
+ if (it.hasNext()){
+ result.append(", " + NL);
+ }
+ }
+ return result.toString();
+ }
+}
+
+final ListComposer listComposer = new ListComposer();
+
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(config.getPluginID());
+ stringBuffer.append(TEXT_2);
+
+ HashSet exportedPackages = new HashSet();
+ exportedPackages.add(config.getMainPackageName());
+ exportedPackages.add(config.getPluginActivatorPackageName());
+
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(listComposer.composeList(exportedPackages));
+
+final Set allRequiredBundles = new LinkedHashSet();
+allRequiredBundles.add("org.eclipse.gef");
+allRequiredBundles.add("org.eclipse.draw2d");
+allRequiredBundles.add("org.eclipse.osgi");
+allRequiredBundles.add("org.eclipse.core.runtime");
+allRequiredBundles.addAll(java.util.Arrays.asList(requiredBundles));
+if (config.needsMapMode()) {
+ allRequiredBundles.add("org.eclipse.gmf.runtime.draw2d.ui");
+}
+
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(listComposer.composeList(allRequiredBundles));
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(TEXT_6);
+ return stringBuffer.toString();
+ }
+}
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
new file mode 100644
index 000000000..9cf70249d
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/PluginActivatorGenerator.java
@@ -0,0 +1,84 @@
+package org.eclipse.gmf.graphdef.codegen.standalone.templates;
+
+import org.eclipse.gmf.graphdef.codegen.*;
+import org.eclipse.gmf.common.codegen.ImportAssistant;
+
+public class PluginActivatorGenerator
+{
+ protected static String nl;
+ public static synchronized PluginActivatorGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ PluginActivatorGenerator result = new PluginActivatorGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = NL + "import org.eclipse.core.runtime.Plugin;" + NL;
+ protected final String TEXT_2 = NL + "import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode;" + NL + "import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeTypes;";
+ protected final String TEXT_3 = NL + NL + "import org.osgi.framework.BundleContext;";
+ protected final String TEXT_4 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
+ protected final String TEXT_5 = " extends Plugin {" + NL;
+ protected final String TEXT_6 = NL + "\tprivate IMapMode myMapMode = MapModeTypes.IDENTITY_MM;";
+ protected final String TEXT_7 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static final String ID = \"";
+ protected final String TEXT_8 = "\"; //$NON-NLS-1$" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate static ";
+ protected final String TEXT_9 = " ourInstance;" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
+ protected final String TEXT_10 = "() {" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void start(BundleContext context) throws Exception {" + NL + "\t\tsuper.start(context);" + NL + "\t\tif (ourInstance != null){" + NL + "\t\t\tthrow new IllegalStateException(\"Plugin: \" + ID + \" already started\");" + NL + "\t\t}" + NL + "\t\tourInstance = this;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void stop(BundleContext context) throws Exception {" + NL + "\t\tif (ourInstance == null){" + NL + "\t\t\tthrow new IllegalStateException(\"Plugin: \" + ID + \" is not started\");" + NL + "\t\t}" + NL + "\t\tourInstance = null;" + NL + "\t\tsuper.stop(context);" + NL + "\t}" + NL + "\t";
+ protected final String TEXT_11 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void setMapMode(IMapMode mapMode) {" + NL + "\t\tmyMapMode = mapMode;" + NL + "\t\tif (myMapMode == null){" + NL + "\t\t\tmyMapMode = MapModeTypes.IDENTITY_MM;" + NL + "\t\t}" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic IMapMode getMapMode() {" + NL + "\t\treturn myMapMode;" + NL + "\t}" + NL;
+ protected final String TEXT_12 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic static ";
+ protected final String TEXT_13 = " getDefault() {" + NL + "\t\treturn ourInstance;" + NL + "\t}" + NL + "}";
+ protected final String TEXT_14 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+final Object[] passedArgs = (Object[]) argument;
+final StandaloneGenerator.Config config = (StandaloneGenerator.Config) passedArgs[0];
+final ImportAssistant importManager = (ImportAssistant) passedArgs[1];
+
+importManager.emitPackageStatement(stringBuffer);
+
+ stringBuffer.append(TEXT_1);
+
+if (config.needsMapMode()){
+
+ stringBuffer.append(TEXT_2);
+
+}
+
+ stringBuffer.append(TEXT_3);
+ importManager.markImportLocation(stringBuffer);
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(config.getPluginActivatorClassName());
+ stringBuffer.append(TEXT_5);
+
+if (config.needsMapMode()){
+
+ stringBuffer.append(TEXT_6);
+
+}
+
+ stringBuffer.append(TEXT_7);
+ stringBuffer.append(config.getPluginID());
+ stringBuffer.append(TEXT_8);
+ stringBuffer.append(config.getPluginActivatorClassName());
+ stringBuffer.append(TEXT_9);
+ stringBuffer.append(config.getPluginActivatorClassName());
+ stringBuffer.append(TEXT_10);
+
+if (config.needsMapMode()){
+
+ stringBuffer.append(TEXT_11);
+
+}
+
+ stringBuffer.append(TEXT_12);
+ stringBuffer.append(config.getPluginActivatorClassName());
+ stringBuffer.append(TEXT_13);
+ importManager.emitSortedImports();
+ stringBuffer.append(TEXT_14);
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/PluginPropertiesGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/PluginPropertiesGenerator.java
new file mode 100644
index 000000000..1563aabd0
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/standalone/templates/PluginPropertiesGenerator.java
@@ -0,0 +1,34 @@
+package org.eclipse.gmf.graphdef.codegen.standalone.templates;
+
+import org.eclipse.gmf.graphdef.codegen.*;
+
+public class PluginPropertiesGenerator
+{
+ protected static String nl;
+ public static synchronized PluginPropertiesGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ PluginPropertiesGenerator result = new PluginPropertiesGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "pluginName = ";
+ protected final String TEXT_2 = NL + "providerName = ";
+ protected final String TEXT_3 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+final StandaloneGenerator.Config config = (StandaloneGenerator.Config) argument;
+
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(config.getPluginFriendlyName());
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(config.getPluginProviderName());
+ stringBuffer.append(TEXT_3);
+ return stringBuffer.toString();
+ }
+}

Back to the top