Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 37412 Details for
Bug 134249
Generate all Figure/Shape properties
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Fixes the subj
patch_134249.txt (text/plain), 52.19 KB, created by
Michael Golubev
on 2006-03-31 09:57:43 EST
(
hide
)
Description:
Fixes the subj
Filename:
MIME Type:
Creator:
Michael Golubev
Created:
2006-03-31 09:57:43 EST
Size:
52.19 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.gmf.tests >Index: src/org/eclipse/gmf/tests/gen/GenericFigureCheck.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gen/GenericFigureCheck.java,v >retrieving revision 1.1 >diff -u -r1.1 GenericFigureCheck.java >--- src/org/eclipse/gmf/tests/gen/GenericFigureCheck.java 30 Mar 2006 13:38:09 -0000 1.1 >+++ src/org/eclipse/gmf/tests/gen/GenericFigureCheck.java 31 Mar 2006 14:57:30 -0000 >@@ -12,24 +12,32 @@ > > package org.eclipse.gmf.tests.gen; > >+import java.lang.reflect.Field; > import java.util.Iterator; > import java.util.List; > >+import org.eclipse.draw2d.Graphics; > import org.eclipse.draw2d.IFigure; > import org.eclipse.draw2d.geometry.PointList; > import org.eclipse.gmf.gmfgraph.BasicFont; >+import org.eclipse.gmf.gmfgraph.Border; > import org.eclipse.gmf.gmfgraph.Color; >-import org.eclipse.gmf.gmfgraph.ColorConstants; >+import org.eclipse.gmf.gmfgraph.CompoundBorder; > import org.eclipse.gmf.gmfgraph.ConstantColor; > import org.eclipse.gmf.gmfgraph.Dimension; > import org.eclipse.gmf.gmfgraph.Figure; > import org.eclipse.gmf.gmfgraph.Font; > import org.eclipse.gmf.gmfgraph.FontStyle; > import org.eclipse.gmf.gmfgraph.GMFGraphPackage; >+import org.eclipse.gmf.gmfgraph.Insets; > import org.eclipse.gmf.gmfgraph.Label; >+import org.eclipse.gmf.gmfgraph.LineBorder; >+import org.eclipse.gmf.gmfgraph.LineKind; >+import org.eclipse.gmf.gmfgraph.MarginBorder; > import org.eclipse.gmf.gmfgraph.Point; > import org.eclipse.gmf.gmfgraph.Polyline; > import org.eclipse.gmf.gmfgraph.RGBColor; >+import org.eclipse.gmf.gmfgraph.Shape; > import org.eclipse.swt.SWT; > import org.eclipse.swt.graphics.FontData; > import org.eclipse.swt.graphics.RGB; >@@ -46,12 +54,12 @@ > checkFigure(myGMFRootFigure, figure); > } > >- private void checkFigure(Figure gmfFigure, IFigure d2dFigure){ >+ protected void checkFigure(Figure gmfFigure, IFigure d2dFigure){ > checkFigureItself(gmfFigure, d2dFigure); > checkFigureChildren(gmfFigure, d2dFigure); > } > >- private void checkFigureChildren(Figure gmfFigure, IFigure d2dFigure){ >+ protected void checkFigureChildren(Figure gmfFigure, IFigure d2dFigure){ > List gmfChildren = gmfFigure.getChildren(); > List d2dChildren = d2dFigure.getChildren(); > assertNotNull(gmfChildren); >@@ -68,17 +76,57 @@ > } > } > >- private void checkFigureItself(Figure gmfFigure, IFigure d2dFigure){ >+ protected void checkFigureItself(Figure gmfFigure, IFigure d2dFigure){ > checkSize(gmfFigure, d2dFigure); >+ //XXX: checkLocation(gmfFigure, d2dFigure); >+ checkMaximumSize(gmfFigure, d2dFigure); >+ checkMinimumSize(gmfFigure, d2dFigure); > checkPreferredSize(gmfFigure, d2dFigure); > checkFont(gmfFigure, d2dFigure); > checkForeground(gmfFigure, d2dFigure); > checkBackgroud(gmfFigure, d2dFigure); >+ checkInsets(gmfFigure, d2dFigure); >+ checkBorder(gmfFigure, d2dFigure); >+ checkShapeProperties(gmfFigure, d2dFigure); > checkLabelText(gmfFigure, d2dFigure); > checkPolylinePoints(gmfFigure, d2dFigure); > } >+ >+ private void checkShapeProperties(Figure gmfFigure, IFigure figure) { >+ if (gmfFigure instanceof Shape){ >+ Shape eShape = (Shape)gmfFigure; >+ assertTrue(figure instanceof org.eclipse.draw2d.Shape); >+ org.eclipse.draw2d.Shape d2dShape = (org.eclipse.draw2d.Shape)figure; >+ checkLineKind(eShape, d2dShape); >+ checkLineWidth(eShape, d2dShape); >+ } >+ } >+ >+ protected void checkLineWidth(Shape eShape, org.eclipse.draw2d.Shape d2dShape) { >+ if (eShape.eIsSet(GMFGraphPackage.eINSTANCE.getShape_LineWidth())){ >+ int expected = eShape.getLineWidth(); >+ assertEquals(expected, d2dShape.getLineWidth()); >+ } >+ } >+ >+ protected void checkLineKind(Shape eShape, org.eclipse.draw2d.Shape d2dShape) { >+ if (eShape.eIsSet(GMFGraphPackage.eINSTANCE.getShape_LineKind())){ >+ LineKind expected = eShape.getLineKind(); >+ assertEquals(transformLineKind(expected), d2dShape.getLineStyle()); >+ } >+ } > >- private void checkPolylinePoints(Figure gmfFigure, IFigure d2dFigure) { >+ private int transformLineKind(LineKind kind){ >+ Object d2dValue = getStaticFieldValue("Unknown LineKind: " + kind, Graphics.class, kind.getName()); >+ assertTrue(d2dValue instanceof Integer); >+ return ((Integer)d2dValue).intValue(); >+ } >+ >+ protected final void checkDimension(Dimension eDimension, org.eclipse.draw2d.geometry.Dimension d2dDimension){ >+ assertEquals(new org.eclipse.draw2d.geometry.Dimension(eDimension.getDx(), eDimension.getDy()), d2dDimension); >+ } >+ >+ protected void checkPolylinePoints(Figure gmfFigure, IFigure d2dFigure) { > if (gmfFigure instanceof Polyline && gmfFigure.eIsSet(GMFGraphPackage.eINSTANCE.getPolyline_Template())){ > Polyline gmfPolyline = (Polyline)gmfFigure; > assertTrue(d2dFigure instanceof org.eclipse.draw2d.Polyline); >@@ -98,7 +146,7 @@ > > } > >- private void checkLabelText(Figure gmfFigure, IFigure d2dFigure) { >+ protected void checkLabelText(Figure gmfFigure, IFigure d2dFigure) { > if (gmfFigure instanceof Label && gmfFigure.eIsSet(GMFGraphPackage.eINSTANCE.getLabel_Text())){ > assertTrue(d2dFigure instanceof org.eclipse.draw2d.Label); > org.eclipse.draw2d.Label d2dLabel = (org.eclipse.draw2d.Label)d2dFigure; >@@ -107,19 +155,19 @@ > } > } > >- private void checkBackgroud(Figure gmfFigure, IFigure figure) { >+ protected void checkBackgroud(Figure gmfFigure, IFigure figure) { > if (gmfFigure.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_BackgroundColor())){ > checkColor(gmfFigure.getBackgroundColor(), figure.getBackgroundColor()); > } > } > >- private void checkForeground(Figure gmfFigure, IFigure figure) { >+ protected void checkForeground(Figure gmfFigure, IFigure figure) { > if (gmfFigure.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())){ > checkColor(gmfFigure.getForegroundColor(), figure.getForegroundColor()); > } > } > >- private void checkColor(Color eColor, org.eclipse.swt.graphics.Color swtColor){ >+ protected final void checkColor(Color eColor, org.eclipse.swt.graphics.Color swtColor){ > assertNotNull(swtColor); > assertNotNull(eColor); > >@@ -134,14 +182,14 @@ > assertEquals(expectedRGB, swtColor.getRGB()); > } > >- private void checkFont(Figure gmfFigure, IFigure figure) { >+ protected void checkFont(Figure gmfFigure, IFigure figure) { > if (gmfFigure.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_Font())){ > Font eFont = gmfFigure.getFont(); > checkFont(eFont, figure.getFont()); > } > } > >- private void checkFont(Font gmfFont, org.eclipse.swt.graphics.Font actual){ >+ protected final void checkFont(Font gmfFont, org.eclipse.swt.graphics.Font actual){ > assertNotNull(actual); > if (gmfFont instanceof BasicFont && actual.getFontData().length == 1){ > BasicFont expected = (BasicFont)gmfFont; >@@ -164,23 +212,22 @@ > } > > private org.eclipse.swt.graphics.Color transformConstantColor(ConstantColor color) { >- switch(color.getValue().getValue()){ >- case ColorConstants.BLACK : return org.eclipse.draw2d.ColorConstants.black; >- case ColorConstants.BLUE : return org.eclipse.draw2d.ColorConstants.blue; >- case ColorConstants.CYAN : return org.eclipse.draw2d.ColorConstants.cyan; >- case ColorConstants.DARK_BLUE : return org.eclipse.draw2d.ColorConstants.darkBlue; >- case ColorConstants.DARK_GRAY: return org.eclipse.draw2d.ColorConstants.darkGray; >- case ColorConstants.DARK_GREEN: return org.eclipse.draw2d.ColorConstants.darkGreen; >- case ColorConstants.GRAY: return org.eclipse.draw2d.ColorConstants.gray; >- case ColorConstants.GREEN: return org.eclipse.draw2d.ColorConstants.green; >- case ColorConstants.LIGHT_BLUE: return org.eclipse.draw2d.ColorConstants.lightBlue; >- case ColorConstants.LIGHT_GRAY: return org.eclipse.draw2d.ColorConstants.lightGray; >- case ColorConstants.LIGHT_GREEN: return org.eclipse.draw2d.ColorConstants.lightGreen; >- case ColorConstants.ORANGE: return org.eclipse.draw2d.ColorConstants.orange; >- case ColorConstants.RED: return org.eclipse.draw2d.ColorConstants.red; >- case ColorConstants.WHITE: return org.eclipse.draw2d.ColorConstants.white; >- case ColorConstants.YELLOW: return org.eclipse.draw2d.ColorConstants.yellow; >- default: throw new IllegalArgumentException("Unknown Color: " + color); >+ Class d2dClass = org.eclipse.draw2d.ColorConstants.class; >+ Object d2dValue = getStaticFieldValue("Unknown color: " + color, d2dClass, color.getValue().getLiteral()); >+ assertTrue(d2dValue instanceof org.eclipse.swt.graphics.Color); >+ return (org.eclipse.swt.graphics.Color)d2dValue; >+ } >+ >+ private Object getStaticFieldValue(String failureMessage, Class clazz, String fieldName){ >+ try { >+ Field constant = clazz.getField(fieldName); >+ assertNotNull(failureMessage, constant); >+ Object value = constant.get(null); >+ assertNotNull(failureMessage, value); >+ return value; >+ } catch (Exception e) { >+ fail(failureMessage + "\n" + e.toString()); >+ throw new InternalError("Unreachable"); > } > } > >@@ -188,18 +235,95 @@ > return new RGB(color.getRed(), color.getGreen(), color.getBlue()); > } > >- private void checkPreferredSize(Figure gmfFigure, IFigure figure) { >+ protected void checkPreferredSize(Figure gmfFigure, IFigure figure) { > if (gmfFigure.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())){ > Dimension ePreferredSize = gmfFigure.getPreferredSize(); >- assertEquals(new org.eclipse.draw2d.geometry.Dimension(ePreferredSize.getDx(), ePreferredSize.getDy()), figure.getPreferredSize()); >+ checkDimension(ePreferredSize, figure.getPreferredSize()); > } > } > >- private void checkSize(Figure gmfFigure, IFigure figure) { >+ protected void checkSize(Figure gmfFigure, IFigure figure) { > if (gmfFigure.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_Size())){ > Point eSize = gmfFigure.getSize(); > assertEquals(new org.eclipse.draw2d.geometry.Dimension(eSize.getX(), eSize.getY()), figure.getSize()); > } > } >+ >+ protected void checkMaximumSize(Figure gmfFigure, IFigure figure) { >+ if (gmfFigure.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_MaximumSize())){ >+ Dimension eSize = gmfFigure.getMaximumSize(); >+ checkDimension(eSize, figure.getMaximumSize()); >+ } >+ } >+ >+ protected void checkMinimumSize(Figure gmfFigure, IFigure figure) { >+ if (gmfFigure.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_MinimumSize())){ >+ Dimension eSize = gmfFigure.getMinimumSize(); >+ checkDimension(eSize, figure.getMinimumSize()); >+ } >+ } >+ >+ >+ protected void checkBorder(Figure gmfFigure, IFigure figure) { >+ if (gmfFigure.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_Border())){ >+ Border eBorder = gmfFigure.getBorder(); >+ checkBorder(eBorder, figure.getBorder(), figure); >+ } >+ } >+ >+ protected final void checkBorder(Border eBorder, org.eclipse.draw2d.Border d2dBorder, IFigure mainD2DFigure){ >+ assertNotNull(eBorder); >+ assertNotNull(d2dBorder); >+ if (eBorder instanceof LineBorder){ >+ checkLineBorder((LineBorder)eBorder, d2dBorder); >+ } else if (eBorder instanceof CompoundBorder){ >+ checkCompoundBorder((CompoundBorder)eBorder, d2dBorder, mainD2DFigure); >+ } else if (eBorder instanceof MarginBorder){ >+ checkMarginBorder((MarginBorder)eBorder, d2dBorder, mainD2DFigure); >+ } >+ } >+ >+ protected final void checkMarginBorder(MarginBorder eBorder, org.eclipse.draw2d.Border d2dBorder, IFigure mainD2DFigure) { >+ assertTrue(d2dBorder instanceof org.eclipse.draw2d.MarginBorder); >+ org.eclipse.draw2d.MarginBorder actual = (org.eclipse.draw2d.MarginBorder)d2dBorder; >+ if (eBorder.eIsSet(GMFGraphPackage.eINSTANCE.getMarginBorder_Insets())){ >+ Insets eInsets = eBorder.getInsets(); >+ checkInsets(eInsets, actual.getInsets(mainD2DFigure)); >+ } >+ } >+ >+ protected final void checkCompoundBorder(CompoundBorder eBorder, org.eclipse.draw2d.Border d2dBorder, IFigure mainD2DFigure){ >+ assertTrue(d2dBorder instanceof org.eclipse.draw2d.CompoundBorder); >+ org.eclipse.draw2d.CompoundBorder actual = (org.eclipse.draw2d.CompoundBorder)d2dBorder; >+ if (eBorder.eIsSet(GMFGraphPackage.eINSTANCE.getCompoundBorder_Inner())){ >+ checkBorder(eBorder.getInner(), actual.getInnerBorder(), mainD2DFigure); >+ } >+ if (eBorder.eIsSet(GMFGraphPackage.eINSTANCE.getCompoundBorder_Outer())){ >+ checkBorder(eBorder.getOuter(), actual.getOuterBorder(), mainD2DFigure); >+ } >+ } >+ >+ protected final void checkLineBorder(LineBorder eBorder, org.eclipse.draw2d.Border d2dBorder){ >+ assertTrue(d2dBorder instanceof org.eclipse.draw2d.LineBorder); >+ org.eclipse.draw2d.LineBorder actual = (org.eclipse.draw2d.LineBorder)d2dBorder; >+ //intentionally always checked, there is a default value mathcing default value in d2d >+ assertEquals(eBorder.getWidth(), actual.getWidth()); >+ >+ if (eBorder.eIsSet(GMFGraphPackage.eINSTANCE.getLineBorder_Color())){ >+ checkColor(eBorder.getColor(), actual.getColor()); >+ } >+ } >+ >+ protected void checkInsets(Figure gmfFigure, IFigure figure) { >+ if (gmfFigure.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_Insets())){ >+ checkInsets(gmfFigure.getInsets(), figure.getInsets()); >+ } >+ } >+ >+ protected final void checkInsets(Insets eInsets, org.eclipse.draw2d.geometry.Insets d2dInsets){ >+ assertNotNull(d2dInsets); >+ assertNotNull(eInsets); >+ assertEquals(new org.eclipse.draw2d.geometry.Insets(eInsets.getTop(), eInsets.getLeft(), eInsets.getBottom(), eInsets.getRight()), d2dInsets); >+ } > > } >Index: src/org/eclipse/gmf/tests/AllTests.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java,v >retrieving revision 1.35 >diff -u -r1.35 AllTests.java >--- src/org/eclipse/gmf/tests/AllTests.java 30 Mar 2006 13:51:00 -0000 1.35 >+++ src/org/eclipse/gmf/tests/AllTests.java 31 Mar 2006 14:57:30 -0000 >@@ -29,6 +29,7 @@ > import org.eclipse.gmf.tests.gen.HandcodedImplTest; > import org.eclipse.gmf.tests.gen.MapModeStrategyTest; > import org.eclipse.gmf.tests.gen.RTFigureTest; >+import org.eclipse.gmf.tests.gen.ShapePropertiesTest; > import org.eclipse.gmf.tests.gen.StandaloneMapModeTest; > import org.eclipse.gmf.tests.gen.ToolDefHandocodedImplTest; > import org.eclipse.gmf.tests.gen.ViewmapProducersTest; >@@ -62,6 +63,7 @@ > suite.addTestSuite(HistoryTest.class); > > suite.addTestSuite(FigureCodegenTest.class); >+ suite.addTestSuite(ShapePropertiesTest.class); > suite.addTestSuite(FigureLayoutTest.class); > suite.addTestSuite(StandaloneMapModeTest.class); > suite.addTestSuite(RTFigureTest.class); >Index: src/org/eclipse/gmf/tests/gen/ShapePropertiesTest.java >=================================================================== >RCS file: src/org/eclipse/gmf/tests/gen/ShapePropertiesTest.java >diff -N src/org/eclipse/gmf/tests/gen/ShapePropertiesTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/gmf/tests/gen/ShapePropertiesTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,188 @@ >+/* >+ * 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: >+ * Michael Golubev (Borland) - initial API and implementation >+ */ >+ >+package org.eclipse.gmf.tests.gen; >+ >+import java.util.Iterator; >+ >+import org.eclipse.gmf.gmfgraph.Color; >+import org.eclipse.gmf.gmfgraph.ColorConstants; >+import org.eclipse.gmf.gmfgraph.CompoundBorder; >+import org.eclipse.gmf.gmfgraph.ConstantColor; >+import org.eclipse.gmf.gmfgraph.Dimension; >+import org.eclipse.gmf.gmfgraph.GMFGraphFactory; >+import org.eclipse.gmf.gmfgraph.Insets; >+import org.eclipse.gmf.gmfgraph.LineBorder; >+import org.eclipse.gmf.gmfgraph.LineKind; >+import org.eclipse.gmf.gmfgraph.MarginBorder; >+import org.eclipse.gmf.gmfgraph.Rectangle; >+import org.eclipse.gmf.gmfgraph.RoundedRectangle; >+import org.eclipse.gmf.gmfgraph.Shape; >+ >+public class ShapePropertiesTest extends FigureCodegenTestBase { >+ public ShapePropertiesTest(String name) { >+ super(name); >+ } >+ >+ public void testShapeLineStyle() { >+ Rectangle container = GMFGraphFactory.eINSTANCE.createRectangle(); >+ container.setName("Container"); >+ for (Iterator kinds = LineKind.VALUES.iterator(); kinds.hasNext(); ) { >+ LineKind next = (LineKind) kinds.next(); >+ Shape shape = GMFGraphFactory.eINSTANCE.createEllipse(); >+ shape.setName("Ellipse_" + next.getLiteral()); >+ shape.setLineKind(next); >+ container.getChildren().add(shape); >+ } >+ performTests(container); >+ } >+ >+ public void testShapeLineWidth() { >+ Shape shape = GMFGraphFactory.eINSTANCE.createRoundedRectangle(); >+ shape.setLineWidth(23); >+ shape.setName("Bold"); >+ performTests(shape); >+ } >+ >+ public void testShapeInsets() { >+ Rectangle withInsets = GMFGraphFactory.eINSTANCE.createRectangle(); >+ withInsets.setName("WithInsets"); >+ Insets insets = GMFGraphFactory.eINSTANCE.createInsets(); >+ insets.setBottom(23); >+ insets.setTop(34); >+ insets.setRight(45); >+ insets.setLeft(56); >+ withInsets.setInsets(insets); >+ >+ performTests(withInsets); >+ } >+ >+ public void testLineBorder() { >+ Rectangle container = GMFGraphFactory.eINSTANCE.createRectangle(); >+ container.setName("Root"); >+ >+ Rectangle colorAndWidth = GMFGraphFactory.eINSTANCE.createRectangle(); >+ colorAndWidth.setName("ColorAndWidth"); >+ LineBorder colorAndWidthBorder = GMFGraphFactory.eINSTANCE.createLineBorder(); >+ colorAndWidthBorder.setColor(createConstantColor(ColorConstants.CYAN_LITERAL)); >+ colorAndWidthBorder.setWidth(23); >+ colorAndWidth.setBorder(colorAndWidthBorder); >+ >+ Rectangle onlyColor = GMFGraphFactory.eINSTANCE.createRectangle(); >+ onlyColor.setName("OnlyColor"); >+ LineBorder onlyColorBorder = GMFGraphFactory.eINSTANCE.createLineBorder(); >+ onlyColorBorder.setColor(createConstantColor(ColorConstants.CYAN_LITERAL)); >+ onlyColor.setBorder(onlyColorBorder); >+ >+ Rectangle onlyWidth = GMFGraphFactory.eINSTANCE.createRectangle(); >+ onlyWidth.setName("OnlyWidth"); >+ LineBorder onlyWidthBorder = GMFGraphFactory.eINSTANCE.createLineBorder(); >+ onlyWidthBorder.setWidth(34); >+ onlyWidth.setBorder(onlyWidthBorder); >+ >+ Rectangle empty = GMFGraphFactory.eINSTANCE.createRectangle(); >+ empty.setName("Empty"); >+ LineBorder emptyBorder = GMFGraphFactory.eINSTANCE.createLineBorder(); >+ empty.setBorder(emptyBorder); >+ >+ container.getChildren().add(colorAndWidth); >+ container.getChildren().add(onlyColor); >+ container.getChildren().add(onlyWidth); >+ container.getChildren().add(empty); >+ >+ performTests(container); >+ } >+ >+ public void testCompoundBorder(){ >+ LineBorder outerOuter = GMFGraphFactory.eINSTANCE.createLineBorder(); >+ outerOuter.setColor(createConstantColor(ColorConstants.BLUE_LITERAL)); >+ outerOuter.setWidth(22); >+ >+ MarginBorder outerInner = GMFGraphFactory.eINSTANCE.createMarginBorder(); >+ outerInner.setInsets(GMFGraphFactory.eINSTANCE.createInsets()); >+ outerInner.getInsets().setBottom(23); >+ outerInner.getInsets().setTop(34); >+ //sic! outerInner.getInsets().setRight(45); >+ //sic! outerInner.getInsets().setLeft(56); >+ >+ CompoundBorder outer = GMFGraphFactory.eINSTANCE.createCompoundBorder(); >+ outer.setOuter(outerOuter); >+ outer.setInner(outerInner); >+ >+ CompoundBorder innerEmpty = GMFGraphFactory.eINSTANCE.createCompoundBorder(); >+ //sic! >+ innerEmpty.setInner(null); >+ innerEmpty.setOuter(null); >+ >+ CompoundBorder result = GMFGraphFactory.eINSTANCE.createCompoundBorder(); >+ result.setOuter(outer); >+ result.setInner(innerEmpty); >+ >+ Rectangle tester = GMFGraphFactory.eINSTANCE.createRectangle(); >+ tester.setBorder(result); >+ tester.setName("Tester"); >+ >+ performTests(tester); >+ } >+ >+ public void testMarginBorder(){ >+ MarginBorder border = GMFGraphFactory.eINSTANCE.createMarginBorder(); >+ border.setInsets(GMFGraphFactory.eINSTANCE.createInsets()); >+ border.getInsets().setBottom(23); >+ border.getInsets().setTop(34); >+ border.getInsets().setRight(45); >+ border.getInsets().setLeft(56); >+ >+ Shape marginTester = GMFGraphFactory.eINSTANCE.createEllipse(); >+ marginTester.setBorder(border); >+ marginTester.setName("MarginTester"); >+ >+ performTests(marginTester); >+ } >+ >+ public void testConstantColors(){ >+ Rectangle rainbow = GMFGraphFactory.eINSTANCE.createRectangle(); >+ rainbow.setName("Rainbow"); >+ for (Iterator colors = ColorConstants.VALUES.iterator(); colors.hasNext();){ >+ ColorConstants next = (ColorConstants)colors.next(); >+ Rectangle nextColored = GMFGraphFactory.eINSTANCE.createRectangle(); >+ nextColored.setName(next.getLiteral()); >+ nextColored.setBackgroundColor(createConstantColor(next)); >+ rainbow.getChildren().add(nextColored); >+ } >+ performTests(rainbow); >+ } >+ >+ public void testMaxAndMinSize(){ >+ RoundedRectangle withMinAndMaxSize = GMFGraphFactory.eINSTANCE.createRoundedRectangle(); >+ withMinAndMaxSize.setName("WithMinAndMaxSize"); >+ withMinAndMaxSize.setMaximumSize(createDimension(1000, 2000)); >+ withMinAndMaxSize.setMinimumSize(createDimension(234, 123)); >+ performTests(withMinAndMaxSize); >+ } >+ >+ private Dimension createDimension(int x, int y){ >+ Dimension result = GMFGraphFactory.eINSTANCE.createDimension(); >+ result.setDx(x); >+ result.setDy(y); >+ return result; >+ } >+ >+ private Color createConstantColor(ColorConstants constant) { >+ ConstantColor result = GMFGraphFactory.eINSTANCE.createConstantColor(); >+ result.setValue(constant); >+ return result; >+ } >+ >+ >+ >+} >#P org.eclipse.gmf.graphdef >Index: src/org/eclipse/gmf/gmfgraph/LineBorder.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.graphdef/src/org/eclipse/gmf/gmfgraph/LineBorder.java,v >retrieving revision 1.1 >diff -u -r1.1 LineBorder.java >--- src/org/eclipse/gmf/gmfgraph/LineBorder.java 5 Jan 2006 17:33:07 -0000 1.1 >+++ src/org/eclipse/gmf/gmfgraph/LineBorder.java 31 Mar 2006 14:57:31 -0000 >@@ -53,6 +53,7 @@ > > /** > * Returns the value of the '<em><b>Width</b></em>' attribute. >+ * The default value is <code>"1"</code>. > * <!-- begin-user-doc --> > * <p> > * If the meaning of the '<em>Width</em>' attribute isn't clear, >@@ -62,7 +63,7 @@ > * @return the value of the '<em>Width</em>' attribute. > * @see #setWidth(int) > * @see org.eclipse.gmf.gmfgraph.GMFGraphPackage#getLineBorder_Width() >- * @model >+ * @model default="1" > * @generated > */ > int getWidth(); >Index: models/gmfgraph.ecore >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.graphdef/models/gmfgraph.ecore,v >retrieving revision 1.13 >diff -u -r1.13 gmfgraph.ecore >--- models/gmfgraph.ecore 7 Mar 2006 18:39:24 -0000 1.13 >+++ models/gmfgraph.ecore 31 Mar 2006 14:57:31 -0000 >@@ -281,7 +281,8 @@ > <eClassifiers xsi:type="ecore:EClass" name="LineBorder" eSuperTypes="#//Border"> > <eStructuralFeatures xsi:type="ecore:EReference" name="color" eType="#//Color" > containment="true"/> >- <eStructuralFeatures xsi:type="ecore:EAttribute" name="width" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> >+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="width" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt" >+ defaultValueLiteral="1"/> > </eClassifiers> > <eClassifiers xsi:type="ecore:EClass" name="MarginBorder" eSuperTypes="#//Border"> > <eStructuralFeatures xsi:type="ecore:EReference" name="insets" eType="#//Insets" >Index: src/org/eclipse/gmf/gmfgraph/impl/GMFGraphPackageImpl.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.graphdef/src/org/eclipse/gmf/gmfgraph/impl/GMFGraphPackageImpl.java,v >retrieving revision 1.12 >diff -u -r1.12 GMFGraphPackageImpl.java >--- src/org/eclipse/gmf/gmfgraph/impl/GMFGraphPackageImpl.java 7 Mar 2006 18:39:24 -0000 1.12 >+++ src/org/eclipse/gmf/gmfgraph/impl/GMFGraphPackageImpl.java 31 Mar 2006 14:57:32 -0000 >@@ -2567,7 +2567,7 @@ > > initEClass(lineBorderEClass, LineBorder.class, "LineBorder", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); > initEReference(getLineBorder_Color(), this.getColor(), null, "color", null, 0, 1, LineBorder.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >- initEAttribute(getLineBorder_Width(), ecorePackage.getEInt(), "width", null, 0, 1, LineBorder.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >+ initEAttribute(getLineBorder_Width(), ecorePackage.getEInt(), "width", "1", 0, 1, LineBorder.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); > > initEClass(marginBorderEClass, MarginBorder.class, "MarginBorder", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); > initEReference(getMarginBorder_Insets(), this.getInsets(), null, "insets", null, 0, 1, MarginBorder.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); >Index: src/org/eclipse/gmf/gmfgraph/impl/LineBorderImpl.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.graphdef/src/org/eclipse/gmf/gmfgraph/impl/LineBorderImpl.java,v >retrieving revision 1.1 >diff -u -r1.1 LineBorderImpl.java >--- src/org/eclipse/gmf/gmfgraph/impl/LineBorderImpl.java 5 Jan 2006 17:33:08 -0000 1.1 >+++ src/org/eclipse/gmf/gmfgraph/impl/LineBorderImpl.java 31 Mar 2006 14:57:32 -0000 >@@ -49,7 +49,7 @@ > * @generated > * @ordered > */ >- protected static final int WIDTH_EDEFAULT = 0; >+ protected static final int WIDTH_EDEFAULT = 1; > > /** > * The cached value of the '{@link #getWidth() <em>Width</em>}' attribute. >#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.4 >diff -u -r1.4 Figure.javajet >--- templates/attr/Figure.javajet 7 Mar 2006 19:04:35 -0000 1.4 >+++ templates/attr/Figure.javajet 31 Mar 2006 14:57:33 -0000 >@@ -20,8 +20,20 @@ > <%} 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();%> > <%=figureVarName%>.setFont(new <%=importManager.getImportedName("org.eclipse.swt.graphics.Font")%>(<%=importManager.getImportedName("org.eclipse.swt.widgets.Display")%>.getCurrent(), "<%=font.getFaceName()%>", <%=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")%>(<%=insets.getTop()%>, <%=insets.getLeft()%>, <%=insets.getBottom()%>, <%=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 >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.4 >diff -u -r1.4 FigureAttrGenerator.java >--- src/org/eclipse/gmf/graphdef/codegen/templates/FigureAttrGenerator.java 7 Mar 2006 19:04:35 -0000 1.4 >+++ src/org/eclipse/gmf/graphdef/codegen/templates/FigureAttrGenerator.java 31 Mar 2006 14:57:33 -0000 >@@ -43,13 +43,33 @@ > protected final String TEXT_25 = ", "; > protected final String TEXT_26 = ");"; > protected final String TEXT_27 = NL + "\t\t"; >- protected final String TEXT_28 = ".setFont(new "; >+ protected final String TEXT_28 = ".setMaximumSize(new "; > protected final String TEXT_29 = "("; >- protected final String TEXT_30 = ".getCurrent(), \""; >- protected final String TEXT_31 = "\", "; >- protected final String TEXT_32 = ", "; >- protected final String TEXT_33 = "."; >- protected final String TEXT_34 = "));"; >+ protected final String TEXT_30 = ", "; >+ protected final String TEXT_31 = "));"; >+ protected final String TEXT_32 = NL + "\t\t"; >+ protected final String TEXT_33 = ".setMinimumSize(new "; >+ protected final String TEXT_34 = "("; >+ protected final String TEXT_35 = ", "; >+ protected final String TEXT_36 = "));"; >+ protected final String TEXT_37 = NL + "\t\t"; >+ protected final String TEXT_38 = ".setFont(new "; >+ protected final String TEXT_39 = "("; >+ protected final String TEXT_40 = ".getCurrent(), \""; >+ protected final String TEXT_41 = "\", "; >+ protected final String TEXT_42 = ", "; >+ protected final String TEXT_43 = "."; >+ protected final String TEXT_44 = "));"; >+ protected final String TEXT_45 = NL + "\t\t"; >+ protected final String TEXT_46 = ".setBorder(new "; >+ protected final String TEXT_47 = "("; >+ protected final String TEXT_48 = ", "; >+ protected final String TEXT_49 = ", "; >+ protected final String TEXT_50 = ", "; >+ protected final String TEXT_51 = "));"; >+ protected final String TEXT_52 = NL + "\t\t"; >+ protected final String TEXT_53 = ".setBorder("; >+ protected final String TEXT_54 = ");"; > > public String generate(Object argument) > { >@@ -122,24 +142,68 @@ > stringBuffer.append(TEXT_25); > stringBuffer.append(dispatcher.DPtoLP(p.getY())); > stringBuffer.append(TEXT_26); >+ } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_MaximumSize())) { >+ Dimension d = figureInstance.getMaximumSize(); >+ stringBuffer.append(TEXT_27); >+ stringBuffer.append(figureVarName); >+ stringBuffer.append(TEXT_28); >+ stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")); >+ stringBuffer.append(TEXT_29); >+ stringBuffer.append(dispatcher.DPtoLP(d.getDx())); >+ stringBuffer.append(TEXT_30); >+ stringBuffer.append(dispatcher.DPtoLP(d.getDy())); >+ stringBuffer.append(TEXT_31); >+ } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_MinimumSize())) { >+ Dimension d = figureInstance.getMinimumSize(); >+ stringBuffer.append(TEXT_32); >+ stringBuffer.append(figureVarName); >+ stringBuffer.append(TEXT_33); >+ stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")); >+ stringBuffer.append(TEXT_34); >+ stringBuffer.append(dispatcher.DPtoLP(d.getDx())); >+ stringBuffer.append(TEXT_35); >+ stringBuffer.append(dispatcher.DPtoLP(d.getDy())); >+ stringBuffer.append(TEXT_36); > } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_Font())) { > // XXX possible CCE when fonts other than Basic added to model > BasicFont font = (BasicFont) figureInstance.getFont(); >- stringBuffer.append(TEXT_27); >+ stringBuffer.append(TEXT_37); > stringBuffer.append(figureVarName); >- stringBuffer.append(TEXT_28); >+ stringBuffer.append(TEXT_38); > stringBuffer.append(importManager.getImportedName("org.eclipse.swt.graphics.Font")); >- stringBuffer.append(TEXT_29); >+ stringBuffer.append(TEXT_39); > stringBuffer.append(importManager.getImportedName("org.eclipse.swt.widgets.Display")); >- stringBuffer.append(TEXT_30); >+ stringBuffer.append(TEXT_40); > stringBuffer.append(font.getFaceName()); >- stringBuffer.append(TEXT_31); >+ stringBuffer.append(TEXT_41); > stringBuffer.append(font.getHeight()); >- stringBuffer.append(TEXT_32); >+ stringBuffer.append(TEXT_42); > stringBuffer.append(importManager.getImportedName("org.eclipse.swt.SWT")); >- stringBuffer.append(TEXT_33); >+ stringBuffer.append(TEXT_43); > stringBuffer.append(font.getStyle().getLiteral()); >- stringBuffer.append(TEXT_34); >+ stringBuffer.append(TEXT_44); >+ } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_Insets())) { >+ Insets insets = figureInstance.getInsets(); >+ stringBuffer.append(TEXT_45); >+ stringBuffer.append(figureVarName); >+ stringBuffer.append(TEXT_46); >+ stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.MarginBorder")); >+ stringBuffer.append(TEXT_47); >+ stringBuffer.append(insets.getTop()); >+ stringBuffer.append(TEXT_48); >+ stringBuffer.append(insets.getLeft()); >+ stringBuffer.append(TEXT_49); >+ stringBuffer.append(insets.getBottom()); >+ stringBuffer.append(TEXT_50); >+ stringBuffer.append(insets.getRight()); >+ stringBuffer.append(TEXT_51); >+ } if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_Border())) { >+ Border border = figureInstance.getBorder(); >+ stringBuffer.append(TEXT_52); >+ stringBuffer.append(figureVarName); >+ stringBuffer.append(TEXT_53); >+ stringBuffer.append(dispatcher.dispatch(border, new Object[] {border, dispatcher})); >+ stringBuffer.append(TEXT_54); > } > return stringBuffer.toString(); > } >Index: src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java,v >retrieving revision 1.15 >diff -u -r1.15 FigureGenerator.java >--- src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java 29 Mar 2006 12:56:04 -0000 1.15 >+++ src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java 31 Mar 2006 14:57:33 -0000 >@@ -16,6 +16,7 @@ > import org.eclipse.gmf.common.codegen.ImportAssistant; > import org.eclipse.gmf.gmfgraph.BorderLayout; > import org.eclipse.gmf.gmfgraph.BorderLayoutData; >+import org.eclipse.gmf.gmfgraph.CompoundBorder; > import org.eclipse.gmf.gmfgraph.CustomFigure; > import org.eclipse.gmf.gmfgraph.CustomLayout; > import org.eclipse.gmf.gmfgraph.CustomLayoutData; >@@ -24,6 +25,8 @@ > import org.eclipse.gmf.gmfgraph.GridLayout; > import org.eclipse.gmf.gmfgraph.GridLayoutData; > import org.eclipse.gmf.gmfgraph.Label; >+import org.eclipse.gmf.gmfgraph.LineBorder; >+import org.eclipse.gmf.gmfgraph.MarginBorder; > import org.eclipse.gmf.gmfgraph.PolygonDecoration; > import org.eclipse.gmf.gmfgraph.Polyline; > import org.eclipse.gmf.gmfgraph.PolylineConnection; >@@ -45,9 +48,12 @@ > import org.eclipse.gmf.graphdef.codegen.templates.InitGridLayoutGenerator; > import org.eclipse.gmf.graphdef.codegen.templates.InitXYLayoutDataGenerator; > import org.eclipse.gmf.graphdef.codegen.templates.LabelAttrGenerator; >+import org.eclipse.gmf.graphdef.codegen.templates.NewCompoundBorderExpressionGenerator; > import org.eclipse.gmf.graphdef.codegen.templates.NewFigureGenerator; > import org.eclipse.gmf.graphdef.codegen.templates.NewLayoutDataGenerator; > import org.eclipse.gmf.graphdef.codegen.templates.NewLayoutGenerator; >+import org.eclipse.gmf.graphdef.codegen.templates.NewLineBorderExpressionGenerator; >+import org.eclipse.gmf.graphdef.codegen.templates.NewMarginBorderExpressionGenerator; > import org.eclipse.gmf.graphdef.codegen.templates.PolygonDecorationAttrGenerator; > import org.eclipse.gmf.graphdef.codegen.templates.PolylineAttrGenerator; > import org.eclipse.gmf.graphdef.codegen.templates.PolylineDecorationAttrGenerator; >@@ -160,6 +166,12 @@ > tr.put(BorderLayoutData.class, "/layoutData/BorderLayoutData.javajet", InitBorderLayoutDataGenerator.class); > tr.put(CustomLayoutData.class, "/layoutData/CustomLayoutData.javajet", InitCustomLayoutDataGenerator.class); > tr.put(XYLayoutData.class, "/layoutData/XYLayoutData.javajet", InitXYLayoutDataGenerator.class); >+ >+ //Borders >+ tr.put(LineBorder.class, "/new/LineBorder.javajet", NewLineBorderExpressionGenerator.class); >+ tr.put(MarginBorder.class, "/new/MarginBorder.javajet", NewMarginBorderExpressionGenerator.class); >+ tr.put(CompoundBorder.class, "/new/CompoundBorder.javajet", NewCompoundBorderExpressionGenerator.class); >+ > return tr; > } > >Index: src/org/eclipse/gmf/graphdef/codegen/templates/NewCompoundBorderExpressionGenerator.java >=================================================================== >RCS file: src/org/eclipse/gmf/graphdef/codegen/templates/NewCompoundBorderExpressionGenerator.java >diff -N src/org/eclipse/gmf/graphdef/codegen/templates/NewCompoundBorderExpressionGenerator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/gmf/graphdef/codegen/templates/NewCompoundBorderExpressionGenerator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,49 @@ >+package org.eclipse.gmf.graphdef.codegen.templates; >+ >+import org.eclipse.gmf.gmfgraph.*; >+import org.eclipse.gmf.graphdef.codegen.*; >+import org.eclipse.gmf.common.codegen.ImportAssistant; >+ >+public class NewCompoundBorderExpressionGenerator >+{ >+ protected static String nl; >+ public static synchronized NewCompoundBorderExpressionGenerator create(String lineSeparator) >+ { >+ nl = lineSeparator; >+ NewCompoundBorderExpressionGenerator result = new NewCompoundBorderExpressionGenerator(); >+ nl = null; >+ return result; >+ } >+ >+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; >+ protected final String TEXT_1 = "\t"; >+ protected final String TEXT_2 = NL + "new "; >+ protected final String TEXT_3 = "(" + NL + "\t"; >+ protected final String TEXT_4 = ", " + NL + "\t"; >+ protected final String TEXT_5 = NL + ")"; >+ >+ public String generate(Object argument) >+ { >+ StringBuffer stringBuffer = new StringBuffer(); >+ >+Object[] args = (Object[]) argument; >+final CompoundBorder border = (CompoundBorder)args[0]; >+final GraphDefDispatcher dispatcher = (GraphDefDispatcher)args[1]; >+final ImportAssistant importManager = dispatcher.getImportManager(); >+ >+//We want NEITHER insert any names into the scope NOR produce statement. We need expression instead. >+ >+ stringBuffer.append(TEXT_1); >+ Border outer = border.getOuter(); >+ Border inner = border.getInner(); >+ >+ stringBuffer.append(TEXT_2); >+ stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.CompoundBorder")); >+ stringBuffer.append(TEXT_3); >+ stringBuffer.append( (outer == null) ? "null" : dispatcher.dispatch(outer, new Object[]{outer, dispatcher})); >+ stringBuffer.append(TEXT_4); >+ stringBuffer.append( (inner == null) ? "null" : dispatcher.dispatch(inner, new Object[]{inner, dispatcher})); >+ stringBuffer.append(TEXT_5); >+ return stringBuffer.toString(); >+ } >+} >Index: templates/new/LineBorder.javajet >=================================================================== >RCS file: templates/new/LineBorder.javajet >diff -N templates/new/LineBorder.javajet >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ templates/new/LineBorder.javajet 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,34 @@ >+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="NewLineBorderExpressionGenerator" >+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.* org.eclipse.gmf.common.codegen.ImportAssistant"%> >+<% >+Object[] args = (Object[]) argument; >+final LineBorder border = (LineBorder)args[0]; >+final GraphDefDispatcher dispatcher = (GraphDefDispatcher)args[1]; >+final ImportAssistant importManager = dispatcher.getImportManager(); >+ >+//We do not want to insert any names into the scope. >+//We want to provide EXPRESSION instead of statement >+%> >+<% >+ String borderClazz = importManager.getImportedName("org.eclipse.draw2d.LineBorder"); >+ boolean hasColor = border.eIsSet(GMFGraphPackage.eINSTANCE.getLineBorder_Color()); >+ boolean hasWidth = border.eIsSet(GMFGraphPackage.eINSTANCE.getLineBorder_Width()); >+ Color colorVal = (hasColor) ? border.getColor() : null; >+ if (hasColor && hasWidth){ >+%> >+new <%=borderClazz%>(<%@ include file="../Color.jetinc"%>, <%=border.getWidth()%>) >+<% >+ } else if (hasColor && !hasWidth) { >+%> >+new <%=borderClazz%>(<%@ include file="../Color.jetinc"%>) >+<% >+ } else if (!hasColor && hasWidth){ >+%> >+new <%=borderClazz%>(<%=border.getWidth()%>) >+<% >+ } else { >+%> >+new <%=borderClazz%>() >+<% >+ } >+%> >Index: src/org/eclipse/gmf/graphdef/codegen/templates/NewLineBorderExpressionGenerator.java >=================================================================== >RCS file: src/org/eclipse/gmf/graphdef/codegen/templates/NewLineBorderExpressionGenerator.java >diff -N src/org/eclipse/gmf/graphdef/codegen/templates/NewLineBorderExpressionGenerator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/gmf/graphdef/codegen/templates/NewLineBorderExpressionGenerator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,125 @@ >+package org.eclipse.gmf.graphdef.codegen.templates; >+ >+import org.eclipse.gmf.gmfgraph.*; >+import org.eclipse.gmf.graphdef.codegen.*; >+import org.eclipse.gmf.common.codegen.ImportAssistant; >+ >+public class NewLineBorderExpressionGenerator >+{ >+ protected static String nl; >+ public static synchronized NewLineBorderExpressionGenerator create(String lineSeparator) >+ { >+ nl = lineSeparator; >+ NewLineBorderExpressionGenerator result = new NewLineBorderExpressionGenerator(); >+ nl = null; >+ return result; >+ } >+ >+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; >+ protected final String TEXT_1 = "new "; >+ protected final String TEXT_2 = "("; >+ protected final String TEXT_3 = "new "; >+ protected final String TEXT_4 = "(null, "; >+ protected final String TEXT_5 = ", "; >+ protected final String TEXT_6 = ", "; >+ protected final String TEXT_7 = ")"; >+ protected final String TEXT_8 = "."; >+ protected final String TEXT_9 = ", "; >+ protected final String TEXT_10 = ")"; >+ protected final String TEXT_11 = NL + "new "; >+ protected final String TEXT_12 = "("; >+ protected final String TEXT_13 = "new "; >+ protected final String TEXT_14 = "(null, "; >+ protected final String TEXT_15 = ", "; >+ protected final String TEXT_16 = ", "; >+ protected final String TEXT_17 = ")"; >+ protected final String TEXT_18 = "."; >+ protected final String TEXT_19 = ")"; >+ protected final String TEXT_20 = NL + "new "; >+ protected final String TEXT_21 = "("; >+ protected final String TEXT_22 = ")"; >+ protected final String TEXT_23 = NL + "new "; >+ protected final String TEXT_24 = "()"; >+ >+ public String generate(Object argument) >+ { >+ StringBuffer stringBuffer = new StringBuffer(); >+ >+Object[] args = (Object[]) argument; >+final LineBorder border = (LineBorder)args[0]; >+final GraphDefDispatcher dispatcher = (GraphDefDispatcher)args[1]; >+final ImportAssistant importManager = dispatcher.getImportManager(); >+ >+//We do not want to insert any names into the scope. >+//We want to provide EXPRESSION instead of statement >+ >+ >+ String borderClazz = importManager.getImportedName("org.eclipse.draw2d.LineBorder"); >+ boolean hasColor = border.eIsSet(GMFGraphPackage.eINSTANCE.getLineBorder_Color()); >+ boolean hasWidth = border.eIsSet(GMFGraphPackage.eINSTANCE.getLineBorder_Width()); >+ Color colorVal = (hasColor) ? border.getColor() : null; >+ if (hasColor && hasWidth){ >+ >+ stringBuffer.append(TEXT_1); >+ stringBuffer.append(borderClazz); >+ stringBuffer.append(TEXT_2); >+ if (colorVal instanceof RGBColor) { >+ stringBuffer.append(TEXT_3); >+ stringBuffer.append(importManager.getImportedName("org.eclipse.swt.graphics.Color")); >+ stringBuffer.append(TEXT_4); >+ stringBuffer.append(((RGBColor) colorVal).getRed()); >+ stringBuffer.append(TEXT_5); >+ stringBuffer.append(((RGBColor) colorVal).getGreen()); >+ stringBuffer.append(TEXT_6); >+ stringBuffer.append(((RGBColor) colorVal).getBlue()); >+ stringBuffer.append(TEXT_7); >+ } else if (colorVal instanceof ConstantColor) { >+ stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.ColorConstants")); >+ stringBuffer.append(TEXT_8); >+ stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral()); >+ } >+ stringBuffer.append(TEXT_9); >+ stringBuffer.append(border.getWidth()); >+ stringBuffer.append(TEXT_10); >+ >+ } else if (hasColor && !hasWidth) { >+ >+ stringBuffer.append(TEXT_11); >+ stringBuffer.append(borderClazz); >+ stringBuffer.append(TEXT_12); >+ if (colorVal instanceof RGBColor) { >+ stringBuffer.append(TEXT_13); >+ stringBuffer.append(importManager.getImportedName("org.eclipse.swt.graphics.Color")); >+ stringBuffer.append(TEXT_14); >+ stringBuffer.append(((RGBColor) colorVal).getRed()); >+ stringBuffer.append(TEXT_15); >+ stringBuffer.append(((RGBColor) colorVal).getGreen()); >+ stringBuffer.append(TEXT_16); >+ stringBuffer.append(((RGBColor) colorVal).getBlue()); >+ stringBuffer.append(TEXT_17); >+ } else if (colorVal instanceof ConstantColor) { >+ stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.ColorConstants")); >+ stringBuffer.append(TEXT_18); >+ stringBuffer.append(((ConstantColor) colorVal).getValue().getLiteral()); >+ } >+ stringBuffer.append(TEXT_19); >+ >+ } else if (!hasColor && hasWidth){ >+ >+ stringBuffer.append(TEXT_20); >+ stringBuffer.append(borderClazz); >+ stringBuffer.append(TEXT_21); >+ stringBuffer.append(border.getWidth()); >+ stringBuffer.append(TEXT_22); >+ >+ } else { >+ >+ stringBuffer.append(TEXT_23); >+ stringBuffer.append(borderClazz); >+ stringBuffer.append(TEXT_24); >+ >+ } >+ >+ return stringBuffer.toString(); >+ } >+} >Index: templates/new/MarginBorder.javajet >=================================================================== >RCS file: templates/new/MarginBorder.javajet >diff -N templates/new/MarginBorder.javajet >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ templates/new/MarginBorder.javajet 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,24 @@ >+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="NewMarginBorderExpressionGenerator" >+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.* org.eclipse.gmf.common.codegen.ImportAssistant"%> >+<% >+Object[] args = (Object[]) argument; >+final MarginBorder border = (MarginBorder)args[0]; >+final GraphDefDispatcher dispatcher = (GraphDefDispatcher)args[1]; >+final ImportAssistant importManager = dispatcher.getImportManager(); >+ >+//Produces EXPRESSION instead of statement >+%> >+<% >+ int top = 0; >+ int left = 0; >+ int bottom = 0; >+ int right = 0; >+ if (border.eIsSet(GMFGraphPackage.eINSTANCE.getMarginBorder_Insets())){ >+ Insets insets = border.getInsets(); >+ top = insets.getTop(); >+ left = insets.getLeft(); >+ bottom = insets.getBottom(); >+ right = insets.getRight(); >+ } >+%> >+new <%=importManager.getImportedName("org.eclipse.draw2d.MarginBorder")%>(<%=top%>, <%=left%>, <%=bottom%>, <%=right%>) >Index: templates/new/CompoundBorder.javajet >=================================================================== >RCS file: templates/new/CompoundBorder.javajet >diff -N templates/new/CompoundBorder.javajet >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ templates/new/CompoundBorder.javajet 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,17 @@ >+<%@ jet package="org.eclipse.gmf.graphdef.codegen.templates" class="NewCompoundBorderExpressionGenerator" >+ imports="org.eclipse.gmf.gmfgraph.* org.eclipse.gmf.graphdef.codegen.* org.eclipse.gmf.common.codegen.ImportAssistant"%> >+<% >+Object[] args = (Object[]) argument; >+final CompoundBorder border = (CompoundBorder)args[0]; >+final GraphDefDispatcher dispatcher = (GraphDefDispatcher)args[1]; >+final ImportAssistant importManager = dispatcher.getImportManager(); >+ >+//We want NEITHER insert any names into the scope NOR produce statement. We need expression instead. >+%> >+ <% Border outer = border.getOuter(); >+ Border inner = border.getInner(); >+ %> >+new <%=importManager.getImportedName("org.eclipse.draw2d.CompoundBorder")%>( >+ <%= (outer == null) ? "null" : dispatcher.dispatch(outer, new Object[]{outer, dispatcher})%>, >+ <%= (inner == null) ? "null" : dispatcher.dispatch(inner, new Object[]{inner, dispatcher})%> >+) >Index: src/org/eclipse/gmf/graphdef/codegen/templates/NewMarginBorderExpressionGenerator.java >=================================================================== >RCS file: src/org/eclipse/gmf/graphdef/codegen/templates/NewMarginBorderExpressionGenerator.java >diff -N src/org/eclipse/gmf/graphdef/codegen/templates/NewMarginBorderExpressionGenerator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/gmf/graphdef/codegen/templates/NewMarginBorderExpressionGenerator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,63 @@ >+package org.eclipse.gmf.graphdef.codegen.templates; >+ >+import org.eclipse.gmf.gmfgraph.*; >+import org.eclipse.gmf.graphdef.codegen.*; >+import org.eclipse.gmf.common.codegen.ImportAssistant; >+ >+public class NewMarginBorderExpressionGenerator >+{ >+ protected static String nl; >+ public static synchronized NewMarginBorderExpressionGenerator create(String lineSeparator) >+ { >+ nl = lineSeparator; >+ NewMarginBorderExpressionGenerator result = new NewMarginBorderExpressionGenerator(); >+ nl = null; >+ return result; >+ } >+ >+ protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; >+ protected final String TEXT_1 = "\t" + NL + "new "; >+ protected final String TEXT_2 = "("; >+ protected final String TEXT_3 = ", "; >+ protected final String TEXT_4 = ", "; >+ protected final String TEXT_5 = ", "; >+ protected final String TEXT_6 = ")"; >+ >+ public String generate(Object argument) >+ { >+ StringBuffer stringBuffer = new StringBuffer(); >+ >+Object[] args = (Object[]) argument; >+final MarginBorder border = (MarginBorder)args[0]; >+final GraphDefDispatcher dispatcher = (GraphDefDispatcher)args[1]; >+final ImportAssistant importManager = dispatcher.getImportManager(); >+ >+//Produces EXPRESSION instead of statement >+ >+ >+ int top = 0; >+ int left = 0; >+ int bottom = 0; >+ int right = 0; >+ if (border.eIsSet(GMFGraphPackage.eINSTANCE.getMarginBorder_Insets())){ >+ Insets insets = border.getInsets(); >+ top = insets.getTop(); >+ left = insets.getLeft(); >+ bottom = insets.getBottom(); >+ right = insets.getRight(); >+ } >+ >+ stringBuffer.append(TEXT_1); >+ stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.MarginBorder")); >+ stringBuffer.append(TEXT_2); >+ stringBuffer.append(top); >+ stringBuffer.append(TEXT_3); >+ stringBuffer.append(left); >+ stringBuffer.append(TEXT_4); >+ stringBuffer.append(bottom); >+ stringBuffer.append(TEXT_5); >+ stringBuffer.append(right); >+ stringBuffer.append(TEXT_6); >+ return stringBuffer.toString(); >+ } >+} >#P org.eclipse.gmf.borland >Index: models/gmfgraph.emf >=================================================================== >RCS file: /cvs/tools/org.eclipse.gmf.borland/models/gmfgraph.emf,v >retrieving revision 1.14 >diff -u -r1.14 gmfgraph.emf >--- models/gmfgraph.emf 7 Mar 2006 18:43:06 -0000 1.14 >+++ models/gmfgraph.emf 31 Mar 2006 15:02:15 -0000 >@@ -273,7 +273,7 @@ > > class LineBorder extends Border { > val Color color; >- attr int width; >+ attr int width = 1; > } > > class MarginBorder extends Border {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 134249
: 37412