Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-11-02 17:38:23 +0000
committeratikhomirov2006-11-02 17:38:23 +0000
commita2b68d799202219e6f19d437e4b0cecde63943da (patch)
tree3d6a68cbf0a0bf1da1d91e3eacdc04a69786ec9d /plugins/org.eclipse.gmf.graphdef.codegen
parent56c861b4a279b3bac1c793aca863ba754ecc8f46 (diff)
downloadorg.eclipse.gmf-tooling-a2b68d799202219e6f19d437e4b0cecde63943da.tar.gz
org.eclipse.gmf-tooling-a2b68d799202219e6f19d437e4b0cecde63943da.tar.xz
org.eclipse.gmf-tooling-a2b68d799202219e6f19d437e4b0cecde63943da.zip
moving towards jet-to-xpand switch
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.java2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/GraphDefDispatcher.java4
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/MapModeCodeGenStrategy.java68
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneGenerator.java16
4 files changed, 18 insertions, 72 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 a1e46aed7..61019f466 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
@@ -90,7 +90,7 @@ public class FigureGenerator implements TextEmitter {
private final boolean myIsInnerClassCode;
public FigureGenerator(FigureQualifiedNameSwitch figureNameSwitch, boolean asInnerClass) {
- this(figureNameSwitch, new MapModeCodeGenStrategy.RuntimeUnspecifiedMapMode(), asInnerClass);
+ this(figureNameSwitch, MapModeCodeGenStrategy.DYNAMIC, asInnerClass);
}
public FigureGenerator(FigureQualifiedNameSwitch figureNameSwitch, MapModeCodeGenStrategy mapModeStrategy, boolean placeStaticFieldsOutsideClassBody) {
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 5cae2833e..567ceb909 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
@@ -47,11 +47,11 @@ public class GraphDefDispatcher extends DispatcherImpl {
}
public String DPtoLP(int deviceUnit){
- return myMapModeStrategy.DPtoLP(deviceUnit);
+ return String.valueOf(deviceUnit);
}
public String LPtoDP(int logicalUnit){
- return myMapModeStrategy.LPtoDP(logicalUnit);
+ return String.valueOf(logicalUnit);
}
public ImportAssistant getImportManager() {
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/MapModeCodeGenStrategy.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/MapModeCodeGenStrategy.java
index 31a03afa9..79c55a699 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/MapModeCodeGenStrategy.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/MapModeCodeGenStrategy.java
@@ -8,70 +8,16 @@
*
* Contributors:
* Michael Golubev (Borland) - initial API and implementation
+ * Artem Tikhomirov (Borland) - redesigned as enumeration
*/
package org.eclipse.gmf.graphdef.codegen;
-import org.eclipse.gmf.common.codegen.ImportAssistant;
-
-public abstract class MapModeCodeGenStrategy {
- public abstract String LPtoDP(int logicalUnit);
- public abstract String DPtoLP(int deviceUnit);
-
- public static class StaticIdentityMapMode extends MapModeCodeGenStrategy {
- public String DPtoLP(int deviceUnit) {
- return String.valueOf(deviceUnit);
- }
-
- public String LPtoDP(int logicalUnit) {
- return String.valueOf(logicalUnit);
- }
- }
-
- public static class RuntimeUnspecifiedMapMode extends MapModeCodeGenStrategy {
- public String DPtoLP(int deviceUnit) {
- StringBuffer result = new StringBuffer();
- result.append(getMapModeAccessor());
- result.append('.');
- result.append("DPtoLP(");
- result.append(deviceUnit);
- result.append(')');
- return result.toString();
- }
-
- public String LPtoDP(int logicalUnit) {
- StringBuffer result = new StringBuffer();
- result.append(getMapModeAccessor());
- result.append('.');
- result.append("LPtoDP(");
- result.append(logicalUnit);
- result.append(')');
- return result.toString();
- }
-
- protected String getMapModeAccessor(){
- return "getMapMode()";
- }
- }
+/**
+ * @author artem
+ */
+public enum MapModeCodeGenStrategy {
- public static class RuntimeMapModeFromPluginClass extends RuntimeUnspecifiedMapMode {
- private final String myPluginActivatorClassFQN;
- private final ImportAssistant myImportAssistant;
+ StaticIdentity,
- public RuntimeMapModeFromPluginClass(ImportAssistant importAssistant, String pluginActivatorClassFQN){
- myImportAssistant = importAssistant;
- myPluginActivatorClassFQN = pluginActivatorClassFQN;
- }
-
- public ImportAssistant getImportAssistant() {
- return myImportAssistant;
- }
-
- protected String getMapModeAccessor() {
- StringBuffer result = new StringBuffer();
- result.append(getImportAssistant().getImportedName(myPluginActivatorClassFQN));
- result.append('.');
- result.append("getDefault().getMapMode()");
- return result.toString();
- }
- }
+ DYNAMIC,
}
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 5a542364a..9380784e7 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
@@ -26,13 +26,13 @@ import org.eclipse.gmf.internal.common.codegen.TextEmitter;
import org.eclipse.gmf.internal.common.codegen.TextMerger;
public class StandaloneGenerator extends GeneratorBase {
- private final Config myArgs;
+ protected final Config myArgs;
private final TextEmitter myFigureGenerator;
private DelegateImportManager myMapModeImportHack;
private final StandaloneEmitters myAuxiliaryGenerators;
private boolean mySkipPluginStructire;
- private final FigureQualifiedNameSwitch myFigureNameSwitch;
- private Processor myProcessor;
+ protected final FigureQualifiedNameSwitch myFigureNameSwitch;
+ protected Processor myProcessor;
public interface Config {
public String getPluginID();
@@ -43,7 +43,7 @@ public class StandaloneGenerator extends GeneratorBase {
public String getPluginActivatorClassName();
public String getPluginActivatorPackageName();
- public boolean needsMapMode();
+ public boolean needsMapMode(); // FIXME remove
}
public static class ConfigImpl implements Config {
@@ -126,9 +126,9 @@ public class StandaloneGenerator extends GeneratorBase {
MapModeCodeGenStrategy strategy;
if (config.needsMapMode()) {
myMapModeImportHack = new DelegateImportManager();
- strategy = new MapModeCodeGenStrategy.RuntimeMapModeFromPluginClass(myMapModeImportHack, pluginActivatorFQN);
+ strategy = MapModeCodeGenStrategy.DYNAMIC;
} else {
- strategy = new MapModeCodeGenStrategy.StaticIdentityMapMode();
+ strategy = MapModeCodeGenStrategy.StaticIdentity;
}
myFigureGenerator = createFigureGenerator(fqnSwitch, strategy);
@@ -171,12 +171,12 @@ public class StandaloneGenerator extends GeneratorBase {
}
}
- private void generatePluginActivator() throws UnexpectedBehaviourException, InterruptedException{
+ protected void generatePluginActivator() throws UnexpectedBehaviourException, InterruptedException{
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 {
+ protected void generatePluginStructure() throws UnexpectedBehaviourException, InterruptedException {
doGenerateFile(myAuxiliaryGenerators.getBuildPropertiesEmitter(), new Path("build.properties"), new Object[] { myArgs });
doGenerateFile(myAuxiliaryGenerators.getManifestMFEmitter(), new Path("META-INF/MANIFEST.MF"), new Object[] { new Object[] { myArgs, myProcessor.getRequiredBundles(myFigureNameSwitch) } });
doGenerateFile(myAuxiliaryGenerators.getPluginPropertiesEmitter(), new Path("plugin.properties"), new Object[] { myArgs });

Back to the top