Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordstadnik2008-07-31 12:17:18 +0000
committerdstadnik2008-07-31 12:17:18 +0000
commit481807ea8b206f10ae74f71eda8e0fbcc943f7a4 (patch)
treebf851dcbee56de413976f582963bbd8c4e26d9f3 /plugins
parentdfe1345ea63ad9c3e344674699ff36f6d0a268fc (diff)
downloadorg.eclipse.gmf-tooling-481807ea8b206f10ae74f71eda8e0fbcc943f7a4.tar.gz
org.eclipse.gmf-tooling-481807ea8b206f10ae74f71eda8e0fbcc943f7a4.tar.xz
org.eclipse.gmf-tooling-481807ea8b206f10ae74f71eda8e0fbcc943f7a4.zip
[234668] support svg figures in gmfgraph
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Attrs.xpt5
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Extras.xpt55
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Runtime.xpt1
-rw-r--r--plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.ext9
4 files changed, 68 insertions, 2 deletions
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Attrs.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Attrs.xpt
index 4893c0346..dd43119e1 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Attrs.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Attrs.xpt
@@ -48,3 +48,8 @@
«EXPAND attr::Shape::shapeAttrs(figureVarName)-»
«EXPAND attr::Figure::figureAttrs(figureVarName)-»
«ENDDEFINE»
+
+«DEFINE Init(EString figureVarName) FOR gmfgraph::SVGFigure-»
+«figureVarName».setURI("«documentURI»", true);
+«EXPAND attr::Figure::figureAttrs(figureVarName)-»
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Extras.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Extras.xpt
index 089b55874..e1ce3e8ff 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Extras.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Extras.xpt
@@ -12,6 +12,7 @@
«IMPORT "http://www.eclipse.org/gmf/2006/GraphicalDefinition"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
+«EXTENSION Util»
«DEFINE localCoordinates FOR gmfgraph::RealFigure»
/**
@@ -46,4 +47,56 @@
«DEFINE extraMethods FOR gmfgraph::ScalablePolygon-»
«EXPAND xtras::ScalablePolygon::behaviour-»
-«ENDDEFINE» \ No newline at end of file
+«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()» «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 org.eclipse.gmf.runtime.lite.svg.SVGUtils.toSWTColor(element, "«attribute»"); //$NON-NLS-1$
+ «ELSE-»
+ return element.getAttributeNS(null, "«attribute»"); //$NON-NLS-1$
+ «ENDIF-»
+ }
+ return null;
+ }
+«ENDDEFINE»
+
+«DEFINE svgPropertySetter FOR gmfgraph::SVGProperty-»
+
+ /**
+ * @generated
+ */
+ public void «setter»(«svgPropertyType()» value) {
+ «IF type == gmfgraph::SVGPropertyType::COLOR-»
+ String svalue = org.eclipse.gmf.runtime.lite.svg.SVGUtils.toSVGColor(getDocument(), 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/Runtime.xpt b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Runtime.xpt
index b4993935d..940ba9011 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Runtime.xpt
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Runtime.xpt
@@ -62,6 +62,7 @@
«DEFINE fqn FOR Polyline»org.eclipse.draw2d.Polyline«ENDDEFINE»
«DEFINE fqn FOR PolylineDecoration»org.eclipse.draw2d.PolylineDecoration«ENDDEFINE»
«DEFINE fqn FOR PolylineConnection»«IF isFullRuntime()»org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx«ELSE»org.eclipse.draw2d.PolylineConnection«ENDIF»«ENDDEFINE»
+«DEFINE fqn FOR 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
diff --git a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.ext b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.ext
index 2b5f72ca5..12e2b2957 100644
--- a/plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.ext
+++ b/plugins/org.eclipse.gmf.graphdef.codegen/templates/Util.ext
@@ -106,4 +106,11 @@ private List[CustomFigure] filterCustom(List[Figure] figures) :
EString messageFormat(EString pattern, List[Object] argument) :
JAVA java.text.MessageFormat.format(java.lang.String, java.lang.Object.List)
-; \ No newline at end of file
+;
+
+String svgPropertyType(gmfgraph::SVGProperty p) :
+ switch (p.type) {
+ case SVGPropertyType::COLOR : "org.eclipse.swt.graphics.Color"
+ default : "String"
+ }
+;

Back to the top