Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-01-06 19:17:28 +0000
committeratikhomirov2006-01-06 19:17:28 +0000
commit136699f9f6899f4876594fa4126f9e118ea57534 (patch)
tree35630922b65473c340d9b3b07d2b4e6caafb5137 /plugins/org.eclipse.gmf.graphdef.codegen/templates
parentc27a9c8b6d75e2b9e09baa27511fc86de0a36941 (diff)
downloadorg.eclipse.gmf-tooling-136699f9f6899f4876594fa4126f9e118ea57534.tar.gz
org.eclipse.gmf-tooling-136699f9f6899f4876594fa4126f9e118ea57534.tar.xz
org.eclipse.gmf-tooling-136699f9f6899f4876594fa4126f9e118ea57534.zip
some templates to support #114177 (graphical definition model) - with GEF IFigure code as an outcome
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen/templates')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/ConcreteShape.javajet52
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/CustomFigure.javajet15
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/DecorationFigure.javajet27
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureAttrs.jetinc0
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureChildren.jetinc27
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/PolylineConnection.javajet39
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/ShapeAttrs.jetinc22
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/decoration.jetinc11
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/instantiate.jetinc19
9 files changed, 212 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/ConcreteShape.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/ConcreteShape.javajet
new file mode 100644
index 000000000..4e2d5b448
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/ConcreteShape.javajet
@@ -0,0 +1,52 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="ShapeGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* java.util.*"%>
+<%
+Shape shapeFig = (Shape) argument;
+final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
+%>
+
+public class <%=shapeFig.getName()%> extends <%=fqnSwitch.doSwitch(shapeFig)%> {
+
+ public <%=shapeFig.getName()%>() {
+<%
+{
+Shape shapeFigure = shapeFig;
+String shapeVarName = "this";
+%>
+<%@ include file="ShapeAttrs.jetinc" %>
+<%
+}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()%>;
+
+ public IFigure getFigure<%=figure.getName()%>() {
+ return f<%=figure.getName()%>;
+ }
+
+ protected void setFigure<%=figure.getName()%>(IFigure figure) {
+ f<%=figure.getName()%> = figure;
+ }
+
+ 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%>;
+ }
+
+<%}%>
+} \ 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/CustomFigure.javajet
new file mode 100644
index 000000000..5ec9a0b97
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/CustomFigure.javajet
@@ -0,0 +1,15 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="CustomFigureGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* java.util.*"%>
+<%
+CustomFigure figure = (CustomFigure) argument;
+final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
+%>
+
+public class <%=figure.getName()%> extends <%=figure.getQualifiedClassName()%> {
+
+ public <%=figure.getName()%>() {
+ // TODO - process custom properties here
+<%String parentFigureVarName = "this";%>
+<%@ include file="FigureChildren.jetinc" %>
+ }
+} \ 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
new file mode 100644
index 000000000..4b08fbe89
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/DecorationFigure.javajet
@@ -0,0 +1,27 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="DecorationFigureGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* java.util.*"%>
+<%
+DecorationFigure figure = (DecorationFigure) argument;
+assert false == figure instanceof CustomFigure;
+final Point scale;
+scale = null; //XXX
+final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
+%>
+
+class <%=figure.getName()%> extends <%=fqnSwitch.doSwitch(figure)%> {
+
+ public <%=figure.getName()%>() {
+<%
+DecorationFigure df = figure;
+String decFigVarName = "this";%>
+<%@ include file="decoration.jetinc" %>
+<%if (scale != null) {%>
+ setScale(<%=scale.getX()%>, <%=scale.getY()%>);
+<%}%>
+<%
+Shape shapeFigure = (Shape) figure;
+String shapeVarName = "this";
+%>
+<%@ include file="ShapeAttrs.jetinc" %>
+ }
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureAttrs.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureAttrs.jetinc
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureAttrs.jetinc
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureChildren.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureChildren.jetinc
new file mode 100644
index 000000000..b00f8055f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/FigureChildren.jetinc
@@ -0,0 +1,27 @@
+<%
+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/PolylineConnection.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/PolylineConnection.javajet
new file mode 100644
index 000000000..d94e36dc2
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/PolylineConnection.javajet
@@ -0,0 +1,39 @@
+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="ConnectionGenerator"
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* java.util.*"%>
+
+<%
+PolylineConnection figure = (PolylineConnection) argument;
+final GMFGraphSwitch fqnSwitch = new FigureQualifiedNameSwitch();
+%>
+
+public class <%=figure.getName()%> extends <%=fqnSwitch.doSwitch(figure)%> {
+
+ public <%=figure.getName()%>() {
+<%Shape shapeFigure = figure;
+String shapeVarName = "this";%>
+<%@ include file="ShapeAttrs.jetinc" %>
+<%if (figure.getSourceDecoration() != null) {%>
+ setSourceDecoration(createSourceDecoration());
+<%}
+if (figure.getTargetDecoration() != null) {%>
+ setTargetDecoration(createTargetDecoration());
+<%}%>
+ }
+
+<%String decFigVarName = "df";
+if (figure.getSourceDecoration() != null) {
+DecorationFigure df = figure.getSourceDecoration();%>
+ private <%=fqnSwitch.doSwitch(df)%> createSourceDecoration() {
+<%@ include file="decoration.jetinc" %>
+ return <%=decFigVarName%>;
+ }
+<%} /*if sourceDecoration != null */ %>
+
+<%if (figure.getTargetDecoration() != null) {
+DecorationFigure df = figure.getTargetDecoration();%>
+ private <%=fqnSwitch.doSwitch(df)%> createTargetDecoration() {
+<%@ include file="decoration.jetinc" %>
+ return <%=decFigVarName%>;
+ }
+<%}%>
+}
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/ShapeAttrs.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/ShapeAttrs.jetinc
new file mode 100644
index 000000000..74945d200
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/ShapeAttrs.jetinc
@@ -0,0 +1,22 @@
+<%
+// PERHAPS, do this with reflection?
+%><%if (shapeFigure.eIsSet(GMFGraphPackage.eINSTANCE.getShape_Fill())) {%>
+ <%=shapeVarName%>.setFill(<%=shapeFigure.isFill()%>);
+<%} if (shapeFigure.eIsSet(GMFGraphPackage.eINSTANCE.getShape_Outline())) {%>
+ <%=shapeVarName%>.setOutline(<%=shapeFigure.isOutline()%>);
+<%} if (shapeFigure.eIsSet(GMFGraphPackage.eINSTANCE.getShape_LineWidth())) {%>
+ <%=shapeVarName%>.setLineWidth(<%=shapeFigure.getLineWidth()%>);
+<%} if (shapeFigure.eIsSet(GMFGraphPackage.eINSTANCE.getShape_LineKind())) {%>
+ <%=shapeVarName%>.setLineStyle(org.eclipse.draw2d.Graphics.<%=shapeFigure.getLineKind().getName()%>);
+<%} if (shapeFigure.eIsSet(GMFGraphPackage.eINSTANCE.getShape_XorFill())) {%>
+ <%=shapeVarName%>.setFillXOR(<%=shapeFigure.isXorFill()%>);
+<%} if (shapeFigure.eIsSet(GMFGraphPackage.eINSTANCE.getShape_XorOutline())) {%>
+ <%=shapeVarName%>.setOutlineXOR(<%=shapeFigure.isXorOutline()%>);
+<%} if (shapeFigure instanceof Polyline && !((Polyline) shapeFigure).getTemplate().isEmpty()) {
+ for (Iterator pointIt = ((Polyline) shapeFigure).getTemplate().iterator(); pointIt.hasNext(); ) {
+ Point p = (Point) pointIt.next();%>
+ <%=shapeVarName%>.addPoint(new org.eclipse.draw2d.geometry.Point(<%=p.getX()%>, <%=p.getY()%>));
+<%}%><%} else if (shapeFigure instanceof RoundedRectangle) {
+ RoundedRectangle rrFigure = (RoundedRectangle) shapeFigure;%>
+ <%=shapeVarName%>.setCornerDimensions(new org.eclipse.draw2d.geometry.Dimension(<%=rrFigure.getCornerWidth()%>, <%=rrFigure.getCornerHeight()%>));
+<%}%><%@ include file="FigureAttrs.jetinc"%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/decoration.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/decoration.jetinc
new file mode 100644
index 000000000..447a41e18
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/decoration.jetinc
@@ -0,0 +1,11 @@
+ <%=fqnSwitch.doSwitch(df)%> <%=decFigVarName%> = new <%=fqnSwitch.doSwitch(df)%>();
+<%@ include file="FigureAttrs.jetinc"%>
+<% /*include FigureChildren*/ %>
+<%if ((df instanceof PolylineDecoration || df instanceof PolygonDecoration) && !((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 instanceof */ %>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/instantiate.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/instantiate.jetinc
new file mode 100644
index 000000000..a25433733
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/instantiate.jetinc
@@ -0,0 +1,19 @@
+<%
+// FigureMarker: figureMarker
+// String: figureVarName
+if (figureMarker instanceof CustomFigure) {
+%>
+ org.eclipse.draw2d.IFigure <%=figureVarName%> = new <%=((CustomFigure) figureMarker).getQualifiedClassName()%>();
+<%@ include file="FigureAttrs.jetinc"%>
+<%} else if (figureMarker instanceof Shape) {
+Shape shapeFigure = (Shape) figureMarker;
+String shapeVarName = figureVarName;%>
+ <%=fqnSwitch.doSwitch(figureMarker)%> <%=figureVarName%> = new <%=fqnSwitch.doSwitch(figureMarker)%>();
+<%@ include file="ShapeAttrs.jetinc"%>
+<%} else if (figureMarker instanceof FigureRef) {%>
+ org.eclipse.draw2d.IFigure <%=figureVarName%> = new <%=((FigureRef) figureMarker).getFigure().getName()%>();
+<%@ include file="FigureAttrs.jetinc"%>
+<%} else if (figureMarker instanceof Label) {%>
+ org.eclipse.draw2d.Label <%=figureVarName%> = new org.eclipse.draw2d.Label();
+ <%=figureVarName%>.setText("<%=((Label) figureMarker).getText()%>");
+<%@ include file="FigureAttrs.jetinc"%><%}%> \ No newline at end of file

Back to the top