Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-06-26 16:49:24 +0000
committeratikhomirov2006-06-26 16:49:24 +0000
commit9093b1177a22db7285ea170ba61cba9949ccb6b7 (patch)
tree55c46fa43eab0565e78f9fb22133f74c35a995dd /plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet
parentd77721c7f3422e6108bea6de89e0016c1a40c0d7 (diff)
downloadorg.eclipse.gmf-tooling-9093b1177a22db7285ea170ba61cba9949ccb6b7.tar.gz
org.eclipse.gmf-tooling-9093b1177a22db7285ea170ba61cba9949ccb6b7.tar.xz
org.eclipse.gmf-tooling-9093b1177a22db7285ea170ba61cba9949ccb6b7.zip
[mgolubev] #148402 Do not create unlimited number of font/color resources.
Diffstat (limited to 'plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet17
1 files changed, 13 insertions, 4 deletions
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())%>));

Back to the top