Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Color.jetinc18
1 files changed, 17 insertions, 1 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);
+ }
+%>
+

Back to the top