Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen/templates')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc18
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet17
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LineBorder.javajet1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet6
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet6
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/classFooter.jetinc10
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/top/staticFields.jetinc12
7 files changed, 61 insertions, 9 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc
index 9ed864a0e..a88e72277 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc
@@ -1 +1,17 @@
-<%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
+<%
+//input: [oeg].gmfgraph.Color colorVal
+//input: String colorName
+//input: [oeg].common.codegen.ImportAssistant importManager
+//input: [oeg].graphdef.codegen GraphDefDispatcher dispatcher
+
+ if (colorVal instanceof RGBColor) {
+ String staticFieldType = importManager.getImportedName("org.eclipse.swt.graphics.Color");
+ String staticFieldName = (colorName == null) ? "COLOR" : colorName;
+ String staticFieldValue = "new " + staticFieldType + "(null, " + ((RGBColor)colorVal).getRed() + ", " + ((RGBColor)colorVal).getGreen() + ", " + ((RGBColor)colorVal).getBlue() + ")";
+%><%=dispatcher.getStaticFieldsManager().addStaticField(staticFieldType, staticFieldName, staticFieldValue)%>
+<% } else if (colorVal instanceof ConstantColor) {%><%=importManager.getImportedName("org.eclipse.draw2d.ColorConstants") + "." + ((ConstantColor) colorVal).getValue().getLiteral()%>
+<% } else {
+ throw new IllegalStateException("Unknown color: " + colorVal);
+ }
+%>
+
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet
index 5cac62da6..d15a4f8a5 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet
@@ -7,12 +7,16 @@ final String figureVarName = args.getVariableName();
final GraphDefDispatcher dispatcher = args.getDispatcher();
final ImportAssistant importManager = dispatcher.getImportManager();
%>
-<%Color colorVal;
+<%
+Color colorVal;
+String colorName;
if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) {
- colorVal = figureInstance.getForegroundColor();%>
+ colorVal = figureInstance.getForegroundColor();
+ colorName = figureInstance.getName().toUpperCase() + "_FORE";%>
<%=figureVarName%>.setForegroundColor(<%@ include file="../Color.jetinc"%>);
<%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) {
- colorVal = figureInstance.getBackgroundColor();%>
+ 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();%>
@@ -37,7 +41,12 @@ if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())
}
}
%>
- <%=figureVarName%>.setFont(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()%>));
+ <%=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())%>));
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LineBorder.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LineBorder.javajet
index 9a1e9de42..35824e222 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LineBorder.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/new/LineBorder.javajet
@@ -14,6 +14,7 @@ final ImportAssistant importManager = dispatcher.getImportManager();
boolean hasColor = border.eIsSet(GMFGraphPackage.eINSTANCE.getLineBorder_Color());
boolean hasWidth = border.eIsSet(GMFGraphPackage.eINSTANCE.getLineBorder_Width());
Color colorVal = (hasColor) ? border.getColor() : null;
+ String colorName = (hasColor) ? "BORDER" : null;
if (hasColor && hasWidth){
%>
new <%=borderClazz%>(<%@ include file="../Color.jetinc"%>, <%=dispatcher.DPtoLP(border.getWidth())%>)
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
index b84b34cef..aa4f4dba1 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/Figure.javajet
@@ -1,11 +1,12 @@
<%@ 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.*"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.* java.util.Iterator;"%>
<%
Object[] args = (Object[]) argument;
Figure figure = (Figure) args[0];
final ImportAssistant importManager = (ImportAssistant) args[1];
final FigureQualifiedNameSwitch fqnSwitch = (FigureQualifiedNameSwitch) args[2];
final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[3];
+final boolean isInnerClass = ((Boolean) args[4]).booleanValue();
%>
<%importManager.emitPackageStatement(stringBuffer);%>
@@ -33,4 +34,5 @@ GraphDefDispatcher.LayoutArgs dispatcherArgs = dispatcher.createLayoutArgs(figur
<%if (false == figure instanceof Polyline) {/*no much sense to define useLocalCoordinates for polyline and its descendants*/%>
<%@ include file="localCoordinates.jetinc"%>
<%}%>
-}<%importManager.emitSortedImports();%>
+<%@ include file="classFooter.jetinc"%>
+<%importManager.emitSortedImports();%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet
index 3ee0477b8..c20e4c0c8 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/PolylineConnection.javajet
@@ -1,11 +1,12 @@
<%@ 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.GraphDefDispatcher"%>
+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.gmfgraph.util.* org.eclipse.gmf.common.codegen.* org.eclipse.gmf.graphdef.codegen.* java.util.Iterator"%>
<%
Object[] args = (Object[]) argument;
PolylineConnection figure = (PolylineConnection) args[0];
final ImportAssistant importManager = (ImportAssistant) args[1];
final FigureQualifiedNameSwitch fqnSwitch = (FigureQualifiedNameSwitch) args[2];
final GraphDefDispatcher dispatcher = (GraphDefDispatcher) args[3];
+final boolean isInnerClass = ((Boolean) args[4]).booleanValue();
%>
<%importManager.emitPackageStatement(stringBuffer);%>
@@ -50,4 +51,5 @@ if (figure.getTargetDecoration() != null) {%>
return df;
}
<%}%>
-}<%importManager.emitSortedImports();%> \ No newline at end of file
+<%@ include file="classFooter.jetinc"%>
+<%importManager.emitSortedImports();%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/classFooter.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/classFooter.jetinc
new file mode 100644
index 000000000..2143d1a51
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/classFooter.jetinc
@@ -0,0 +1,10 @@
+<%
+//input: [oeg].graphdef.codegen GraphDefDispatcher dispatcher
+//input: boolean isInnerClass
+if (isInnerClass){ /*put fields out of inner class body*/ %>
+}
+ <%@ include file="staticFields.jetinc"%>
+<% } else { %>
+ <%@ include file="staticFields.jetinc"%>
+}
+<%}%>
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/staticFields.jetinc b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/staticFields.jetinc
new file mode 100644
index 000000000..2ddbf7166
--- /dev/null
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/top/staticFields.jetinc
@@ -0,0 +1,12 @@
+<%
+//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