### Eclipse Workspace Patch 1.0 #P org.eclipse.gmf.graphdef.codegen Index: templates/attr/Figure.javajet =================================================================== RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/Figure.javajet,v retrieving revision 1.7 diff -u -r1.7 Figure.javajet --- templates/attr/Figure.javajet 26 Jun 2006 16:49:29 -0000 1.7 +++ templates/attr/Figure.javajet 8 Sep 2006 16:21:29 -0000 @@ -6,17 +6,37 @@ final String figureVarName = args.getVariableName(); final GraphDefDispatcher dispatcher = args.getDispatcher(); final ImportAssistant importManager = dispatcher.getImportManager(); + +class SafeColorName { + public String getForegroundName(Figure figure){ + return getName(figure, "_FORE"); + } + + public String getBackgroundName(Figure figure){ + return getName(figure, "_BACK"); + } + + private String getName(Figure figure, String suffix){ + String figureName = figure.getName(); + //just safety -- see #156702 + if (figureName == null){ + figureName = "AUX"; + } + return figureName.toUpperCase() + suffix; + } +} +final SafeColorName safeColorName = new SafeColorName(); %> <% Color colorVal; String colorName; if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) { colorVal = figureInstance.getForegroundColor(); - colorName = figureInstance.getName().toUpperCase() + "_FORE";%> + colorName = safeColorName.getForegroundName(figureInstance);%> <%=figureVarName%>.setForegroundColor(<%@ include file="../Color.jetinc"%>); <%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) { colorVal = figureInstance.getBackgroundColor(); - colorName = figureInstance.getName().toUpperCase() + "_BACK";%> + colorName = safeColorName.getBackgroundName(figureInstance);%> <%=figureVarName%>.setBackgroundColor(<%@ include file="../Color.jetinc"%>); <%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) { Dimension d = figureInstance.getPreferredSize();%> Index: src/org/eclipse/gmf/graphdef/codegen/templates/FigureAttrGenerator.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/FigureAttrGenerator.java,v retrieving revision 1.9 diff -u -r1.9 FigureAttrGenerator.java --- src/org/eclipse/gmf/graphdef/codegen/templates/FigureAttrGenerator.java 24 Jul 2006 17:38:38 -0000 1.9 +++ src/org/eclipse/gmf/graphdef/codegen/templates/FigureAttrGenerator.java 8 Sep 2006 16:21:29 -0000 @@ -64,12 +64,32 @@ final GraphDefDispatcher dispatcher = args.getDispatcher(); final ImportAssistant importManager = dispatcher.getImportManager(); +class SafeColorName { + public String getForegroundName(Figure figure){ + return getName(figure, "_FORE"); + } + + public String getBackgroundName(Figure figure){ + return getName(figure, "_BACK"); + } + + private String getName(Figure figure, String suffix){ + String figureName = figure.getName(); + //just safety -- see #156702 + if (figureName == null){ + figureName = "AUX"; + } + return figureName.toUpperCase() + suffix; + } +} +final SafeColorName safeColorName = new SafeColorName(); + Color colorVal; String colorName; if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) { colorVal = figureInstance.getForegroundColor(); - colorName = figureInstance.getName().toUpperCase() + "_FORE"; + colorName = safeColorName.getForegroundName(figureInstance); stringBuffer.append(TEXT_1); stringBuffer.append(figureVarName); stringBuffer.append(TEXT_2); @@ -94,7 +114,7 @@ stringBuffer.append(TEXT_3); } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())) { colorVal = figureInstance.getBackgroundColor(); - colorName = figureInstance.getName().toUpperCase() + "_BACK"; + colorName = safeColorName.getBackgroundName(figureInstance); stringBuffer.append(TEXT_4); stringBuffer.append(figureVarName); stringBuffer.append(TEXT_5); #P org.eclipse.gmf.tests Index: src/org/eclipse/gmf/tests/setup/figures/AbstractFigureGeneratorSetup.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.gmf/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/figures/AbstractFigureGeneratorSetup.java,v retrieving revision 1.1 diff -u -r1.1 AbstractFigureGeneratorSetup.java --- src/org/eclipse/gmf/tests/setup/figures/AbstractFigureGeneratorSetup.java 27 Jul 2006 14:08:14 -0000 1.1 +++ src/org/eclipse/gmf/tests/setup/figures/AbstractFigureGeneratorSetup.java 8 Sep 2006 16:21:35 -0000 @@ -13,10 +13,10 @@ import junit.framework.Assert; +import org.eclipse.gmf.gmfgraph.ColorConstants; import org.eclipse.gmf.gmfgraph.Figure; import org.eclipse.gmf.gmfgraph.FigureGallery; import org.eclipse.gmf.gmfgraph.GMFGraphFactory; -import org.eclipse.gmf.gmfgraph.Point; import org.eclipse.gmf.gmfgraph.PolygonDecoration; import org.eclipse.gmf.gmfgraph.PolylineConnection; import org.eclipse.gmf.graphdef.codegen.StandaloneGenerator.Config; @@ -85,31 +85,22 @@ if (myEcoreContainmentRef == null) { myEcoreContainmentRef = GMFGraphFactory.eINSTANCE.createPolylineConnection(); myEcoreContainmentRef.setName("ContainmentRef"); - PolygonDecoration df = createRhomb(); + PolygonDecoration df = createBlueRhomb(); df.setFill(true); myEcoreContainmentRef.setSourceDecoration(df); } return myEcoreContainmentRef; } - private PolygonDecoration createRhomb() { + private PolygonDecoration createBlueRhomb() { PolygonDecoration df = GMFGraphFactory.eINSTANCE.createPolygonDecoration(); - Point p = GMFGraphFactory.eINSTANCE.createPoint(); - p.setX(-1); - p.setY(1); - df.getTemplate().add(p); - p = GMFGraphFactory.eINSTANCE.createPoint(); - p.setX(0); - p.setY(0); - df.getTemplate().add(p); - p = GMFGraphFactory.eINSTANCE.createPoint(); - p.setX(-1); - p.setY(-1); - df.getTemplate().add(p); - p = GMFGraphFactory.eINSTANCE.createPoint(); - p.setX(-2); - p.setY(0); - df.getTemplate().add(p); + df.getTemplate().add(FigureGeneratorUtil.createPoint(-1, 1)); + df.getTemplate().add(FigureGeneratorUtil.createPoint(0, 0)); + df.getTemplate().add(FigureGeneratorUtil.createPoint(-1, -1)); + df.getTemplate().add(FigureGeneratorUtil.createPoint(-2, 0)); + + df.setBackgroundColor(FigureGeneratorUtil.createConstantColor(ColorConstants.BLUE_LITERAL)); + df.setForegroundColor(FigureGeneratorUtil.createRGBColor(0, 0, 255)); return df; }