Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-11-02 16:58:29 -0500
committeratikhomirov2006-11-02 16:58:29 -0500
commit87f9ae89b931710cf24bd695b81ab8e3d219c88a (patch)
treec0382fe2792d9359c1ee17ca9a346eb22bf21b29 /plugins/org.eclipse.gmf.graphdef.codegen/templates/attr
parentbfa530a7515d8bc44f9d0c4d89d6db7ad9403dda (diff)
downloadorg.eclipse.gmf-tooling-87f9ae89b931710cf24bd695b81ab8e3d219c88a.tar.gz
org.eclipse.gmf-tooling-87f9ae89b931710cf24bd695b81ab8e3d219c88a.tar.xz
org.eclipse.gmf-tooling-87f9ae89b931710cf24bd695b81ab8e3d219c88a.zip
JET templates for gmfgraph model replaced with Xpand counterparts.
MapMode handling simplified
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen/templates/attr')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet43
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.xpt37
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomFigure.javajet10
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Decoration.xpt51
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet56
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.xpt84
-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.javajet27
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.xpt47
13 files changed, 219 insertions, 202 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet
deleted file mode 100644
index afd9d391e..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.javajet
+++ /dev/null
@@ -1,43 +0,0 @@
-<%@ 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];
-boolean insertingArbitraryCode = false;
-for (Iterator attributes = instance.getAttributes().iterator(); !insertingArbitraryCode && attributes.hasNext();){
- insertingArbitraryCode = ((CustomAttribute)attributes.next()).isMultiStatementValue();
-}
-%>
-<% if (insertingArbitraryCode) {%>
- {
-<% }%>
-<%
-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
-%>
-<% if (insertingArbitraryCode) {%>
- }
-<% }%>
-
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.xpt
new file mode 100644
index 000000000..26b38b281
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomClass.xpt
@@ -0,0 +1,37 @@
+/*
+ * 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"»
+«EXTENSION Util»
+
+«DEFINE Init(EString instanceVarName) FOR gmfgraph::CustomClass»
+«EXPAND customAttribute(instanceVarName) FOREACH attributes»
+«ENDDEFINE»
+
+«DEFINE customAttribute(EString instanceVarName) FOR gmfgraph::CustomAttribute»
+«EXPAND customAttrValueImpl-»
+«IF directAccess»
+«instanceVarName».«name» = «EXPAND customAttrValue»;
+«ELSE»
+«instanceVarName».set«name.toFirstUpper()»(«EXPAND customAttrValue»);
+«ENDIF»
+«ENDDEFINE»
+
+«DEFINE customAttrValueImpl FOR gmfgraph::CustomAttribute»
+«IF multiStatementValue-»
+«messageFormat(value, {"attr" + name.toFirstUpper()})-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE customAttrValue FOR gmfgraph::CustomAttribute»
+«IF multiStatementValue»attr«name.toFirstUpper()»«ELSE-»«value»«ENDIF-»
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomFigure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomFigure.javajet
deleted file mode 100644
index cc599b288..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/CustomFigure.javajet
+++ /dev/null
@@ -1,10 +0,0 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="CustomFigureAttrGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher"%>
-<%
-GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
-final CustomFigure figureInstance = (CustomFigure) args.getFigure();
-final String figureVarName = args.getVariableName();
-final GraphDefDispatcher dispatcher = args.getDispatcher();
-%>
-<%=dispatcher.dispatch("customAttributes", new Object[] {figureInstance, dispatcher, figureVarName})%>
-<%=dispatcher.dispatch("Figure", args)%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Decoration.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Decoration.xpt
new file mode 100644
index 000000000..4e9257c39
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Decoration.xpt
@@ -0,0 +1,51 @@
+/*
+ * 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 polylineAttrs(String figureVarName) FOR gmfgraph::PolylineDecoration-»
+«EXPAND attr::Shape::shapeAttrs(figureVarName)-»
+«EXPAND templatePoints(figureVarName)-»
+«EXPAND scale(figureVarName)-»
+«ENDDEFINE»
+
+«DEFINE polylineAttrs(String figureVarName) FOR gmfgraph::PolygonDecoration-»
+«EXPAND attr::Shape::shapeAttrs(figureVarName)-»
+«EXPAND templatePoints(figureVarName)-»
+«EXPAND scale(figureVarName)-»
+«ENDDEFINE»
+
+«DEFINE templatePoints(String figureVarName) FOR gmfgraph::Polyline-»
+«IF !template.isEmpty()-»
+org.eclipse.draw2d.geometry.PointList pl = new org.eclipse.draw2d.geometry.PointList();
+«EXPAND templatePoint("pl") FOREACH template-»
+«figureVarName».setTemplate(pl);
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE templatePoint(String pointListVarName) FOR gmfgraph::Point-»
+«pointListVarName».addPoint(«EXPAND MapMode::map»);
+«ENDDEFINE»
+
+«DEFINE scale(String figureVarName) FOR gmfgraph::PolylineDecoration-»
+«IF !template.isEmpty()-»
+«figureVarName».setScale(«EXPAND MapMode::map FOR 7», «EXPAND MapMode::map FOR 3»);
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE scale(String figureVarName) FOR gmfgraph::PolygonDecoration-»
+«IF !template.isEmpty()-»
+«figureVarName».setScale(«EXPAND MapMode::map FOR 7», «EXPAND MapMode::map FOR 3»);
+«ENDIF-»
+«ENDDEFINE» \ 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
deleted file mode 100644
index d15a4f8a5..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet
+++ /dev/null
@@ -1,56 +0,0 @@
-<%@ 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.GraphDefDispatcher"%>
-<%
-GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
-final Figure figureInstance = args.getFigure();
-final String figureVarName = args.getVariableName();
-final GraphDefDispatcher dispatcher = args.getDispatcher();
-final ImportAssistant importManager = dispatcher.getImportManager();
-%>
-<%
-Color colorVal;
-String colorName;
-if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
- colorVal = figureInstance.getForegroundColor();
- colorName = figureInstance.getName().toUpperCase() + "_FORE";%>
- <%=figureVarName%>.setForegroundColor(<%@ include file="../Color.jetinc"%>);
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
- colorVal = figureInstance.getBackgroundColor();
- colorName = figureInstance.getName().toUpperCase() + "_BACK";%>
- <%=figureVarName%>.setBackgroundColor(<%@ include file="../Color.jetinc"%>);
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) {
- Dimension d = figureInstance.getPreferredSize();%>
- <%=figureVarName%>.setPreferredSize(<%=dispatcher.DPtoLP(d.getDx())%>, <%=dispatcher.DPtoLP(d.getDy())%>);
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_Size())) {
- Point p = figureInstance.getSize();%>
- <%=figureVarName%>.setSize(<%=dispatcher.DPtoLP(p.getX())%>, <%=dispatcher.DPtoLP(p.getY())%>);
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_MaximumSize())) {
- Dimension d = figureInstance.getMaximumSize();%>
- <%=figureVarName%>.setMaximumSize(new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%>(<%=dispatcher.DPtoLP(d.getDx())%>, <%=dispatcher.DPtoLP(d.getDy())%>));
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_MinimumSize())) {
- Dimension d = figureInstance.getMinimumSize();%>
- <%=figureVarName%>.setMinimumSize(new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%>(<%=dispatcher.DPtoLP(d.getDx())%>, <%=dispatcher.DPtoLP(d.getDy())%>));
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_Font())) {
- // XXX possible CCE when fonts other than Basic added to model
- BasicFont font = (BasicFont) figureInstance.getFont();
- String fontName = font.getFaceName();
- if (fontName == null || fontName.trim().length() == 0){
- org.eclipse.swt.graphics.Font system = org.eclipse.swt.widgets.Display.getDefault().getSystemFont();
- if (system != null && system.getFontData().length > 0){
- fontName = system.getFontData()[0].getName();
- }
- }
- %>
- <%=figureVarName%>.setFont(
- <%=dispatcher.getStaticFieldsManager().addStaticField(
- importManager.getImportedName("org.eclipse.swt.graphics.Font"),
- figureInstance.getName().toUpperCase() + "_FONT",
- "new " + importManager.getImportedName("org.eclipse.swt.graphics.Font") + "(" + importManager.getImportedName("org.eclipse.swt.widgets.Display") + ".getCurrent(), \"" + fontName + "\", " + font.getHeight() + ", " + importManager.getImportedName("org.eclipse.swt.SWT") + "." + font.getStyle().getLiteral() + ")"
- )%>);
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_Insets())) {
- Insets insets = figureInstance.getInsets();%>
- <%=figureVarName%>.setBorder(new <%=importManager.getImportedName("org.eclipse.draw2d.MarginBorder")%>(<%=dispatcher.DPtoLP(insets.getTop())%>, <%=dispatcher.DPtoLP(insets.getLeft())%>, <%=dispatcher.DPtoLP(insets.getBottom())%>, <%=dispatcher.DPtoLP(insets.getRight())%>));
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_Border())) {
- Border border = figureInstance.getBorder();%>
- <%=figureVarName%>.setBorder(<%=dispatcher.dispatch(border, new Object[] {border, dispatcher})%>);
-<%}%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.xpt
new file mode 100644
index 000000000..844e8eeb2
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.xpt
@@ -0,0 +1,84 @@
+/*
+ * 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 figureAttrs(EString figureVarName) FOR gmfgraph::Figure-»
+«EXPAND foregroundColor(this, figureVarName) FOR foregroundColor-»
+«EXPAND backgroundColor(this, figureVarName) FOR backgroundColor-»
+«EXPAND font(this, figureVarName) FOR font-»
+«EXPAND preferredSize(figureVarName) FOR preferredSize-»
+«EXPAND maximumSize(figureVarName) FOR maximumSize-»
+«EXPAND minimumSize(figureVarName) FOR minimumSize-»
+«EXPAND size(figureVarName) FOR size-»
+«EXPAND insets(figureVarName) FOR insets-»
+«EXPAND Border::Init(figureVarName) FOR border-»
+«ENDDEFINE»
+
+«DEFINE foregroundColor(gmfgraph::Figure figure, String figureVarName) FOR gmfgraph::Color-»
+ «figureVarName».setForegroundColor(«EXPAND color(figure.name.toUpperCase() + "_FORE")»);
+«ENDDEFINE»
+«DEFINE backgroundColor(gmfgraph::Figure figure, String figureVarName) FOR gmfgraph::Color-»
+ «figureVarName».setBackgroundColor(«EXPAND color(figure.name.toUpperCase() + "_BACK")»);
+«ENDDEFINE»
+
+«DEFINE preferredSize(EString figureVarName) FOR gmfgraph::Dimension-»
+«figureVarName».setPreferredSize(new org.eclipse.draw2d.geometry.Dimension(«EXPAND MapMode::map»));
+«ENDDEFINE»
+
+«DEFINE maximumSize(EString figureVarName) FOR gmfgraph::Dimension-»
+«figureVarName».setMaximumSize(new org.eclipse.draw2d.geometry.Dimension(«EXPAND MapMode::map»));
+«ENDDEFINE»
+
+«DEFINE minimumSize(EString figureVarName) FOR gmfgraph::Dimension-»
+«figureVarName».setMinimumSize(new org.eclipse.draw2d.geometry.Dimension(«EXPAND MapMode::map»));
+«ENDDEFINE»
+
+«DEFINE size(EString figureVarName) FOR gmfgraph::Point-»
+«figureVarName».setSize(«EXPAND MapMode::map»);
+«ENDDEFINE»
+
+«DEFINE insets(EString figureVarName) FOR gmfgraph::Insets-»
+«REM»using MarginBorder for insets is not good idea«ENDREM»
+«figureVarName».setBorder(new org.eclipse.draw2d.MarginBorder(«EXPAND MapMode::map»));
+«ENDDEFINE»
+
+«DEFINE font(Figure figure, EString figureVarName) FOR gmfgraph::Font»
+«ERROR "This is abstact definition, just to overcome some xpand polymorphism limitations"»
+«ENDDEFINE»
+
+«DEFINE color(String variableName) FOR gmfgraph::Color»
+«ERROR "This is abstact definition, just to overcome some xpand polymorphism limitations"»
+«ENDDEFINE»
+
+«DEFINE color(String variableName) FOR gmfgraph::RGBColor-»
+«variableName-»
+«FILE "" staticFields»
+static final org.eclipse.swt.graphics.Color «variableName» = new org.eclipse.swt.graphics.Color(null, «red», «green», «blue»);
+«ENDFILE»
+«ENDDEFINE»
+
+«DEFINE color(String variableName) FOR gmfgraph::ConstantColor-»
+org.eclipse.draw2d.ColorConstants.«value.literal-»
+«ENDDEFINE»
+
+«DEFINE font(Figure figure, EString figureVarName) FOR gmfgraph::BasicFont-»
+«LET figure.name + "_FONT" AS variableName»
+«figureVarName».setFont(«variableName»);
+«FILE "" staticFields»
+static final org.eclipse.swt.graphics.Font «variableName» = new org.eclipse.swt.graphics.Font(org.eclipse.swt.widgets.Display.getCurrent(), «IF null == faceName || faceName.trim().length() == 0»org.eclipse.swt.widgets.Display.getDefault().getSystemFont().getFontData()[0].getName()«ELSE»"«faceName»"«ENDIF», «height», org.eclipse.swt.SWT.«style.literal»);
+«ENDFILE»
+«ENDLET»
+«ENDDEFINE»
+
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Label.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Label.javajet
deleted file mode 100644
index ee6031beb..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Label.javajet
+++ /dev/null
@@ -1,11 +0,0 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="LabelAttrGenerator"
- imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher"%>
-<%
-GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
-final Label figureInstance = (Label) args.getFigure();
-final String figureVarName = args.getVariableName();
-final GraphDefDispatcher 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
deleted file mode 100644
index f6a79b709..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylgonDecoration.javajet
+++ /dev/null
@@ -1,7 +0,0 @@
-<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="PolygonDecorationAttrGenerator"
- imports="org.eclipse.gmf.graphdef.codegen.GraphDefDispatcher"%>
-<%
-GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
-final GraphDefDispatcher 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
deleted file mode 100644
index 2fc5a5704..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Polyline.javajet
+++ /dev/null
@@ -1,16 +0,0 @@
-<%@ 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.GraphDefDispatcher"%>
-<%
-GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
-final Polyline figureInstance = (Polyline) args.getFigure();
-final String figureVarName = args.getVariableName();
-final GraphDefDispatcher dispatcher = args.getDispatcher();
-final ImportAssistant importManager = dispatcher.getImportManager();
-%>
-<%=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
deleted file mode 100644
index d7f485228..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylineDecoration.javajet
+++ /dev/null
@@ -1,21 +0,0 @@
-<%@ 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.GraphDefDispatcher java.util.*"%>
-<%
-GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
-// not PolylineDecoration, as we use same template from PolygonDecoration
-final Polyline figureInstance = (Polyline) args.getFigure();
-final String figureVarName = args.getVariableName();
-final GraphDefDispatcher dispatcher = args.getDispatcher();
-final ImportAssistant importManager = dispatcher.getImportManager();
-%>
-// 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(<%=dispatcher.DPtoLP(7)%>, <%=dispatcher.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
deleted file mode 100644
index 3267b4b51..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/RoundedRectangle.javajet
+++ /dev/null
@@ -1,11 +0,0 @@
-<%@ 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.GraphDefDispatcher"%>
-<%
-GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
-final RoundedRectangle figureInstance = (RoundedRectangle) args.getFigure();
-final String figureVarName = args.getVariableName();
-final GraphDefDispatcher dispatcher = args.getDispatcher();
-final ImportAssistant importManager = dispatcher.getImportManager();
-%>
-<%=dispatcher.dispatch("Shape", args)%>
-<%=figureVarName%>.setCornerDimensions(new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%>(<%=dispatcher.DPtoLP(figureInstance.getCornerWidth())%>, <%=dispatcher.DPtoLP(figureInstance.getCornerHeight())%>));
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.javajet
deleted file mode 100644
index 934a11c6a..000000000
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.javajet
+++ /dev/null
@@ -1,27 +0,0 @@
-<%@ 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.GraphDefDispatcher"%>
-<%
-GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument;
-final Shape figureInstance = (Shape) args.getFigure();
-final String figureVarName = args.getVariableName();
-final GraphDefDispatcher dispatcher = args.getDispatcher();
-final ImportAssistant importManager = dispatcher.getImportManager();
-%>
-<%
-// Most of the properties are set only if corresponding eProperty isSet.
-// The difference is in the default values. If default value of eProperty matches d2d one, the setter may be omitted.
-// d2d.Shape#fill == true (matches default of gmfgraph.Shape#fill), while d2d.Polyline#fill == false, thus we need additional check.
-// Note Polygon in the check instead of Polyline - (it looks like) there's no sense to setFill(true) for polylines in any case.
-%><%if (figureInstance instanceof Polygon ^ figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_Fill())) {%>
- <%=figureVarName%>.setFill(<%=figureInstance.isFill()%>);
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_Outline())) {%>
- <%=figureVarName%>.setOutline(<%=figureInstance.isOutline()%>);
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_LineWidth())) {%>
- <%=figureVarName%>.setLineWidth(<%=figureInstance.getLineWidth()%>);
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_LineKind())) {%>
- <%=figureVarName%>.setLineStyle(<%=importManager.getImportedName("org.eclipse.draw2d.Graphics")%>.<%=figureInstance.getLineKind().getName()%>);
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_XorFill())) {%>
- <%=figureVarName%>.setFillXOR(<%=figureInstance.isXorFill()%>);
-<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getShape_XorOutline())) {%>
- <%=figureVarName%>.setOutlineXOR(<%=figureInstance.isXorOutline()%>);
-<%}%><%=dispatcher.dispatch("Figure", args)%> \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.xpt
new file mode 100644
index 000000000..0cc32c81f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Shape.xpt
@@ -0,0 +1,47 @@
+/*
+ * 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"»
+
+// XXX call figureAttrs from this?
+«DEFINE shapeAttrs(EString figureVarName) FOR Shape-»
+«EXPAND fill(figureVarName)-»
+«EXPAND xorFill(figureVarName)-»
+«EXPAND outline(figureVarName)-»
+«EXPAND xorOutline(figureVarName)-»
+«EXPAND lineWidth(figureVarName)-»
+«EXPAND lineKind(figureVarName)-»
+«ENDDEFINE»
+
+«DEFINE fill(EString figureVarName) FOR Shape-»
+«figureVarName».setFill(«fill»);
+«ENDDEFINE»
+
+«DEFINE xorFill(EString figureVarName) FOR Shape-»
+«figureVarName».setFillXOR(«xorFill»);
+«ENDDEFINE»
+
+«DEFINE outline(EString figureVarName) FOR Shape-»
+«figureVarName».setOutline(«outline»);
+«ENDDEFINE»
+
+«DEFINE xorOutline(EString figureVarName) FOR Shape-»
+«figureVarName».setOutlineXOR(«xorOutline»);
+«ENDDEFINE»
+
+«DEFINE lineWidth(EString figureVarName) FOR Shape-»
+«figureVarName».setLineWidth(«lineWidth»);
+«ENDDEFINE»
+
+«DEFINE lineKind(EString figureVarName) FOR Shape-»
+«figureVarName».setLineStyle(org.eclipse.draw2d.Graphics.«lineKind.literal»);
+«ENDDEFINE»

Back to the top