diff options
Diffstat (limited to 'plugins')
32 files changed, 1493 insertions, 7 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/.classpath b/plugins/org.eclipse.gmf.graphdef.codegen/.classpath index 64c5e31b7..155fe578b 100644 --- a/plugins/org.eclipse.gmf.graphdef.codegen/.classpath +++ b/plugins/org.eclipse.gmf.graphdef.codegen/.classpath @@ -3,5 +3,6 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="templates.qvtlib"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/.project b/plugins/org.eclipse.gmf.graphdef.codegen/.project index 83d1d07fc..305aa5806 100644 --- a/plugins/org.eclipse.gmf.graphdef.codegen/.project +++ b/plugins/org.eclipse.gmf.graphdef.codegen/.project @@ -20,9 +20,24 @@ <arguments> </arguments> </buildCommand> + <buildCommand> + <name>org.eclipse.m2m.qvt.oml.QvtBuilder</name> + <arguments> + <dictionary> + <key>src_container</key> + <value>templates.migrated</value> + </dictionary> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.gmf.xpand.xpandBuilder</name> + <arguments> + </arguments> + </buildCommand> </buildSpec> <natures> <nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.eclipse.m2m.qvt.oml.project.TransformationNature</nature> </natures> </projectDescription> diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.gmf.graphdef.codegen/.settings/org.eclipse.core.resources.prefs index 3f449731b..938c00d0c 100644 --- a/plugins/org.eclipse.gmf.graphdef.codegen/.settings/org.eclipse.core.resources.prefs +++ b/plugins/org.eclipse.gmf.graphdef.codegen/.settings/org.eclipse.core.resources.prefs @@ -1,3 +1,4 @@ -#Wed Nov 15 17:26:19 MSK 2006 +#Mon Dec 29 13:39:37 CET 2008 eclipse.preferences.version=1 encoding/templates=ISO-8859-1 +encoding/templates.migrated=ISO-8859-1 diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/.xpand-root b/plugins/org.eclipse.gmf.graphdef.codegen/.xpand-root new file mode 100644 index 000000000..d55f09bb6 --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/.xpand-root @@ -0,0 +1 @@ +templates.migrated diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/META-INF/MANIFEST.MF b/plugins/org.eclipse.gmf.graphdef.codegen/META-INF/MANIFEST.MF index 154b91aed..76e68abf4 100644 --- a/plugins/org.eclipse.gmf.graphdef.codegen/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.gmf.graphdef.codegen/META-INF/MANIFEST.MF @@ -10,7 +10,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)", org.eclipse.gmf.graphdef;bundle-version="[2.0.0,3.0.0)";visibility:=reexport, org.eclipse.emf.codegen;bundle-version="[2.3.0,3.0.0)", org.eclipse.draw2d;bundle-version="[3.2.0,4.0.0)", - org.eclipse.gmf.xpand;bundle-version="[1.0.0,2.0.0)" + org.eclipse.gmf.xpand;bundle-version="[2.0.0,3.0.0)" Export-Package: org.eclipse.gmf.graphdef.codegen, org.eclipse.gmf.internal.graphdef.codegen;x-friends:="org.eclipse.gmf.graphdef.codegen.ui,org.eclipse.gmf.tests" Bundle-Activator: org.eclipse.gmf.internal.graphdef.codegen.Activator diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/plugin.xml b/plugins/org.eclipse.gmf.graphdef.codegen/plugin.xml new file mode 100644 index 000000000..f3436bb5c --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/plugin.xml @@ -0,0 +1,5 @@ +<plugin> + <extension point="org.eclipse.m2m.qvt.oml.javaBlackboxUnits"> + <library class="NativeUtil"><metamodel nsURI="http://www.eclipse.org/gmf/2006/GraphicalDefinition"/><metamodel nsURI="http://www.eclipse.org/emf/2002/Ecore"/></library> + </extension> +</plugin>
\ No newline at end of file diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java index fa0870c2d..2df3e3fd0 100644 --- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java +++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/graphdef/codegen/FigureGenerator.java @@ -18,6 +18,7 @@ import java.util.HashMap; import java.util.Map; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EcorePackage; import org.eclipse.gmf.common.UnexpectedBehaviourException; import org.eclipse.gmf.gmfgraph.Figure; import org.eclipse.gmf.gmfgraph.FigureDescriptor; @@ -26,7 +27,7 @@ import org.eclipse.gmf.internal.graphdef.codegen.Activator; import org.eclipse.gmf.internal.xpand.BufferOutput; import org.eclipse.gmf.internal.xpand.ResourceManager; import org.eclipse.gmf.internal.xpand.XpandFacade; -import org.eclipse.gmf.internal.xpand.expression.Variable; +import org.eclipse.gmf.internal.xpand.model.Variable; import org.eclipse.gmf.internal.xpand.util.ContextFactory; public class FigureGenerator implements TextEmitter { @@ -71,13 +72,13 @@ public class FigureGenerator implements TextEmitter { } final ArrayList<Variable> globals = new ArrayList<Variable>(); if (mapModeStrategy == MapModeCodeGenStrategy.DYNAMIC) { - globals.add(new Variable(VAR_MM_ACCESS, mapModeAccessor == null ? "" : mapModeAccessor)); + globals.add(new Variable(VAR_MM_ACCESS, EcorePackage.eINSTANCE.getEString(), mapModeAccessor == null ? "" : mapModeAccessor)); } if (runtimeToken != null) { - globals.add(new Variable(VAR_RT_TOKEN, runtimeToken)); + globals.add(new Variable(VAR_RT_TOKEN, EcorePackage.eINSTANCE.getEString(), runtimeToken)); } additionalFields = new StringBuilder(); - globals.add(new Variable(VAR_OUTPUT_FIELDS, "") { + globals.add(new Variable(VAR_OUTPUT_FIELDS, EcorePackage.eINSTANCE.getEString(), "") { public Object getValue() { return additionalFields.toString(); } diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/Activator.java b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/Activator.java index 2ccd46325..9d1e83bb2 100644 --- a/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/Activator.java +++ b/plugins/org.eclipse.gmf.graphdef.codegen/src/org/eclipse/gmf/internal/graphdef/codegen/Activator.java @@ -37,7 +37,7 @@ public class Activator extends Plugin { public static ResourceManager createResourceEngine(MapModeCodeGenStrategy strategy, URL... dynamicTemplates) { try { - URL baseURL = instance.getBundle().getEntry("/templates/"); + URL baseURL = instance.getBundle().getEntry("/templates.migrated/"); ArrayList<URL> urls = new ArrayList<URL>(3); if (dynamicTemplates != null) { // XXX perhaps, add strategy token to each url diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Attrs.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Attrs.xpt new file mode 100644 index 000000000..0abaebdb9 --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Attrs.xpt @@ -0,0 +1,68 @@ +/* + * 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ + +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» + +«REM»Define attributes for Figures (for DecorationFigure subclasses see Decoration.xpt)«ENDREM» + +«DEFINE Init(figureVarName : String) FOR gmfgraph::Figure» +«REM»Polymorphic entry point for any Figure's subclass attributes«ENDREM» +«EXPAND attr::Figure::figureAttrs(figureVarName)» +«ENDDEFINE» + +«DEFINE Init(figureVarName : String) FOR gmfgraph::Shape-» +«EXPAND attr::Shape::shapeAttrs(figureVarName)-» +«EXPAND attr::Figure::figureAttrs(figureVarName)-» +«ENDDEFINE» + +«DEFINE Init(figureVarName : String) FOR gmfgraph::Label-» +«figureVarName».setText("«text»"); +«EXPAND attr::Figure::figureAttrs(figureVarName)-» +«ENDDEFINE» + +«DEFINE Init(figureVarName : String) FOR gmfgraph::RoundedRectangle-» +«figureVarName».setCornerDimensions(new org.eclipse.draw2d.geometry.Dimension(«EXPAND MapMode::_map FOR cornerWidth», «EXPAND MapMode::_map FOR cornerHeight»)); +«EXPAND attr::Shape::shapeAttrs(figureVarName)-» +«EXPAND attr::Figure::figureAttrs(figureVarName)-» +«ENDDEFINE» + +«DEFINE Init(figureVarName : String) FOR gmfgraph::CustomFigure-» +«EXPAND attr::CustomClass::Init(figureVarName)-» +«EXPAND attr::Figure::figureAttrs(figureVarName)-» +«ENDDEFINE» + +«DEFINE Init(figureVarName : String) FOR gmfgraph::Polyline-» +«FOREACH template->asSequence() AS pt-» +«figureVarName».addPoint(new org.eclipse.draw2d.geometry.Point(«EXPAND MapMode::_map FOR pt»)); +«ENDFOREACH-» +«EXPAND attr::Shape::shapeAttrs(figureVarName)-» +«EXPAND attr::Figure::figureAttrs(figureVarName)-» +«ENDDEFINE» + +«DEFINE Init(figureVarName : String) FOR gmfgraph::SVGFigure-» +«figureVarName».setURI("«documentURI»"); +«IF noCanvasWidth-» +«figureVarName».setSpecifyCanvasWidth(false); +«ENDIF-» +«IF noCanvasHeight-» +«figureVarName».setSpecifyCanvasHeight(false); +«ENDIF-» +«IF areaOfInterest <> null-» +«figureVarName».setAreaOfInterest(«EXPAND Instance FOR areaOfInterest»); +«ENDIF-» +«EXPAND attr::Figure::figureAttrs(figureVarName)-» +«ENDDEFINE» + +«DEFINE Instance FOR gmfgraph::Rectangle2D-» +new java.awt.geom.Rectangle2D.Float(«x»f, «y»f, «width»f, «height»f) +«ENDDEFINE» diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Border.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Border.xpt new file mode 100644 index 000000000..5261b3d93 --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Border.xpt @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2006, 2008 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ + +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» +«EXTENSION Util» + +«DEFINE Init(figureVarName : String) FOR gmfgraph::Border-» +«figureVarName».setBorder(«EXPAND border(figureVarName)»); +«ENDDEFINE» + +«DEFINE InitMethods FOR gmfgraph::Figure» +«FOREACH getBordersInUse() AS b»«EXPAND initMethod((getBordersInUse()->indexOf(b) - 1)) FOR b»«ENDFOREACH-» +«ENDDEFINE» + +«DEFINE initMethod(c : Integer) FOR gmfgraph::CustomBorder-» + /** + * @generated + */ + private org.eclipse.draw2d.Border createBorder«c»() { + «EXPAND Runtime::newInstance('result')» + «EXPAND attr::CustomClass::Init('result')» + return result; + } +«ENDDEFINE» + +«DEFINE border(figureVarName : String) FOR gmfgraph::Border» +«ERROR 'This is an abstract definition border(String, Border) invoked for ' + self.repr()» +«ENDDEFINE» + +«DEFINE border(figureVarName : String) FOR gmfgraph::LineBorder-» +new org.eclipse.draw2d.LineBorder(«IF null = color»null«ELSE»«EXPAND attr::Figure::color(figureVarName.toUpper() + '_BORDER') FOR color»«ENDIF», «EXPAND MapMode::_map FOR width»)«ENDDEFINE» + +«DEFINE border(figureVarName : String) FOR gmfgraph::MarginBorder-» +new org.eclipse.draw2d.MarginBorder(«EXPAND MapMode::_map FOR insets»)«ENDDEFINE» + +«DEFINE border(figureVarName : String) FOR gmfgraph::CompoundBorder-» +new org.eclipse.draw2d.CompoundBorder(«IF outer = null»null«ELSE»«EXPAND border(figureVarName) FOR outer»«ENDIF», «IF inner = null»null«ELSE»«EXPAND border(figureVarName) FOR inner»«ENDIF») +«ENDDEFINE» + +«DEFINE border(figureVarName : String) FOR gmfgraph::CustomBorder-» +createBorder«getBordersInUse()->size()»()«addBorder(self)-» +«ENDDEFINE» + +«DEFINE border(figureVarName : String) FOR gmfgraph::BorderRef-» +«EXPAND border(figureVarName) FOR actual-» +«ENDDEFINE»
\ No newline at end of file diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Children.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Children.xpt new file mode 100644 index 000000000..4cc59d94c --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Children.xpt @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2006, 2007 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ + +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» +«EXTENSION Util» + +«DEFINE CreateChildren FOR gmfgraph::RealFigure-» + /** + * @generated + */ + private void createContents(){ +«EXPAND instantiate(0, self, 'this') FOREACH children» + } +«ENDDEFINE» + +«DEFINE instantiate(count : Integer, parentFigure : gmfgraph::RealFigure, parentFigureVariable : String) FOR gmfgraph::Figure» +«ERROR 'Abstract instantiate(int, RealFigure, String)'» +«ENDDEFINE» + +«DEFINE instantiate(count : Integer, parentFigure : gmfgraph::RealFigure, parentFigureVariable : String) FOR gmfgraph::FigureRef-» +/*FIXME referenced figures are just not yet fully-functional; need process attrs and layout here*/ +«EXPAND instantiate(count, parentFigure, parentFigureVariable) FOR figure-» +«ENDDEFINE» + +«DEFINE instantiate(count : Integer, parentFigure : gmfgraph::RealFigure, parentFigureVariable : String) FOR gmfgraph::RealFigure» +«LET figureVariableName(self, count) AS figureVarName» +«EXPAND newFigureInstance(figureVarName)» +«EXPAND Attrs::Init(figureVarName)-» +«IF null = layoutData or null = parentFigure.layout-»«REM»Check for (parentLayout != null) to avoid generating data that won't be used. Not sure it's essential, but it was that way with old jet templates«ENDREM» +«parentFigureVariable».add(«figureVarName»); +«ELSE-» +«EXPAND LayoutData::Init(parentFigureVariable, figureVarName) FOR layoutData-» +«ENDIF-» +«EXPAND Layout::Init(figureVarName) FOR layout-» +«EXPAND instantiate(count + 1, self, figureVarName) FOREACH children-» +«ENDLET» +«ENDDEFINE» + +«DEFINE newFigureInstance(figureVarName : String) FOR gmfgraph::RealFigure»«IF needsField(self)»«figureVarName» = «EXPAND Runtime::newInstance»;«ELSE»«EXPAND Runtime::newInstance(figureVarName)»«ENDIF»«ENDDEFINE» + +«DEFINE newFigureInstance(figureVarName : String) FOR gmfgraph::ScalablePolygon-» +«LET figureVarName.firstToUpper() + 'Class' AS localClassName-» +class «localClassName» extends «EXPAND Runtime::fqn» { +«EXPAND xtras::ScalablePolygon::behaviour-» +}; +«IF not needsField(self)»«localClassName» «ENDIF»«figureVarName» = new «localClassName»(); +«ENDLET-» +«ENDDEFINE» diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Decoration.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Decoration.xpt new file mode 100644 index 000000000..47331504f --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Decoration.xpt @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2006, 2007 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ + +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» +«EXTENSION Util» + +«REM»Instantiate and define attributes for DecorationFigures«ENDREM» + +«DEFINE Instantiate(figureVarName : String) FOR gmfgraph::DecorationFigure-» +«EXPAND Runtime::newInstance(figureVarName)» +«EXPAND Attrs::Init(figureVarName)» +«ENDDEFINE» + +«REM»Guess, can't delegate to attrs through Attrs::Init because there's already Init for Polyline«ENDREM» +«DEFINE Instantiate(figureVarName : String) FOR gmfgraph::PolylineDecoration-» +«EXPAND Runtime::newInstance(figureVarName)» +«EXPAND attr::Decoration::polylineAttrs(figureVarName)-» +«ENDDEFINE» + +«REM»Copy of above template for PolylineDecoration, just because PolygonDecoration doesn't extend PolylineDecoration in draw2d and gmfgraph«ENDREM» +«DEFINE Instantiate(figureVarName : String) FOR gmfgraph::PolygonDecoration-» +«EXPAND Runtime::newInstance(figureVarName)» +«EXPAND attr::Decoration::polylineAttrs(figureVarName)-» +«ENDDEFINE»
\ No newline at end of file diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Extras.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Extras.xpt new file mode 100644 index 000000000..5c2806e7f --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Extras.xpt @@ -0,0 +1,111 @@ +/* + * 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ + +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» +«EXTENSION Util» + +«DEFINE localCoordinates FOR gmfgraph::RealFigure» + /** + * @generated + */ + private boolean myUseLocalCoordinates = «not (children)[gmfgraph::Polyline]->isEmpty()»; + + /** + * @generated + */ + protected boolean useLocalCoordinates() { + return myUseLocalCoordinates; + } + + /** + * @generated + */ + protected void setUseLocalCoordinates(boolean useLocalCoordinates) { + myUseLocalCoordinates = useLocalCoordinates; + } +«ENDDEFINE» + +«DEFINE localCoordinates FOR gmfgraph::Polyline-» +«ENDDEFINE» + +«DEFINE localCoordinates FOR gmfgraph::Label-» +«ENDDEFINE» + + +«DEFINE extraMethods FOR gmfgraph::Figure-» +«ENDDEFINE» + +«DEFINE extraMethods FOR gmfgraph::ScalablePolygon-» +«EXPAND xtras::ScalablePolygon::behaviour-» +«ENDDEFINE» + +«DEFINE extraMethods FOR gmfgraph::SVGFigure-» +«EXPAND svgProperty FOREACH properties-» +«ENDDEFINE» + +«DEFINE svgProperty FOR gmfgraph::SVGProperty-» +«IF getter <> null-» + «EXPAND svgPropertyGetter-» +«ENDIF-» +«IF setter <> null-» + «EXPAND svgPropertySetter-» +«ENDIF-» +«ENDDEFINE» + +«DEFINE svgPropertyGetter FOR gmfgraph::SVGProperty-» + + /** + * @generated + */ + public «svgPropertyType(self)» «getter»() { + org.w3c.dom.NodeList nodes = getNodes("«_query»"); //$NON-NLS-1$ + if (nodes.getLength() > 0) { + org.w3c.dom.Element element = (org.w3c.dom.Element) nodes.item(0); + «IF type = gmfgraph::SVGPropertyType::COLOR-» + return getColor(element, "«attribute»"); //$NON-NLS-1$ + «ELSEIF type = gmfgraph::SVGPropertyType::FLOAT-» + String value = element.getAttributeNS(null, "«attribute»"); //$NON-NLS-1$ + return Float.parseFloat(value); + «ELSE-» + return element.getAttributeNS(null, "«attribute»"); //$NON-NLS-1$ + «ENDIF-» + } + «IF type = gmfgraph::SVGPropertyType::FLOAT-» + return 0; + «ELSE-» + return null; + «ENDIF-» + } +«ENDDEFINE» + +«DEFINE svgPropertySetter FOR gmfgraph::SVGProperty-» + + /** + * @generated + */ + public void «setter»(«svgPropertyType(self)» value) { + «IF type = gmfgraph::SVGPropertyType::COLOR-» + String svalue = org.eclipse.gmf.runtime.lite.svg.SVGUtils.toSVGColor(getDocument(), value); + «ELSEIF type = gmfgraph::SVGPropertyType::FLOAT-» + String svalue = Float.toString(value); + «ENDIF-» + org.w3c.dom.NodeList nodes = getNodes("«_query»"); //$NON-NLS-1$ + for (int i = 0; i < nodes.getLength(); i++) { + ((org.w3c.dom.Element) nodes.item(i)).setAttributeNS(null, "«attribute»", //$NON-NLS-1$ + «IF type = gmfgraph::SVGPropertyType::STRING»value«ELSE»svalue«ENDIF»); + } + «IF callSuper-» + super.«setter»(value); + «ENDIF-» + } +«ENDDEFINE» diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Layout.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Layout.xpt new file mode 100644 index 000000000..f3ac3a956 --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Layout.xpt @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2006, 2008 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: + * Artem Tikhomirov (Borland) - initial API and implementation + * Michael Golubev (Borland) - GridLayout attributes + */ + +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» +«EXTENSION Util» + +«DEFINE Init(owningFigureVariable : String) FOR gmfgraph::Layout-» +«owningFigureVariable».setLayoutManager(«EXPAND Runtime::newInstance»); +«ENDDEFINE» + +«DEFINE Init(owningFigureVariable : String) FOR gmfgraph::LayoutRef-» +«EXPAND Init(owningFigureVariable) FOR actual-» +«ENDDEFINE» + +«DEFINE Init(owningFigureVariable : String) FOR gmfgraph::BorderLayout-» +«LET 'layout' + owningFigureVariable.firstToUpper() AS layoutVarName» + «EXPAND Runtime::newInstance(layoutVarName)» +«IF null <> spacing-» + «layoutVarName».setHorizontalSpacing(«spacing.dx»);// TODO mapMode? + «layoutVarName».setVerticalSpacing(«spacing.dy»); +«ENDIF-» + «owningFigureVariable».setLayoutManager(«layoutVarName»); +«ENDLET» +«ENDDEFINE» + +«DEFINE Init(owningFigureVariable : String) FOR gmfgraph::GridLayout-» +«LET 'layout' + owningFigureVariable.firstToUpper() AS layoutVarName» + «EXPAND Runtime::newInstance(layoutVarName)» + «layoutVarName».numColumns = «numColumns»; + «layoutVarName».makeColumnsEqualWidth = «equalWidth»; +«IF null <> spacing-» + «layoutVarName».horizontalSpacing = «spacing.dx»; + «layoutVarName».verticalSpacing = «spacing.dy»; +«ENDIF-» +«IF null <> margins-» + «layoutVarName».marginWidth = «margins.dx»; + «layoutVarName».marginHeight = «margins.dy»; +«ENDIF-» + «owningFigureVariable».setLayoutManager(«layoutVarName»); +«ENDLET» +«ENDDEFINE» + +«DEFINE Init(owningFigureVariable : String) FOR gmfgraph::FlowLayout-» +«LET 'layout' + owningFigureVariable.firstToUpper() AS layoutVarName» + «EXPAND Runtime::newInstance(layoutVarName)» + «layoutVarName».setStretchMinorAxis(«matchMinorSize»); + «layoutVarName».setMinorAlignment(«EXPAND Runtime::fqn».«EXPAND alignment(forceSingleLine) FOR minorAlignment»); +«IF forceSingleLine» + «layoutVarName».setSpacing(«majorSpacing»); + «layoutVarName».setVertical(«vertical»); +«ELSE» + «layoutVarName».setMajorAlignment(«EXPAND Runtime::fqn».«EXPAND alignment(forceSingleLine) FOR majorAlignment»); + «layoutVarName».setMajorSpacing(«majorSpacing»); + «layoutVarName».setMinorSpacing(«minorSpacing»); + «layoutVarName».setHorizontal(«not vertical»); +«ENDIF» + «owningFigureVariable».setLayoutManager(«layoutVarName»); +«ENDLET» +«ENDDEFINE» + +«DEFINE Init(owningFigureVariable : String) FOR gmfgraph::CustomLayout-» +«LET 'layout' + owningFigureVariable.firstToUpper() AS layoutVarName» + «EXPAND Runtime::newInstance(layoutVarName)» +«EXPAND attr::CustomClass::Init(layoutVarName)-» + «owningFigureVariable».setLayoutManager(«layoutVarName»); +«ENDLET» +«ENDDEFINE» + +«DEFINE alignment(forceSingleLine : Boolean) FOR gmfgraph::Alignment-» +«IF self = gmfgraph::Alignment::BEGINNING-» +«IF forceSingleLine»ALIGN_TOPLEFT«ELSE»ALIGN_LEFTTOP«ENDIF-» +«ELSEIF self = gmfgraph::Alignment::END-» +«IF forceSingleLine»ALIGN_BOTTOMRIGHT«ELSE»ALIGN_RIGHTBOTTOM«ENDIF-» +«ELSE-» +ALIGN_CENTER«ENDIF-» +«REM»XXX implement as extension +switch (value) { + case Alignment.BEGINNING : "" + default : "" +}«ENDREM» +«ENDDEFINE» diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/LayoutData.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/LayoutData.xpt new file mode 100644 index 000000000..c631dc4e9 --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/LayoutData.xpt @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2006, 2007 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ + +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» +«EXTENSION Util» + +«DEFINE Init(parentFigureVariable : String, owningFigureVariable : String) FOR gmfgraph::LayoutData» +«ERROR 'Abstract definition, there should be specific template for ' + self.repr()» +«ENDDEFINE» + +«DEFINE Init(parentFigureVariable : String, owningFigureVariable : String) FOR gmfgraph::BorderLayoutData» +«parentFigureVariable».add(«owningFigureVariable», org.eclipse.draw2d.BorderLayout.«borderLayoutConstant(self)»); +«ENDDEFINE» + +«DEFINE Init(parentFigureVariable : String, owningFigureVariable : String) FOR gmfgraph::XYLayoutData» +«parentFigureVariable».add(«owningFigureVariable», «EXPAND newRectangle»); +«ENDDEFINE» + +«DEFINE Init(parentFigureVariable : String, owningFigureVariable : String) FOR gmfgraph::CustomLayoutData» +«LET 'constraint' + owningFigureVariable.firstToUpper() AS constraintVarName-» +«qualifiedClassName» «constraintVarName» = new «qualifiedClassName»(); +«EXPAND attr::CustomClass::Init(constraintVarName)» +«parentFigureVariable».add(«owningFigureVariable», «constraintVarName»); +«ENDLET-» +«ENDDEFINE» + +«DEFINE Init(parentFigureVariable : String, owningFigureVariable : String) FOR gmfgraph::GridLayoutData» +«LET 'constraint' + owningFigureVariable.firstToUpper() AS constraintVarName» +«EXPAND Runtime::newInstance(constraintVarName)» +«constraintVarName».verticalAlignment = «EXPAND Runtime::fqn».«verticalAlignment.repr()»;«REM».literal, not .name!«ENDREM» +«constraintVarName».horizontalAlignment = «EXPAND Runtime::fqn».«horizontalAlignment.repr()»; +«constraintVarName».horizontalIndent = «horizontalIndent»; +«constraintVarName».horizontalSpan = «horizontalSpan»; +«constraintVarName».verticalSpan = «verticalSpan»; +«constraintVarName».grabExcessHorizontalSpace = «grabExcessHorizontalSpace»; +«constraintVarName».grabExcessVerticalSpace = «grabExcessVerticalSpace»; +«IF null <> sizeHint-» +«constraintVarName».widthHint = «sizeHint.dx»; +«constraintVarName».heightHint = «sizeHint.dy»; +«ENDIF-» +«parentFigureVariable».add(«owningFigureVariable», «constraintVarName»); +«ENDLET» +«ENDDEFINE» + +«DEFINE newRectangle FOR gmfgraph::XYLayoutData» +new org.eclipse.draw2d.geometry.Rectangle(«IF null <> topLeft-» +«EXPAND MapMode::_map FOR topLeft», «ELSE»0, 0, «ENDIF-» +«IF null <> size-» +«EXPAND MapMode::_map FOR size»«ELSE»0, 0«ENDIF») +«ENDDEFINE»
\ No newline at end of file diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/MapMode.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/MapMode.xpt new file mode 100644 index 000000000..71d389ef6 --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/MapMode.xpt @@ -0,0 +1,35 @@ +/* + * 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ + +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» + +«REM»No mapMode at all«ENDREM» + +«DEFINE _map FOR gmfgraph::Dimension-» +«dx», «dy-» +«ENDDEFINE» + +«DEFINE _map FOR gmfgraph::Point-» +«x», «y-» +«ENDDEFINE» + +«DEFINE _map FOR Integer» +«self-» +«ENDDEFINE» + +«DEFINE _map FOR gmfgraph::Insets-» +«top», «left», «bottom», «right-» +«ENDDEFINE» + +«DEFINE Activator FOR OclAny-» +«ENDDEFINE»
\ No newline at end of file diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Runtime.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Runtime.xpt new file mode 100644 index 000000000..a8749b93d --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Runtime.xpt @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2007 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ + +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» +«EXTENSION Util» + +«DEFINE newInstance(figureVarName : String) FOR gmfgraph::Figure»«EXPAND fqn» «figureVarName» = «EXPAND newInstance»;«ENDDEFINE» +«DEFINE newInstance FOR gmfgraph::Figure»new «EXPAND fqn»()«ENDDEFINE» + +«DEFINE newInstance(layoutVarName : String) FOR gmfgraph::Layout»«EXPAND fqn» «layoutVarName» = «EXPAND newInstance»;«ENDDEFINE» +«DEFINE newInstance FOR gmfgraph::Layout»new «EXPAND fqn»()«ENDDEFINE» + +«DEFINE newInstance(constraintVarName : String) FOR gmfgraph::LayoutData»«EXPAND fqn» «constraintVarName» = «EXPAND newInstance»;«ENDDEFINE» +«DEFINE newInstance FOR gmfgraph::LayoutData»new «EXPAND fqn»()«ENDDEFINE» + +«DEFINE newInstance(borderVarName : String) FOR gmfgraph::Border»«EXPAND fqn» «borderVarName» = «EXPAND newInstance»;«ENDDEFINE» +«DEFINE newInstance FOR gmfgraph::Border»new «EXPAND fqn»()«ENDDEFINE» + + +«DEFINE fqn FOR gmfgraph::Figure»«ERROR 'Abstract definition fqn(Figure)'»«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::Layout»«ERROR 'Abstract definition fqn(Layout)'»«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::LayoutData»«ERROR 'Abstract definition fqn(LayoutData)'»«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::Border»«ERROR 'Abstract definition fqn(Border)'»«ENDDEFINE» + +//////////////////////// +«DEFINE fqn FOR gmfgraph::CustomLayout»«qualifiedClassName»«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::CustomBorder»«qualifiedClassName»«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::CustomFigure»«qualifiedClassName»«ENDDEFINE» + +//////////////////////// +«DEFINE fqn FOR gmfgraph::FlowLayout»«IF forceSingleLine»org.eclipse.draw2d.ToolbarLayout«ELSE»org.eclipse.draw2d.FlowLayout«ENDIF»«ENDDEFINE» + +«DEFINE fqn FOR gmfgraph::XYLayout»org.eclipse.draw2d.XYLayout«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::XYLayoutData»org.eclipse.draw2d.geometry.Rectangle«ENDDEFINE» + +«DEFINE fqn FOR gmfgraph::GridLayout»org.eclipse.draw2d.GridLayout«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::GridLayoutData»org.eclipse.draw2d.GridData«ENDDEFINE» + +«DEFINE fqn FOR gmfgraph::StackLayout»org.eclipse.draw2d.StackLayout«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::BorderLayout»org.eclipse.draw2d.BorderLayout«ENDDEFINE» + +//////////////////////// +«DEFINE fqn FOR gmfgraph::FigureRef»«EXPAND fqn FOR figure»«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::Label»«IF isFullRuntime()»org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel«ELSE»org.eclipse.draw2d.Label«ENDIF»«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::LabeledContainer»org.eclipse.draw2d.LabeledContainer«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::Rectangle»org.eclipse.draw2d.RectangleFigure«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::RoundedRectangle»org.eclipse.draw2d.RoundedRectangle«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::Ellipse»org.eclipse.draw2d.Ellipse«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::Polygon»org.eclipse.draw2d.Polygon«ENDDEFINE» +«REM»FIXME«ENDREM»«DEFINE fqn FOR gmfgraph::ScalablePolygon»org.eclipse.draw2d.Shape«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::PolygonDecoration»org.eclipse.draw2d.PolygonDecoration«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::Polyline»org.eclipse.draw2d.Polyline«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::PolylineDecoration»org.eclipse.draw2d.PolylineDecoration«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::PolylineConnection»«IF isFullRuntime()»org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx«ELSE»org.eclipse.draw2d.PolylineConnection«ENDIF»«ENDDEFINE» +«DEFINE fqn FOR gmfgraph::SVGFigure»org.eclipse.gmf.runtime.lite.svg.SVGFigure«ENDDEFINE» + +«REM» +to utilize around, need to fix XpandExecutionContextImpl to get aspects not only from relative aspects/ path, but from +template file as well. +// Full GMF Runtime +//////////////////////// +«AROUND fqn FOR PolylineConnection»«IF isFullRuntime()»org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx«ELSE»«targetDef.proceed()»«ENDIF»«ENDAROUND» +«AROUND fqn FOR Label»«IF isFullRuntime()»org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel«ELSE»«targetDef.proceed()»«ENDIF»«ENDAROUND» +«ENDREM»
\ No newline at end of file diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Util.qvto b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Util.qvto new file mode 100644 index 000000000..eee24c2d8 --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/Util.qvto @@ -0,0 +1,135 @@ +import xpt.GlobalVarOperations; +import xpt.StringOperations; + +modeltype graphicalDefinition uses "http://www.eclipse.org/gmf/2006/GraphicalDefinition"; + +library Util; + +property bordersInUse : Sequence(graphicalDefinition::CustomBorder) = Sequence { }; + +helper addBorder(border : graphicalDefinition::CustomBorder) : OclVoid { + bordersInUse := bordersInUse->including(border); + return null +} + +helper clearBorders() : OclVoid { + bordersInUse := Sequence { }; + return null +} + +helper getBordersInUse() : Sequence(graphicalDefinition::CustomBorder) { + return bordersInUse; +} + +helper compilationUnitName(figure : graphicalDefinition::FigureDescriptor) : String { + return figure.name.firstToUpper() +} + +helper hasSourceDecoration(figure : graphicalDefinition::PolylineConnection) : Boolean { + return null <> figure.sourceDecoration +} + +helper requiredBundles(referencedBundles : Sequence(String)) : Sequence(String) { + return (if isFullRuntime() then Sequence { 'org.eclipse.core.runtime', 'org.eclipse.draw2d', 'org.eclipse.gmf.runtime.draw2d.ui' }->union(referencedBundles)->asOrderedSet()->asSequence()->asOrderedSet()->asSequence() else Sequence { 'org.eclipse.core.runtime', 'org.eclipse.draw2d' }->union(referencedBundles)->asOrderedSet()->asSequence()->asOrderedSet()->asSequence() endif) +} + +helper additionalStaticFields() : String { +return xpandGetStringGlobalVar('outputStaticFields') +} + +helper hasTargetDecoration(figure : graphicalDefinition::PolylineConnection) : Boolean { + return null <> figure.targetDecoration +} + +helper isFullRuntime() : Boolean { + return (if internalCheckRuntimeToken() <> null then internalCheckRuntimeToken().toLower() = 'full' else true endif) +} + +helper internalCheckRuntimeToken() : String { +return xpandGetStringGlobalVar('runtimeToken') +} + +helper needsField(figure : graphicalDefinition::RealFigure) : Boolean { + return figure.descriptor <> null and figure.descriptor.accessors.figure->includes(figure) +} + +helper figureVariableName(figure : graphicalDefinition::RealFigure, count : Integer) : String { + return (if needsField(figure) then figure.figureFieldName() else (if figure.name <> null and figure.name.trim().xpandLength() > 0 then figure.name.xpandToFirstLower() + count.repr() else figure.variableNameStem() + count.repr() endif) endif) +} + +helper graphicalDefinition::FigureRef::nameStem() : String { + return self.figure.variableNameStem() +} + +helper graphicalDefinition::Figure::nameStem() : String { + return self.variableNameStem() +} + +helper graphicalDefinition::Figure::variableNameStem() : String { + return 'fig' +} + +helper graphicalDefinition::RealFigure::variableNameStem() : String { + return 'fig' +} + +helper graphicalDefinition::Shape::variableNameStem() : String { + return 'shape' +} + +helper graphicalDefinition::Rectangle::variableNameStem() : String { + return 'rect' +} + +helper graphicalDefinition::RoundedRectangle::variableNameStem() : String { + return 'rrect' +} + +helper graphicalDefinition::Ellipse::variableNameStem() : String { + return 'elli' +} + +helper graphicalDefinition::Polyline::variableNameStem() : String { + return 'polyline' +} + +helper graphicalDefinition::Label::variableNameStem() : String { + return 'l' +} + +helper graphicalDefinition::DecorationFigure::variableNameStem() : String { + return 'dec' +} + +helper graphicalDefinition::ConnectionFigure::variableNameStem() : String { + return 'conn' +} + +helper graphicalDefinition::RealFigure::figureFieldName() : String { + return figureFieldName(self.descriptor.accessors->select(a | self = a.figure)->asSequence()) +} + +helper figureFieldName(aaa : Sequence(graphicalDefinition::ChildAccess)) : String { + return aaa->collect(x | x.figureFieldName())->first() +} + +helper graphicalDefinition::ChildAccess::figureFieldName() : String { + return 'f' + (if self.accessor.xpandStartsWith('get') and self.accessor.xpandLength() > 3 then self.accessor.xpandSubstring(3) else self.accessor endif) +} + +helper borderLayoutConstant(layoutData : graphicalDefinition::BorderLayoutData) : String { + return switch { case (layoutData.alignment = graphicalDefinition::Alignment::BEGINNING) (if layoutData.vertical then 'TOP' else 'LEFT' endif); case (layoutData.alignment = graphicalDefinition::Alignment::END) (if layoutData.vertical then 'BOTTOM' else 'RIGHT' endif); else 'CENTER'; } +} + +helper allCustomAccessors(fd : graphicalDefinition::FigureDescriptor) : Sequence(graphicalDefinition::FigureAccessor) { + return filterCustom(Sequence { fd.actualFigure }).customChildren +} + +helper filterCustom(figures : Sequence(graphicalDefinition::Figure)) : Sequence(graphicalDefinition::CustomFigure) { + return (if figures->isEmpty() then Sequence { } else (figures)[graphicalDefinition::CustomFigure]->union(filterCustom((figures)[graphicalDefinition::RealFigure].children))->asOrderedSet()->asSequence() endif)->collect(it | it)->asSequence() +} + + +helper svgPropertyType(p : graphicalDefinition::SVGProperty) : String { + return switch { case (p.type = graphicalDefinition::SVGPropertyType::COLOR) 'org.eclipse.swt.graphics.Color'; case (p.type = graphicalDefinition::SVGPropertyType::FLOAT) 'float'; else 'String'; } +} diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/attr/CustomClass.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/attr/CustomClass.xpt new file mode 100644 index 000000000..e0de76eb2 --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/attr/CustomClass.xpt @@ -0,0 +1,38 @@ +/* + * 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» +«EXTENSION Util» +«EXTENSION NativeUtil» + +«DEFINE Init(instanceVarName : String) FOR gmfgraph::CustomClass» +«EXPAND customAttribute(instanceVarName) FOREACH attributes» +«ENDDEFINE» + +«DEFINE customAttribute(instanceVarName : String) FOR gmfgraph::CustomAttribute» +«EXPAND customAttrValueImpl-» +«IF directAccess» +«instanceVarName».«name» = «EXPAND customAttrValue»; +«ELSE» +«instanceVarName».set«name.firstToUpper()»(«EXPAND customAttrValue»); +«ENDIF» +«ENDDEFINE» + +«DEFINE customAttrValueImpl FOR gmfgraph::CustomAttribute» +«IF multiStatementValue-» +«messageFormat(value, Sequence { 'attr' + name.firstToUpper() })-» +«ENDIF-» +«ENDDEFINE» + +«DEFINE customAttrValue FOR gmfgraph::CustomAttribute» +«IF multiStatementValue»attr«name.firstToUpper()»«ELSE-»«value»«ENDIF-» +«ENDDEFINE»
\ No newline at end of file diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/attr/Decoration.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/attr/Decoration.xpt new file mode 100644 index 000000000..40ae0f367 --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/attr/Decoration.xpt @@ -0,0 +1,53 @@ +/* + * 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» +«IMPORT 'templates'» +«EXTENSION Util» + +«DEFINE polylineAttrs(figureVarName : String) FOR gmfgraph::PolylineDecoration-» +«EXPAND attr::Shape::shapeAttrs(figureVarName)-» +«EXPAND attr::Figure::figureAttrs(figureVarName)-» +«EXPAND templatePoints(figureVarName)-» +«EXPAND scale(figureVarName)-» +«ENDDEFINE» + +«DEFINE polylineAttrs(figureVarName : String) FOR gmfgraph::PolygonDecoration-» +«EXPAND attr::Shape::shapeAttrs(figureVarName)-» +«EXPAND attr::Figure::figureAttrs(figureVarName)-» +«EXPAND templatePoints(figureVarName)-» +«EXPAND scale(figureVarName)-» +«ENDDEFINE» + +«DEFINE templatePoints(figureVarName : String) FOR gmfgraph::Polyline-» +«IF not template->isEmpty()-» +org.eclipse.draw2d.geometry.PointList pl = new org.eclipse.draw2d.geometry.PointList(); +«EXPAND templatePoint('pl') FOREACH template-» +«figureVarName».setTemplate(pl); +«ENDIF-» +«ENDDEFINE» + +«DEFINE templatePoint(pointListVarName : String) FOR gmfgraph::Point-» +«pointListVarName».addPoint(«EXPAND MapMode::_map»); +«ENDDEFINE» + +«DEFINE scale(figureVarName : String) FOR gmfgraph::PolylineDecoration-» +«IF not template->isEmpty()-» +«figureVarName».setScale(«EXPAND MapMode::_map FOR 7», «EXPAND MapMode::_map FOR 3»); +«ENDIF-» +«ENDDEFINE» + +«DEFINE scale(figureVarName : String) FOR gmfgraph::PolygonDecoration-» +«IF not template->isEmpty()-» +«figureVarName».setScale(«EXPAND MapMode::_map FOR 7», «EXPAND MapMode::_map FOR 3»); +«ENDIF-» +«ENDDEFINE»
\ No newline at end of file diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/attr/Figure.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/attr/Figure.xpt new file mode 100644 index 000000000..1e0984f6d --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/attr/Figure.xpt @@ -0,0 +1,96 @@ +/* + * 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» +«IMPORT 'templates'» +«EXTENSION Util» +«EXTENSION xpt::StringOperations» + +«DEFINE figureAttrs(figureVarName : String) FOR gmfgraph::Figure-» +«EXPAND foregroundColor(self, figureVarName) FOR foregroundColor-» +«EXPAND backgroundColor(self, figureVarName) FOR backgroundColor-» +«EXPAND font(figureVarName) FOR font-» +«EXPAND preferredSize(figureVarName) FOR preferredSize-» +«EXPAND maximumSize(figureVarName) FOR maximumSize-» +«EXPAND minimumSize(figureVarName) FOR minimumSize-» +«EXPAND position(figureVarName) FOR location-» +«EXPAND size(figureVarName) FOR size-» +«EXPAND insets(figureVarName) FOR insets-» +«EXPAND Border::Init(figureVarName) FOR border-» +«ENDDEFINE» + +«DEFINE foregroundColor(figure : gmfgraph::Figure, figureVarName : String) FOR gmfgraph::Color-» + «figureVarName».setForegroundColor(«EXPAND color(figureVarName.toUpper() + '_FORE')»); +«ENDDEFINE» +«DEFINE backgroundColor(figure : gmfgraph::Figure, figureVarName : String) FOR gmfgraph::Color-» + «figureVarName».setBackgroundColor(«EXPAND color(figureVarName.toUpper() + '_BACK')»); +«ENDDEFINE» + +«DEFINE preferredSize(figureVarName : String) FOR gmfgraph::Dimension-» +«figureVarName».setPreferredSize(new org.eclipse.draw2d.geometry.Dimension(«EXPAND MapMode::_map»)); +«ENDDEFINE» + +«DEFINE maximumSize(figureVarName : String) FOR gmfgraph::Dimension-» +«figureVarName».setMaximumSize(new org.eclipse.draw2d.geometry.Dimension(«EXPAND MapMode::_map»)); +«ENDDEFINE» + +«DEFINE minimumSize(figureVarName : String) FOR gmfgraph::Dimension-» +«figureVarName».setMinimumSize(new org.eclipse.draw2d.geometry.Dimension(«EXPAND MapMode::_map»)); +«ENDDEFINE» + +«DEFINE position(figureVarName : String) FOR gmfgraph::Point-» +«figureVarName».setLocation(new org.eclipse.draw2d.geometry.Point(«EXPAND MapMode::_map»)); +«ENDDEFINE» + +«DEFINE size(figureVarName : String) FOR gmfgraph::Point-» +«figureVarName».setSize(«EXPAND MapMode::_map»); +«ENDDEFINE» + +«DEFINE insets(figureVarName : String) FOR gmfgraph::Insets-» +«REM»using MarginBorder for insets is not good idea«ENDREM» +«figureVarName».setBorder(new org.eclipse.draw2d.MarginBorder(«EXPAND MapMode::_map»)); +«ENDDEFINE» + +«DEFINE font(figureVarName : String) FOR gmfgraph::Font» +«ERROR 'This is abstact definition, just to overcome some xpand polymorphism limitations'» +«ENDDEFINE» + +«DEFINE color(variableName : String) FOR gmfgraph::Color» +«ERROR 'This is abstact definition, just to overcome some xpand polymorphism limitations'» +«ENDDEFINE» + +«DEFINE color(variableName : String) FOR gmfgraph::RGBColor-» +«variableName-» +«FILE '' staticFields» +/** + * @generated + */ +static final org.eclipse.swt.graphics.Color «variableName» = new org.eclipse.swt.graphics.Color(null, «red», «green», «blue»); +«ENDFILE» +«ENDDEFINE» + +«DEFINE color(variableName : String) FOR gmfgraph::ConstantColor-» +org.eclipse.draw2d.ColorConstants.«value-» +«ENDDEFINE» + +«DEFINE font(figureVarName : String) FOR gmfgraph::BasicFont-» +«LET figureVarName.toUpper() + '_FONT' AS variableName» +«figureVarName».setFont(«variableName»); +«FILE '' staticFields» +/** + * @generated + */ +static final org.eclipse.swt.graphics.Font «variableName» = new org.eclipse.swt.graphics.Font(org.eclipse.swt.widgets.Display.getCurrent(), «IF null = faceName or faceName.trim().xpandLength() = 0»org.eclipse.swt.widgets.Display.getDefault().getSystemFont().getFontData()[0].getName()«ELSE»"«faceName»"«ENDIF», «height», org.eclipse.swt.SWT.«style»); +«ENDFILE» +«ENDLET» +«ENDDEFINE» + diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/attr/Shape.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/attr/Shape.xpt new file mode 100644 index 000000000..6c1d00ca0 --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/attr/Shape.xpt @@ -0,0 +1,56 @@ +/* + * 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» + +«REM» +org.eclipse.draw2d.Shape + private boolean fill = true, outline = true, xorFill, xorOutline; +«ENDREM» +«DEFINE shapeAttrs(figureVarName : String) FOR gmfgraph::Shape-» +«EXPAND fill(figureVarName)-» +«IF xorFill»«EXPAND xorFill(figureVarName)»«ENDIF-» +«IF not outline»«EXPAND outline(figureVarName)»«ENDIF-» +«IF xorOutline»«EXPAND xorOutline(figureVarName)»«ENDIF-» +«IF lineWidth <> 1»«EXPAND lineWidth(figureVarName)»«ENDIF-» +«IF lineKind <> gmfgraph::LineKind::LINE_SOLID»«EXPAND lineKind(figureVarName)»«ENDIF-» +«ENDDEFINE» + +«DEFINE fill(figureVarName : String) FOR gmfgraph::Shape-» +«IF not fill»«figureVarName».setFill(«fill»); +«ENDIF-» +«ENDDEFINE» + +«DEFINE fill(figureVarName : String) FOR gmfgraph::Polygon-» +«IF fill»«figureVarName».setFill(«fill»); +«ENDIF-» +«ENDDEFINE» + +«DEFINE xorFill(figureVarName : String) FOR gmfgraph::Shape-» +«figureVarName».setFillXOR(«xorFill»); +«ENDDEFINE» + +«DEFINE outline(figureVarName : String) FOR gmfgraph::Shape-» +«figureVarName».setOutline(«outline»); +«ENDDEFINE» + +«DEFINE xorOutline(figureVarName : String) FOR gmfgraph::Shape-» +«figureVarName».setOutlineXOR(«xorOutline»); +«ENDDEFINE» + +«DEFINE lineWidth(figureVarName : String) FOR gmfgraph::Shape-» +«figureVarName».setLineWidth(«lineWidth»); +«ENDDEFINE» + +«DEFINE lineKind(figureVarName : String) FOR gmfgraph::Shape-» +«figureVarName».setLineStyle(org.eclipse.draw2d.Graphics.«lineKind»); +«ENDDEFINE» diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/plugin/Activator.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/plugin/Activator.xpt new file mode 100644 index 000000000..1c39deefe --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/plugin/Activator.xpt @@ -0,0 +1,70 @@ +/* + * 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» +«IMPORT 'templates'» + +«DEFINE Init(packageName : String, pluginActivatorClassName : String, pluginID : String) FOR Collection(OclAny)-» +«EXPAND Init(packageName, pluginActivatorClassName, pluginID) FOR ''-» +«ENDDEFINE» + +«DEFINE Init(packageName : String, pluginActivatorClassName : String, pluginID : String) FOR OclAny-» +package «packageName»; + +/** + * @generated + */ +public class «pluginActivatorClassName» extends org.eclipse.core.runtime.Plugin { + + /** + * @generated + */ + public static final String ID = "«pluginID»"; //$NON-NLS-1$ + + /** + * @generated + */ + private static «pluginActivatorClassName» ourInstance; + + /** + * @generated + */ + public «pluginActivatorClassName»() { + } + + /** + * @generated + */ + public void start(org.osgi.framework.BundleContext context) throws Exception { + super.start(context); + ourInstance = this; + } + + /** + * @generated + */ + public void stop(org.osgi.framework.BundleContext context) throws Exception { + ourInstance = null; + super.stop(context); + } + + /** + * @generated + */ + public static «pluginActivatorClassName» getDefault() { + return ourInstance; + } +«EXPAND MapMode::Activator-» +«EXPAND additions-» +} +«ENDDEFINE» + +«DEFINE additions FOR OclAny»«ENDDEFINE»
\ No newline at end of file diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/plugin/BuildProperties.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/plugin/BuildProperties.xpt new file mode 100644 index 000000000..ee6d03784 --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/plugin/BuildProperties.xpt @@ -0,0 +1,18 @@ +/* + * 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ + +«DEFINE Init FOR OclAny-» +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ +«ENDDEFINE»
\ No newline at end of file diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/plugin/Manifest.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/plugin/Manifest.xpt new file mode 100644 index 000000000..1d10a67f1 --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/plugin/Manifest.xpt @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2006, 2007 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ +«EXTENSION Util» + +/* + * FIXME add a simple model (either non-generated, .ecore only?) to descripbe GenConfig + */ + +«DEFINE Init(pluginID : String, pluginActivatorQualifiedName : String, exportedPackages : Sequence(String), referencedBundles : Sequence(String)) FOR OclAny-» +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: «pluginID»; singleton:=true +Bundle-Version: 1.0.0 +Bundle-Vendor: %providerName +Bundle-Activator: «pluginActivatorQualifiedName» +Bundle-Localization: plugin +Export-Package:«EXPAND exportPackageHeader FOR exportedPackages» +Require-Bundle:«EXPAND requireBundleHeader FOR requiredBundles(referencedBundles)» +Eclipse-LazyStart: true +«EXPAND additions-» +«ENDDEFINE» + +«DEFINE exportPackageHeader FOR Sequence(String)-» +«EXPAND print FOREACH self SEPARATOR ', +'-» +«ENDDEFINE» + +«REM»FIXME Set[String] - improve union recognition«ENDREM» +«DEFINE requireBundleHeader FOR Collection(OclAny)-» +«EXPAND print FOREACH (self->collect(it | it))[String]->asSequence() SEPARATOR ', +'-» +«ENDDEFINE» + +«DEFINE print FOR String» «self»«ENDDEFINE» + +«DEFINE additions FOR OclAny»«ENDDEFINE»
\ No newline at end of file diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/plugin/PluginProperties.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/plugin/PluginProperties.xpt new file mode 100644 index 000000000..2e3ee1d45 --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/plugin/PluginProperties.xpt @@ -0,0 +1,16 @@ +/* + * 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ + +«DEFINE Init(pluginName : String, providerName : String) FOR OclAny-» +pluginName = «pluginName» +providerName = «providerName» +«ENDDEFINE»
\ No newline at end of file diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/rt_mm/MapMode.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/rt_mm/MapMode.xpt new file mode 100644 index 000000000..424bf03ca --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/rt_mm/MapMode.xpt @@ -0,0 +1,58 @@ +/* + * 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ + +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» +«EXTENSION rt_mm::MapModeUtil» + +«REM»Using MapMode«ENDREM» + +«DEFINE _map FOR gmfgraph::Dimension-» +«EXPAND deviceToLogic FOR dx», «EXPAND deviceToLogic FOR dy-» +«ENDDEFINE» + +«DEFINE _map FOR gmfgraph::Point-» +«EXPAND deviceToLogic FOR x», «EXPAND deviceToLogic FOR y-» +«ENDDEFINE» + +«DEFINE _map FOR Integer-» +«EXPAND deviceToLogic-» +«ENDDEFINE» + +«DEFINE _map FOR gmfgraph::Insets-» +«EXPAND deviceToLogic FOR top», «EXPAND deviceToLogic FOR left», «EXPAND deviceToLogic FOR bottom», «EXPAND deviceToLogic FOR right-» +«ENDDEFINE» + +«DEFINE deviceToLogic FOR Integer-» +«mapModeAccessor()»getMapMode().DPtoLP(«self») +«ENDDEFINE» + +«DEFINE Activator FOR OclAny-» + private org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode myMapMode = org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeTypes.IDENTITY_MM; + + /** + * @generated + */ + public void setMapMode(org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode mapMode) { + myMapMode = mapMode; + if (myMapMode == null){ + myMapMode = org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeTypes.IDENTITY_MM; + } + } + + /** + * @generated + */ + public org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode getMapMode() { + return myMapMode; + } +«ENDDEFINE»
\ No newline at end of file diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/rt_mm/MapModeUtil.qvto b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/rt_mm/MapModeUtil.qvto new file mode 100644 index 000000000..fdb4309e1 --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/rt_mm/MapModeUtil.qvto @@ -0,0 +1,7 @@ +import xpt.GlobalVarOperations; + +library MapModeUtil; + +helper mapModeAccessor() : String { +return xpandGetStringGlobalVar('mapModeAccessor') +} diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/top/Descriptor.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/top/Descriptor.xpt new file mode 100644 index 000000000..ea65f103d --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/top/Descriptor.xpt @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2007 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ + +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» +«IMPORT 'templates'» +«EXTENSION Util» +«EXTENSION xpt::StringOperations» + +«DEFINE Top(packageStmt : String) FOR gmfgraph::FigureDescriptor» +«IF packageStmt <> null and packageStmt.xpandLength() > 0»package «packageStmt»; +«ENDIF-» +/** + * @generated + */ +public class «compilationUnitName(self)» extends «EXPAND Runtime::fqn FOR actualFigure» { +«EXPAND body» +«additionalStaticFields()» +} +«ENDDEFINE» + + + +«DEFINE Inner FOR gmfgraph::FigureDescriptor» +/** + * @generated + */ +public class «compilationUnitName(self)» extends «EXPAND Runtime::fqn FOR actualFigure» { +«EXPAND body» +} +«additionalStaticFields()» +«ENDDEFINE» + +«REM»«ENDREM» +«DEFINE body FOR gmfgraph::FigureDescriptor» + +«EXPAND accessorField FOREACH accessors->select(a | not (allCustomAccessors(self).typedFigure)[gmfgraph::Figure]->includes(a.figure))» + +«EXPAND Figure::ClassBody(compilationUnitName(self)) FOR actualFigure» + +«EXPAND accessorToField FOREACH accessors->select(a | not (allCustomAccessors(self).typedFigure)[gmfgraph::Figure]->includes(a.figure))» +«FOREACH accessors->select(a | (allCustomAccessors(self).typedFigure)[gmfgraph::Figure]->includes(a.figure))->asSequence() AS a-» +«EXPAND accessorToCustom(allCustomAccessors(self)->select(fa | fa.typedFigure = a.figure)) FOR a» +«ENDFOREACH-» +«ENDDEFINE» + + +«DEFINE accessorField FOR gmfgraph::ChildAccess-» + /** + * @generated + */ + private «EXPAND Runtime::fqn FOR figure» «self.figureFieldName()»; +«ENDDEFINE» + +«REM»ChildAccess points to figure we've generated, there's a field for it«ENDREM» +«DEFINE accessorToField FOR gmfgraph::ChildAccess-» + /** + * @generated + */ + public «EXPAND Runtime::fqn FOR figure» «accessor»() { + return «self.figureFieldName()»; + } +«ENDDEFINE» + +«REM»ChildAccess points to some child of a CustomFigure, need to delegate to it's accessor +Perhaps, should add support for ChildAccess not being generated (in case they are have same name as +FigureAccessor.accessor +«ENDREM» +«DEFINE accessorToCustom(fa : Sequence(gmfgraph::FigureAccessor)) FOR gmfgraph::ChildAccess-» + /** + * @generated + */ + public «EXPAND Runtime::fqn FOR figure» «accessor»() { + return «fa.accessor->first()»; + } +«ENDDEFINE»
\ No newline at end of file diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/top/Figure.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/top/Figure.xpt new file mode 100644 index 000000000..4ba4c7918 --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/top/Figure.xpt @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2006, 2007 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: + * Artem Tikhomirov (Borland) - initial API and implementation + */ + +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» +«IMPORT 'templates'» +«EXTENSION Util» + +«DEFINE ClassBody(cuName : String) FOR gmfgraph::Figure»«ERROR 'abstract ClassBody(Figure)'»«ENDDEFINE» + +«DEFINE ClassBody(cuName : String) FOR gmfgraph::FigureRef-» +«EXPAND ClassBody(cuName) FOR figure-» +«ENDDEFINE» + +«DEFINE ClassBody(cuName : String) FOR gmfgraph::RealFigure-» + /** + * @generated + */ + public «cuName»() { +«clearBorders()-» + «EXPAND Layout::Init('this') FOR layout-» + «EXPAND Attrs::Init('this')-» +«IF not (children)[gmfgraph::Figure]->isEmpty()-» + createContents(); + } +«EXPAND Children::CreateChildren-» +«EXPAND Border::InitMethods» +«ELSE-» + } +«ENDIF-» +«EXPAND Extras::extraMethods» +«EXPAND Extras::localCoordinates» +«EXPAND additions-» +«ENDDEFINE» + +«DEFINE ClassBody(cuName : String) FOR gmfgraph::PolylineConnection-» + /** + * @generated + */ + public «cuName»() { + «EXPAND Attrs::Init('this')» +«IF not (children)[gmfgraph::Label]->isEmpty()-» + createContents(); +«ENDIF-» +«IF hasSourceDecoration(self)-» + setSourceDecoration(createSourceDecoration()); +«ENDIF-» +«IF hasTargetDecoration(self)-» + setTargetDecoration(createTargetDecoration()); +«ENDIF-» + } +«IF not (children)[gmfgraph::Label]->isEmpty()» +«REM» + Copy of Children::CreateChildren with temp workaround to generate child figures for labels only. + Though this is temp workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=193180, I'm not sure + what's the right approach with e.g. decoration as child of a link. +«ENDREM» + /** + * @generated + */ + private void createContents(){ +«EXPAND Children::instantiate(0, self, 'this') FOREACH (children)[gmfgraph::Label]» + } +«ENDIF-» +«IF hasSourceDecoration(self)» + /** + * @generated + */ + private org.eclipse.draw2d.RotatableDecoration createSourceDecoration() { + «EXPAND Decoration::Instantiate('df') FOR sourceDecoration-» + return df; + } +«ENDIF-» +«IF hasTargetDecoration(self)» + /** + * @generated + */ + private org.eclipse.draw2d.RotatableDecoration createTargetDecoration() { + «EXPAND Decoration::Instantiate('df') FOR targetDecoration-» + return df; + } +«ENDIF-» +«EXPAND additions-» +«ENDDEFINE» + +«REM»Our regular way to add smth inside generated class body«ENDREM» +«DEFINE additions FOR gmfgraph::Figure»«ENDDEFINE»
\ No newline at end of file diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/xtras/ScalablePolygon.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/xtras/ScalablePolygon.xpt new file mode 100644 index 000000000..6fcd2e6a3 --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.migrated/xtras/ScalablePolygon.xpt @@ -0,0 +1,94 @@ +/* + * 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 + */ + +«IMPORT 'http://www.eclipse.org/gmf/2006/GraphicalDefinition'» +«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» + + +«DEFINE behaviour FOR gmfgraph::ScalablePolygon-» + /** + * @generated + */ + private final org.eclipse.draw2d.geometry.PointList myTemplate = new org.eclipse.draw2d.geometry.PointList(); + /** + * @generated + */ + private org.eclipse.draw2d.geometry.Rectangle myTemplateBounds; + + /** + * @generated + */ + public void addPoint(org.eclipse.draw2d.geometry.Point point){ + myTemplate.addPoint(point); + myTemplateBounds = null; + } + + /** + * @generated + */ + protected void fillShape(org.eclipse.draw2d.Graphics graphics) { + org.eclipse.draw2d.geometry.Rectangle bounds = getBounds(); + graphics.pushState(); + graphics.translate(bounds.x, bounds.y); + graphics.fillPolygon(scalePointList()); + graphics.popState(); + } + + /** + * @generated + */ + protected void outlineShape(org.eclipse.draw2d.Graphics graphics) { + org.eclipse.draw2d.geometry.Rectangle bounds = getBounds(); + graphics.pushState(); + graphics.translate(bounds.x, bounds.y); + graphics.drawPolygon(scalePointList()); + graphics.popState(); + } + + /** + * @generated + */ + private org.eclipse.draw2d.geometry.Rectangle getTemplateBounds(){ + if (myTemplateBounds == null){ + myTemplateBounds = myTemplate.getBounds().getCopy().union(0, 0); + //just safety -- we are going to use this as divider + if (myTemplateBounds.width < 1){ + myTemplateBounds.width = 1; + } + if (myTemplateBounds.height < 1){ + myTemplateBounds.height = 1; + } + } + return myTemplateBounds; + } + + /** + * @generated + */ + private int[] scalePointList() { + org.eclipse.draw2d.geometry.Rectangle pointsBounds = getTemplateBounds(); + org.eclipse.draw2d.geometry.Rectangle actualBounds = getBounds(); + + float xScale = ((float) actualBounds.width) / pointsBounds.width; + float yScale = ((float) actualBounds.height) / pointsBounds.height; + + if (xScale == 1 && yScale == 1) { + return myTemplate.toIntArray(); + } + int[] scaled = (int[]) myTemplate.toIntArray().clone(); + for (int i = 0; i < scaled.length; i += 2) { + scaled[i] = (int) Math.floor(scaled[i] * xScale); + scaled[i + 1] = (int) Math.floor(scaled[i + 1] * yScale); + } + return scaled; + } +«ENDDEFINE»
\ No newline at end of file diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates.qvtlib/NativeUtil.java b/plugins/org.eclipse.gmf.graphdef.codegen/templates.qvtlib/NativeUtil.java new file mode 100644 index 000000000..d10a5419c --- /dev/null +++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates.qvtlib/NativeUtil.java @@ -0,0 +1,6 @@ +import org.eclipse.m2m.qvt.oml.blackbox.java.Operation; +import org.eclipse.m2m.qvt.oml.blackbox.java.Operation.Kind; +public class NativeUtil { +@Operation(contextual = false, kind = Kind.HELPER) +public static String messageFormat(String pattern, java.util.List<Object> argument) { return java.text.MessageFormat.format(pattern, argument.toArray(new Object[argument.size()])); } +}
\ No newline at end of file |