### Eclipse Workspace Patch 1.0 #P org.eclipse.gmf.tests Index: src/org/eclipse/gmf/tests/gen/RTFigureTest.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.gmf/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gen/RTFigureTest.java,v retrieving revision 1.5 diff -u -r1.5 RTFigureTest.java --- src/org/eclipse/gmf/tests/gen/RTFigureTest.java 30 Mar 2006 13:38:09 -0000 1.5 +++ src/org/eclipse/gmf/tests/gen/RTFigureTest.java 31 Mar 2006 11:07:10 -0000 @@ -14,6 +14,7 @@ import junit.framework.TestCase; import org.eclipse.core.runtime.IStatus; +import org.eclipse.draw2d.Triangle; import org.eclipse.gmf.gmfgraph.Alignment; import org.eclipse.gmf.gmfgraph.BasicFont; import org.eclipse.gmf.gmfgraph.BorderLayout; @@ -32,8 +33,6 @@ import org.eclipse.gmf.gmfgraph.RGBColor; import org.eclipse.gmf.gmfgraph.util.RuntimeFQNSwitch; import org.eclipse.gmf.graphdef.codegen.StandaloneGenerator; -import org.eclipse.gmf.tests.Plugin; -import org.eclipse.gmf.tests.draw2d.CustomFigureNoProperties; public class RTFigureTest extends TestCase { @@ -71,8 +70,8 @@ CustomFigure bottomCustom = GMFGraphFactory.eINSTANCE.createCustomFigure(); bottomCustom.setName("BottomCustom"); - bottomCustom.setBundleName(Plugin.getPluginID()); - bottomCustom.setQualifiedClassName(CustomFigureNoProperties.class.getName()); + bottomCustom.setBundleName("org.eclipse.draw2d"); + bottomCustom.setQualifiedClassName(Triangle.class.getName()); RGBColor blue = GMFGraphFactory.eINSTANCE.createRGBColor(); red.setBlue(255); bottomCustom.setForegroundColor(blue); Index: src/org/eclipse/gmf/tests/gen/FigureCodegenTest.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.gmf/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gen/FigureCodegenTest.java,v retrieving revision 1.6 diff -u -r1.6 FigureCodegenTest.java --- src/org/eclipse/gmf/tests/gen/FigureCodegenTest.java 30 Mar 2006 13:38:09 -0000 1.6 +++ src/org/eclipse/gmf/tests/gen/FigureCodegenTest.java 31 Mar 2006 11:07:08 -0000 @@ -12,6 +12,7 @@ package org.eclipse.gmf.tests.gen; import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.ScrollBar; import org.eclipse.gmf.common.codegen.NullImportAssistant; import org.eclipse.gmf.gmfgraph.CustomAttribute; import org.eclipse.gmf.gmfgraph.CustomFigure; @@ -20,13 +21,12 @@ import org.eclipse.gmf.gmfgraph.util.RuntimeFQNSwitch; import org.eclipse.gmf.graphdef.codegen.FigureGenerator; import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx; -import org.eclipse.gmf.tests.Plugin; -import org.eclipse.gmf.tests.draw2d.CustomFigureWithProperties; /** * @author artem */ public class FigureCodegenTest extends FigureCodegenTestBase { + public FigureCodegenTest(String name) { super(name); } @@ -58,20 +58,24 @@ public void testGenCustomFigureWithAttributes(){ CustomFigure result = GMFGraphFactory.eINSTANCE.createCustomFigure(); - result.setName("MyRectangleWithInner40x40"); - result.setBundleName(Plugin.getPluginID()); - result.setQualifiedClassName(CustomFigureWithProperties.class.getName()); + result.setName("MyHorizontalScrollBar"); + result.setBundleName(DRAW2D); + result.setQualifiedClassName(ScrollBar.class.getName()); - CustomAttribute innerWidthAttr = GMFGraphFactory.eINSTANCE.createCustomAttribute(); - innerWidthAttr.setName("innerWidth"); - innerWidthAttr.setValue("40"); - result.getAttributes().add(innerWidthAttr); + CustomAttribute minimum = GMFGraphFactory.eINSTANCE.createCustomAttribute(); + minimum.setName("minimum"); + minimum.setValue("1"); + result.getAttributes().add(minimum); - CustomAttribute innerHeightAttr = GMFGraphFactory.eINSTANCE.createCustomAttribute(); - innerHeightAttr.setName("innerHeight"); - innerHeightAttr.setValue("40"); - innerHeightAttr.setDirectAccess(true); - result.getAttributes().add(innerHeightAttr); + CustomAttribute maximum = GMFGraphFactory.eINSTANCE.createCustomAttribute(); + maximum.setName("Maximum"); //note first 'M' + maximum.setValue("99"); + result.getAttributes().add(maximum); + + CustomAttribute orientation = GMFGraphFactory.eINSTANCE.createCustomAttribute(); + orientation.setName("horizontal"); + orientation.setValue("true"); + result.getAttributes().add(orientation); Dimension outerPrefSize = GMFGraphFactory.eINSTANCE.createDimension(); outerPrefSize.setDx(100); @@ -80,14 +84,17 @@ FigureCheck customCheck = new FigureCheck(){ public void checkFigure(IFigure figure) { - assertTrue(figure instanceof CustomFigureWithProperties); - CustomFigureWithProperties custom = (CustomFigureWithProperties)figure; - assertEquals(40, custom.getInnerWidth()); - assertEquals(40, custom.innerHeight); + assertTrue(figure instanceof ScrollBar); + ScrollBar custom = (ScrollBar)figure; + assertEquals(1, custom.getMinimum()); + assertEquals(99, custom.getMaximum()); + assertTrue(custom.isHorizontal()); + + assertEquals(new org.eclipse.draw2d.geometry.Dimension(100, 100), custom.getPreferredSize()); } }; - performTests(result); + //performTests(result); ScrollBar creates additional children performTests(result, customCheck); } } Index: src/org/eclipse/gmf/tests/gen/FigureCodegenTestBase.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.gmf/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gen/FigureCodegenTestBase.java,v retrieving revision 1.8 diff -u -r1.8 FigureCodegenTestBase.java --- src/org/eclipse/gmf/tests/gen/FigureCodegenTestBase.java 30 Mar 2006 13:38:09 -0000 1.8 +++ src/org/eclipse/gmf/tests/gen/FigureCodegenTestBase.java 31 Mar 2006 11:07:08 -0000 @@ -46,7 +46,6 @@ import org.eclipse.gmf.graphdef.codegen.StandaloneGenerator; import org.eclipse.gmf.tests.CompileUtil; import org.eclipse.gmf.tests.Plugin; -import org.eclipse.gmf.tests.draw2d.CustomFigureNoProperties; import org.eclipse.gmf.tests.setup.SessionSetup; import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.core.dom.AST; @@ -61,6 +60,7 @@ * @author michael.golubev */ public class FigureCodegenTestBase extends TestCase { + protected static final String DRAW2D = "org.eclipse.draw2d"; private FigureGenerator figureGenerator; public FigureCodegenTestBase(String name) { @@ -157,9 +157,9 @@ // custom top-level, hierarchical children, no custom properties protected final Figure figure1() { CustomFigure cf = GMFGraphFactory.eINSTANCE.createCustomFigure(); - cf.setName("MyXRectangle"); - cf.setBundleName(Plugin.getPluginID()); - cf.setQualifiedClassName(CustomFigureNoProperties.class.getName()); + cf.setName("MyRRectangleAsCustom"); + cf.setBundleName(DRAW2D); + cf.setQualifiedClassName(org.eclipse.draw2d.RoundedRectangle.class.getName()); Point p = GMFGraphFactory.eINSTANCE.createPoint(); p.setX(1023); p.setY(33); Index: src/org/eclipse/gmf/tests/draw2d/CustomFigureWithProperties.java =================================================================== RCS file: src/org/eclipse/gmf/tests/draw2d/CustomFigureWithProperties.java diff -N src/org/eclipse/gmf/tests/draw2d/CustomFigureWithProperties.java --- src/org/eclipse/gmf/tests/draw2d/CustomFigureWithProperties.java 30 Mar 2006 13:38:09 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,68 +0,0 @@ -/* - * 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.draw2d; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.swt.graphics.Color; - -public class CustomFigureWithProperties extends RectangleFigure { - private int myInnerWidth = 20; - - /** - * Intentionally public to test CustomAttribute#isDirectAccess - */ - public int innerHeight = 20; - - public void setInnerWidth(int innerWidth){ - myInnerWidth = innerWidth; - } - - public int getInnerWidth() { - return myInnerWidth; - } - - public Color getInnerColor(){ - return isRed(getBackgroundColor()) ? ColorConstants.green : ColorConstants.red; - } - - protected void outlineShape(Graphics graphics) { - super.outlineShape(graphics); - Rectangle r = getBounds(); - if (myInnerWidth > 0 && innerHeight > 0 && myInnerWidth < r.width && innerHeight < r.height){ - int innerX = r.x + (myInnerWidth - r.width) / 2; - int innerY = r.y + (innerHeight - r.height) / 2; - graphics.drawRectangle(innerX, innerY, myInnerWidth, innerHeight); - } - } - - protected void fillShape(Graphics graphics) { - super.fillShape(graphics); - Rectangle r = getBounds(); - if (myInnerWidth > 0 && innerHeight > 0 && myInnerWidth < r.width - 2 && innerHeight < r.height - 2){ - graphics.pushState(); - graphics.setBackgroundColor(getInnerColor()); - int innerX = r.x + (myInnerWidth - r.width) / 2 + 1; - int innerY = r.y + (innerHeight - r.height) / 2 + 1; - graphics.fillRectangle(innerX + 1, innerY + 1, myInnerWidth - 1, innerHeight + 1); - graphics.popState(); - } - } - - private static boolean isRed(Color color){ - //do not use RGB to avoid object creation - return color != null && color.getRed() == 255 && color.getBlue() == 0 && color.getGreen() == 0; - } -} Index: src/org/eclipse/gmf/tests/draw2d/CustomFigureNoProperties.java =================================================================== RCS file: src/org/eclipse/gmf/tests/draw2d/CustomFigureNoProperties.java diff -N src/org/eclipse/gmf/tests/draw2d/CustomFigureNoProperties.java --- src/org/eclipse/gmf/tests/draw2d/CustomFigureNoProperties.java 30 Mar 2006 13:38:09 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,27 +0,0 @@ -/* - * 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.draw2d; - -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.geometry.Rectangle; - -public class CustomFigureNoProperties extends RectangleFigure { - protected void outlineShape(Graphics graphics) { - super.outlineShape(graphics); - - Rectangle r = getBounds(); - graphics.drawLine(r.getBottomLeft(), r.getTopRight()); - graphics.drawLine(r.getBottomRight(), r.getTopLeft()); - } -} Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/technology/org.eclipse.gmf/tests/org.eclipse.gmf.tests/META-INF/MANIFEST.MF,v retrieving revision 1.15 diff -u -r1.15 MANIFEST.MF --- META-INF/MANIFEST.MF 30 Mar 2006 13:38:09 -0000 1.15 +++ META-INF/MANIFEST.MF 31 Mar 2006 11:07:08 -0000 @@ -19,4 +19,3 @@ org.eclipse.gmf.codegen.ui Bundle-Activator: org.eclipse.gmf.tests.Plugin Eclipse-LazyStart: true -Export-Package: org.eclipse.gmf.tests.draw2d