Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2010-04-21 18:01:43 -0400
committeratikhomirov2010-04-21 18:01:43 -0400
commitfff3cb83c5dfb94a01e0f5abaac4ad4e6e863e74 (patch)
tree733fa93d0e54829b79ba2371d4c93760e9e5baaa
parent647484e48e1f54a3b28e5e8cbf9e0db2f171ed9a (diff)
downloadorg.eclipse.gmf-tooling-fff3cb83c5dfb94a01e0f5abaac4ad4e6e863e74.tar.gz
org.eclipse.gmf-tooling-fff3cb83c5dfb94a01e0f5abaac4ad4e6e863e74.tar.xz
org.eclipse.gmf-tooling-fff3cb83c5dfb94a01e0f5abaac4ad4e6e863e74.zip
[142010] Use Draw2D 'native' Polyline and Polygon shapes instead of localCoordinates hack.
-rw-r--r--plugins/org.eclipse.gmf.codegen/models/gmfgen.emf3
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/NodeEditPart.xpt29
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editparts/Utils.qvto4
3 files changed, 21 insertions, 15 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/models/gmfgen.emf b/plugins/org.eclipse.gmf.codegen/models/gmfgen.emf
index 913fe3bfc..51045daa5 100644
--- a/plugins/org.eclipse.gmf.codegen/models/gmfgen.emf
+++ b/plugins/org.eclipse.gmf.codegen/models/gmfgen.emf
@@ -919,6 +919,9 @@ class FigureViewmap extends Viewmap {
attr String[1] figureQualifiedClassName;
}
+// XXX for NodeEditPart#getPrimaryShape() I need figure's FQN.
+// Full RT doesn't generate this method, although makes no precautions not to use it from outside
+// Lite RT generates (null) in this case.
class SnippetViewmap extends Viewmap {
attr String body;
}
diff --git a/plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/NodeEditPart.xpt b/plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/NodeEditPart.xpt
index 9eea0b8df..876e3f8ce 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/NodeEditPart.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/NodeEditPart.xpt
@@ -51,7 +51,7 @@
«ENDDEFINE»
«DEFINE installCreationRolePolicy FOR gmfgen::GenNode-»
-«IF hasChildren(self) or hasChildrenInListCompartments(self)-»
+«IF self.childNodes->notEmpty() or hasChildrenInListCompartments(self)-»
installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE, «EXPAND _creationEditPolicyNewInstance»);
«ENDIF-»
«ENDDEFINE»
@@ -176,19 +176,22 @@ new org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolic
}
«ENDDEFINE»
+/*
+ FIXME
+ 1. single generation of createNodeShape(), with inner body filled by polymorphic initPrimaryShape, same as in Lite RT
+ 2. getPrimaryShape() for SnippetViewmap. Other templates use it regardless of Viewmap kind, perhaps need to add className to SnippetViewmap (with IFigure being default?)
+ 3. Common (single and shared with Lite RT) condition when to force useLocalConstraints. Lite checks for compartments isEmpty, shouldn't we do the same?
+*/
«DEFINE createNodeShape(node : gmfgen::GenNode) FOR gmfgen::Viewmap-»
«ERROR 'Unknown viewmap: ' + self.repr()-»
«ENDDEFINE»
+
«DEFINE createNodeShape(node : gmfgen::GenNode) FOR gmfgen::FigureViewmap-»
«LET (if figureQualifiedClassName = null then 'org.eclipse.draw2d.RectangleFigure' else figureQualifiedClassName endif) AS fqn-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.draw2d.IFigure createNodeShape() {
- return primaryShape = new «fqn»()«IF node.getLayoutType() = gmfgen::ViewmapLayoutType::XY_LAYOUT»{
- protected boolean useLocalCoordinates() {
- return true;
- }
- }«ENDIF»;
+ return primaryShape = new «fqn»()«IF node.childNodes->notEmpty() and node.getLayoutType() = gmfgen::ViewmapLayoutType::XY_LAYOUT»«EXPAND forceUseLocalCoordinates»«ENDIF»;
}
«EXPAND getPrimaryShapeMethod FOR fqn-»
@@ -205,16 +208,20 @@ new org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolic
«DEFINE createNodeShape(node : gmfgen::GenNode) FOR gmfgen::InnerClassViewmap-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.draw2d.IFigure createNodeShape() {
- «className» figure = new «className»();
- «IF node.childNodes->size() > 0 and node.getLayoutType() = gmfgen::ViewmapLayoutType::XY_LAYOUT-»
- figure.setUseLocalCoordinates(true);
- «ENDIF-»
- return primaryShape = figure;
+ return primaryShape = new «className»()«IF node.childNodes->notEmpty() and node.getLayoutType() = gmfgen::ViewmapLayoutType::XY_LAYOUT»«EXPAND forceUseLocalCoordinates»«ENDIF»;
}
«EXPAND getPrimaryShapeMethod FOR className-»
«ENDDEFINE»
+«DEFINE forceUseLocalCoordinates FOR OclAny-»
+{
+ protected boolean useLocalCoordinates() {
+ return true;
+ }
+}«-»
+«ENDDEFINE»
+
«DEFINE getPrimaryShapeMethod FOR String-»
«EXPAND xpt::Common::generatedMemberComment»
public «self» getPrimaryShape() {
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editparts/Utils.qvto b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editparts/Utils.qvto
index 26b0592f6..9fd49bf31 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editparts/Utils.qvto
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editparts/Utils.qvto
@@ -38,10 +38,6 @@ helper hasFixedChildren(node : gmfgen::GenNode) : Boolean {
return getInnerFixedLabels(node)->size() > 0 or getPinnedCompartments(node)->size() > 0
}
-helper hasChildren(node : gmfgen::GenNode) : Boolean {
- return not node.childNodes->isEmpty()
-}
-
helper listCompartmentHasChildren(compartment : gmfgen::GenCompartment) : Boolean {
return compartment.listLayout and compartment.childNodes->size() > 0
}

Back to the top