Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-02-13 17:36:07 +0000
committeratikhomirov2006-02-13 17:36:07 +0000
commitf8757a97d7e3a5e73cbc0be2d438e3921bc2a2e8 (patch)
treec3712afb5d03429a0b1f9a44a2694d1fb180ef5b /plugins/org.eclipse.gmf.graphdef.codegen
parent80e4035d3bf83b8a35983bc23587f49485a14d3e (diff)
downloadorg.eclipse.gmf-tooling-f8757a97d7e3a5e73cbc0be2d438e3921bc2a2e8.tar.gz
org.eclipse.gmf-tooling-f8757a97d7e3a5e73cbc0be2d438e3921bc2a2e8.tar.xz
org.eclipse.gmf-tooling-f8757a97d7e3a5e73cbc0be2d438e3921bc2a2e8.zip
[mgolubev] #127252 layout support
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/META-INF/MANIFEST.MF12
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java30
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/GraphDefDispatcher.java59
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/CustomClassAttributesGenerator.java87
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java24
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitBorderLayoutDataGenerator.java77
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitBorderLayoutGenerator.java54
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitCustomLayoutDataGenerator.java46
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitCustomLayoutGenerator.java34
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitGridLayoutDataGenerator.java120
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitGridLayoutGenerator.java85
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewFigureGenerator.java7
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewLayoutDataGenerator.java44
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewLayoutGenerator.java63
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java94
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet36
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet10
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/BorderLayout.javajet17
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/CustomLayout.javajet8
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/GridLayout.javajet25
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/BorderLayoutData.javajet40
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/CustomLayoutData.javajet10
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/GridLayoutData.javajet31
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet5
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Layout.javajet21
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LayoutData.javajet16
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet18
27 files changed, 1006 insertions, 67 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/META-INF/MANIFEST.MF b/plugins/org.eclipse.gmf.graphdef.codegen/META-INF/MANIFEST.MF
index 60c5f7b1b..1713ab36e 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/META-INF/MANIFEST.MF
@@ -1,13 +1,15 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
+Bundle-Name: Graphical Definition Code Generator
Bundle-SymbolicName: org.eclipse.gmf.graphdef.codegen;singleton:=true
Bundle-Version: 1.0.0.qualifier
-Bundle-Vendor: %providerName
+Bundle-Vendor: Eclipse.org
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.gmf.graphdef;visibility:=reexport,
- org.eclipse.gmf.common,
org.eclipse.emf.ecore,
- org.eclipse.emf.codegen
+ org.eclipse.gmf.common,
+ org.eclipse.gmf.graphdef;visibility:=reexport,
+ org.eclipse.emf.codegen,
+ org.eclipse.draw2d
+
Export-Package: org.eclipse.gmf.graphdef.codegen
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 7b4d856c7..43d46202d 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
@@ -15,7 +15,13 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.codegen.jet.JETException;
import org.eclipse.gmf.common.codegen.ImportAssistant;
import org.eclipse.gmf.common.codegen.NullImportAssistant;
+import org.eclipse.gmf.gmfgraph.BorderLayout;
+import org.eclipse.gmf.gmfgraph.BorderLayoutData;
+import org.eclipse.gmf.gmfgraph.CustomLayout;
+import org.eclipse.gmf.gmfgraph.CustomLayoutData;
import org.eclipse.gmf.gmfgraph.Figure;
+import org.eclipse.gmf.gmfgraph.GridLayout;
+import org.eclipse.gmf.gmfgraph.GridLayoutData;
import org.eclipse.gmf.gmfgraph.Label;
import org.eclipse.gmf.gmfgraph.PolygonDecoration;
import org.eclipse.gmf.gmfgraph.Polyline;
@@ -25,10 +31,19 @@ import org.eclipse.gmf.gmfgraph.RoundedRectangle;
import org.eclipse.gmf.gmfgraph.Shape;
import org.eclipse.gmf.gmfgraph.util.FigureQualifiedNameSwitch;
import org.eclipse.gmf.gmfgraph.util.GMFGraphSwitch;
+import org.eclipse.gmf.graphdef.codegen.templates.CustomClassAttributesGenerator;
import org.eclipse.gmf.graphdef.codegen.templates.FigureAttrGenerator;
import org.eclipse.gmf.graphdef.codegen.templates.FigureChildrenGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.InitBorderLayoutDataGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.InitBorderLayoutGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.InitCustomLayoutDataGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.InitCustomLayoutGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.InitGridLayoutDataGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.InitGridLayoutGenerator;
import org.eclipse.gmf.graphdef.codegen.templates.LabelAttrGenerator;
import org.eclipse.gmf.graphdef.codegen.templates.NewFigureGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.NewLayoutDataGenerator;
+import org.eclipse.gmf.graphdef.codegen.templates.NewLayoutGenerator;
import org.eclipse.gmf.graphdef.codegen.templates.PolygonDecorationAttrGenerator;
import org.eclipse.gmf.graphdef.codegen.templates.PolylineAttrGenerator;
import org.eclipse.gmf.graphdef.codegen.templates.PolylineDecorationAttrGenerator;
@@ -101,7 +116,7 @@ public class FigureGenerator {
tr.put(Figure.class, "/templates/top/Figure.javajet", TopFigureGenerator.class);
return tr;
}
-
+
// XXX NOTE, the fact we use "instantiate" and "Children" strings
// helps us to postpone resolution of the next problem (one we make these twwo overridable):
// it's not possible to tell from single dispatcher.dispatch(Figure, args) what's the intention -
@@ -124,6 +139,19 @@ public class FigureGenerator {
tr.put("Shape", "/templates/attr/Shape.javajet", ShapeAttrGenerator.class);
tr.put("Figure", "/templates/attr/Figure.javajet", FigureAttrGenerator.class);
tr.put("PolylineDecoration", "/templates/attr/PolylineDecoration.javajet", PolylineDecorationAttrGenerator.class);
+
+ // Custom attributes support
+ tr.put("customAttributes", "/templates/attr/CustomConfigurableClass.javajet", CustomClassAttributesGenerator.class);
+ // Layout related dispatching chain.
+ tr.put("createLayout", "/templates/new/Layout.javajet", NewLayoutGenerator.class);
+ tr.put(GridLayout.class, "/templates/layout/GridLayout.javajet", InitGridLayoutGenerator.class);
+ tr.put(BorderLayout.class, "/templates/layout/BorderLayout.javajet", InitBorderLayoutGenerator.class);
+ tr.put(CustomLayout.class, "/templates/layout/CustomLayout.javajet", InitCustomLayoutGenerator.class);
+
+ tr.put("createLayoutData", "/templates/new/LayoutData.javajet", NewLayoutDataGenerator.class);
+ tr.put(GridLayoutData.class, "/templates/layoutData/GridLayoutData.javajet", InitGridLayoutDataGenerator.class);
+ tr.put(BorderLayoutData.class, "/templates/layoutData/BorderLayoutData.javajet", InitBorderLayoutDataGenerator.class);
+ tr.put(CustomLayoutData.class, "/templates/layoutData/CustomLayoutData.javajet", InitCustomLayoutDataGenerator.class);
return tr;
}
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 045f2df90..20634d921 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
@@ -13,6 +13,8 @@ package org.eclipse.gmf.graphdef.codegen;
import org.eclipse.gmf.common.codegen.ImportAssistant;
import org.eclipse.gmf.gmfgraph.Figure;
+import org.eclipse.gmf.gmfgraph.Layout;
+import org.eclipse.gmf.gmfgraph.LayoutData;
import org.eclipse.gmf.gmfgraph.util.GMFGraphSwitch;
import org.eclipse.gmf.internal.codegen.dispatch.DispatcherImpl;
import org.eclipse.gmf.internal.codegen.dispatch.EmitterFactory;
@@ -30,7 +32,7 @@ public class GraphDefDispatcher extends DispatcherImpl {
myImportManager = importManager;
myFqnSwitch = fqnSwitch;
}
-
+
public ImportAssistant getImportManager() {
return myImportManager;
}
@@ -38,12 +40,23 @@ public class GraphDefDispatcher extends DispatcherImpl {
public GMFGraphSwitch getFQNSwitch() {
return myFqnSwitch;
}
-
-
+
public Args create(Figure figure, String figureVarName) {
return new Args(this, figure, figureVarName);
}
+ public LayoutArgs createLayoutArgs(Args inherit, String layoutVarName) {
+ return new LayoutArgs(inherit, layoutVarName);
+ }
+
+ public LayoutArgs createLayoutArgs(Args inherit) {
+ return new LayoutArgs(inherit);
+ }
+
+ public LayoutArgs createLayoutArgs(Figure figure, String figureVarName, String layoutVarName) {
+ return new LayoutArgs(this, figure, figureVarName, layoutVarName);
+ }
+
public static class Args {
private final Figure myFigure;
private final String myFigureVarName;
@@ -55,6 +68,10 @@ public class GraphDefDispatcher extends DispatcherImpl {
myFigureVarName = figureVarName;
}
+ protected Args(Args other) {
+ this(other.getDispatcher(), other.getFigure(), other.getVariableName());
+ }
+
public Figure getFigure() {
return myFigure;
}
@@ -67,4 +84,40 @@ public class GraphDefDispatcher extends DispatcherImpl {
return myOwner;
}
}
+
+ public static class LayoutArgs extends Args {
+ private final String myLayoutVariableName;
+
+ /**
+ * @param layoutVariableName
+ * may be either name of layout manager or figure constraint,
+ * because there are no contexts requiring both of names in the
+ * same time
+ */
+ public LayoutArgs(Args inherit, String layoutVariableName) {
+ super(inherit);
+ myLayoutVariableName = layoutVariableName;
+ }
+
+ public LayoutArgs(Args args) {
+ this(args, args.getVariableName() + "Layout");
+ }
+
+ public LayoutArgs(GraphDefDispatcher owner, Figure figure, String figureVarName, String layoutVarName) {
+ super(owner, figure, figureVarName);
+ myLayoutVariableName = layoutVarName;
+ }
+
+ public Layout getLayout() {
+ return getFigure().getLayout();
+ }
+
+ public LayoutData getData() {
+ return getFigure().getLayoutData();
+ }
+
+ public String getLayoutVariableName() {
+ return myLayoutVariableName;
+ }
+ }
}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/CustomClassAttributesGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/CustomClassAttributesGenerator.java
new file mode 100644
index 000000000..69138c367
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/CustomClassAttributesGenerator.java
@@ -0,0 +1,87 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.emf.codegen.util.CodeGenUtil;
+import java.util.*;
+
+public class CustomClassAttributesGenerator
+{
+ protected static String nl;
+ public static synchronized CustomClassAttributesGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CustomClassAttributesGenerator result = new CustomClassAttributesGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = NL + "\t\t{";
+ protected final String TEXT_2 = NL + "\t\t\t";
+ protected final String TEXT_3 = ";";
+ protected final String TEXT_4 = NL + "\t\t\t";
+ protected final String TEXT_5 = ".";
+ protected final String TEXT_6 = " = ";
+ protected final String TEXT_7 = ";\t\t";
+ protected final String TEXT_8 = NL + "\t\t\t";
+ protected final String TEXT_9 = ".set";
+ protected final String TEXT_10 = "(";
+ protected final String TEXT_11 = ");";
+ protected final String TEXT_12 = "\t";
+ protected final String TEXT_13 = NL + "\t\t}" + NL;
+ protected final String TEXT_14 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+final CustomClass instance = (CustomClass) ((Object[]) argument)[0];
+//final GraphDefDispatcher dispatcher = (GraphDefDispatcher) ((Object[]) argument)[1];
+final String varName = (String) ((Object[]) argument)[2];
+
+ stringBuffer.append(TEXT_1);
+
+int attrIndex = 0;
+for (Iterator attrs = instance.getAttributes().iterator(); attrs.hasNext(); attrIndex++){
+ CustomAttribute next = (CustomAttribute) attrs.next();
+ String varValue;
+ if (next.isMultiStatementValue()){
+ varValue = "attr" + attrIndex;
+
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(java.text.MessageFormat.format(next.getValue(), new Object[] {varValue}));
+ stringBuffer.append(TEXT_3);
+ } else {
+ varValue = next.getValue();
+}
+ if (next.isDirectAccess()) {
+
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(varName);
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(next.getName());
+ stringBuffer.append(TEXT_6);
+ stringBuffer.append(varValue);
+ stringBuffer.append(TEXT_7);
+
+ } else {
+
+ stringBuffer.append(TEXT_8);
+ stringBuffer.append(varName);
+ stringBuffer.append(TEXT_9);
+ stringBuffer.append(CodeGenUtil.capName(next.getName()));
+ stringBuffer.append(TEXT_10);
+ stringBuffer.append(varValue);
+ stringBuffer.append(TEXT_11);
+
+ }
+
+ stringBuffer.append(TEXT_12);
+
+} //for
+
+ stringBuffer.append(TEXT_13);
+ stringBuffer.append(TEXT_14);
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java
index 23c834123..976cf05a7 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureChildrenGenerator.java
@@ -1,7 +1,7 @@
package org.eclipse.gmf.graphdef.codegen.templates;
import org.eclipse.gmf.gmfgraph.*;
-import org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher;
+import org.eclipse.gmf.graphdef.codegen.*;
import java.util.*;
public class FigureChildrenGenerator
@@ -19,9 +19,10 @@ public class FigureChildrenGenerator
protected final String TEXT_1 = "";
protected final String TEXT_2 = NL + "\t\t// FIXME instantiate - FigureRef - dispatch to 'instantiate' template?" + NL + "\t\t";
protected final String TEXT_3 = NL + "\t\t";
- protected final String TEXT_4 = ".add(";
- protected final String TEXT_5 = ");";
- protected final String TEXT_6 = NL;
+ protected final String TEXT_4 = NL + "\t\t";
+ protected final String TEXT_5 = ".add(";
+ protected final String TEXT_6 = ");" + NL + "\t\t";
+ protected final String TEXT_7 = NL;
public String generate(Object argument)
{
@@ -49,14 +50,19 @@ while (!l.isEmpty()) {
if (figureMarker instanceof FigureRef) {
throw new IllegalStateException("FIXME: sorry, don't support FigureRef for a while");
}
- final String figureVarName = "fig" + (figureCount++);
+ final String figureVarName = "fig" + figureCount;
+ final String layoutDataVarName = "layData" + figureCount;
+ figureCount++;
stringBuffer.append(TEXT_2);
- stringBuffer.append(dispatcher.dispatch("instantiate", dispatcher.create((Figure) figureMarker, figureVarName)));
+ GraphDefDispatcher.Args dargs = dispatcher.create((Figure) figureMarker, figureVarName);
stringBuffer.append(TEXT_3);
- stringBuffer.append(parentFigureVarName);
+ stringBuffer.append(dispatcher.dispatch("instantiate", dargs));
stringBuffer.append(TEXT_4);
- stringBuffer.append(figureVarName);
+ stringBuffer.append(parentFigureVarName);
stringBuffer.append(TEXT_5);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_6);
+ stringBuffer.append(dispatcher.dispatch("createLayoutData", dispatcher.createLayoutArgs(dargs, layoutDataVarName)));
if (_nxt instanceof Figure && !((Figure) _nxt).getChildren().isEmpty()) {
l.addFirst(marker);
@@ -66,7 +72,7 @@ if (_nxt instanceof Figure && !((Figure) _nxt).getChildren().isEmpty()) {
} // if
} // while
- stringBuffer.append(TEXT_6);
+ stringBuffer.append(TEXT_7);
return stringBuffer.toString();
}
}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitBorderLayoutDataGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitBorderLayoutDataGenerator.java
new file mode 100644
index 000000000..8d4208140
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitBorderLayoutDataGenerator.java
@@ -0,0 +1,77 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.graphdef.codegen.*;
+
+public class InitBorderLayoutDataGenerator
+{
+ protected static String nl;
+ public static synchronized InitBorderLayoutDataGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ InitBorderLayoutDataGenerator result = new InitBorderLayoutDataGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL + "\t\t";
+ protected final String TEXT_3 = ".getParent().getLayoutManager().setConstraint(";
+ protected final String TEXT_4 = ", ";
+ protected final String TEXT_5 = ".";
+ protected final String TEXT_6 = ");" + NL;
+ protected final String TEXT_7 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final BorderLayoutData gmfLayoutData = (BorderLayoutData) argsBundle.getData();
+final String figureVarName = argsBundle.getVariableName();
+final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
+
+ stringBuffer.append(TEXT_1);
+
+Alignment alignment = gmfLayoutData.getAlignment();
+if (alignment == null){
+ alignment = Alignment.CENTER_LITERAL;
+}
+final String constantName;
+switch(alignment.getValue()){
+ case Alignment.CENTER:
+ case Alignment.FILL:
+ constantName = "CENTER";
+ break;
+ case Alignment.BEGINNING:
+ if (gmfLayoutData.isVertical()){
+ constantName = "TOP";
+ } else {
+ constantName = "LEFT";
+ }
+ break;
+ case Alignment.END:
+ if (gmfLayoutData.isVertical()){
+ constantName = "BOTTOM";
+ } else {
+ constantName = "RIGHT";
+ }
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown Alignment: " + gmfLayoutData.getAlignment());
+}
+
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(dispatcher.getImportManager().getImportedName("org.eclipse.draw2d.BorderLayout"));
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(constantName);
+ stringBuffer.append(TEXT_6);
+ stringBuffer.append(TEXT_7);
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitBorderLayoutGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitBorderLayoutGenerator.java
new file mode 100644
index 000000000..d0b9649a7
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitBorderLayoutGenerator.java
@@ -0,0 +1,54 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.graphdef.codegen.*;
+
+public class InitBorderLayoutGenerator
+{
+ protected static String nl;
+ public static synchronized InitBorderLayoutGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ InitBorderLayoutGenerator result = new InitBorderLayoutGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL + "\t\t";
+ protected final String TEXT_3 = ".setHorizontalSpacing(";
+ protected final String TEXT_4 = ");" + NL + "\t\t";
+ protected final String TEXT_5 = ".setVerticalSpacing(";
+ protected final String TEXT_6 = ");";
+ protected final String TEXT_7 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final BorderLayout gmfLayout = (BorderLayout) argsBundle.getLayout();
+final String layouterVarName = argsBundle.getLayoutVariableName();
+
+ stringBuffer.append(TEXT_1);
+
+Dimension spacing = gmfLayout.getSpacing();
+if (spacing != null){
+
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(layouterVarName);
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(spacing.getDx());
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(layouterVarName);
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(spacing.getDy());
+ stringBuffer.append(TEXT_6);
+
+}
+
+ stringBuffer.append(TEXT_7);
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitCustomLayoutDataGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitCustomLayoutDataGenerator.java
new file mode 100644
index 000000000..e2ec6256c
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitCustomLayoutDataGenerator.java
@@ -0,0 +1,46 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.graphdef.codegen.*;
+
+public class InitCustomLayoutDataGenerator
+{
+ protected static String nl;
+ public static synchronized InitCustomLayoutDataGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ InitCustomLayoutDataGenerator result = new InitCustomLayoutDataGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = " ";
+ protected final String TEXT_3 = " = new ";
+ protected final String TEXT_4 = "();";
+ protected final String TEXT_5 = NL;
+ protected final String TEXT_6 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+GraphDefDispatcher.LayoutArgs args = (GraphDefDispatcher.LayoutArgs) argument;
+final CustomLayoutData layoutData = (CustomLayoutData) args.getData();
+final GraphDefDispatcher dispatcher = args.getDispatcher();
+final String layoutImplClassName = dispatcher.getImportManager().getImportedName((String) dispatcher.getFQNSwitch().doSwitch(layoutData));
+
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(layoutImplClassName);
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(args.getLayoutVariableName());
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(layoutImplClassName);
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(dispatcher.dispatch("customAttributes", new Object[] {layoutData, dispatcher, args.getLayoutVariableName()}));
+ stringBuffer.append(TEXT_6);
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitCustomLayoutGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitCustomLayoutGenerator.java
new file mode 100644
index 000000000..c687f0b47
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitCustomLayoutGenerator.java
@@ -0,0 +1,34 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.graphdef.codegen.*;
+
+public class InitCustomLayoutGenerator
+{
+ protected static String nl;
+ public static synchronized InitCustomLayoutGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ InitCustomLayoutGenerator result = new InitCustomLayoutGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final CustomLayout layout = (CustomLayout) argsBundle.getLayout();
+final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
+
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(dispatcher.dispatch("customAttributes", new Object[] {layout, dispatcher, argsBundle.getLayoutVariableName()} ));
+ stringBuffer.append(TEXT_2);
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitGridLayoutDataGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitGridLayoutDataGenerator.java
new file mode 100644
index 000000000..ff12032c6
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitGridLayoutDataGenerator.java
@@ -0,0 +1,120 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.graphdef.codegen.*;
+
+public class InitGridLayoutDataGenerator
+{
+ protected static String nl;
+ public static synchronized InitGridLayoutDataGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ InitGridLayoutDataGenerator result = new InitGridLayoutDataGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "\t\t\t";
+ protected final String TEXT_2 = " ";
+ protected final String TEXT_3 = " = new ";
+ protected final String TEXT_4 = "();" + NL + "\t\t\t";
+ protected final String TEXT_5 = ".verticalAlignment = ";
+ protected final String TEXT_6 = ";" + NL + "\t\t\t";
+ protected final String TEXT_7 = ".horizontalAlignment = ";
+ protected final String TEXT_8 = ";";
+ protected final String TEXT_9 = NL + "\t\t\t";
+ protected final String TEXT_10 = ".widthHint = ";
+ protected final String TEXT_11 = ";" + NL + "\t\t\t";
+ protected final String TEXT_12 = ".heightHint = ";
+ protected final String TEXT_13 = ";";
+ protected final String TEXT_14 = NL + "\t\t\t";
+ protected final String TEXT_15 = ".horizontalIndent = ";
+ protected final String TEXT_16 = ";" + NL + "\t\t\t";
+ protected final String TEXT_17 = ".horizontalSpan = ";
+ protected final String TEXT_18 = ";" + NL + "\t\t\t";
+ protected final String TEXT_19 = ".verticalSpan = ";
+ protected final String TEXT_20 = ";" + NL + "\t\t\t";
+ protected final String TEXT_21 = ".grabExcessHorizontalSpace = ";
+ protected final String TEXT_22 = ";" + NL + "\t\t\t";
+ protected final String TEXT_23 = ".grabExcessVerticalSpace = ";
+ protected final String TEXT_24 = ";" + NL + "\t\t\t";
+ protected final String TEXT_25 = ".getParent().getLayoutManager().setConstraint(";
+ protected final String TEXT_26 = ", ";
+ protected final String TEXT_27 = ");" + NL;
+ protected final String TEXT_28 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final GridLayoutData gmfLayoutData = (GridLayoutData) argsBundle.getData();
+final String figureVarName = argsBundle.getVariableName();
+final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
+final String layoutConstraintVarName = argsBundle.getLayoutVariableName();
+
+final String layoutImplClassName = dispatcher.getImportManager().getImportedName((String) dispatcher.getFQNSwitch().doSwitch(gmfLayoutData));
+
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(layoutImplClassName);
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(layoutConstraintVarName);
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(layoutImplClassName);
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(layoutConstraintVarName);
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(gmfLayoutData.getVerticalAlignment().getValue());
+ stringBuffer.append(TEXT_6);
+ stringBuffer.append(layoutConstraintVarName);
+ stringBuffer.append(TEXT_7);
+ stringBuffer.append(gmfLayoutData.getHorizontalAlignment().getValue());
+ stringBuffer.append(TEXT_8);
+
+Dimension sizeHint = gmfLayoutData.getSizeHint();
+if (sizeHint != null){
+
+ stringBuffer.append(TEXT_9);
+ stringBuffer.append(layoutConstraintVarName);
+ stringBuffer.append(TEXT_10);
+ stringBuffer.append(sizeHint.getDx());
+ stringBuffer.append(TEXT_11);
+ stringBuffer.append(layoutConstraintVarName);
+ stringBuffer.append(TEXT_12);
+ stringBuffer.append(sizeHint.getDy());
+ stringBuffer.append(TEXT_13);
+
+}
+
+ stringBuffer.append(TEXT_14);
+ stringBuffer.append(layoutConstraintVarName);
+ stringBuffer.append(TEXT_15);
+ stringBuffer.append(gmfLayoutData.getHorizontalIndent());
+ stringBuffer.append(TEXT_16);
+ stringBuffer.append(layoutConstraintVarName);
+ stringBuffer.append(TEXT_17);
+ stringBuffer.append(gmfLayoutData.getHorizontalSpan());
+ stringBuffer.append(TEXT_18);
+ stringBuffer.append(layoutConstraintVarName);
+ stringBuffer.append(TEXT_19);
+ stringBuffer.append(gmfLayoutData.getVerticalSpan());
+ stringBuffer.append(TEXT_20);
+ stringBuffer.append(layoutConstraintVarName);
+ stringBuffer.append(TEXT_21);
+ stringBuffer.append(gmfLayoutData.isGrabExcessHorizontalSpace());
+ stringBuffer.append(TEXT_22);
+ stringBuffer.append(layoutConstraintVarName);
+ stringBuffer.append(TEXT_23);
+ stringBuffer.append(gmfLayoutData.isGrabExcessVerticalSpace());
+ stringBuffer.append(TEXT_24);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_25);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_26);
+ stringBuffer.append(layoutConstraintVarName);
+ stringBuffer.append(TEXT_27);
+ stringBuffer.append(TEXT_28);
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitGridLayoutGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitGridLayoutGenerator.java
new file mode 100644
index 000000000..552996c12
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/InitGridLayoutGenerator.java
@@ -0,0 +1,85 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.graphdef.codegen.*;
+
+public class InitGridLayoutGenerator
+{
+ protected static String nl;
+ public static synchronized InitGridLayoutGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ InitGridLayoutGenerator result = new InitGridLayoutGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "\t\t";
+ protected final String TEXT_2 = ".numColumns = ";
+ protected final String TEXT_3 = ";" + NL + "\t\t";
+ protected final String TEXT_4 = ".makeColumnsEqualWidth = ";
+ protected final String TEXT_5 = ";";
+ protected final String TEXT_6 = NL + "\t\t";
+ protected final String TEXT_7 = ".marginWidth = ";
+ protected final String TEXT_8 = ";" + NL + "\t\t";
+ protected final String TEXT_9 = ".marginHeight = ";
+ protected final String TEXT_10 = ";";
+ protected final String TEXT_11 = NL + "\t\t";
+ protected final String TEXT_12 = ".horizontalSpacing = ";
+ protected final String TEXT_13 = ";" + NL + "\t\t";
+ protected final String TEXT_14 = ".verticalSpacing = ";
+ protected final String TEXT_15 = ";";
+ protected final String TEXT_16 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final GridLayout gmfLayout = (GridLayout) argsBundle.getLayout();
+final String layouterVarName = argsBundle.getLayoutVariableName();
+
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(layouterVarName);
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(gmfLayout.getNumColumns());
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(layouterVarName);
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(gmfLayout.isEqualWidth());
+ stringBuffer.append(TEXT_5);
+
+Dimension margins = gmfLayout.getMargins();
+if (margins != null){
+
+ stringBuffer.append(TEXT_6);
+ stringBuffer.append(layouterVarName);
+ stringBuffer.append(TEXT_7);
+ stringBuffer.append(margins.getDx());
+ stringBuffer.append(TEXT_8);
+ stringBuffer.append(layouterVarName);
+ stringBuffer.append(TEXT_9);
+ stringBuffer.append(margins.getDy());
+ stringBuffer.append(TEXT_10);
+
+}
+Dimension spacing = gmfLayout.getSpacing();
+if (spacing != null){
+
+ stringBuffer.append(TEXT_11);
+ stringBuffer.append(layouterVarName);
+ stringBuffer.append(TEXT_12);
+ stringBuffer.append(spacing.getDx());
+ stringBuffer.append(TEXT_13);
+ stringBuffer.append(layouterVarName);
+ stringBuffer.append(TEXT_14);
+ stringBuffer.append(spacing.getDy());
+ stringBuffer.append(TEXT_15);
+
+}
+
+ stringBuffer.append(TEXT_16);
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewFigureGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewFigureGenerator.java
index 5d631465c..0d0d42ca7 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewFigureGenerator.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewFigureGenerator.java
@@ -1,7 +1,7 @@
package org.eclipse.gmf.graphdef.codegen.templates;
import org.eclipse.gmf.gmfgraph.*;
-import org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher;
+import org.eclipse.gmf.graphdef.codegen.*;
public class NewFigureGenerator
{
@@ -20,6 +20,8 @@ public class NewFigureGenerator
protected final String TEXT_3 = " = new ";
protected final String TEXT_4 = "();";
protected final String TEXT_5 = NL;
+ protected final String TEXT_6 = NL;
+ protected final String TEXT_7 = NL;
public String generate(Object argument)
{
@@ -42,6 +44,9 @@ final String figureClassName = dispatcher.getImportManager().getImportedName((St
stringBuffer.append(TEXT_4);
stringBuffer.append(TEXT_5);
stringBuffer.append(args.getDispatcher().dispatch(figureInstance, args));
+ stringBuffer.append(TEXT_6);
+ stringBuffer.append(args.getDispatcher().dispatch("createLayout", dispatcher.createLayoutArgs(args)));
+ stringBuffer.append(TEXT_7);
return stringBuffer.toString();
}
}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewLayoutDataGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewLayoutDataGenerator.java
new file mode 100644
index 000000000..2abce94e3
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewLayoutDataGenerator.java
@@ -0,0 +1,44 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.graphdef.codegen.*;
+
+public class NewLayoutDataGenerator
+{
+ protected static String nl;
+ public static synchronized NewLayoutDataGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ NewLayoutDataGenerator result = new NewLayoutDataGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = "\t\t\t";
+ protected final String TEXT_3 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+// NOTE: this code expects that constrainted figure is already added to its parent
+
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
+final LayoutData gmfLayoutData = argsBundle.getData();
+final Figure figureInstance = argsBundle.getFigure();
+
+// merely makes sure layoutData present
+// and parent figure got chance to have layout initialized
+
+if (gmfLayoutData != null && figureInstance.getParent() != null && figureInstance.getParent().getLayout() != null) {
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append(dispatcher.dispatch(gmfLayoutData, argsBundle));
+ stringBuffer.append(TEXT_2);
+ }
+ stringBuffer.append(TEXT_3);
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewLayoutGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewLayoutGenerator.java
new file mode 100644
index 000000000..07c371abc
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/NewLayoutGenerator.java
@@ -0,0 +1,63 @@
+package org.eclipse.gmf.graphdef.codegen.templates;
+
+import org.eclipse.gmf.gmfgraph.*;
+import org.eclipse.gmf.graphdef.codegen.*;
+
+public class NewLayoutGenerator
+{
+ protected static String nl;
+ public static synchronized NewLayoutGenerator create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ NewLayoutGenerator result = new NewLayoutGenerator();
+ nl = null;
+ return result;
+ }
+
+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL + "\t\t";
+ protected final String TEXT_3 = " ";
+ protected final String TEXT_4 = " = new ";
+ protected final String TEXT_5 = "();" + NL + "\t\t";
+ protected final String TEXT_6 = "\t" + NL + "\t\t";
+ protected final String TEXT_7 = ".setLayoutManager(";
+ protected final String TEXT_8 = ");";
+ protected final String TEXT_9 = NL;
+
+ public String generate(Object argument)
+ {
+ StringBuffer stringBuffer = new StringBuffer();
+
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final FigureMarker figureMarker = argsBundle.getFigure();
+final String figureVarName = argsBundle.getVariableName();
+final String layouterVarName = argsBundle.getLayoutVariableName();
+final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
+
+ stringBuffer.append(TEXT_1);
+
+Layout gmfLayout= figureMarker.getLayout();
+if (gmfLayout != null){
+ final String layouterImplClass = dispatcher.getImportManager().getImportedName((String) dispatcher.getFQNSwitch().doSwitch(gmfLayout));
+
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(layouterImplClass);
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(layouterVarName);
+ stringBuffer.append(TEXT_4);
+ stringBuffer.append(layouterImplClass);
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(argsBundle.getDispatcher().dispatch(gmfLayout, argsBundle));
+ stringBuffer.append(TEXT_6);
+ stringBuffer.append(figureVarName);
+ stringBuffer.append(TEXT_7);
+ stringBuffer.append(layouterVarName);
+ stringBuffer.append(TEXT_8);
+
+}
+
+ stringBuffer.append(TEXT_9);
+ return stringBuffer.toString();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java
index bacc7ee17..5bb99e24e 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/TopShapeGenerator.java
@@ -3,7 +3,7 @@ package org.eclipse.gmf.graphdef.codegen.templates;
import org.eclipse.gmf.gmfgraph.*;
import org.eclipse.gmf.gmfgraph.util.*;
import org.eclipse.gmf.common.codegen.*;
-import org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher;
+import org.eclipse.gmf.graphdef.codegen.*;
import java.util.*;
public class TopShapeGenerator
@@ -22,24 +22,29 @@ public class TopShapeGenerator
protected final String TEXT_2 = NL + NL + "/**" + NL + " * @generated" + NL + " */" + NL + "public class ";
protected final String TEXT_3 = " extends ";
protected final String TEXT_4 = " {" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic ";
- protected final String TEXT_5 = "() {" + NL + "\t\t";
- protected final String TEXT_6 = NL + "\t\tsetFigure";
- protected final String TEXT_7 = "(createFigure";
- protected final String TEXT_8 = "());" + NL + "\t\tadd(getFigure";
- protected final String TEXT_9 = "());";
- protected final String TEXT_10 = NL + "\t}" + NL;
- protected final String TEXT_11 = NL + NL + "\tprivate IFigure f";
- protected final String TEXT_12 = "; " + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic IFigure getFigure";
- protected final String TEXT_13 = "() {" + NL + "\t\treturn f";
- protected final String TEXT_14 = ";" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void setFigure";
- protected final String TEXT_15 = "(IFigure figure) {" + NL + "\t\tf";
- protected final String TEXT_16 = " = figure;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate IFigure createFigure";
- protected final String TEXT_17 = "() {";
- protected final String TEXT_18 = NL;
- protected final String TEXT_19 = NL;
- protected final String TEXT_20 = NL + "\t\treturn rv;" + NL + "\t}" + NL;
- protected final String TEXT_21 = NL + "}";
- protected final String TEXT_22 = NL;
+ protected final String TEXT_5 = "() {";
+ protected final String TEXT_6 = "\t" + NL + "\t\t";
+ protected final String TEXT_7 = NL + "\t\t";
+ protected final String TEXT_8 = NL + "\t\t" + NL + "\t\torg.eclipse.draw2d.IFigure ";
+ protected final String TEXT_9 = " = createFigure";
+ protected final String TEXT_10 = "();" + NL + "\t\tsetFigure";
+ protected final String TEXT_11 = "(";
+ protected final String TEXT_12 = ");" + NL + "\t\tadd(";
+ protected final String TEXT_13 = ");" + NL + "\t\t";
+ protected final String TEXT_14 = "\t\t";
+ protected final String TEXT_15 = NL + "\t}" + NL;
+ protected final String TEXT_16 = NL + NL + "\tprivate IFigure f";
+ protected final String TEXT_17 = "; " + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic IFigure getFigure";
+ protected final String TEXT_18 = "() {" + NL + "\t\treturn f";
+ protected final String TEXT_19 = ";" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected void setFigure";
+ protected final String TEXT_20 = "(IFigure figure) {" + NL + "\t\tf";
+ protected final String TEXT_21 = " = figure;" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate IFigure createFigure";
+ protected final String TEXT_22 = "() {";
+ protected final String TEXT_23 = NL;
+ protected final String TEXT_24 = NL;
+ protected final String TEXT_25 = NL + "\t\treturn rv;" + NL + "\t}" + NL;
+ protected final String TEXT_26 = NL + "}";
+ protected final String TEXT_27 = NL;
public String generate(Object argument)
{
@@ -60,45 +65,58 @@ final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[3];
stringBuffer.append(TEXT_4);
stringBuffer.append(figure.getName());
stringBuffer.append(TEXT_5);
- stringBuffer.append(dispatcher.dispatch(figure, dispatcher.create(figure, "this")));
-for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext();) {
- Figure next = (Figure) it.next();
+GraphDefDispatcher.LayoutArgs dispatcherArgs = dispatcher.createLayoutArgs(figure, "this", "myGenLayoutManager");
+
stringBuffer.append(TEXT_6);
- stringBuffer.append(next.getName());
+ stringBuffer.append(dispatcher.dispatch("createLayout", dispatcherArgs));
stringBuffer.append(TEXT_7);
- stringBuffer.append(next.getName());
+ stringBuffer.append(dispatcher.dispatch(figure, dispatcherArgs));
+
+for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext();) {
+ Figure next = (Figure) it.next();
+ final String childVarName = "child" + next.getName();
stringBuffer.append(TEXT_8);
- stringBuffer.append(next.getName());
+ stringBuffer.append(childVarName);
stringBuffer.append(TEXT_9);
- }
+ stringBuffer.append(next.getName());
stringBuffer.append(TEXT_10);
+ stringBuffer.append(next.getName());
+ stringBuffer.append(TEXT_11);
+ stringBuffer.append(childVarName);
+ stringBuffer.append(TEXT_12);
+ stringBuffer.append(childVarName);
+ stringBuffer.append(TEXT_13);
+ stringBuffer.append(dispatcher.dispatch("createLayoutData", dispatcher.createLayoutArgs(next, childVarName, "layout" + next.getName())));
+ stringBuffer.append(TEXT_14);
+ }
+ stringBuffer.append(TEXT_15);
int fc = 0;
for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext(); fc++) {
Figure next = (Figure) it.next();
- stringBuffer.append(TEXT_11);
+ stringBuffer.append(TEXT_16);
stringBuffer.append(next.getName());
- stringBuffer.append(TEXT_12);
+ stringBuffer.append(TEXT_17);
stringBuffer.append(next.getName());
- stringBuffer.append(TEXT_13);
+ stringBuffer.append(TEXT_18);
stringBuffer.append(next.getName());
- stringBuffer.append(TEXT_14);
+ stringBuffer.append(TEXT_19);
stringBuffer.append(next.getName());
- stringBuffer.append(TEXT_15);
+ stringBuffer.append(TEXT_20);
stringBuffer.append(next.getName());
- stringBuffer.append(TEXT_16);
+ stringBuffer.append(TEXT_21);
stringBuffer.append(next.getName());
- stringBuffer.append(TEXT_17);
- stringBuffer.append(TEXT_18);
+ stringBuffer.append(TEXT_22);
+ stringBuffer.append(TEXT_23);
stringBuffer.append(dispatcher.dispatch("instantiate", dispatcher.create(next, "rv")));
- stringBuffer.append(TEXT_19);
+ stringBuffer.append(TEXT_24);
stringBuffer.append(dispatcher.dispatch("Children", new Object[] {next.getChildren(), dispatcher, "rv"}));
- stringBuffer.append(TEXT_20);
+ stringBuffer.append(TEXT_25);
}
- stringBuffer.append(TEXT_21);
+ stringBuffer.append(TEXT_26);
importManager.emitSortedImports();
- stringBuffer.append(TEXT_22);
+ stringBuffer.append(TEXT_27);
return stringBuffer.toString();
}
}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet
new file mode 100644
index 000000000..5d7424e22
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet
@@ -0,0 +1,36 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="CustomClassAttributesGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.emf.codegen.util.CodeGenUtil java.util.* "%>
+<%
+final CustomClass instance = (CustomClass) ((Object[]) argument)[0];
+//final GraphDefDispatcher dispatcher = (GraphDefDispatcher) ((Object[]) argument)[1];
+final String varName = (String) ((Object[]) argument)[2];
+%>
+
+ {
+<%
+int attrIndex = 0;
+for (Iterator attrs = instance.getAttributes().iterator(); attrs.hasNext(); attrIndex++){
+ CustomAttribute next = (CustomAttribute) attrs.next();
+ String varValue;
+ if (next.isMultiStatementValue()){
+ varValue = "attr" + attrIndex;
+%>
+ <%=java.text.MessageFormat.format(next.getValue(), new Object[] {varValue})%>;
+<% } else {
+ varValue = next.getValue();
+}
+ if (next.isDirectAccess()) {
+%>
+ <%=varName%>.<%=next.getName()%> = <%=varValue%>;
+<%
+ } else {
+%>
+ <%=varName%>.set<%=CodeGenUtil.capName(next.getName())%>(<%=varValue%>);
+<%
+ }
+%>
+<%
+} //for
+%>
+ }
+
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
index f2a51c57a..eb76ac6cc 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
@@ -1,5 +1,5 @@
<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="FigureChildrenGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher java.util.*"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.* java.util.*"%>
<%
Object[] args = (Object[]) argument;
List/*<Figure>*/ figureChildren = (List) args[0];
@@ -23,10 +23,14 @@ while (!l.isEmpty()) {
if (figureMarker instanceof FigureRef) {
throw new IllegalStateException("FIXME: sorry, don't support FigureRef for a while");
}
- final String figureVarName = "fig" + (figureCount++);%>
+ final String figureVarName = "fig" + figureCount;
+ final String layoutDataVarName = "layData" + figureCount;
+ figureCount++;%>
// FIXME instantiate - FigureRef - dispatch to 'instantiate' template?
- <%=dispatcher.dispatch("instantiate", dispatcher.create((Figure) figureMarker, figureVarName))%>
+ <%GraphDefDispatcher.Args dargs = dispatcher.create((Figure) figureMarker, figureVarName);%>
+ <%=dispatcher.dispatch("instantiate", dargs)%>
<%=parentFigureVarName%>.add(<%=figureVarName%>);
+ <%=dispatcher.dispatch("createLayoutData", dispatcher.createLayoutArgs(dargs, layoutDataVarName))%>
<%
if (_nxt instanceof Figure && !((Figure) _nxt).getChildren().isEmpty()) {
l.addFirst(marker);
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/BorderLayout.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/BorderLayout.javajet
new file mode 100644
index 000000000..f86fb4889
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/BorderLayout.javajet
@@ -0,0 +1,17 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="InitBorderLayoutGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.*"%>
+<%
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final BorderLayout gmfLayout = (BorderLayout) argsBundle.getLayout();
+final String layouterVarName = argsBundle.getLayoutVariableName();
+%>
+
+<%
+Dimension spacing = gmfLayout.getSpacing();
+if (spacing != null){
+%>
+ <%=layouterVarName%>.setHorizontalSpacing(<%=spacing.getDx()%>);
+ <%=layouterVarName%>.setVerticalSpacing(<%=spacing.getDy()%>);
+<%
+}
+%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/CustomLayout.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/CustomLayout.javajet
new file mode 100644
index 000000000..0345832a6
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/CustomLayout.javajet
@@ -0,0 +1,8 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="InitCustomLayoutGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.*"%>
+<%
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final CustomLayout layout = (CustomLayout) argsBundle.getLayout();
+final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
+%>
+<%=dispatcher.dispatch("customAttributes", new Object[] {layout, dispatcher, argsBundle.getLayoutVariableName()} )%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/GridLayout.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/GridLayout.javajet
new file mode 100644
index 000000000..4f162a721
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layout/GridLayout.javajet
@@ -0,0 +1,25 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="InitGridLayoutGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.*"%>
+<%
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final GridLayout gmfLayout = (GridLayout) argsBundle.getLayout();
+final String layouterVarName = argsBundle.getLayoutVariableName();
+%>
+ <%=layouterVarName%>.numColumns = <%=gmfLayout.getNumColumns()%>;
+ <%=layouterVarName%>.makeColumnsEqualWidth = <%=gmfLayout.isEqualWidth()%>;
+<%
+Dimension margins = gmfLayout.getMargins();
+if (margins != null){
+%>
+ <%=layouterVarName%>.marginWidth = <%=margins.getDx()%>;
+ <%=layouterVarName%>.marginHeight = <%=margins.getDy()%>;
+<%
+}
+Dimension spacing = gmfLayout.getSpacing();
+if (spacing != null){
+%>
+ <%=layouterVarName%>.horizontalSpacing = <%=spacing.getDx()%>;
+ <%=layouterVarName%>.verticalSpacing = <%=spacing.getDy()%>;
+<%
+}
+%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/BorderLayoutData.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/BorderLayoutData.javajet
new file mode 100644
index 000000000..18525aaf2
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/BorderLayoutData.javajet
@@ -0,0 +1,40 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="InitBorderLayoutDataGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.*"%>
+<%
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final BorderLayoutData gmfLayoutData = (BorderLayoutData) argsBundle.getData();
+final String figureVarName = argsBundle.getVariableName();
+final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
+%>
+
+<%
+Alignment alignment = gmfLayoutData.getAlignment();
+if (alignment == null){
+ alignment = Alignment.CENTER_LITERAL;
+}
+final String constantName;
+switch(alignment.getValue()){
+ case Alignment.CENTER:
+ case Alignment.FILL:
+ constantName = "CENTER";
+ break;
+ case Alignment.BEGINNING:
+ if (gmfLayoutData.isVertical()){
+ constantName = "TOP";
+ } else {
+ constantName = "LEFT";
+ }
+ break;
+ case Alignment.END:
+ if (gmfLayoutData.isVertical()){
+ constantName = "BOTTOM";
+ } else {
+ constantName = "RIGHT";
+ }
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown Alignment: " + gmfLayoutData.getAlignment());
+}
+%>
+ <%=figureVarName%>.getParent().getLayoutManager().setConstraint(<%=figureVarName%>, <%=dispatcher.getImportManager().getImportedName("org.eclipse.draw2d.BorderLayout")%>.<%=constantName%>);
+
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/CustomLayoutData.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/CustomLayoutData.javajet
new file mode 100644
index 000000000..4dec5729f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/CustomLayoutData.javajet
@@ -0,0 +1,10 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="InitCustomLayoutDataGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.*"%>
+<%
+GraphDefDispatcher.LayoutArgs args = (GraphDefDispatcher.LayoutArgs) argument;
+final CustomLayoutData layoutData = (CustomLayoutData) args.getData();
+final GraphDefDispatcher dispatcher = args.getDispatcher();
+final String layoutImplClassName = dispatcher.getImportManager().getImportedName((String) dispatcher.getFQNSwitch().doSwitch(layoutData));
+%>
+<%=layoutImplClassName%> <%=args.getLayoutVariableName()%> = new <%=layoutImplClassName%>();
+<%=dispatcher.dispatch("customAttributes", new Object[] {layoutData, dispatcher, args.getLayoutVariableName()})%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/GridLayoutData.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/GridLayoutData.javajet
new file mode 100644
index 000000000..362940518
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/layoutData/GridLayoutData.javajet
@@ -0,0 +1,31 @@
+
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="InitGridLayoutDataGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.*"%>
+<%
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final GridLayoutData gmfLayoutData = (GridLayoutData) argsBundle.getData();
+final String figureVarName = argsBundle.getVariableName();
+final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
+final String layoutConstraintVarName = argsBundle.getLayoutVariableName();
+
+final String layoutImplClassName = dispatcher.getImportManager().getImportedName((String) dispatcher.getFQNSwitch().doSwitch(gmfLayoutData));
+%>
+ <%=layoutImplClassName%> <%=layoutConstraintVarName%> = new <%=layoutImplClassName%>();
+ <%=layoutConstraintVarName%>.verticalAlignment = <%=gmfLayoutData.getVerticalAlignment().getValue()%>;
+ <%=layoutConstraintVarName%>.horizontalAlignment = <%=gmfLayoutData.getHorizontalAlignment().getValue()%>;
+<%
+Dimension sizeHint = gmfLayoutData.getSizeHint();
+if (sizeHint != null){
+%>
+ <%=layoutConstraintVarName%>.widthHint = <%=sizeHint.getDx()%>;
+ <%=layoutConstraintVarName%>.heightHint = <%=sizeHint.getDy()%>;
+<%
+}
+%>
+ <%=layoutConstraintVarName%>.horizontalIndent = <%=gmfLayoutData.getHorizontalIndent()%>;
+ <%=layoutConstraintVarName%>.horizontalSpan = <%=gmfLayoutData.getHorizontalSpan()%>;
+ <%=layoutConstraintVarName%>.verticalSpan = <%=gmfLayoutData.getVerticalSpan()%>;
+ <%=layoutConstraintVarName%>.grabExcessHorizontalSpace = <%=gmfLayoutData.isGrabExcessHorizontalSpace()%>;
+ <%=layoutConstraintVarName%>.grabExcessVerticalSpace = <%=gmfLayoutData.isGrabExcessVerticalSpace()%>;
+ <%=figureVarName%>.getParent().getLayoutManager().setConstraint(<%=figureVarName%>, <%=layoutConstraintVarName%>);
+
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet
index eecabf0fd..39bff0a20 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet
@@ -1,5 +1,5 @@
<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="NewFigureGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.*"%>
<%
GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
final Figure figureInstance = args.getFigure();
@@ -10,4 +10,5 @@ final String figureClassName = dispatcher.getImportManager().getImportedName((St
// PRODUCES instance AND (!) initializes attributes
%>
<%=figureClassName%> <%=figureVarName%> = new <%=figureClassName%>();
-<%=args.getDispatcher().dispatch(figureInstance, args)%> \ No newline at end of file
+<%=args.getDispatcher().dispatch(figureInstance, args)%>
+<%=args.getDispatcher().dispatch("createLayout", dispatcher.createLayoutArgs(args))%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Layout.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Layout.javajet
new file mode 100644
index 000000000..ac8bd568b
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Layout.javajet
@@ -0,0 +1,21 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="NewLayoutGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.*"%>
+<%
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final FigureMarker figureMarker = argsBundle.getFigure();
+final String figureVarName = argsBundle.getVariableName();
+final String layouterVarName = argsBundle.getLayoutVariableName();
+final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
+%>
+
+<%
+Layout gmfLayout= figureMarker.getLayout();
+if (gmfLayout != null){
+ final String layouterImplClass = dispatcher.getImportManager().getImportedName((String) dispatcher.getFQNSwitch().doSwitch(gmfLayout));
+%>
+ <%=layouterImplClass%> <%=layouterVarName%> = new <%=layouterImplClass%>();
+ <%=argsBundle.getDispatcher().dispatch(gmfLayout, argsBundle)%>
+ <%=figureVarName%>.setLayoutManager(<%=layouterVarName%>);
+<%
+}
+%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LayoutData.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LayoutData.javajet
new file mode 100644
index 000000000..efe9f349f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LayoutData.javajet
@@ -0,0 +1,16 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="NewLayoutDataGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.*"%>
+<%
+// NOTE: this code expects that constrainted figure is already added to its parent
+
+GraphDefDispatcher.LayoutArgs argsBundle = (GraphDefDispatcher.LayoutArgs) argument;
+final GraphDefDispatcher dispatcher = argsBundle.getDispatcher();
+final LayoutData gmfLayoutData = argsBundle.getData();
+final Figure figureInstance = argsBundle.getFigure();
+
+// merely makes sure layoutData present
+// and parent figure got chance to have layout initialized
+
+if (gmfLayoutData != null && figureInstance.getParent() != null && figureInstance.getParent().getLayout() != null) {%>
+<%=dispatcher.dispatch(gmfLayoutData, argsBundle)%>
+<%}%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet
index 34d9f1df9..c5854561c 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet
@@ -1,5 +1,5 @@
<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="TopShapeGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher java.util.*"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.* java.util.*"%>
<%
Object[] args = (Object[]) argument;
Shape figure = (Shape) args[0];
@@ -18,12 +18,20 @@ public class <%=figure.getName()%> extends <%=importManager.getImportedName((Str
* @generated
*/
public <%=figure.getName()%>() {
- <%=dispatcher.dispatch(figure, dispatcher.create(figure, "this"))%>
+<%
+GraphDefDispatcher.LayoutArgs dispatcherArgs = dispatcher.createLayoutArgs(figure, "this", "myGenLayoutManager");
+%>
+ <%=dispatcher.dispatch("createLayout", dispatcherArgs)%>
+ <%=dispatcher.dispatch(figure, dispatcherArgs)%>
<%
for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext();) {
- Figure next = (Figure) it.next();%>
- setFigure<%=next.getName()%>(createFigure<%=next.getName()%>());
- add(getFigure<%=next.getName()%>());
+ Figure next = (Figure) it.next();
+ final String childVarName = "child" + next.getName();%>
+
+ org.eclipse.draw2d.IFigure <%=childVarName%> = createFigure<%=next.getName()%>();
+ setFigure<%=next.getName()%>(<%=childVarName%>);
+ add(<%=childVarName%>);
+ <%=dispatcher.dispatch("createLayoutData", dispatcher.createLayoutArgs(next, childVarName, "layout" + next.getName()))%>
<%}%>
}

Back to the top