Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-02-06 18:10:22 +0000
committeratikhomirov2006-02-06 18:10:22 +0000
commitab3cbec7ac30ebc2acac1565d3a11e5de969c32b (patch)
tree6975082a424975a565a3ea20368f2279f968c1c2 /plugins/org.eclipse.gmf.graphdef.codegen/templates
parent6e7a0cab3de84e293361d07e3545872589e22f68 (diff)
downloadorg.eclipse.gmf-tooling-ab3cbec7ac30ebc2acac1565d3a11e5de969c32b.tar.gz
org.eclipse.gmf-tooling-ab3cbec7ac30ebc2acac1565d3a11e5de969c32b.tar.xz
org.eclipse.gmf-tooling-ab3cbec7ac30ebc2acac1565d3a11e5de969c32b.zip
major refactoring of gmfgraph codegen utilizing dispatcher infrastructure
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen/templates')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc2
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/ConcreteShape.javajet67
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/DecorationFigure.javajet32
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureAttrs.jetinc11
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureChildren.jetinc27
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Label.javajet24
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet19
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Label.javajet11
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylgonDecoration.javajet7
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Polyline.javajet16
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylineDecoration.javajet21
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/RoundedRectangle.javajet11
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.javajet (renamed from plugins/org.eclipse.gmf.graphdef.codegen/templates/ShapeAttrs.javajet)14
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet40
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/decoration.jetinc20
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/instantiate.jetinc20
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet13
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet (renamed from plugins/org.eclipse.gmf.graphdef.codegen/templates/CustomFigure.javajet)16
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet (renamed from plugins/org.eclipse.gmf.graphdef.codegen/templates/PolylineConnection.javajet)26
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet61
20 files changed, 223 insertions, 235 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc
index 08bcde1e4..9ed864a0e 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc
@@ -1 +1 @@
-<%if (colorVal instanceof RGBColor) {%>new org.eclipse.swt.graphics.Color(null, <%=((RGBColor) colorVal).getRed()%>, <%=((RGBColor) colorVal).getGreen()%>, <%=((RGBColor) colorVal).getBlue()%>)<%} else if (colorVal instanceof ConstantColor) {%>org.eclipse.draw2d.ColorConstants.<%=((ConstantColor) colorVal).getValue().getLiteral()%><%}%> \ No newline at end of file
+<%if (colorVal instanceof RGBColor) {%>new <%=importManager.getImportedName("org.eclipse.swt.graphics.Color")%>(null, <%=((RGBColor) colorVal).getRed()%>, <%=((RGBColor) colorVal).getGreen()%>, <%=((RGBColor) colorVal).getBlue()%>)<%} else if (colorVal instanceof ConstantColor) {%><%=importManager.getImportedName("org.eclipse.draw2d.ColorConstants")%>.<%=((ConstantColor) colorVal).getValue().getLiteral()%><%}%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/ConcreteShape.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/ConcreteShape.javajet
deleted file mode 100644
index 448a04e09..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/ConcreteShape.javajet
+++ /dev/null
@@ -1,67 +0,0 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="ShapeGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher java.util.*"%>
-<%
-Object[] args = (Object[]) argument;
-Shape shapeFig = (Shape) args[0];
-final ImportAssistant importManager = (ImportAssistant) args[1];
-final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
-final Dispatcher dispatcher = (Dispatcher) args[2];
-%>
-
-<%importManager.markImportLocation(stringBuffer);%>
-
-/**
- * @generated
- */
-public class <%=shapeFig.getName()%> extends <%=importManager.getImportedName((String) fqnSwitch.doSwitch(shapeFig))%> {
-
- /**
- * @generated
- */
- public <%=shapeFig.getName()%>() {
-<%=dispatcher.dispatch("ShapeAttrs", dispatcher.create(shapeFig, "this", importManager, fqnSwitch))%>
-<%
-for (Iterator it = shapeFig.getResolvedChildren().iterator(); it.hasNext();) {
- Figure next = (Figure) it.next();%>
- setFigure<%=next.getName()%>(createFigure<%=next.getName()%>());
- add(getFigure<%=next.getName()%>());
-<%}%>
- }
-
-<%
-int fc = 0;
-for (Iterator it = shapeFig.getResolvedChildren().iterator(); it.hasNext(); fc++) {
- Figure figure = (Figure) it.next();%>
-
- private IFigure f<%=figure.getName()%>;
-
- /**
- * @generated
- */
- public IFigure getFigure<%=figure.getName()%>() {
- return f<%=figure.getName()%>;
- }
-
- /**
- * @generated
- */
- protected void setFigure<%=figure.getName()%>(IFigure figure) {
- f<%=figure.getName()%> = figure;
- }
-
- /**
- * @generated
- */
- private IFigure createFigure<%=figure.getName()%>() {
-<%
-String parentFigureVarName = "rv" + fc;
-{ // scope
-FigureMarker figureMarker = figure;
-String figureVarName = parentFigureVarName;%>
-<%@ include file="instantiate.jetinc" %><%}%>
-<%@ include file="FigureChildren.jetinc" %>
- return <%=parentFigureVarName%>;
- }
-
-<%}%>
-}<%importManager.emitSortedImports();%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/DecorationFigure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/DecorationFigure.javajet
deleted file mode 100644
index ca932986c..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/DecorationFigure.javajet
+++ /dev/null
@@ -1,32 +0,0 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="DecorationFigureGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* java.util.*"%>
-<%
-Object[] args = (Object[]) argument;
-DecorationFigure figure = (DecorationFigure) args[0];
-final ImportAssistant importManager = (ImportAssistant) args[1];
-assert false == figure instanceof CustomFigure;
-final Point scale;
-scale = null; //XXX
-final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
-%>
-
-<%importManager.markImportLocation(stringBuffer);%>
-
-/**
- * @generated
- */
-class <%=figure.getName()%> extends <%=importManager.getImportedName((String) fqnSwitch.doSwitch(figure))%> {
-
- /**
- * @generated
- */
- public <%=figure.getName()%>() {
-<%
-DecorationFigure df = figure;
-String decFigVarName = "this";%>
-<%@ include file="decoration.jetinc" %>
-<%if (scale != null) {%>
- setScale(<%=scale.getX()%>, <%=scale.getY()%>);
-<%}%>
- }
-}<%importManager.emitSortedImports();%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureAttrs.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureAttrs.jetinc
deleted file mode 100644
index b16cc7aaa..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureAttrs.jetinc
+++ /dev/null
@@ -1,11 +0,0 @@
-<%Color colorVal;
-if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
- colorVal = figureInstance.getForegroundColor();%>
- <%=figureVarName%>.setForegroundColor(<%@ include file="Color.jetinc"%>);
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
- colorVal = figureInstance.getBackgroundColor();%>
- <%=figureVarName%>.setBackgroundColor(<%@ include file="Color.jetinc"%>);
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) {
- Dimension d = figureInstance.getPreferredSize();%>
- <%=figureVarName%>.setPreferredSize(getMapMode().DPtoLP(<%=d.getDx()%>), getMapMode().DPtoLP(<%=d.getDy()%>));
-<%}%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureChildren.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureChildren.jetinc
deleted file mode 100644
index b00f8055f..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureChildren.jetinc
+++ /dev/null
@@ -1,27 +0,0 @@
-<%
-LinkedList l = new LinkedList();
-l.addAll(figure.getChildren());
-final Object marker = new Object();
-Stack figureVarNamesStack = new Stack();
-int figureCount = 0;
-while (!l.isEmpty()) {
- Object _nxt = l.removeFirst();
- if (_nxt == marker) {
- parentFigureVarName = (String) figureVarNamesStack.pop();
- continue;
- }
- FigureMarker figureMarker = (FigureMarker) _nxt;
- String figureVarName = "fig" + (figureCount++);%>
-<%@ include file="instantiate.jetinc" %>
- <%=parentFigureVarName%>.add(<%=figureVarName%>);
-<%
-if (_nxt instanceof Figure && !((Figure) _nxt).getChildren().isEmpty()) {
- l.addFirst(marker);
- l.addAll(0, ((Figure) _nxt).getChildren());
- figureVarNamesStack.push(parentFigureVarName);
- parentFigureVarName = figureVarName; // go on processing children of new parentFigure
-}
-%>
-<%
-} // while
-%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Label.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Label.javajet
deleted file mode 100644
index ecbd3eb02..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Label.javajet
+++ /dev/null
@@ -1,24 +0,0 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="LabelGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.*"%>
-
-<%
-Object[] args = (Object[]) argument;
-Label figure = (Label) args[0];
-final ImportAssistant importManager = (ImportAssistant) args[1];
-%>
-
-<%importManager.markImportLocation(stringBuffer);%>
-
-/**
- * @generated
- */
-public class <%=figure.getName()%> extends <%=importManager.getImportedName("org.eclipse.draw2d.Label")%> {
-
- /**
- * @generated
- */
- public <%=figure.getName()%>() {
- super();
- }
-
-}<%importManager.emitSortedImports();%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet
new file mode 100644
index 000000000..7cd0f28ef
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet
@@ -0,0 +1,19 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="FigureAttrGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
+<%
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final Figure figureInstance = args.getFigure();
+final String figureVarName = args.getVariableName();
+final ImportAssistant importManager = args.getImportManager();
+%>
+<%Color colorVal;
+if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
+ colorVal = figureInstance.getForegroundColor();%>
+ <%=figureVarName%>.setForegroundColor(<%@ include file="../Color.jetinc"%>);
+<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
+ colorVal = figureInstance.getBackgroundColor();%>
+ <%=figureVarName%>.setBackgroundColor(<%@ include file="../Color.jetinc"%>);
+<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) {
+ Dimension d = figureInstance.getPreferredSize();%>
+ <%=figureVarName%>.setPreferredSize(getMapMode().DPtoLP(<%=d.getDx()%>), getMapMode().DPtoLP(<%=d.getDy()%>));
+<%}%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Label.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Label.javajet
new file mode 100644
index 000000000..8d8582514
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Label.javajet
@@ -0,0 +1,11 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="LabelAttrGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
+<%
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final Label figureInstance = (Label) args.getFigure();
+final String figureVarName = args.getVariableName();
+final Dispatcher dispatcher = args.getDispatcher();
+%>
+<%if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getLabel_Text())) {%>
+<%=figureVarName%>.setText("<%=figureInstance.getText()%>");
+<%}%><%=dispatcher.dispatch("Figure", args)%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylgonDecoration.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylgonDecoration.javajet
new file mode 100644
index 000000000..11eec09bb
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylgonDecoration.javajet
@@ -0,0 +1,7 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="PolygonDecorationAttrGenerator"
+ imports="org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
+<%
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final Dispatcher dispatcher = args.getDispatcher();
+%>
+<%=dispatcher.dispatch("PolylineDecoration", args)%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Polyline.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Polyline.javajet
new file mode 100644
index 000000000..497789253
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Polyline.javajet
@@ -0,0 +1,16 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="PolylineAttrGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
+<%
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final Polyline figureInstance = (Polyline) args.getFigure();
+final String figureVarName = args.getVariableName();
+final ImportAssistant importManager = args.getImportManager();
+final Dispatcher dispatcher = args.getDispatcher();
+%>
+<%=dispatcher.dispatch("Shape", args)%>
+<%if (!figureInstance.getTemplate().isEmpty()) {
+ final String pointClassName = importManager.getImportedName("org.eclipse.draw2d.geometry.Point");
+ for (java.util.Iterator pointIt = figureInstance.getTemplate().iterator(); pointIt.hasNext(); ) {
+ Point p = (Point) pointIt.next();%>
+ <%=figureVarName%>.addPoint(new <%=pointClassName%>(<%=p.getX()%>, <%=p.getY()%>));
+<%}}%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylineDecoration.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylineDecoration.javajet
new file mode 100644
index 000000000..0a4b53871
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylineDecoration.javajet
@@ -0,0 +1,21 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="PolylineDecorationAttrGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher java.util.*"%>
+<%
+Dispatcher.Args args = (Dispatcher.Args) argument;
+// not PolylineDecoration, as we use same template from PolygonDecoration
+final Polyline figureInstance = (Polyline) args.getFigure();
+final String figureVarName = args.getVariableName();
+final ImportAssistant importManager = args.getImportManager();
+final Dispatcher dispatcher = args.getDispatcher();
+%>
+// dispatchNext?
+<%=dispatcher.dispatch("Shape", args)%>
+<%if (!figureInstance.getTemplate().isEmpty()) {%>
+ <%=importManager.getImportedName("org.eclipse.draw2d.geometry.PointList")%> pl = new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.PointList")%>();
+<% for (Iterator pointIt = figureInstance.getTemplate().iterator(); pointIt.hasNext(); ) {
+ Point p = (Point) pointIt.next();%>
+ pl.addPoint(<%=p.getX()%>, <%=p.getY()%>);
+<% } /*for*/ %>
+ <%=figureVarName%>.setTemplate(pl);
+ <%=figureVarName%>.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));
+<% } /*!if getTemplate().isEmpty()*/ %>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/RoundedRectangle.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/RoundedRectangle.javajet
new file mode 100644
index 000000000..fd4a27459
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/RoundedRectangle.javajet
@@ -0,0 +1,11 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="RoundedRectAttrGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
+<%
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final RoundedRectangle figureInstance = (RoundedRectangle) args.getFigure();
+final String figureVarName = args.getVariableName();
+final ImportAssistant importManager = args.getImportManager();
+final Dispatcher dispatcher = args.getDispatcher();
+%>
+<%=dispatcher.dispatch("Shape", args)%>
+<%=figureVarName%>.setCornerDimensions(new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%>(getMapMode().DPtoLP(<%=figureInstance.getCornerWidth()%>), getMapMode().DPtoLP(<%=figureInstance.getCornerHeight()%>))); \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/ShapeAttrs.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.javajet
index 815afd334..288fe8fb7 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/ShapeAttrs.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.javajet
@@ -1,10 +1,11 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="ShapeAttrsGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* java.util.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="ShapeAttrGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
<%
Dispatcher.Args args = (Dispatcher.Args) argument;
final Shape figureInstance = (Shape) args.getFigure();
final String figureVarName = args.getVariableName();
final ImportAssistant importManager = args.getImportManager();
+final Dispatcher dispatcher = args.getDispatcher();
%>
<%
// PERHAPS, do this with reflection?
@@ -20,11 +21,4 @@ final ImportAssistant importManager = args.getImportManager();
<%=figureVarName%>.setFillXOR(<%=figureInstance.isXorFill()%>);
<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_XorOutline())) {%>
<%=figureVarName%>.setOutlineXOR(<%=figureInstance.isXorOutline()%>);
-<%} if (figureInstance instanceof Polyline && !((Polyline) figureInstance).getTemplate().isEmpty()) {
- for (Iterator pointIt = ((Polyline) figureInstance).getTemplate().iterator(); pointIt.hasNext(); ) {
- Point p = (Point) pointIt.next();%>
- <%=figureVarName%>.addPoint(new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Point")%>(<%=p.getX()%>, <%=p.getY()%>));
-<%}%><%} else if (figureInstance instanceof RoundedRectangle) {
- RoundedRectangle rrFigure = (RoundedRectangle) figureInstance;%>
- <%=figureVarName%>.setCornerDimensions(new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%>(getMapMode().DPtoLP(<%=rrFigure.getCornerWidth()%>), getMapMode().DPtoLP(<%=rrFigure.getCornerHeight()%>)));
-<%}%><%@ include file="FigureAttrs.jetinc"%> \ No newline at end of file
+<%}%><%=dispatcher.dispatch("Figure", args)%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
new file mode 100644
index 000000000..b89aa0274
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/children/Figure.javajet
@@ -0,0 +1,40 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="FigureChildrenGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher java.util.*"%>
+<%
+Object[] args = (Object[]) argument;
+List/*<Figure>*/ figureChildren = (List) args[0];
+final ImportAssistant importManager = (ImportAssistant) args[1];
+final GMFGraphSwitch fqnSwitch = (GMFGraphSwitch) args[2];
+final Dispatcher dispatcher = (Dispatcher) args[3];
+String parentFigureVarName = (String) args[4];
+%>
+
+<%
+LinkedList l = new LinkedList();
+l.addAll(figureChildren);
+final Object marker = new Object();
+Stack figureVarNamesStack = new Stack();
+int figureCount = 0;
+while (!l.isEmpty()) {
+ Object _nxt = l.removeFirst();
+ if (_nxt == marker) {
+ parentFigureVarName = (String) figureVarNamesStack.pop();
+ continue;
+ }
+ final FigureMarker figureMarker = (FigureMarker) _nxt;
+ if (figureMarker instanceof FigureRef) {
+ throw new IllegalStateException("FIXME: sorry, don't support FigureRef for a while");
+ }
+ final String figureVarName = "fig" + (figureCount++);%>
+ // FIXME instantiate - FigureRef - dispatch to 'instantiate' template?
+ <%=dispatcher.dispatch("instantiate", dispatcher.create((Figure) figureMarker, figureVarName, importManager, fqnSwitch))%>
+ <%=parentFigureVarName%>.add(<%=figureVarName%>);
+<%
+if (_nxt instanceof Figure && !((Figure) _nxt).getChildren().isEmpty()) {
+ l.addFirst(marker);
+ l.addAll(0, ((Figure) _nxt).getChildren());
+ figureVarNamesStack.push(parentFigureVarName);
+ parentFigureVarName = figureVarName; // go on processing children of new parentFigure
+} // if
+} // while
+%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/decoration.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/decoration.jetinc
deleted file mode 100644
index be64196f9..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/decoration.jetinc
+++ /dev/null
@@ -1,20 +0,0 @@
- <%=fqnSwitch.doSwitch(df)%> <%=decFigVarName%> = new <%=fqnSwitch.doSwitch(df)%>();
-<% { // scope
-Figure figureInstance = df;
-String figureVarName = decFigVarName;
-%>
-<%@ include file="FigureAttrs.jetinc"%><%} // scope %>
-<% /*include FigureChildren*/ %>
-<%
-if ((df instanceof PolylineDecoration || df instanceof PolygonDecoration)) {
- if (!((Polyline) df).getTemplate().isEmpty()) {
-%>
- org.eclipse.draw2d.geometry.PointList pl = new org.eclipse.draw2d.geometry.PointList();
-<% for (Iterator pointIt = ((Polyline) df).getTemplate().iterator(); pointIt.hasNext(); ) {
- Point p = (Point) pointIt.next();%>
- pl.addPoint(<%=p.getX()%>, <%=p.getY()%>);
-<% } /*for*/ %>
- <%=decFigVarName%>.setTemplate(pl);
-<% } /*!if getTemplate().isEmpty()*/ %>
- <%=decFigVarName%>.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));
-<%} /*if instanceof */ %>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/instantiate.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/instantiate.jetinc
deleted file mode 100644
index 99cc56df9..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/instantiate.jetinc
+++ /dev/null
@@ -1,20 +0,0 @@
-<%
-// FigureMarker: figureMarker
-// String: figureVarName
-if (figureMarker instanceof CustomFigure) {
- CustomFigure figureInstance = (CustomFigure) figureMarker;
-%>
- <%=fqnSwitch.doSwitch(figureMarker)%> <%=figureVarName%> = new <%=fqnSwitch.doSwitch(figureMarker)%>();
-<%@ include file="FigureAttrs.jetinc"%>
-<%} else if (figureMarker instanceof Shape) {
-Shape figureInstance = (Shape) figureMarker;%>
- <%=fqnSwitch.doSwitch(figureMarker)%> <%=figureVarName%> = new <%=fqnSwitch.doSwitch(figureMarker)%>();
-<%=dispatcher.dispatch("ShapeAttrs", dispatcher.create(figureInstance, figureVarName, importManager, fqnSwitch))%>
-<%} else if (figureMarker instanceof FigureRef) {%>
- org.eclipse.draw2d.IFigure <%=figureVarName%> = new <%=((FigureRef) figureMarker).getFigure().getName()%>();
-<%} else if (figureMarker instanceof Label) {
- Label figureInstance = (Label) figureMarker;
-%>
- <%=fqnSwitch.doSwitch(figureMarker)%> <%=figureVarName%> = new <%=fqnSwitch.doSwitch(figureMarker)%>();
- <%=figureVarName%>.setText("<%=((Label) figureMarker).getText()%>");
-<%@ include file="FigureAttrs.jetinc"%><%}%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet
new file mode 100644
index 000000000..0c380c210
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/Figure.javajet
@@ -0,0 +1,13 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="NewFigureGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
+<%
+Dispatcher.Args args = (Dispatcher.Args) argument;
+final Figure figureInstance = args.getFigure();
+final String figureVarName = args.getVariableName();
+final ImportAssistant importManager = args.getImportManager();
+final String figureClassName = importManager.getImportedName((String) args.getFQNSwitch().doSwitch(figureInstance));
+
+// PRODUCES instance AND (!) initializes attributes
+%>
+<%=figureClassName%> <%=figureVarName%> = new <%=figureClassName%>();
+<%=args.getDispatcher().dispatch(figureInstance, args)%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/CustomFigure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
index 981d23bae..d633f069f 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/CustomFigure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
@@ -1,8 +1,8 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="CustomFigureGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher java.util.*"%>
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="TopFigureGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
<%
Object[] args = (Object[]) argument;
-CustomFigure figure = (CustomFigure) args[0];
+Figure figure = (Figure) args[0];
final ImportAssistant importManager = (ImportAssistant) args[1];
final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
final Dispatcher dispatcher = (Dispatcher) args[2];
@@ -13,14 +13,12 @@ final Dispatcher dispatcher = (Dispatcher) args[2];
/**
* @generated
*/
-public class <%=figure.getName()%> extends <%=importManager.getImportedName(figure.getQualifiedClassName())%> {
-
+public class <%=figure.getName()%> extends <%=importManager.getImportedName((String) fqnSwitch.doSwitch(figure))%> {
/**
* @generated
*/
public <%=figure.getName()%>() {
- // TODO - process custom properties here
-<%String parentFigureVarName = "this";%>
-<%@ include file="FigureChildren.jetinc" %>
+ <%=dispatcher.dispatch(figure, dispatcher.create(figure, "this", importManager, fqnSwitch))%>
+ <%=dispatcher.dispatch("Children", new Object[] {figure.getChildren(), importManager, fqnSwitch, dispatcher, "this"})%>
}
-}<%importManager.emitSortedImports();%> \ No newline at end of file
+}<%importManager.emitSortedImports();%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/PolylineConnection.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet
index ca11d4de0..fdae4a8ab 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/PolylineConnection.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet
@@ -1,6 +1,5 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="ConnectionGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher java.util.*"%>
-
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="TopConnectionGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.Dispatcher"%>
<%
Object[] args = (Object[]) argument;
PolylineConnection figure = (PolylineConnection) args[0];
@@ -20,7 +19,7 @@ public class <%=figure.getName()%> extends <%=importManager.getImportedName("org
* @generated
*/
public <%=figure.getName()%>() {
-<%=dispatcher.dispatch("ShapeAttrs", dispatcher.create(figure, "this", importManager, fqnSwitch))%>
+<%=dispatcher.dispatch("Shape", dispatcher.create(figure, "this", importManager, fqnSwitch))%>
<%if (figure.getSourceDecoration() != null) {%>
setSourceDecoration(createSourceDecoration());
<%}
@@ -29,26 +28,25 @@ if (figure.getTargetDecoration() != null) {%>
<%}%>
}
-<%String decFigVarName = "df";
-if (figure.getSourceDecoration() != null) {
-DecorationFigure df = figure.getSourceDecoration();%>
+<%if (figure.getSourceDecoration() != null) {
+ final String className = importManager.getImportedName((String) fqnSwitch.doSwitch(figure.getSourceDecoration()));%>
/**
* @generated
*/
- private <%=fqnSwitch.doSwitch(df)%> createSourceDecoration() {
-<%@ include file="decoration.jetinc" %>
- return <%=decFigVarName%>;
+ private <%=className%> createSourceDecoration() {
+<%=dispatcher.dispatch("instantiate", dispatcher.create(figure.getSourceDecoration(), "df", importManager, fqnSwitch))%>
+ return df;
}
<%} /*if sourceDecoration != null */ %>
<%if (figure.getTargetDecoration() != null) {
-DecorationFigure df = figure.getTargetDecoration();%>
+ final String className = importManager.getImportedName((String) fqnSwitch.doSwitch(figure.getTargetDecoration()));%>
/**
* @generated
*/
- private <%=fqnSwitch.doSwitch(df)%> createTargetDecoration() {
-<%@ include file="decoration.jetinc" %>
- return <%=decFigVarName%>;
+ private <%=className%> createTargetDecoration() {
+<%=dispatcher.dispatch("instantiate", dispatcher.create(figure.getTargetDecoration(), "df", importManager, fqnSwitch))%>
+ return df;
}
<%}%>
}<%importManager.emitSortedImports();%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet
new file mode 100644
index 000000000..755205349
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Shape.javajet
@@ -0,0 +1,61 @@
+<%@ 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.Dispatcher java.util.*"%>
+<%
+Object[] args = (Object[]) argument;
+Shape figure = (Shape) args[0];
+final ImportAssistant importManager = (ImportAssistant) args[1];
+final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
+final Dispatcher dispatcher = (Dispatcher) args[2];
+%>
+
+<%importManager.markImportLocation(stringBuffer);%>
+
+/**
+ * @generated
+ */
+public class <%=figure.getName()%> extends <%=importManager.getImportedName((String) fqnSwitch.doSwitch(figure))%> {
+ /**
+ * @generated
+ */
+ public <%=figure.getName()%>() {
+ <%=dispatcher.dispatch(figure, dispatcher.create(figure, "this", importManager, fqnSwitch))%>
+<%
+for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext();) {
+ Figure next = (Figure) it.next();%>
+ setFigure<%=next.getName()%>(createFigure<%=next.getName()%>());
+ add(getFigure<%=next.getName()%>());
+<%}%>
+ }
+
+<%
+int fc = 0;
+for (Iterator it = figure.getResolvedChildren().iterator(); it.hasNext(); fc++) {
+ Figure next = (Figure) it.next();%>
+
+ private IFigure f<%=next.getName()%>;
+
+ /**
+ * @generated
+ */
+ public IFigure getFigure<%=next.getName()%>() {
+ return f<%=next.getName()%>;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setFigure<%=next.getName()%>(IFigure figure) {
+ f<%=next.getName()%> = figure;
+ }
+
+ /**
+ * @generated
+ */
+ private IFigure createFigure<%=next.getName()%>() {
+<%=dispatcher.dispatch("instantiate", dispatcher.create(next, "rv", importManager, fqnSwitch))%>
+<%=dispatcher.dispatch("Children", new Object[] {next.getChildren(), importManager, fqnSwitch, dispatcher, "rv"})%>
+ return rv;
+ }
+
+<%}%>
+}<%importManager.emitSortedImports();%>

Back to the top