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 35297 Details for
Bug 129328
GMFGraph codegeneration to handle IMapMode using configurable way
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
It should fix the subj
patch_129328.txt (text/plain), 25.72 KB, created by
Michael Golubev
on 2006-02-24 08:50:56 EST
(
hide
)
Description:
It should fix the subj
Filename:
MIME Type:
Creator:
Michael Golubev
Created:
2006-02-24 08:50:56 EST
Size:
25.72 KB
patch
obsolete
>### 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.2 >diff -u -r1.2 Figure.javajet >--- templates/attr/Figure.javajet 6 Feb 2006 22:21:41 -0000 1.2 >+++ templates/attr/Figure.javajet 24 Feb 2006 13:51:14 -0000 >@@ -4,7 +4,8 @@ > GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument; > final Figure figureInstance = args.getFigure(); > final String figureVarName = args.getVariableName(); >-final ImportAssistant importManager = args.getDispatcher().getImportManager(); >+final GraphDefDispatcher dispatcher = args.getDispatcher(); >+final ImportAssistant importManager = dispatcher.getImportManager(); > %> > <%Color colorVal; > if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) { >@@ -15,5 +16,5 @@ > <%=figureVarName%>.setBackgroundColor(<%@ include file="../Color.jetinc"%>); > <%} if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_PreferredSize())) { > Dimension d = figureInstance.getPreferredSize();%> >- <%=figureVarName%>.setPreferredSize(getMapMode().DPtoLP(<%=d.getDx()%>), getMapMode().DPtoLP(<%=d.getDy()%>)); >+ <%=figureVarName%>.setPreferredSize(<%=dispatcher.DPtoLP(d.getDx())%>, <%=dispatcher.DPtoLP(d.getDy())%>); > <%}%> >\ No newline at end of file >Index: templates/attr/PolylineDecoration.javajet >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/PolylineDecoration.javajet,v >retrieving revision 1.2 >diff -u -r1.2 PolylineDecoration.javajet >--- templates/attr/PolylineDecoration.javajet 6 Feb 2006 22:21:41 -0000 1.2 >+++ templates/attr/PolylineDecoration.javajet 24 Feb 2006 13:51:14 -0000 >@@ -17,5 +17,5 @@ > pl.addPoint(<%=p.getX()%>, <%=p.getY()%>); > <% } /*for*/ %> > <%=figureVarName%>.setTemplate(pl); >- <%=figureVarName%>.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3)); >+ <%=figureVarName%>.setScale(<%=dispatcher.DPtoLP(7)%>, <%=dispatcher.DPtoLP(3)%>); > <% } /*!if getTemplate().isEmpty()*/ %> >Index: templates/attr/RoundedRectangle.javajet >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.graphdef.codegen/templates/attr/RoundedRectangle.javajet,v >retrieving revision 1.2 >diff -u -r1.2 RoundedRectangle.javajet >--- templates/attr/RoundedRectangle.javajet 6 Feb 2006 22:21:41 -0000 1.2 >+++ templates/attr/RoundedRectangle.javajet 24 Feb 2006 13:51:14 -0000 >@@ -8,4 +8,4 @@ > final ImportAssistant importManager = dispatcher.getImportManager(); > %> > <%=dispatcher.dispatch("Shape", args)%> >-<%=figureVarName%>.setCornerDimensions(new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%>(getMapMode().DPtoLP(<%=figureInstance.getCornerWidth()%>), getMapMode().DPtoLP(<%=figureInstance.getCornerHeight()%>))); >\ No newline at end of file >+<%=figureVarName%>.setCornerDimensions(new <%=importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")%>(<%=dispatcher.DPtoLP(figureInstance.getCornerWidth())%>, <%=dispatcher.DPtoLP(figureInstance.getCornerHeight())%>)); >\ No newline at end of file >Index: src/org/eclipse/gmf/graphdef/codegen/templates/PolylineDecorationAttrGenerator.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/PolylineDecorationAttrGenerator.java,v >retrieving revision 1.2 >diff -u -r1.2 PolylineDecorationAttrGenerator.java >--- src/org/eclipse/gmf/graphdef/codegen/templates/PolylineDecorationAttrGenerator.java 6 Feb 2006 22:21:42 -0000 1.2 >+++ src/org/eclipse/gmf/graphdef/codegen/templates/PolylineDecorationAttrGenerator.java 24 Feb 2006 13:51:14 -0000 >@@ -27,8 +27,10 @@ > protected final String TEXT_8 = ");"; > protected final String TEXT_9 = NL + "\t\t"; > protected final String TEXT_10 = ".setTemplate(pl);" + NL + "\t\t"; >- protected final String TEXT_11 = ".setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));"; >- protected final String TEXT_12 = NL; >+ protected final String TEXT_11 = ".setScale("; >+ protected final String TEXT_12 = ", "; >+ protected final String TEXT_13 = ");"; >+ protected final String TEXT_14 = NL; > > public String generate(Object argument) > { >@@ -63,8 +65,12 @@ > stringBuffer.append(TEXT_10); > stringBuffer.append(figureVarName); > stringBuffer.append(TEXT_11); >- } /*!if getTemplate().isEmpty()*/ >+ stringBuffer.append(dispatcher.DPtoLP(7)); > stringBuffer.append(TEXT_12); >+ stringBuffer.append(dispatcher.DPtoLP(3)); >+ stringBuffer.append(TEXT_13); >+ } /*!if getTemplate().isEmpty()*/ >+ stringBuffer.append(TEXT_14); > return stringBuffer.toString(); > } > } >Index: src/org/eclipse/gmf/graphdef/codegen/templates/RoundedRectAttrGenerator.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/templates/RoundedRectAttrGenerator.java,v >retrieving revision 1.2 >diff -u -r1.2 RoundedRectAttrGenerator.java >--- src/org/eclipse/gmf/graphdef/codegen/templates/RoundedRectAttrGenerator.java 6 Feb 2006 22:21:42 -0000 1.2 >+++ src/org/eclipse/gmf/graphdef/codegen/templates/RoundedRectAttrGenerator.java 24 Feb 2006 13:51:14 -0000 >@@ -19,9 +19,9 @@ > protected final String TEXT_1 = ""; > protected final String TEXT_2 = NL; > protected final String TEXT_3 = ".setCornerDimensions(new "; >- protected final String TEXT_4 = "(getMapMode().DPtoLP("; >- protected final String TEXT_5 = "), getMapMode().DPtoLP("; >- protected final String TEXT_6 = ")));"; >+ protected final String TEXT_4 = "("; >+ protected final String TEXT_5 = ", "; >+ protected final String TEXT_6 = "));"; > > public String generate(Object argument) > { >@@ -40,9 +40,9 @@ > stringBuffer.append(TEXT_3); > stringBuffer.append(importManager.getImportedName("org.eclipse.draw2d.geometry.Dimension")); > stringBuffer.append(TEXT_4); >- stringBuffer.append(figureInstance.getCornerWidth()); >+ stringBuffer.append(dispatcher.DPtoLP(figureInstance.getCornerWidth())); > stringBuffer.append(TEXT_5); >- stringBuffer.append(figureInstance.getCornerHeight()); >+ stringBuffer.append(dispatcher.DPtoLP(figureInstance.getCornerHeight())); > stringBuffer.append(TEXT_6); > return stringBuffer.toString(); > } >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.2 >diff -u -r1.2 FigureAttrGenerator.java >--- src/org/eclipse/gmf/graphdef/codegen/templates/FigureAttrGenerator.java 6 Feb 2006 22:21:42 -0000 1.2 >+++ src/org/eclipse/gmf/graphdef/codegen/templates/FigureAttrGenerator.java 24 Feb 2006 13:51:14 -0000 >@@ -35,9 +35,9 @@ > protected final String TEXT_17 = "."; > protected final String TEXT_18 = ");"; > protected final String TEXT_19 = NL + "\t\t"; >- protected final String TEXT_20 = ".setPreferredSize(getMapMode().DPtoLP("; >- protected final String TEXT_21 = "), getMapMode().DPtoLP("; >- protected final String TEXT_22 = "));"; >+ protected final String TEXT_20 = ".setPreferredSize("; >+ protected final String TEXT_21 = ", "; >+ protected final String TEXT_22 = ");"; > > public String generate(Object argument) > { >@@ -46,7 +46,8 @@ > GraphDefDispatcher.Args args = (GraphDefDispatcher.Args) argument; > final Figure figureInstance = args.getFigure(); > final String figureVarName = args.getVariableName(); >-final ImportAssistant importManager = args.getDispatcher().getImportManager(); >+final GraphDefDispatcher dispatcher = args.getDispatcher(); >+final ImportAssistant importManager = dispatcher.getImportManager(); > > Color colorVal; > if (figureInstance.eIsSet(GMFGraphPackage.eINSTANCE.getFigure_ForegroundColor())) { >@@ -96,9 +97,9 @@ > stringBuffer.append(TEXT_19); > stringBuffer.append(figureVarName); > stringBuffer.append(TEXT_20); >- stringBuffer.append(d.getDx()); >+ stringBuffer.append(dispatcher.DPtoLP(d.getDx())); > stringBuffer.append(TEXT_21); >- stringBuffer.append(d.getDy()); >+ stringBuffer.append(dispatcher.DPtoLP(d.getDy())); > stringBuffer.append(TEXT_22); > } > 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.11 >diff -u -r1.11 FigureGenerator.java >--- src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java 16 Feb 2006 19:09:29 -0000 1.11 >+++ src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java 24 Feb 2006 13:51:14 -0000 >@@ -76,8 +76,12 @@ > public FigureGenerator() { > this(null, new NullImportAssistant(), new FigureQualifiedNameSwitch()); > } >- >+ > public FigureGenerator(String aPackageName, ImportAssistant importManager, GMFGraphSwitch figureNameSwitch) { >+ this(aPackageName, importManager, figureNameSwitch, new MapModeCodeGenStrategy.RuntimeUnspecifiedMapMode(importManager)); >+ } >+ >+ public FigureGenerator(String aPackageName, ImportAssistant importManager, GMFGraphSwitch figureNameSwitch, MapModeCodeGenStrategy mapModeStrategy) { > packageName = aPackageName; > final Bundle thisBundle = Platform.getBundle("org.eclipse.gmf.graphdef.codegen"); > final String[] variables = new String[] { >@@ -102,9 +106,9 @@ > }; > String[] templatePath = new String[] {thisBundle.getEntry("/templates/").toString()}; > EmitterFactory topFactory = new EmitterFactory(templatePath, fillTopLevel(), true, variables, true); >- myTopDispatcher = new GraphDefDispatcher(topFactory, keyMap, importManager, figureNameSwitch); >+ myTopDispatcher = new GraphDefDispatcher(topFactory, keyMap, importManager, figureNameSwitch, mapModeStrategy); > EmitterFactory innerFactory = new EmitterFactory(templatePath, fillAttrs(), true, variables, true); >- myInnerDispatcher = new GraphDefDispatcher(innerFactory, keyMap, importManager, figureNameSwitch); >+ myInnerDispatcher = new GraphDefDispatcher(innerFactory, keyMap, importManager, figureNameSwitch, mapModeStrategy); > } > > /** >Index: src/org/eclipse/gmf/graphdef/codegen/GraphDefDispatcher.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/GraphDefDispatcher.java,v >retrieving revision 1.3 >diff -u -r1.3 GraphDefDispatcher.java >--- src/org/eclipse/gmf/graphdef/codegen/GraphDefDispatcher.java 15 Feb 2006 14:44:35 -0000 1.3 >+++ src/org/eclipse/gmf/graphdef/codegen/GraphDefDispatcher.java 24 Feb 2006 13:51:14 -0000 >@@ -26,11 +26,22 @@ > public class GraphDefDispatcher extends DispatcherImpl { > private final ImportAssistant myImportManager; > private final GMFGraphSwitch myFqnSwitch; >- >- public GraphDefDispatcher(EmitterFactory factory, KeyMap keyMap, ImportAssistant importManager, GMFGraphSwitch fqnSwitch) { >+ private final MapModeCodeGenStrategy myMapModeStrategy; >+ >+ public GraphDefDispatcher(EmitterFactory factory, KeyMap keyMap, ImportAssistant importManager, GMFGraphSwitch fqnSwitch, MapModeCodeGenStrategy mapModeStrategy) { > super(factory, keyMap); >+ assert mapModeStrategy != null; > myImportManager = importManager; > myFqnSwitch = fqnSwitch; >+ myMapModeStrategy = mapModeStrategy; >+ } >+ >+ public String DPtoLP(int deviceUnit){ >+ return myMapModeStrategy.DPtoLP(deviceUnit); >+ } >+ >+ public String LPtoDP(int logicalUnit){ >+ return myMapModeStrategy.LPtoDP(logicalUnit); > } > > public ImportAssistant getImportManager() { >Index: src/org/eclipse/gmf/graphdef/codegen/MapModeCodeGenStrategy.java >=================================================================== >RCS file: src/org/eclipse/gmf/graphdef/codegen/MapModeCodeGenStrategy.java >diff -N src/org/eclipse/gmf/graphdef/codegen/MapModeCodeGenStrategy.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/gmf/graphdef/codegen/MapModeCodeGenStrategy.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,90 @@ >+/* >+ * Copyright (c) 2005 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.graphdef.codegen; >+ >+import org.eclipse.gmf.common.codegen.ImportAssistant; >+ >+public abstract class MapModeCodeGenStrategy { >+ private final ImportAssistant myImportAssistant; >+ >+ public abstract String LPtoDP(int logicalUnit); >+ public abstract String DPtoLP(int deviceUnit); >+ >+ public MapModeCodeGenStrategy(ImportAssistant importAssistant){ >+ myImportAssistant = importAssistant; >+ } >+ >+ public ImportAssistant getImportAssistant() { >+ return myImportAssistant; >+ } >+ >+ public static class StaticIdentityMapMode extends MapModeCodeGenStrategy { >+ public StaticIdentityMapMode(ImportAssistant importAssistant){ >+ super(importAssistant); >+ } >+ >+ public String DPtoLP(int deviceUnit) { >+ return String.valueOf(deviceUnit); >+ } >+ >+ public String LPtoDP(int logicalUnit) { >+ return String.valueOf(logicalUnit); >+ } >+ } >+ >+ public static class RuntimeUnspecifiedMapMode extends MapModeCodeGenStrategy { >+ public RuntimeUnspecifiedMapMode(ImportAssistant importAssistant){ >+ super(importAssistant); >+ } >+ >+ public String DPtoLP(int deviceUnit) { >+ StringBuffer result = new StringBuffer(); >+ result.append(getMapModeAccessor()); >+ result.append('.'); >+ result.append("DPtoLP("); >+ result.append(deviceUnit); >+ result.append(')'); >+ return result.toString(); >+ } >+ >+ public String LPtoDP(int logicalUnit) { >+ StringBuffer result = new StringBuffer(); >+ result.append(getMapModeAccessor()); >+ result.append('.'); >+ result.append("LPtoDP("); >+ result.append(logicalUnit); >+ result.append(')'); >+ return result.toString(); >+ } >+ >+ protected String getMapModeAccessor(){ >+ return "getMapMode()"; >+ } >+ } >+ >+ public static class RuntimeMapModeFromPluginClass extends RuntimeUnspecifiedMapMode { >+ private final String myPluginActivatorClassFQN; >+ >+ public RuntimeMapModeFromPluginClass(ImportAssistant importAssistant, String pluginActivatorClassFQN){ >+ super(importAssistant); >+ myPluginActivatorClassFQN = pluginActivatorClassFQN; >+ } >+ >+ protected String getMapModeAccessor() { >+ StringBuffer result = new StringBuffer(); >+ result.append(getImportAssistant().getImportedName(myPluginActivatorClassFQN)); >+ result.append('.'); >+ result.append("getDefault().getMapMode()"); >+ return result.toString(); >+ } >+ } >+} >#P org.eclipse.gmf.tests >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.27 >diff -u -r1.27 AllTests.java >--- src/org/eclipse/gmf/tests/AllTests.java 13 Feb 2006 17:36:07 -0000 1.27 >+++ src/org/eclipse/gmf/tests/AllTests.java 24 Feb 2006 13:51:16 -0000 >@@ -25,6 +25,8 @@ > import org.eclipse.gmf.tests.gen.FigureCodegenTest; > import org.eclipse.gmf.tests.gen.FigureLayoutTest; > 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.ToolDefHandocodedImplTest; > import org.eclipse.gmf.tests.gen.ViewmapProducersTest; > import org.eclipse.gmf.tests.rt.AuditRulesTest; >@@ -33,8 +35,8 @@ > import org.eclipse.gmf.tests.setup.LinksSessionSetup; > import org.eclipse.gmf.tests.setup.SessionSetup; > import org.eclipse.gmf.tests.setup.TestSetupTest; >-import org.eclipse.gmf.tests.tr.NamingStrategyTest; > import org.eclipse.gmf.tests.tr.GenModelTransformerBasicRTTest; >+import org.eclipse.gmf.tests.tr.NamingStrategyTest; > > public class AllTests { > >@@ -52,6 +54,8 @@ > > suite.addTestSuite(FigureCodegenTest.class); > suite.addTestSuite(FigureLayoutTest.class); >+ suite.addTestSuite(RTFigureTest.class); >+ suite.addTestSuite(MapModeStrategyTest.class); > suite.addTestSuite(ViewmapProducersTest.class); > suite.addTestSuite(ToolDefHandocodedImplTest.class); > suite.addTestSuite(AuditHandcodedTest.class); >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.2 >diff -u -r1.2 FigureCodegenTestBase.java >--- src/org/eclipse/gmf/tests/gen/FigureCodegenTestBase.java 20 Feb 2006 12:18:33 -0000 1.2 >+++ src/org/eclipse/gmf/tests/gen/FigureCodegenTestBase.java 24 Feb 2006 13:51:16 -0000 >@@ -11,13 +11,8 @@ > */ > package org.eclipse.gmf.tests.gen; > >-import java.net.MalformedURLException; >- > import junit.framework.TestCase; > >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.runtime.IStatus; > import org.eclipse.emf.codegen.jet.JETException; > import org.eclipse.gmf.common.codegen.ImportUtil; > import org.eclipse.gmf.gmfgraph.ConnectionFigure; >@@ -35,15 +30,11 @@ > import org.eclipse.gmf.gmfgraph.RoundedRectangle; > import org.eclipse.gmf.gmfgraph.util.FigureQualifiedNameSwitch; > import org.eclipse.gmf.graphdef.codegen.FigureGenerator; >-import org.eclipse.gmf.tests.CompileUtil; >-import org.eclipse.gmf.tests.Plugin; > import org.eclipse.jdt.core.compiler.IProblem; > import org.eclipse.jdt.core.dom.AST; > import org.eclipse.jdt.core.dom.ASTNode; > import org.eclipse.jdt.core.dom.ASTParser; > import org.eclipse.jdt.core.dom.CompilationUnit; >-import org.osgi.framework.Bundle; >-import org.osgi.framework.BundleException; > > /** > * TODO generate project, compile and instaniate figures to make sure values are set (like figure's bg/fg color) >@@ -92,34 +83,34 @@ > } > } > >- private GMFGraphGenerator.Config getGMFGraphGeneratorConfig(){ >- return new GMFGraphGenerator.ConfigImpl(getTestPluginName(), getFigurePackageName()); >- } >- >- protected final Class generateAndCompile(GMFGraphGenerator.Config config, Figure figure) { >- try { >- GMFGraphGenerator.GMFGraphTree tree = new GMFGraphGenerator.GMFGraphTree.EObjectAdapter(figure); >- GMFGraphGenerator generator = new GMFGraphGenerator(tree, config); >- generator.run(); >- assertTrue(generator.getRunStatus().getSeverity() < IStatus.ERROR); >- >- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(config.getPluginName()); >- IStatus compileStatus = new CompileUtil().build(project); >- assertTrue(compileStatus.getMessage(), compileStatus.getSeverity() < IStatus.ERROR); >- >- String url = project.getLocation().toFile().toURL().toExternalForm(); >- Bundle bundle = Plugin.getBundleContext().installBundle(url); >- >- return bundle.loadClass(config.getMainPackageName() + "." + figure.getName()); >- } catch (MalformedURLException e) { >- fail(e.getMessage()); >- } catch (BundleException e) { >- fail(e.getMessage()); >- } catch (ClassNotFoundException e) { >- fail(e.getMessage()); >- } >- throw new InternalError("Impossible"); >- } >+// private StandaloneGenerator.Config getGMFGraphGeneratorConfig(){ >+// return new StandaloneGenerator.ConfigImpl(getTestPluginName(), getFigurePackageName()); >+// } >+// >+// protected final Class generateAndCompile(StandaloneGenerator.Config config, Figure figure) { >+// try { >+// GMFGraphTree tree = new GMFGraphTree.EObjectAdapter(figure); >+// StandaloneGenerator generator = new StandaloneGenerator(tree, config); >+// generator.run(); >+// assertTrue(generator.getRunStatus().getSeverity() < IStatus.ERROR); >+// >+// IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(config.getPluginID()); >+// IStatus compileStatus = new CompileUtil().build(project); >+// assertTrue(compileStatus.getMessage(), compileStatus.getSeverity() < IStatus.ERROR); >+// >+// String url = project.getLocation().toFile().toURL().toExternalForm(); >+// Bundle bundle = Plugin.getBundleContext().installBundle(url); >+// >+// return bundle.loadClass(config.getMainPackageName() + "." + figure.getName()); >+// } catch (MalformedURLException e) { >+// fail(e.getMessage()); >+// } catch (BundleException e) { >+// fail(e.getMessage()); >+// } catch (ClassNotFoundException e) { >+// fail(e.getMessage()); >+// } >+// throw new InternalError("Impossible"); >+// } > > // custom top-level, hierarchical children. > protected final Figure figure1() { >@@ -210,6 +201,18 @@ > return df; > } > >+ protected final String getFigurePackageName(){ >+ return "org.eclipse.gmf.tests.sample.figures"; >+ } >+ >+ protected final String getTestPluginName(){ >+ return "org.eclipse.gmf.tests.sample.figures." + getName() + ".t" + System.currentTimeMillis(); >+ } >+ >+ protected final String getPluginActivatorClassFQN(){ >+ return getFigurePackageName() + ".PluginActivator"; >+ } >+ > private FigureGenerator getGenerator() { > if (figureGenerator == null) { > String packageName = getFigurePackageName(); >@@ -218,11 +221,4 @@ > return figureGenerator; > } > >- private String getFigurePackageName(){ >- return "org.eclipse.gmf.tests.sample.figures"; >- } >- >- private String getTestPluginName(){ >- return "org.eclipse.gmf.tests.sample.figures." + getName() + ".t" + System.currentTimeMillis(); >- } > } >Index: src/org/eclipse/gmf/tests/gen/MapModeStrategyTest.java >=================================================================== >RCS file: src/org/eclipse/gmf/tests/gen/MapModeStrategyTest.java >diff -N src/org/eclipse/gmf/tests/gen/MapModeStrategyTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/gmf/tests/gen/MapModeStrategyTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,89 @@ >+/* >+ * Copyright (c) 2005 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 org.eclipse.gmf.common.codegen.ImportAssistant; >+import org.eclipse.gmf.common.codegen.ImportUtil; >+import org.eclipse.gmf.gmfgraph.Dimension; >+import org.eclipse.gmf.gmfgraph.Figure; >+import org.eclipse.gmf.gmfgraph.GMFGraphFactory; >+import org.eclipse.gmf.gmfgraph.RoundedRectangle; >+import org.eclipse.gmf.gmfgraph.util.FigureQualifiedNameSwitch; >+import org.eclipse.gmf.graphdef.codegen.FigureGenerator; >+import org.eclipse.gmf.graphdef.codegen.MapModeCodeGenStrategy; >+ >+public class MapModeStrategyTest extends FigureCodegenTestBase { >+ public MapModeStrategyTest(String name) { >+ super(name); >+ } >+ >+ public void testPreferredSize(){ >+ checkAllStrategies(createFigureWithPrefferedSize()); >+ } >+ >+ public void testRoundedRectangleCorners(){ >+ RoundedRectangle rounded = GMFGraphFactory.eINSTANCE.createRoundedRectangle(); >+ rounded.setName("RoundedRectangleWithCorners"); >+ rounded.setCornerWidth(23); >+ rounded.setCornerHeight(14); >+ checkAllStrategies(rounded); >+ } >+ >+ private void checkAllStrategies(Figure figure){ >+ String baseName = figure.getName(); >+ try { >+ setCustomFigureGenerator(createGenerator(createStaticIdentity())); >+ figure.setName(baseName + "_StaticIdentity"); >+ performTests(figure); >+ >+ setCustomFigureGenerator(createGenerator(createDefaultStrategy())); >+ figure.setName(baseName + "_DefaultMapMode"); >+ performTests(figure); >+ >+ setCustomFigureGenerator(createGenerator(createStandaloneStrategy())); >+ figure.setName(baseName + "_StandaloneMapMode"); >+ performTests(figure); >+ } finally { >+ figure.setName(baseName); >+ } >+ } >+ >+ private Figure createFigureWithPrefferedSize(){ >+ Figure figure = figure2(); >+ figure.setName("Figure2WithPreferredSize"); >+ Dimension preferredSize = GMFGraphFactory.eINSTANCE.createDimension(); >+ preferredSize.setDx(234); >+ preferredSize.setDy(567); >+ figure.setPreferredSize(preferredSize); >+ return figure; >+ } >+ >+ private MapModeCodeGenStrategy createStaticIdentity(){ >+ return new MapModeCodeGenStrategy.StaticIdentityMapMode(createImportAssistant()); >+ } >+ >+ private MapModeCodeGenStrategy createDefaultStrategy(){ >+ return new MapModeCodeGenStrategy.RuntimeUnspecifiedMapMode(createImportAssistant()); >+ } >+ >+ private MapModeCodeGenStrategy createStandaloneStrategy(){ >+ return new MapModeCodeGenStrategy.RuntimeMapModeFromPluginClass(createImportAssistant(), getPluginActivatorClassFQN()); >+ } >+ >+ private ImportAssistant createImportAssistant(){ >+ return new ImportUtil(getFigurePackageName()); >+ } >+ >+ private FigureGenerator createGenerator(MapModeCodeGenStrategy strategy) { >+ return new FigureGenerator(strategy.getImportAssistant().getPackageName(), strategy.getImportAssistant(), new FigureQualifiedNameSwitch(), strategy); >+ } >+}
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 129328
: 35297 |
36822
|
36892