Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen/templates/top')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet31
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt95
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet46
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Top.javajet53
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/customBorderFactoryMethods.jetinc38
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/localCoordinates.jetinc29
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/scalablePolygonAsInnerClass.jetinc20
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/scalablePolygonBehavior.jetinc76
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/staticFields.jetinc12
9 files changed, 95 insertions, 305 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
deleted file mode 100644
index 5feebb82a..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
+++ /dev/null
@@ -1,31 +0,0 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="TopFigureGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.* org.eclipse.emf.ecore.* java.util.Iterator org.eclipse.emf.ecore.util.EcoreUtil org.eclipse.emf.codegen.util.CodeGenUtil; "%>
-<%
-final GraphDefDispatcher.Args innerArgs = (GraphDefDispatcher.Args) ((Object[]) argument)[0];
-final Figure figure = innerArgs.getFigure();
-final GraphDefDispatcher dispatcher = innerArgs.getDispatcher();
-final ImportAssistant importManager = dispatcher.getImportManager();
-%>
-
-<%@ include file="customBorderFactoryMethods.jetinc"%>
-<%if (figure instanceof ScalablePolygon) {%>
-<%@ include file="scalablePolygonBehavior.jetinc"%>
-<%}%>
-
- /**
- * @generated
- */
- public <%=figure.getName()%>() {
-<%
-GraphDefDispatcher.LayoutArgs dispatcherArgs = dispatcher.createLayoutArgs(figure, "this", "myGenLayoutManager", null);
-%>
- <%=dispatcher.dispatch("createLayout", dispatcherArgs)%>
- <%=dispatcher.dispatch(figure, dispatcherArgs)%>
- createContents();
- }
-
-<%=dispatcher.dispatch("Children", dispatcherArgs)%>
-
-<%if (false == figure instanceof Polyline) {/*no much sense to define useLocalCoordinates for polyline and its descendants*/%>
-<%@ include file="localCoordinates.jetinc"%>
-<%}%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt
new file mode 100644
index 000000000..932398ae9
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.xpt
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2006 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+
+«IMPORT "http://www.eclipse.org/gmf/2005/GraphicalDefinition"»
+«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
+«IMPORT "templates"»
+«EXTENSION Util»
+
+«DEFINE FigureClass(boolean isInnerClass) FOR gmfgraph::Figure»
+«packageStatement()»
+/**
+ * @generated
+ */
+public class «compilationUnitName()» extends «qualifiedClassNameGEF()» {
+ /**
+ * @generated
+ */
+ public «compilationUnitName()»() {
+ «EXPAND Layout::Init("this") FOR layout-»
+ «EXPAND Attrs::Init("this")-»
+«IF !children.typeSelect(Figure).isEmpty()-»
+ createContents();
+ }
+«EXPAND Children::CreateChildren-»
+«ELSE-»
+ }
+«ENDIF-»
+«additionalMethods()»
+«EXPAND Extras::extraMethods»
+«EXPAND Extras::localCoordinates»
+«IF isInnerClass-»
+}
+«additionalStaticFields()»
+«ELSE-»
+«additionalStaticFields()»
+}
+«ENDIF-»
+«ENDDEFINE»
+
+
+«DEFINE FigureClass(boolean isInnerClass) FOR gmfgraph::PolylineConnection»
+«packageStatement()»
+/**
+ * @generated
+ */
+public class «compilationUnitName()» extends «qualifiedClassNameGEF()» {
+
+ /**
+ * @generated
+ */
+ public «compilationUnitName()»() {
+ «EXPAND Attrs::Init("this")»
+«IF hasSourceDecoration()-»
+ setSourceDecoration(createSourceDecoration());
+«ENDIF-»
+«IF hasTargetDecoration()-»
+ setTargetDecoration(createTargetDecoration());
+«ENDIF-»
+ }
+«IF hasSourceDecoration()»
+ /**
+ * @generated
+ */
+ private org.eclipse.draw2d.RotatableDecoration createSourceDecoration() {
+ «EXPAND Decoration::Instantiate("df") FOR sourceDecoration-»
+ return df;
+ }
+«ENDIF-»
+«IF hasTargetDecoration()»
+ /**
+ * @generated
+ */
+ private org.eclipse.draw2d.RotatableDecoration createTargetDecoration() {
+ «EXPAND Decoration::Instantiate("df") FOR targetDecoration-»
+ return df;
+ }
+«ENDIF-»
+«additionalMethods()»
+«IF isInnerClass-»
+}
+«additionalStaticFields()»
+«ELSE-»
+«additionalStaticFields()»
+}
+«ENDIF-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet
deleted file mode 100644
index b72f2c976..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet
+++ /dev/null
@@ -1,46 +0,0 @@
-<%@ 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.* org.eclipse.emf.ecore.* java.util.Iterator org.eclipse.emf.ecore.util.EcoreUtil org.eclipse.emf.codegen.util.CodeGenUtil;"%>
-<%
-final GraphDefDispatcher.Args innerArgs = (GraphDefDispatcher.Args) ((Object[]) argument)[0];
-final PolylineConnection figure = (PolylineConnection)innerArgs.getFigure();
-final GraphDefDispatcher dispatcher = innerArgs.getDispatcher();
-final ImportAssistant importManager = dispatcher.getImportManager();
-final FigureQualifiedNameSwitch fqnSwitch = dispatcher.getFQNSwitch();
-%>
-
-<%@ include file="customBorderFactoryMethods.jetinc"%>
-
- /**
- * @generated
- */
- public <%=figure.getName()%>() {
-<%=dispatcher.dispatch("Shape", dispatcher.create(figure, "this"))%>
-<%if (figure.getSourceDecoration() != null) {%>
- setSourceDecoration(createSourceDecoration());
-<%}
-if (figure.getTargetDecoration() != null) {%>
- setTargetDecoration(createTargetDecoration());
-<%}%>
- }
-
-<%if (figure.getSourceDecoration() != null) {
- final String className = fqnSwitch.get(figure.getSourceDecoration(), importManager);%>
- /**
- * @generated
- */
- private <%=className%> createSourceDecoration() {
-<%=dispatcher.dispatch("instantiate", dispatcher.create(figure.getSourceDecoration(), "df"))%>
- return df;
- }
-<%} /*if sourceDecoration != null */ %>
-
-<%if (figure.getTargetDecoration() != null) {
- final String className = fqnSwitch.get(figure.getTargetDecoration(), importManager);%>
- /**
- * @generated
- */
- private <%=className%> createTargetDecoration() {
-<%=dispatcher.dispatch("instantiate", dispatcher.create(figure.getTargetDecoration(), "df"))%>
- return df;
- }
-<%}%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Top.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Top.javajet
deleted file mode 100644
index be427c250..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Top.javajet
+++ /dev/null
@@ -1,53 +0,0 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="TopGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.* org.eclipse.emf.ecore.* java.util.Iterator org.eclipse.emf.ecore.util.EcoreUtil; "%>
-<%
-Object[] args = (Object[]) argument;
-Figure figure = (Figure) args[0];
-final GraphDefDispatcher /*inner*/dispatcher = (GraphDefDispatcher) args[1];
-final GraphDefDispatcher topDispatcher = (GraphDefDispatcher) args[2];
-final boolean isStaticFieldsOutsideClassBody = ((Boolean) args[3]).booleanValue();
-
-class Asserter {
- void makeAssert(boolean checkTrue){
- assert checkTrue;
- //temporarily use more forced way to ensure assertion
- //TODO: replace with single assert
- if (!checkTrue){
- throw new IllegalStateException("Enable Assertions");
- }
- }
-}
-
-final Asserter myAsserter = new Asserter();
-myAsserter.makeAssert(topDispatcher.getImportManager() == /*inner*/dispatcher.getImportManager());
-myAsserter.makeAssert(topDispatcher.getFQNSwitch() == /*inner*/dispatcher.getFQNSwitch());
-
-final ImportAssistant importManager = topDispatcher.getImportManager();
-final FigureQualifiedNameSwitch fqnSwitch = topDispatcher.getFQNSwitch();
-%>
-<%importManager.emitPackageStatement(stringBuffer);%>
-
-<%importManager.markImportLocation(stringBuffer);%>
-
-/**
- * @generated
- */
-public class <%=importManager.getCompilationUnitName()%> extends <%=fqnSwitch.get(figure, importManager)%> {
-
-<%@ include file="scalablePolygonAsInnerClass.jetinc"%>
-
-<% /*NOTE: class structure is selected by topDispatcher, but children, attributes etc -- by inner dispatcher*/ %>
-<%=topDispatcher.dispatch(figure, new Object[] {
- /*inner*/dispatcher.create(figure, "this"),
- topDispatcher.create(figure, "this")
-})%>
-
-<%
-if (isStaticFieldsOutsideClassBody){ /*put fields out of inner class body*/ %>
-}
- <%@ include file="staticFields.jetinc"%>
-<% } else { %>
- <%@ include file="staticFields.jetinc"%>
-}
-<%}%>
-<%importManager.emitSortedImports();%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/customBorderFactoryMethods.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/customBorderFactoryMethods.jetinc
deleted file mode 100644
index 78d4422f3..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/customBorderFactoryMethods.jetinc
+++ /dev/null
@@ -1,38 +0,0 @@
-<%
-//input: [oeg].common.codegen.ImportAssistant importManager
-//input: [oeg].graphdef.codegen GraphDefDispatcher dispatcher
-//input: [oeg].gmfgraph.Figure figure
-
-{ //namespace -- use "bfm" (stands for BorderFactoryMethod) to avoid name clashes
- int bfmNextIndex = 1;
- String bfmLastFigureName = "";
- for (Iterator bfmAllCustomBorders = EcoreUtil.getAllContents(figure, false); bfmAllCustomBorders.hasNext();){
- EObject bfmNext = (EObject)bfmAllCustomBorders.next();
- if (GMFGraphPackage.eINSTANCE.getFigure().isSuperTypeOf(bfmNext.eClass())){
- bfmLastFigureName = (String)bfmNext.eGet(GMFGraphPackage.eINSTANCE.getIdentity_Name());
- if (bfmLastFigureName == null){
- bfmLastFigureName = "";
- }
- }
- // XXX [artem] why not do this with ((Figure) bfmNext).getBorder()?
- if (bfmNext.eClass().getClassifierID() != GMFGraphPackage.CUSTOM_BORDER){
- continue;
- }
-
- String bfmNextImplClass = dispatcher.getFQNSwitch().get(bfmNext, importManager);
- String bfmNextMethodName = "createBorder_" + CodeGenUtil.capName(bfmLastFigureName) + "_" + (bfmNextIndex++);
-
-%>
- /**
- * @generated
- */
- private <%=importManager.getImportedName("org.eclipse.draw2d.Border")%> <%=bfmNextMethodName%>() {
- <%=bfmNextImplClass%> result = new <%=bfmNextImplClass%>();
- <%=dispatcher.dispatch("customAttributes", new Object[] {bfmNext, dispatcher, "result"} )%>
- return result;
- }
-<%
- dispatcher.getAuxiliaryDataStorage().registerData(bfmNext, bfmNextMethodName);
- }
-} //end of namespace
-%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/localCoordinates.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/localCoordinates.jetinc
deleted file mode 100644
index 94e33768e..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/localCoordinates.jetinc
+++ /dev/null
@@ -1,29 +0,0 @@
-<%
-// simple heuristic to detect need for local coordinates
-boolean useLocalDefaultValue = false;
-for (java.util.Iterator it = figure.getChildren().iterator(); it.hasNext(); ) {
- if (it.next() instanceof Polyline) {
- useLocalDefaultValue = true;
- break;
- }
-}
-%>
- /**
- * @generated
- */
- private boolean myUseLocalCoordinates = <%=useLocalDefaultValue%>;
-
- /**
- * @generated
- */
- protected boolean useLocalCoordinates() {
- return myUseLocalCoordinates;
- }
-
- /**
- * @generated
- */
- protected void setUseLocalCoordinates(boolean useLocalCoordinates) {
- myUseLocalCoordinates = useLocalCoordinates;
- }
- \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/scalablePolygonAsInnerClass.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/scalablePolygonAsInnerClass.jetinc
deleted file mode 100644
index 77213ee45..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/scalablePolygonAsInnerClass.jetinc
+++ /dev/null
@@ -1,20 +0,0 @@
-<%
-//input: [oeg].gmfgraph.Figure figure
-{ //namespace, prefix spic (stands for Scalable Polygon as Inner Class) to avoid name clashes
- boolean spicFound = false;
- for (Iterator spicAllPolygons = EcoreUtil.getAllContents(figure, false); !spicFound && spicAllPolygons.hasNext();){
- EObject spicNext = (EObject)spicAllPolygons.next();
- spicFound = GMFGraphPackage.eINSTANCE.getScalablePolygon().isSuperTypeOf(spicNext.eClass());
- }
- if (spicFound) {
-%>
-/**
- * @generated
- */
-public class ScalablePolygon extends org.eclipse.draw2d.Shape {
-<%@ include file="scalablePolygonBehavior.jetinc"%>
-}
-<%
- }
-} // end of namespace
-%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/scalablePolygonBehavior.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/scalablePolygonBehavior.jetinc
deleted file mode 100644
index 457cb650c..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/scalablePolygonBehavior.jetinc
+++ /dev/null
@@ -1,76 +0,0 @@
- /**
- * @generated
- */
- private final org.eclipse.draw2d.geometry.PointList myTemplate = new org.eclipse.draw2d.geometry.PointList();
- /**
- * @generated
- */
- private org.eclipse.draw2d.geometry.Rectangle myTemplateBounds;
-
- /**
- * @generated
- */
- public void addPoint(org.eclipse.draw2d.geometry.Point point){
- myTemplate.addPoint(point);
- myTemplateBounds = null;
- }
-
- /**
- * @generated
- */
- protected void fillShape(org.eclipse.draw2d.Graphics graphics) {
- org.eclipse.draw2d.geometry.Rectangle bounds = getBounds();
- graphics.pushState();
- graphics.translate(bounds.x, bounds.y);
- graphics.fillPolygon(scalePointList());
- graphics.popState();
- }
-
- /**
- * @generated
- */
- protected void outlineShape(org.eclipse.draw2d.Graphics graphics) {
- org.eclipse.draw2d.geometry.Rectangle bounds = getBounds();
- graphics.pushState();
- graphics.translate(bounds.x, bounds.y);
- graphics.drawPolygon(scalePointList());
- graphics.popState();
- }
-
- /**
- * @generated
- */
- private org.eclipse.draw2d.geometry.Rectangle getTemplateBounds(){
- if (myTemplateBounds == null) {
- myTemplateBounds = myTemplate.getBounds().getCopy().union(0, 0);
- //just safety -- we are going to use this as divider
- if (myTemplateBounds.width < 1){
- myTemplateBounds.width = 1;
- }
- if (myTemplateBounds.height < 1){
- myTemplateBounds.height = 1;
- }
- }
- return myTemplateBounds;
- }
-
- /**
- * @generated
- */
- private int[] scalePointList() {
- org.eclipse.draw2d.geometry.Rectangle pointsBounds = getTemplateBounds();
- org.eclipse.draw2d.geometry.Rectangle actualBounds = getBounds();
-
- float xScale = ((float) actualBounds.width) / pointsBounds.width;
- float yScale = ((float) actualBounds.height) / pointsBounds.height;
-
- if (xScale == 1 && yScale == 1) {
- return myTemplate.toIntArray();
- }
- int[] scaled = (int[]) myTemplate.toIntArray().clone();
- for (int i = 0; i < scaled.length; i += 2) {
- scaled[i] = (int) Math.floor(scaled[i] * xScale);
- scaled[i + 1] = (int) Math.floor(scaled[i + 1] * yScale);
- }
- return scaled;
- }
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/staticFields.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/staticFields.jetinc
deleted file mode 100644
index 2ddbf7166..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/staticFields.jetinc
+++ /dev/null
@@ -1,12 +0,0 @@
-<%
-//input: [oeg].graphdef.codegen GraphDefDispatcher dispatcher
-for (Iterator allFields = dispatcher.getStaticFieldsManager().allFields(); allFields.hasNext();) {
- StaticFieldsManager.StaticField next = (StaticFieldsManager.StaticField)allFields.next(); %>
-
- /**
- * @generated
- */
- public static final <%=next.getType()%> <%=next.getName()%> = <%=next.getValue()%>;
-<%
-}
-%>

Back to the top