Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2007-05-28 13:33:47 +0000
committeratikhomirov2007-05-28 13:33:47 +0000
commitb9c2e8ba0dcf0fec890f43da131fe59ff8d0bdd9 (patch)
treedfc1fe9aaa3654eb23b6975d1bcaeffa37bad9ad /plugins/org.eclipse.gmf.graphdef.codegen
parentd82588c35a079238625cef04c59ad3cfeaa1b304 (diff)
downloadorg.eclipse.gmf-tooling-b9c2e8ba0dcf0fec890f43da131fe59ff8d0bdd9.tar.gz
org.eclipse.gmf-tooling-b9c2e8ba0dcf0fec890f43da131fe59ff8d0bdd9.tar.xz
org.eclipse.gmf-tooling-b9c2e8ba0dcf0fec890f43da131fe59ff8d0bdd9.zip
FigureDescriptor with explicit means to access children introduced into gmfgraph
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.java67
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/NamingStrategy.java11
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/StandaloneGenerator.java26
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/CanvasProcessor.java91
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/DiagramElementsCopier.java32
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/GalleryMirrorProcessor.java58
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/GalleryProcessor.java6
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Attrs.xpt2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Border.xpt48
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt47
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Decoration.xpt2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Extras.xpt4
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Layout.xpt2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/LayoutData.xpt2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/MapMode.xpt2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Runtime.xpt3
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.ext65
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.xpt2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Decoration.xpt2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.xpt19
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.xpt19
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/plugin/Manifest.xpt4
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/rt_mm/MapMode.xpt2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Descriptor.xpt57
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt51
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/xtras/ScalablePolygon.xpt2
26 files changed, 299 insertions, 327 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 f5f2a6814..fa0870c2d 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
@@ -19,8 +19,8 @@ import java.util.Map;
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.FigureDescriptor;
import org.eclipse.gmf.internal.common.codegen.TextEmitter;
import org.eclipse.gmf.internal.graphdef.codegen.Activator;
import org.eclipse.gmf.internal.xpand.BufferOutput;
@@ -33,41 +33,37 @@ 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;
- private Variable packageStatement;
-
- private StringBuilder additionalMethods;
-
private final boolean myIsInnerClassCode;
private StringBuilder additionalFields;
+ private String packageStatement;
+
/**
* 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(String runtimeToken, String packageStmt, boolean asInnerClass) {
+ this(runtimeToken, packageStmt, MapModeCodeGenStrategy.DYNAMIC, "getMapMode().", asInnerClass);
}
- public FigureGenerator(String runtimeToken, MapModeCodeGenStrategy mapModeStrategy, String mapModeAccessor, boolean asInnerClass) {
- this(runtimeToken, mapModeStrategy, mapModeAccessor, asInnerClass, null);
+ public FigureGenerator(String runtimeToken, String packageStmt, MapModeCodeGenStrategy mapModeStrategy, String mapModeAccessor, boolean asInnerClass) {
+ this(runtimeToken, packageStmt, mapModeStrategy, mapModeAccessor, asInnerClass, null);
}
- public FigureGenerator(String runtimeToken, MapModeCodeGenStrategy mapModeStrategy, String mapModeAccessor, boolean asInnerClass, URL[] dynamicTemplates) {
+ public FigureGenerator(String runtimeToken, String packageStmt, MapModeCodeGenStrategy mapModeStrategy, String mapModeAccessor, boolean asInnerClass, URL[] dynamicTemplates) {
myIsInnerClassCode = asInnerClass;
+ this.packageStatement = packageStmt;
if (mapModeStrategy == MapModeCodeGenStrategy.STATIC) {
if (mapModeAccessor != null && mapModeAccessor.trim().length() > 0) {
throw new IllegalArgumentException("Can't use map mode accessor with identity map mode");
@@ -80,14 +76,6 @@ public class FigureGenerator implements TextEmitter {
if (runtimeToken != null) {
globals.add(new Variable(VAR_RT_TOKEN, runtimeToken));
}
- packageStatement = new Variable(VAR_PACKAGE_STMT, "");
- globals.add(packageStatement);
- additionalMethods = new StringBuilder();
- globals.add(new Variable(VAR_OUTPUT_METHODS, "") {
- public Object getValue() {
- return additionalMethods.toString();
- }
- });
additionalFields = new StringBuilder();
globals.add(new Variable(VAR_OUTPUT_FIELDS, "") {
public Object getValue() {
@@ -96,7 +84,6 @@ public class FigureGenerator implements TextEmitter {
});
result = new StringBuilder(200);
Map<String, StringBuilder> slots = new HashMap<String, StringBuilder>();
- slots.put(SLOT_METHODS, additionalMethods);
slots.put(SLOT_FIELDS, additionalFields);
BufferOutput bufferOutput = new BufferOutput(result, slots);
@@ -104,22 +91,36 @@ public class FigureGenerator implements TextEmitter {
xpandFacade = new XpandFacade(ContextFactory.createXpandContext(resourceManager, bufferOutput, globals, getClass().getClassLoader()));
}
- public String go(Figure figure, ImportAssistant importAssistant) {
+ public String getPackageName() {
+ return packageStatement;
+ }
+
+ public String fqnSwitch(Figure figure) {
result.setLength(0);
- additionalMethods.setLength(0);
additionalFields.setLength(0);
- StringBuffer ss = new StringBuffer();
- importAssistant.emitPackageStatement(ss);
- packageStatement.setValue(ss.toString());
- xpandFacade.evaluate("top::Figure::FigureClass", figure, new Object[] {myIsInnerClassCode});
- final String resultString = result.toString();
- return resultString;
+ xpandFacade.evaluate("Runtime::fqn", figure, null);
+ return result.toString();
+ }
+
+ /**
+ * @param packageStmt can be null if asInnerClass was true
+ * @param figure
+ */
+ public String go(FigureDescriptor figure) {
+ result.setLength(0);
+ additionalFields.setLength(0);
+ if (myIsInnerClassCode) {
+ xpandFacade.evaluate("top::Descriptor::Inner", figure, null);
+ } else {
+ xpandFacade.evaluate("top::Descriptor::Top", figure, new Object[] { packageStatement });
+ }
+ return result.toString();
}
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("(Figure, ImportAssistant) expected as arguments, not " + arguments);
+ if (arguments == null || arguments.length != 1 || false == arguments[0] instanceof FigureDescriptor) {
+ throw new UnexpectedBehaviourException("(FigureDescriptor) expected as arguments, not " + arguments);
}
- return go((Figure) arguments[0], (ImportAssistant) arguments[1]);
+ return go((FigureDescriptor) arguments[0]);
}
}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/NamingStrategy.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/NamingStrategy.java
index 241865a49..34ffe4f00 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/NamingStrategy.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/NamingStrategy.java
@@ -13,15 +13,14 @@
package org.eclipse.gmf.graphdef.codegen;
import org.eclipse.emf.codegen.util.CodeGenUtil;
-import org.eclipse.gmf.gmfgraph.Figure;
+import org.eclipse.gmf.gmfgraph.ChildAccess;
/**
- * FIXME [artem] no reason for singleton
+ * XXX [artem] use gmfgraph::Util.ext figureFieldGetter instead or any other *common* way instead.
*/
public class NamingStrategy {
- public static NamingStrategy INSTANCE = new NamingStrategy();
-
- public String getChildFigureGetterName(Figure childFigure){
- return "getFigure" + CodeGenUtil.capName(CodeGenUtil.validJavaIdentifier(childFigure.getName()));
+
+ public static String getChildFigureGetterName(ChildAccess childFigure){
+ return "getFigure" + CodeGenUtil.capName(CodeGenUtil.validJavaIdentifier(childFigure.getAccessor()));
}
}
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 26f486cf7..c62774016 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
@@ -20,8 +20,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.emf.codegen.merge.java.JControlModel;
import org.eclipse.emf.codegen.util.CodeGenUtil;
import org.eclipse.gmf.common.UnexpectedBehaviourException;
-import org.eclipse.gmf.common.codegen.ImportAssistant;
-import org.eclipse.gmf.gmfgraph.Figure;
+import org.eclipse.gmf.gmfgraph.FigureDescriptor;
import org.eclipse.gmf.gmfgraph.util.FigureQualifiedNameSwitch;
import org.eclipse.gmf.internal.common.codegen.DefaultTextMerger;
import org.eclipse.gmf.internal.common.codegen.GeneratorBase;
@@ -38,7 +37,7 @@ public class StandaloneGenerator extends GeneratorBase {
private final StandaloneEmitters myAuxiliaryGenerators;
private boolean mySkipPluginStructire;
protected Processor myProcessor;
- private final Map<String, Figure> myCallbackFigures = new LinkedHashMap<String, Figure>();
+ private final Map<String, FigureDescriptor> myCallbackFigures = new LinkedHashMap<String, FigureDescriptor>();
public interface Config {
public String getPluginID();
@@ -125,7 +124,7 @@ public class StandaloneGenerator extends GeneratorBase {
}
public interface ProcessorCallback {
- public String visitFigure(Figure f) throws InterruptedException;
+ public String visitFigure(FigureDescriptor f) throws InterruptedException;
}
@@ -148,7 +147,7 @@ public class StandaloneGenerator extends GeneratorBase {
accessor = null;
}
- myFigureGenerator = new FigureGenerator(config.getRuntimeToken(), strategy, accessor, false, dynamicTemplates);
+ myFigureGenerator = new FigureGenerator(config.getRuntimeToken(), getPackageName(), strategy, accessor, false, dynamicTemplates);
myAuxiliaryGenerators = new StandaloneEmitters(strategy, dynamicTemplates);
}
@@ -198,18 +197,21 @@ public class StandaloneGenerator extends GeneratorBase {
private void generateTopLevelFigures() throws InterruptedException {
myCallbackFigures.clear(); // just in case
myProcessor.go(new ProcessorCallback() {
- public String visitFigure(Figure f) throws InterruptedException {
+ public String visitFigure(FigureDescriptor f) throws InterruptedException {
return StandaloneGenerator.this.visitFigure(f);
}
}, myArgs);
}
- private String visitFigure(Figure figure) throws InterruptedException {
- final ImportAssistant importAssistant = new ImportUtil(getPackageName(), CodeGenUtil.validJavaIdentifier(figure.getName()));
- Object[] args = new Object[] { figure, importAssistant };
- doGenerateJavaClass(myFigureGenerator, getPackageName(), importAssistant.getCompilationUnitName(), args);
- final String qualifiedName = composeFQN(getPackageName(), importAssistant.getCompilationUnitName());
- myCallbackFigures.put(qualifiedName, figure);
+ private String visitFigure(FigureDescriptor figureDescriptor) throws InterruptedException {
+ // XXX either use compilationUnitName from Util.ext or pass cu name as template argument
+ if (figureDescriptor.getName() == null) {
+ throw new IllegalArgumentException("FigureDescriptor needs a name");
+ }
+ final String compilationUnitName = CodeGenUtil.validJavaIdentifier(CodeGenUtil.capName(figureDescriptor.getName()));
+ doGenerateJavaClass(myFigureGenerator, getPackageName(), compilationUnitName, figureDescriptor);
+ final String qualifiedName = composeFQN(getPackageName(), compilationUnitName);
+ myCallbackFigures.put(qualifiedName, figureDescriptor);
return qualifiedName;
}
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 ee8597578..d75f4d8e4 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
@@ -16,21 +16,18 @@ import java.util.HashSet;
import java.util.LinkedList;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.gmfgraph.Canvas;
+import org.eclipse.gmf.gmfgraph.ChildAccess;
import org.eclipse.gmf.gmfgraph.Compartment;
import org.eclipse.gmf.gmfgraph.Connection;
import org.eclipse.gmf.gmfgraph.CustomFigure;
import org.eclipse.gmf.gmfgraph.DiagramLabel;
-import org.eclipse.gmf.gmfgraph.Figure;
-import org.eclipse.gmf.gmfgraph.FigureAccessor;
+import org.eclipse.gmf.gmfgraph.FigureDescriptor;
import org.eclipse.gmf.gmfgraph.FigureGallery;
-import org.eclipse.gmf.gmfgraph.FigureHandle;
import org.eclipse.gmf.gmfgraph.GMFGraphFactory;
import org.eclipse.gmf.gmfgraph.GMFGraphPackage;
import org.eclipse.gmf.gmfgraph.Node;
import org.eclipse.gmf.gmfgraph.util.FigureQualifiedNameSwitch;
-import org.eclipse.gmf.graphdef.codegen.NamingStrategy;
import org.eclipse.gmf.graphdef.codegen.StandaloneGenerator.Config;
import org.eclipse.gmf.graphdef.codegen.StandaloneGenerator.Processor;
import org.eclipse.gmf.graphdef.codegen.StandaloneGenerator.ProcessorCallback;
@@ -97,86 +94,55 @@ public class CanvasProcessor extends Processor {
private void handleNodes() throws InterruptedException {
for (Node next : myInput.getNodes()) {
- handleFigure(next.getNodeFigure());
+ handleFigure(next.getFigure());
}
}
private void handleLinks() throws InterruptedException {
for (Connection next : myInput.getConnections()) {
- handleFigure(next.getConnectionFigure());
+ handleFigure(next.getFigure());
}
}
private void handleCompartments() throws InterruptedException {
for (Compartment next : myInput.getCompartments()) {
- FigureHandle nextFigure = next.getFigure();
+ FigureDescriptor nextFigure = next.getFigure();
if (nextFigure == null){
throw new NullPointerException("Compartment without figure : " + next);
}
- if (nextFigure instanceof Figure) {
- handleFigure((Figure) nextFigure);
- } else {
- throw new IllegalStateException("Don't support accessors for compartments yet");
- }
+ handleFigure(nextFigure);
}
}
private void handleLabels() throws InterruptedException {
for (DiagramLabel next : myInput.getLabels()) {
- if (next.getFigure() instanceof FigureAccessor) {
- assert myElementCopier.containsKey(next.getFigure()) : "Should be copied as part of previously referenced CustomFigure";
+ if (next.getAccessor() != null) {
+ // accessor
+ ChildAccess labelAccess = next.getAccessor();
+ // XXX nothing to do?
} else {
- assert next.getFigure() instanceof Figure;
- Figure f = (Figure) next.getFigure();
- if (isInsideProcessedFigure(f)) {
- // obviously, fact we got here means f is !getReferencingElements().isEmpty()
- // feedback.findAccessorFor(f)
- FigureAccessor accessor = GMFGraphFactory.eINSTANCE.createFigureAccessor();
- accessor.setAccessor(NamingStrategy.INSTANCE.getChildFigureGetterName(f));
- myElementCopier.put(f, accessor);
- // find closest ancestor figure
- /* XXX assume there's no cases like
- * Node1 --> Rect1
- * Node2 --> |- Rect2
- * Label --> |- gef.Label
- * and the Label we process is from Node1.
- * With the current approach, we'll get mirrored Rect2 instead of mirrored Rect1.
- */
- Figure parent = f;
- do {
- parent = parent.getParent();
- // parent can't be null, as we checked isInsideProcessedFigure prior to that.
- } while (!myElementCopier.containsKey(parent));
- assert myElementCopier.get(parent) instanceof CustomFigure : "We used to keep custom figures only in the mirrored gallery";
- ((CustomFigure) myElementCopier.get(parent)).getCustomChildren().add(accessor);
- } else {
- handleFigure(f);
- }
-
+ handleFigure(next.getFigure());
}
}
}
- private boolean isInsideProcessedFigure(Figure f) {
- return EcoreUtil.isAncestor(myElementCopier.keySet(), f);
- }
-
- private void handleFigure(Figure figure) throws InterruptedException {
- if (myElementCopier.isSubstituted(figure)) {
+ private void handleFigure(FigureDescriptor fd) throws InterruptedException {
+ if (myElementCopier.isSubstituted(fd)) {
// already processed, nothing to do
return;
// XXX originally CustomFigures do not get into history of elementCopier,
// hence may still get copied more than once. Perhaps, makes sense to have separate 'History'
// to keep track of processed figures?
}
- if (figure instanceof CustomFigure && isPlainBareCustomFigure((CustomFigure) figure)) {
+ if (fd.getActualFigure() instanceof CustomFigure && isPlainBareCustomFigure((CustomFigure) fd.getActualFigure())) {
// XXX an implementationBundle might be an issue here (#x#),
// since myOutcomeGallery gonna get one we generate, while the original CustomFigure
- // may have one specified in the ownining FigureGallery.
- myOutcomeGallery.getFigures().add((CustomFigure) myElementCopier.copy(figure));
+ // may have one specified in the ownining FigureGallery.
+ final CustomFigure f = (CustomFigure) fd.getActualFigure();
+ myOutcomeGallery.getFigures().add(myElementCopier.xcopy(f));
} else {
- String fqn = myCallback.visitFigure(figure);
- myElementCopier.registerSubstitution(figure, createCustomFigure(figure, fqn));
+ String fqn = myCallback.visitFigure(fd);
+ myElementCopier.registerSubstitution(fd, createCustomFigure(fd, fqn));
}
}
@@ -189,12 +155,9 @@ public class CanvasProcessor extends Processor {
return false;
}
final LinkedList<EStructuralFeature> featuresToCheck = new LinkedList<EStructuralFeature>(figure.eClass().getEAllStructuralFeatures());
- featuresToCheck.remove(GMFGraphPackage.eINSTANCE.getIdentity_Name());
- featuresToCheck.remove(GMFGraphPackage.eINSTANCE.getFigure_Children());
- featuresToCheck.remove(GMFGraphPackage.eINSTANCE.getFigureMarker_Parent());
- featuresToCheck.remove(GMFGraphPackage.eINSTANCE.getFigureHandle_ReferencingElements());
+ featuresToCheck.remove(GMFGraphPackage.eINSTANCE.getRealFigure_Name());
+ featuresToCheck.remove(GMFGraphPackage.eINSTANCE.getRealFigure_Children());
- featuresToCheck.remove(GMFGraphPackage.eINSTANCE.getCustomClass_BundleName());
featuresToCheck.remove(GMFGraphPackage.eINSTANCE.getCustomClass_QualifiedClassName());
featuresToCheck.remove(GMFGraphPackage.eINSTANCE.getCustomFigure_CustomChildren());
@@ -209,11 +172,13 @@ public class CanvasProcessor extends Processor {
return true;
}
- private CustomFigure createCustomFigure(Figure original, String fqn) {
- CustomFigure cf = DiagramElementsCopier.createCustomFigure(original);
- cf.setName(original.getName());
+ private FigureDescriptor createCustomFigure(FigureDescriptor original, String fqn) {
+ CustomFigure cf = GalleryMirrorProcessor.createCustomFigure(original.getActualFigure());
cf.setQualifiedClassName(fqn);
- myOutcomeGallery.getFigures().add(cf);
- return cf;
+ FigureDescriptor fd = GMFGraphFactory.eINSTANCE.createFigureDescriptor();
+ fd.setName(original.getName());
+ fd.setActualFigure(cf);
+ myOutcomeGallery.getDescriptors().add(fd);
+ return fd;
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/DiagramElementsCopier.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/DiagramElementsCopier.java
index 02ecc48fc..05d1191ae 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/DiagramElementsCopier.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/DiagramElementsCopier.java
@@ -16,24 +16,25 @@ import java.util.HashSet;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.gmf.gmfgraph.ConnectionFigure;
-import org.eclipse.gmf.gmfgraph.CustomFigure;
-import org.eclipse.gmf.gmfgraph.DecorationFigure;
-import org.eclipse.gmf.gmfgraph.Figure;
-import org.eclipse.gmf.gmfgraph.GMFGraphFactory;
+import org.eclipse.gmf.gmfgraph.FigureDescriptor;
class DiagramElementsCopier extends EcoreUtil.Copier {
- private final HashSet<Figure> myOriginalFigures = new HashSet<Figure>();
+ private final HashSet<FigureDescriptor> myOriginalFigures = new HashSet<FigureDescriptor>();
- public void registerSubstitution(Figure original, CustomFigure substituted){
+ public void registerSubstitution(FigureDescriptor original, FigureDescriptor substituted){
put(original, substituted);
myOriginalFigures.add(original);
}
- public boolean isSubstituted(Figure original) {
+ public boolean isSubstituted(FigureDescriptor original) {
return containsKey(original);
}
+ @SuppressWarnings("unchecked")
+ public <T extends EObject> T xcopy(T original) {
+ return (T) super.copy(original);
+ }
+
protected void copyReference(EReference eReference, EObject eObject, EObject copyEObject) {
if (EcoreUtil.isAncestor(myOriginalFigures, eObject)){
//no such features in the CustomFigure's
@@ -41,19 +42,4 @@ class DiagramElementsCopier extends EcoreUtil.Copier {
}
super.copyReference(eReference, eObject, copyEObject);
}
-
- /**
- * FIXME this method has nothing to do with DiagramElementsCopier
- */
- static CustomFigure createCustomFigure(Figure original){
- GMFGraphFactory factory = GMFGraphFactory.eINSTANCE;
- if (original instanceof DecorationFigure){
- return factory.createCustomDecoration();
- }
- if (original instanceof ConnectionFigure){
- return factory.createCustomConnection();
- }
- return factory.createCustomFigure();
- }
-
} \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/GalleryMirrorProcessor.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/GalleryMirrorProcessor.java
index c007161ee..250d359f0 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/GalleryMirrorProcessor.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/GalleryMirrorProcessor.java
@@ -12,12 +12,14 @@
package org.eclipse.gmf.internal.graphdef.codegen;
import java.util.Collections;
-import java.util.Enumeration;
import java.util.IdentityHashMap;
import java.util.Map;
+import org.eclipse.gmf.gmfgraph.ConnectionFigure;
import org.eclipse.gmf.gmfgraph.CustomFigure;
+import org.eclipse.gmf.gmfgraph.DecorationFigure;
import org.eclipse.gmf.gmfgraph.Figure;
+import org.eclipse.gmf.gmfgraph.FigureDescriptor;
import org.eclipse.gmf.gmfgraph.FigureGallery;
import org.eclipse.gmf.gmfgraph.GMFGraphFactory;
import org.eclipse.gmf.graphdef.codegen.StandaloneGenerator.Config;
@@ -29,12 +31,11 @@ import org.eclipse.gmf.graphdef.codegen.StandaloneGenerator.ProcessorCallback;
* @author artem
*/
public class GalleryMirrorProcessor extends GalleryProcessor {
- private final GenerationInfoImpl myGenerationInfo;
+ private final Map<FigureDescriptor, String> myFigure2FQN = new IdentityHashMap<FigureDescriptor, String>();
private String myGeneratedBundle;
public GalleryMirrorProcessor(FigureGallery[] input) {
super(input);
- myGenerationInfo = new GenerationInfoImpl();
}
public void go(ProcessorCallback callback, Config config) throws InterruptedException {
@@ -47,49 +48,34 @@ public class GalleryMirrorProcessor extends GalleryProcessor {
result.setName("GeneratedGallery"); // FIXME smth reasonable
result.setImplementationBundle(myGeneratedBundle);
- for (Enumeration<Figure> originalFigures = myGenerationInfo.getProcessedFigures(); originalFigures.hasMoreElements();) {
- Figure nextOriginal = originalFigures.nextElement();
- String nextConvertedFqn = myGenerationInfo.getGeneratedClassFQN(nextOriginal);
- CustomFigure custom = DiagramElementsCopier.createCustomFigure(nextOriginal);
- custom.setName(nextOriginal.getName());
- custom.setBundleName(myGeneratedBundle);
+ for (FigureDescriptor fd : myFigure2FQN.keySet()) {
+ Figure nextOriginal = fd.getActualFigure();
+ String nextConvertedFqn = myFigure2FQN.get(fd);
+ CustomFigure custom = createCustomFigure(nextOriginal);
+ custom.setName(fd.getName());
custom.setQualifiedClassName(nextConvertedFqn);
-
+
result.getFigures().add(custom);
}
return result;
}
- public GenerationInfo getGenerationInfo() {
- return myGenerationInfo;
- }
-
- protected void handle(Figure next, String fqn) {
- myGenerationInfo.registerFQN(next, fqn);
+ public Map<FigureDescriptor, String> getGenerationInfo() {
+ return Collections.unmodifiableMap(myFigure2FQN);
}
- public interface GenerationInfo {
- // FIXME use iterator instead to allow enhanced for loop
- public Enumeration<Figure> getProcessedFigures();
- public String getGeneratedClassFQN(Figure figure);
+ protected void handle(FigureDescriptor next, String fqn) {
+ myFigure2FQN.put(next, fqn);
}
- private static class GenerationInfoImpl implements GenerationInfo {
- private final Map<Figure, String> myFigure2FQN = new IdentityHashMap<Figure, String>();
-
- public GenerationInfoImpl(){
+ static CustomFigure createCustomFigure(Figure original){
+ GMFGraphFactory factory = GMFGraphFactory.eINSTANCE;
+ if (original instanceof DecorationFigure){
+ return factory.createCustomDecoration();
+ }
+ if (original instanceof ConnectionFigure){
+ return factory.createCustomConnection();
}
-
- public void registerFQN(Figure figure, String fqn){
- myFigure2FQN.put(figure, fqn);
- }
-
- public String getGeneratedClassFQN(Figure figure) {
- return myFigure2FQN.get(figure);
- }
-
- public Enumeration<Figure> getProcessedFigures() {
- return Collections.enumeration(myFigure2FQN.keySet());
- }
+ return factory.createCustomFigure();
}
}
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 8191de585..3a0defe79 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
@@ -14,7 +14,7 @@ package org.eclipse.gmf.internal.graphdef.codegen;
import java.util.Arrays;
import java.util.HashSet;
-import org.eclipse.gmf.gmfgraph.Figure;
+import org.eclipse.gmf.gmfgraph.FigureDescriptor;
import org.eclipse.gmf.gmfgraph.FigureGallery;
import org.eclipse.gmf.gmfgraph.util.FigureQualifiedNameSwitch;
import org.eclipse.gmf.graphdef.codegen.StandaloneGenerator.Config;
@@ -39,7 +39,7 @@ public class GalleryProcessor extends Processor {
public void go(ProcessorCallback callback, Config config) throws InterruptedException {
for (int i = 0; i < myInput.length; i++) {
- for (Figure next : myInput[i].getFigures()) {
+ for (FigureDescriptor next : myInput[i].getDescriptors()) {
String fqn = callback.visitFigure(next);
handle(next, fqn);
}
@@ -49,7 +49,7 @@ public class GalleryProcessor extends Processor {
/**
* does nothing by default, override to do smth usable
*/
- protected void handle(Figure next, String fqn) {
+ protected void handle(FigureDescriptor next, String fqn) {
}
public String[] getRequiredBundles(FigureQualifiedNameSwitch fqnSwitch) {
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Attrs.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Attrs.xpt
index d746b366c..4893c0346 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Attrs.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Attrs.xpt
@@ -10,7 +10,7 @@
* Artem Tikhomirov (Borland) - initial API and implementation
*/
-«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«REM»Define attributes for Figures (for DecorationFigure subclasses see Decoration.xpt)«ENDREM»
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Border.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Border.xpt
index 78e9f6b4b..02847b54f 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Border.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Border.xpt
@@ -10,46 +10,36 @@
* Artem Tikhomirov (Borland) - initial API and implementation
*/
-«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«EXTENSION Util»
-«DEFINE Init(EString figureVarName) FOR gmfgraph::Border-»
+«DEFINE Init(String figureVarName) FOR gmfgraph::Border-»
«figureVarName».setBorder(«EXPAND border(figureVarName)»);
«ENDDEFINE»
-«DEFINE border(EString figureVarName) FOR gmfgraph::Border»
-«ERROR "This is an abstract definition"»
+«DEFINE Init(String figureVarName) FOR gmfgraph::CustomBorder-»
+{
+ «EXPAND Runtime::newInstance("result")»
+ «EXPAND attr::CustomClass::Init("result")»
+ «figureVarName».setBorder(result);
+}
«ENDDEFINE»
-«DEFINE border(EString figureVarName) FOR gmfgraph::LineBorder-»
-new org.eclipse.draw2d.LineBorder(«IF null == color»null«ELSE»«EXPAND attr::Figure::color(figureVarName + "_BORDER") FOR color»«ENDIF», «EXPAND MapMode::map FOR width»)
+«DEFINE border(String figureVarName) FOR gmfgraph::Border»
+«ERROR "This is an abstract definition border(String, Border) invoked for " + this»
«ENDDEFINE»
-«DEFINE border(EString figureVarName) FOR gmfgraph::CompoundBorder-»
-new org.eclipse.draw2d.CompoundBorder(«IF null == outer»null«ELSE»«EXPAND border(figureVarName) FOR outer»«ENDIF», «IF null == inner»null«ELSE»«EXPAND border(figureVarName) FOR inner»«ENDIF»)
-«ENDDEFINE»
+«DEFINE border(String figureVarName) FOR gmfgraph::LineBorder-»
+new org.eclipse.draw2d.LineBorder(«IF null == color»null«ELSE»«EXPAND attr::Figure::color(figureVarName.toUpperCase() + "_BORDER") FOR color»«ENDIF», «EXPAND MapMode::map FOR width»)«ENDDEFINE»
-«DEFINE border(EString figureVarName) FOR gmfgraph::MarginBorder-»
-new org.eclipse.draw2d.MarginBorder(«EXPAND MapMode::map FOR insets»)
-«ENDDEFINE»
+«DEFINE border(String figureVarName) FOR gmfgraph::MarginBorder-»
+new org.eclipse.draw2d.MarginBorder(«EXPAND MapMode::map FOR insets»)«ENDDEFINE»
-«DEFINE border(EString figureVarName) FOR gmfgraph::CustomBorder-»
-«LET methodName(figureVarName) AS methodName-»
-«methodName»()
-«EXPAND customBorderMethod(methodName)-»
-«ENDLET-»
+«DEFINE border(String figureVarName) FOR gmfgraph::CompoundBorder-»
+new org.eclipse.draw2d.CompoundBorder(«IF outer == null»null«ELSE»«EXPAND internalNewInstance(figureVarName) FOR outer»«ENDIF», «IF inner == null»null«ELSE»«EXPAND internalNewInstance(figureVarName) FOR inner»«ENDIF»)
«ENDDEFINE»
-«DEFINE customBorderMethod(String methodName) FOR gmfgraph::CustomBorder-»
-«FILE "" additionalMethods-»
- /**
- * @generated
- */
- private org.eclipse.draw2d.Border «methodName»() {
- «EXPAND Runtime::newInstance("result")»
- «EXPAND attr::CustomClass::Init("result")»
- return result;
- }
-«ENDFILE-»
-«ENDDEFINE» \ No newline at end of file
+«DEFINE internalNewInstance(String figureVarName) FOR gmfgraph::Border-»
+«IF {this}.typeSelect(gmfgraph::CustomBorder).isEmpty()»«EXPAND border(figureVarName)»«ELSE»«EXPAND Runtime::newInstance»«ENDIF-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt
index f81dc9d14..3251db6ab 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Children.xpt
@@ -10,29 +10,29 @@
* Artem Tikhomirov (Borland) - initial API and implementation
*/
-«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«EXTENSION Util»
-«DEFINE CreateChildren FOR gmfgraph::Figure-»
+«DEFINE CreateChildren FOR gmfgraph::RealFigure-»
/**
* @generated
*/
private void createContents(){
-«EXPAND instantiate(0, this, "this") FOREACH children.typeSelect(gmfgraph::Figure)»
+«EXPAND instantiate(0, this, "this") FOREACH children»
}
-«EXPAND accessors FOREACH children.typeSelect(gmfgraph::Figure)»
«ENDDEFINE»
-«DEFINE instantiate(EInt count, gmfgraph::Figure parentFigure, String parentFigureVariable) FOR gmfgraph::FigureMarker»
-«ERROR "Placeholder, though should never get here as long as there\'s typeSelect above"»
+«DEFINE instantiate(EInt count, gmfgraph::RealFigure parentFigure, String parentFigureVariable) FOR gmfgraph::Figure»
+«ERROR "Abstract instantiate(int, RealFigure, String)"»
«ENDDEFINE»
-«DEFINE accessors FOR gmfgraph::FigureMarker»
-«ERROR "Placeholder, though should never get here as long as there\'s typeSelect above"»
+«DEFINE instantiate(EInt count, gmfgraph::RealFigure parentFigure, EString parentFigureVariable) FOR gmfgraph::FigureRef-»
+/*FIXME referenced figures are just not yet fully-functional; need process attrs and layout here*/
+«EXPAND instantiate(count, parentFigure, parentFigureVariable) FOR figure-»
«ENDDEFINE»
-«DEFINE instantiate(EInt count, gmfgraph::Figure parentFigure, EString parentFigureVariable) FOR gmfgraph::Figure»
+«DEFINE instantiate(EInt count, gmfgraph::RealFigure parentFigure, EString parentFigureVariable) FOR gmfgraph::RealFigure»
«LET figureVariableName(count) AS figureVarName»
«EXPAND newFigureInstance(figureVarName)»
«EXPAND Attrs::Init(figureVarName)-»
@@ -41,9 +41,9 @@
«ELSE-»
«EXPAND LayoutData::Init(parentFigureVariable, figureVarName) FOR layoutData-»
«ENDIF-»
-«IF !referencingElements.isEmpty()»«figureFieldSetter()»(«figureVarName»);«ENDIF-»
+«IF needsField()»«figureFieldName()» = «figureVarName»;«ENDIF-»
«EXPAND Layout::Init(figureVarName) FOR layout-»
-«EXPAND instantiate(count + 1, this, figureVarName) FOREACH children.typeSelect(gmfgraph::Figure)-»
+«EXPAND instantiate(count + 1, this, figureVarName) FOREACH children-»
«ENDLET»
«ENDDEFINE»
@@ -57,28 +57,3 @@ class «localClassName» extends «EXPAND Runtime::fqn» {
«localClassName» «figureVarName» = new «localClassName»();
«ENDLET-»
«ENDDEFINE»
-
-«DEFINE accessors FOR gmfgraph::Figure-»
-«IF !referencingElements.isEmpty()-»
- /**
- * @generated
- */
- private «EXPAND Runtime::fqn» «figureFieldName()»;
-
- /**
- * @generated
- */
- public «EXPAND Runtime::fqn» «figureFieldGetter()»() {
- return «figureFieldName()»;
- }
-
- /**
- * @generated
- */
- private void «figureFieldSetter()»(«EXPAND Runtime::fqn» fig){
- «figureFieldName()» = fig;
- }
-«ENDIF-»
-«EXPAND accessors FOREACH children.typeSelect(gmfgraph::Figure)»
-«ENDDEFINE»
-
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Decoration.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Decoration.xpt
index f0e5e8bca..0cc3ab646 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Decoration.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Decoration.xpt
@@ -10,7 +10,7 @@
* Artem Tikhomirov (Borland) - initial API and implementation
*/
-«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«EXTENSION Util»
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Extras.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Extras.xpt
index 43d54ef31..089b55874 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Extras.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Extras.xpt
@@ -10,10 +10,10 @@
* Artem Tikhomirov (Borland) - initial API and implementation
*/
-«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
-«DEFINE localCoordinates FOR gmfgraph::Figure»
+«DEFINE localCoordinates FOR gmfgraph::RealFigure»
/**
* @generated
*/
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Layout.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Layout.xpt
index 21e34200b..43cf8ce03 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Layout.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Layout.xpt
@@ -11,7 +11,7 @@
* Michael Golubev (Borland) - GridLayout attributes
*/
-«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«EXTENSION Util»
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/LayoutData.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/LayoutData.xpt
index e62434e39..e74cd6c97 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/LayoutData.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/LayoutData.xpt
@@ -10,7 +10,7 @@
* Artem Tikhomirov (Borland) - initial API and implementation
*/
-«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«EXTENSION Util»
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/MapMode.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/MapMode.xpt
index e08557d81..3d137edd6 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/MapMode.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/MapMode.xpt
@@ -10,7 +10,7 @@
* Artem Tikhomirov (Borland) - initial API and implementation
*/
-«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«REM»No mapMode at all«ENDREM»
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Runtime.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Runtime.xpt
index b66f8c80c..605c6b68f 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Runtime.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Runtime.xpt
@@ -10,7 +10,7 @@
* Artem Tikhomirov (Borland) - initial API and implementation
*/
-«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«EXTENSION Util»
@@ -50,6 +50,7 @@
«DEFINE fqn FOR BorderLayout»org.eclipse.draw2d.BorderLayout«ENDDEFINE»
////////////////////////
+«DEFINE fqn FOR FigureRef»«EXPAND fqn FOR figure»«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»
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.ext b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.ext
index a21f4176a..7c3dc7e49 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.ext
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.ext
@@ -10,10 +10,10 @@
* Artem Tikhomirov (Borland) - initial API and implementation
*/
-import "http://www.eclipse.org/gmf/2005/GraphicalDefinition";
+import "http://www.eclipse.org/gmf/2006/GraphicalDefinition";
import "http://www.eclipse.org/emf/2002/Ecore";
-EString compilationUnitName(gmfgraph::Figure figure) :
+String compilationUnitName(gmfgraph::FigureDescriptor figure) :
figure.name.toFirstUpper()
;
@@ -27,22 +27,10 @@ List[String] requiredBundles(List[String] referencedBundles) :
{"org.eclipse.core.runtime","org.eclipse.draw2d"}.union(referencedBundles).toList().purgeDups()
;
-String packageStatement() :
-GLOBALVAR packageStatement
-;
-
-String additionalMethods() :
-GLOBALVAR outputAdditionalMethods
-;
-
String additionalStaticFields() :
GLOBALVAR outputStaticFields
;
-String methodName(gmfgraph::CustomBorder customBorder, String figureVarName) :
- "createBorder" + figureVarName
-;
-
EBoolean hasTargetDecoration(gmfgraph::PolylineConnection figure) :
null != figure.targetDecoration
;
@@ -53,22 +41,49 @@ cached boolean isFullRuntime() :
private String internalCheckRuntimeToken() : GLOBALVAR runtimeToken;
-//nonNull(ecore::EObject obj) :
-// {obj}.select(e | null != e)
-//;
+boolean needsField(gmfgraph::RealFigure figure) :
+ // XXX consider adding generation option "fields for all figures"
+ figure.descriptor != null && figure.descriptor.accessors.figure.contains(figure)
+;
-figureVariableName(gmfgraph::Figure figure, EInt count) :
- figure.name.toFirstLower() + count
+String figureVariableName(gmfgraph::RealFigure figure, EInt count) :
+ figure.name != null && figure.name.trim().length() > 0 ?
+ figure.name.toFirstLower() + count :
+ variableNameStem(figure) + count
;
-figureFieldName(gmfgraph::Figure figure) :
- "f" + figure.name
+String nameStem(FigureRef fig) : variableNameStem(fig.figure);
+String nameStem(Figure fig) : variableNameStem(fig);
+
+// actually, should be smth like fig.eClass().name
+private String variableNameStem(Figure fig) : "fig";
+private String variableNameStem(RealFigure fig) : "fig";
+private String variableNameStem(Shape fig) : "shape";
+private String variableNameStem(Rectangle fig) : "rect";
+private String variableNameStem(RoundedRectangle fig) : "rrect";
+private String variableNameStem(Ellipse fig) : "elli";
+private String variableNameStem(Polyline fig) : "polyline";
+private String variableNameStem(Label fig) : "l";
+private String variableNameStem(DecorationFigure fig) : "dec";
+private String variableNameStem(ConnectionFigure fig) : "conn";
+
+
+// assert needsField() == true
+String figureFieldName(gmfgraph::RealFigure figure) :
+ figureFieldName(figure.descriptor.accessors.select(a | (figure == a.figure)))
;
-figureFieldGetter(gmfgraph::Figure figure) :
- "getFigure" + figure.name
+
+private String figureFieldName(List[ChildAccess] aaa) :
+ aaa.collect(x | figureFieldName(x)).toList().first()
;
-figureFieldSetter(gmfgraph::Figure figure) :
- "setFigure" + figure.name
+
+String figureFieldName(gmfgraph::ChildAccess childAccess) :
+ "f" + childAccess.accessor
+;
+
+// assert needsField() == true
+String figureFieldGetter(gmfgraph::ChildAccess childAccess) :
+ "getFigure" + childAccess.accessor
;
String borderLayoutConstant(gmfgraph::BorderLayoutData layoutData) :
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.xpt
index 26b38b281..974fb3977 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.xpt
@@ -9,7 +9,7 @@
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
*/
-«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«EXTENSION Util»
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Decoration.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Decoration.xpt
index 1ad81d328..98a90f00e 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Decoration.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Decoration.xpt
@@ -9,7 +9,7 @@
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
*/
-«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«IMPORT "templates"»
«EXTENSION Util»
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.xpt
index 8a08202c6..0b42ecbf6 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.xpt
@@ -9,7 +9,7 @@
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
*/
-«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«IMPORT "templates"»
«EXTENSION Util»
@@ -17,20 +17,21 @@
«DEFINE figureAttrs(EString figureVarName) FOR gmfgraph::Figure-»
«EXPAND foregroundColor(this, figureVarName) FOR foregroundColor-»
«EXPAND backgroundColor(this, figureVarName) FOR backgroundColor-»
-«EXPAND font(this, figureVarName) FOR font-»
+«EXPAND font(figureVarName) FOR font-»
«EXPAND preferredSize(figureVarName) FOR preferredSize-»
«EXPAND maximumSize(figureVarName) FOR maximumSize-»
«EXPAND minimumSize(figureVarName) FOR minimumSize-»
+«EXPAND position(figureVarName) FOR location-»
«EXPAND size(figureVarName) FOR size-»
«EXPAND insets(figureVarName) FOR insets-»
«EXPAND Border::Init(figureVarName) FOR border-»
«ENDDEFINE»
«DEFINE foregroundColor(gmfgraph::Figure figure, String figureVarName) FOR gmfgraph::Color-»
- «figureVarName».setForegroundColor(«EXPAND color(figure.name.toUpperCase() + "_FORE")»);
+ «figureVarName».setForegroundColor(«EXPAND color(figureVarName.toUpperCase() + "_FORE")»);
«ENDDEFINE»
«DEFINE backgroundColor(gmfgraph::Figure figure, String figureVarName) FOR gmfgraph::Color-»
- «figureVarName».setBackgroundColor(«EXPAND color(figure.name.toUpperCase() + "_BACK")»);
+ «figureVarName».setBackgroundColor(«EXPAND color(figureVarName.toUpperCase() + "_BACK")»);
«ENDDEFINE»
«DEFINE preferredSize(EString figureVarName) FOR gmfgraph::Dimension-»
@@ -45,6 +46,10 @@
«figureVarName».setMinimumSize(new org.eclipse.draw2d.geometry.Dimension(«EXPAND MapMode::map»));
«ENDDEFINE»
+«DEFINE position(String figureVarName) FOR gmfgraph::Point-»
+«figureVarName».setLocation(new org.eclipse.draw2d.geometry.Point(«EXPAND MapMode::map»));
+«ENDDEFINE»
+
«DEFINE size(EString figureVarName) FOR gmfgraph::Point-»
«figureVarName».setSize(«EXPAND MapMode::map»);
«ENDDEFINE»
@@ -54,7 +59,7 @@
«figureVarName».setBorder(new org.eclipse.draw2d.MarginBorder(«EXPAND MapMode::map»));
«ENDDEFINE»
-«DEFINE font(Figure figure, EString figureVarName) FOR gmfgraph::Font»
+«DEFINE font(String figureVarName) FOR gmfgraph::Font»
«ERROR "This is abstact definition, just to overcome some xpand polymorphism limitations"»
«ENDDEFINE»
@@ -76,8 +81,8 @@ static final org.eclipse.swt.graphics.Color «variableName» = new org.eclipse.swt
org.eclipse.draw2d.ColorConstants.«value.literal-»
«ENDDEFINE»
-«DEFINE font(Figure figure, EString figureVarName) FOR gmfgraph::BasicFont-»
-«LET figure.name + "_FONT" AS variableName»
+«DEFINE font(String figureVarName) FOR gmfgraph::BasicFont-»
+«LET figureVarName.toUpperCase() + "_FONT" AS variableName»
«figureVarName».setFont(«variableName»);
«FILE "" staticFields»
/**
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.xpt
index 0cc32c81f..5f8f472c6 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.xpt
@@ -9,17 +9,20 @@
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
*/
-«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
-// XXX call figureAttrs from this?
+«REM»
+org.eclipse.draw2d.Shape
+ private boolean fill = true, outline = true, xorFill, xorOutline;
+«ENDREM»
«DEFINE shapeAttrs(EString figureVarName) FOR Shape-»
-«EXPAND fill(figureVarName)-»
-«EXPAND xorFill(figureVarName)-»
-«EXPAND outline(figureVarName)-»
-«EXPAND xorOutline(figureVarName)-»
-«EXPAND lineWidth(figureVarName)-»
-«EXPAND lineKind(figureVarName)-»
+«IF !fill»«EXPAND fill(figureVarName)»«ENDIF-»
+«IF xorFill»«EXPAND xorFill(figureVarName)»«ENDIF-»
+«IF !outline»«EXPAND outline(figureVarName)»«ENDIF-»
+«IF xorOutline»«EXPAND xorOutline(figureVarName)»«ENDIF-»
+«IF lineWidth != 1»«EXPAND lineWidth(figureVarName)»«ENDIF-»
+«IF lineKind.value != LineKind::LINE_SOLID.value»«EXPAND lineKind(figureVarName)»«ENDIF-»
«ENDDEFINE»
«DEFINE fill(EString figureVarName) FOR Shape-»
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 16fb3877c..df990e44b 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/plugin/Manifest.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/plugin/Manifest.xpt
@@ -11,6 +11,10 @@
*/
«EXTENSION Util»
+/*
+ * FIXME add a simple model (either non-generated, .ecore only?) to descripbe GenConfig
+ */
+
«DEFINE Init(String pluginID, String pluginActivatorQualifiedName, List[String] exportedPackages, List[String] referencedBundles) FOR Object-»
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/rt_mm/MapMode.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/rt_mm/MapMode.xpt
index feb2c53d3..1ecc2cfec 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/rt_mm/MapMode.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/rt_mm/MapMode.xpt
@@ -10,7 +10,7 @@
* Artem Tikhomirov (Borland) - initial API and implementation
*/
-«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«EXTENSION rt_mm::MapModeUtil»
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Descriptor.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Descriptor.xpt
new file mode 100644
index 000000000..fb8f56d4b
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Descriptor.xpt
@@ -0,0 +1,57 @@
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
+«IMPORT "templates"»
+«EXTENSION Util»
+
+«DEFINE Top(String packageStmt) FOR gmfgraph::FigureDescriptor»
+«IF packageStmt != null && packageStmt.length() > 0»package «packageStmt»;
+«ENDIF-»
+/**
+ * @generated
+ */
+public class «compilationUnitName()» extends «EXPAND Runtime::fqn FOR actualFigure» {
+
+«EXPAND accessorField FOREACH accessors»
+
+«EXPAND Figure::ClassBody(compilationUnitName()) FOR actualFigure»
+
+«EXPAND accessorMethod FOREACH accessors»
+
+«additionalStaticFields()»
+}
+«ENDDEFINE»
+
+
+
+«DEFINE Inner FOR gmfgraph::FigureDescriptor»
+/**
+ * @generated
+ */
+public class «compilationUnitName()» extends «EXPAND Runtime::fqn FOR actualFigure» {
+
+«EXPAND accessorField FOREACH accessors»
+
+«EXPAND Figure::ClassBody(compilationUnitName()) FOR actualFigure»
+
+«EXPAND accessorMethod FOREACH accessors»
+}
+«additionalStaticFields()»
+«ENDDEFINE»
+
+
+«DEFINE accessorField FOR gmfgraph::ChildAccess-»
+ /**
+ * @generated
+ */
+ private «EXPAND Runtime::fqn FOR figure» «figureFieldName()»;
+«ENDDEFINE»
+
+«DEFINE accessorMethod FOR gmfgraph::ChildAccess-»
+ /**
+ * @generated
+ */
+ public «EXPAND Runtime::fqn FOR figure» «figureFieldGetter()»() {
+ return «figureFieldName()»;
+ }
+«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 ec4062fdf..6bf15569f 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt
@@ -10,21 +10,22 @@
* Artem Tikhomirov (Borland) - initial API and implementation
*/
-«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«IMPORT "templates"»
«EXTENSION Util»
-«DEFINE FigureClass(boolean isInnerClass) FOR gmfgraph::Figure-»
-«packageStatement()»
-/**
- * @generated
- */
-public class «compilationUnitName()» extends «EXPAND Runtime::fqn» {
+«DEFINE ClassBody(String cuName) FOR gmfgraph::Figure»«ERROR "abstract ClassBody(Figure)"»«ENDDEFINE»
+
+«DEFINE ClassBody(String cuName) FOR gmfgraph::FigureRef-»
+«EXPAND ClassBody(cuName) FOR figure-»
+«ENDDEFINE»
+
+«DEFINE ClassBody(String cuName) FOR gmfgraph::RealFigure-»
/**
* @generated
*/
- public «compilationUnitName()»() {
+ public «cuName»() {
«EXPAND Layout::Init("this") FOR layout-»
«EXPAND Attrs::Init("this")-»
«IF !children.typeSelect(Figure).isEmpty()-»
@@ -34,30 +35,16 @@ public class «compilationUnitName()» extends «EXPAND Runtime::fqn» {
«ELSE-»
}
«ENDIF-»
-«additionalMethods()»
«EXPAND Extras::extraMethods»
«EXPAND Extras::localCoordinates»
-«IF isInnerClass-»
-}
-«additionalStaticFields()»
-«ELSE-»
-«additionalStaticFields()»
-}
-«ENDIF-»
+«EXPAND additions-»
«ENDDEFINE»
-
-«DEFINE FigureClass(boolean isInnerClass) FOR gmfgraph::PolylineConnection-»
-«packageStatement()»
-/**
- * @generated
- */
-public class «compilationUnitName()» extends «EXPAND Runtime::fqn» {
-
+«DEFINE ClassBody(String cuName) FOR gmfgraph::PolylineConnection-»
/**
* @generated
*/
- public «compilationUnitName()»() {
+ public «cuName»() {
«EXPAND Attrs::Init("this")»
«IF hasSourceDecoration()-»
setSourceDecoration(createSourceDecoration());
@@ -84,12 +71,8 @@ public class «compilationUnitName()» extends «EXPAND Runtime::fqn» {
return df;
}
«ENDIF-»
-«additionalMethods()»
-«IF isInnerClass-»
-}
-«additionalStaticFields()»
-«ELSE-»
-«additionalStaticFields()»
-}
-«ENDIF-»
-«ENDDEFINE» \ No newline at end of file
+«EXPAND additions-»
+«ENDDEFINE»
+
+«REM»Our regular way to add smth inside generated class body«ENDREM»
+«DEFINE additions FOR gmfgraph::Figure»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/xtras/ScalablePolygon.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/xtras/ScalablePolygon.xpt
index b3e48e828..fa29cce91 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/xtras/ScalablePolygon.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/xtras/ScalablePolygon.xpt
@@ -10,7 +10,7 @@
* Michael Golubev (Borland) - initial API and implementation
*/
-«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»

Back to the top