Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2016-07-21 13:25:16 +0000
committerChristian W. Damus2016-07-21 16:43:56 +0000
commitc4e479a253353098700237eb317a5dc4f3bf785c (patch)
treeb7d6b15b07509517eb5d82991372a31924d21115 /extraplugins
parentada3256c591a10dbf30af88d0a285cc33f3fa640 (diff)
downloadorg.eclipse.papyrus-c4e479a253353098700237eb317a5dc4f3bf785c.tar.gz
org.eclipse.papyrus-c4e479a253353098700237eb317a5dc4f3bf785c.tar.xz
org.eclipse.papyrus-c4e479a253353098700237eb317a5dc4f3bf785c.zip
Bug 497841: [Model Import] Size of imported capsule part is smaller than in legacy model causing additional layout issues
https://bugs.eclipse.org/bugs/show_bug.cgi?id=497841 Don't attempt to create port views as children of the structure diagram itself (not the frame) because they wouldn't be provided by the view service, anyways. Ensure proper himetric conversion to pixels according to the host system's display resolution and the 2540 units per inch scaling to avoid considerable drift in the layout. (cherry-picked from streams/2.0-maintenance) Change-Id: I4bc66c014cca85ca35c5c34e3e4ef856da54123b
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.m2m.qvto/META-INF/MANIFEST.MF3
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.m2m.qvto/src/org/eclipse/papyrus/m2m/qvto/NotationTypes.java35
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/transform/RSAStructureDiagram.qvto43
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/transform/RSAToPapyrus.qvto36
4 files changed, 94 insertions, 23 deletions
diff --git a/extraplugins/migration/org.eclipse.papyrus.m2m.qvto/META-INF/MANIFEST.MF b/extraplugins/migration/org.eclipse.papyrus.m2m.qvto/META-INF/MANIFEST.MF
index 137a664c7f1..0387eb3dd58 100644
--- a/extraplugins/migration/org.eclipse.papyrus.m2m.qvto/META-INF/MANIFEST.MF
+++ b/extraplugins/migration/org.eclipse.papyrus.m2m.qvto/META-INF/MANIFEST.MF
@@ -3,7 +3,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.m2m.qvt.oml;bundle-version="3.4.0",
org.eclipse.m2m.qvt.oml.runtime,
- org.eclipse.gmf.runtime.notation;bundle-version="1.7.0"
+ org.eclipse.gmf.runtime.notation;bundle-version="1.7.0",
+ org.eclipse.gmf.runtime.draw2d.ui;bundle-version="1.9.0"
Export-Package: org.eclipse.papyrus.m2m.qvto
Bundle-Vendor: Eclipse Modeling Project
Bundle-ActivationPolicy: lazy
diff --git a/extraplugins/migration/org.eclipse.papyrus.m2m.qvto/src/org/eclipse/papyrus/m2m/qvto/NotationTypes.java b/extraplugins/migration/org.eclipse.papyrus.m2m.qvto/src/org/eclipse/papyrus/m2m/qvto/NotationTypes.java
index c3cb40b3f6e..12d7c15a2f7 100644
--- a/extraplugins/migration/org.eclipse.papyrus.m2m.qvto/src/org/eclipse/papyrus/m2m/qvto/NotationTypes.java
+++ b/extraplugins/migration/org.eclipse.papyrus.m2m.qvto/src/org/eclipse/papyrus/m2m/qvto/NotationTypes.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2016 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,13 +8,18 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 497841
*****************************************************************************/
package org.eclipse.papyrus.m2m.qvto;
import java.util.LinkedList;
import java.util.List;
+import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeTypes;
+import org.eclipse.gmf.runtime.notation.Anchor;
+import org.eclipse.gmf.runtime.notation.LayoutConstraint;
import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
+import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
import org.eclipse.m2m.qvt.oml.blackbox.java.Operation;
import org.eclipse.m2m.qvt.oml.blackbox.java.Operation.Kind;
@@ -22,22 +27,36 @@ import org.eclipse.m2m.qvt.oml.blackbox.java.Operation.Kind;
public class NotationTypes {
+ @Operation(contextual = true, kind = Kind.QUERY)
+ public static int toPixels(LayoutConstraint self, Integer himetric) {
+ return (himetric == null) ? -1 : convertToPixels(himetric);
+ }
+
+ @Operation(contextual = true, kind = Kind.QUERY)
+ public static int toPixels(View self, Integer himetric) {
+ return (himetric == null) ? -1 : convertToPixels(himetric);
+ }
+
+ @Operation(contextual = true, kind = Kind.QUERY)
+ public static int toPixels(Anchor self, Integer himetric) {
+ return (himetric == null) ? -1 : convertToPixels(himetric);
+ }
+
@Operation(contextual = true, kind = Kind.HELPER)
public static void copyBendpoints(final RelativeBendpoints source, RelativeBendpoints target, boolean convertToPixels) {
List<RelativeBendpoint> result = new LinkedList<RelativeBendpoint>();
- for(Object point : source.getPoints()) {
- if(point instanceof RelativeBendpoint) {
- RelativeBendpoint pointCopy = new RelativeBendpoint(((RelativeBendpoint)point).convertToString());
+ for (Object point : source.getPoints()) {
+ if (point instanceof RelativeBendpoint) {
+ RelativeBendpoint pointCopy = new RelativeBendpoint(((RelativeBendpoint) point).convertToString());
result.add(pointCopy);
}
}
- if(convertToPixels) {
-
+ if (convertToPixels) {
List<RelativeBendpoint> convertedResult = new LinkedList<RelativeBendpoint>();
- for(RelativeBendpoint point : result) {
+ for (RelativeBendpoint point : result) {
convertedResult.add(convertToPixels(point));
}
@@ -59,6 +78,6 @@ public class NotationTypes {
}
private static int convertToPixels(int source) {
- return source / 25;
+ return MapModeTypes.HIMETRIC_MM.LPtoDP(source);
}
}
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/transform/RSAStructureDiagram.qvto b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/transform/RSAStructureDiagram.qvto
index ac4d0b1e768..3dab008f30f 100644
--- a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/transform/RSAStructureDiagram.qvto
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/transform/RSAStructureDiagram.qvto
@@ -8,7 +8,7 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- * Christian W. Damus - bug 461980
+ * Christian W. Damus - bugs 461980, 497841
*****************************************************************************/
import RSAToPapyrus;
@@ -99,6 +99,20 @@ mapping inout Node::defaultFrameSize() {
} endif;
}
+mapping inout Node::defaultSize(dWidth : Integer, dHeight : Integer) when {
+ self.layoutConstraint.oclIsKindOf(notation::Size) and
+ let size = self.layoutConstraint.oclAsType(notation::Size) in
+ size.width = -1 or size.height = -1
+} {
+ var size : Size = self.layoutConstraint.oclAsType(notation::Size);
+ if (size.width = -1) then {
+ size.width := dWidth;
+ } endif;
+ if (size.height = -1) then {
+ size.height := dHeight;
+ } endif;
+}
+
/***** Nodes **********/
mapping UMLShape::toPapyrusShape() : Shape inherits Shape::toPapyrusShape when {
@@ -158,9 +172,34 @@ mapping UMLShape::toPapyrusShape() : Shape inherits Shape::toPapyrusShape when {
self.element.oclIsTypeOf(Interaction)
)
}{
-
+
+ if (result.type = '3070') {
+ // Handle default size of part shape
+ result.map defaultSize(160, 40);
+ }
}
+/****** Adjustments to newly attached output views ******/
+
+mapping inout Node::adjustNode() disjuncts
+ Node::adjustStructureCompartment
+;
+
+mapping inout Node::adjustStructureCompartment() when {
+ self.type = '7073'
+} {
+ // All ports, even internal ports, are children of the frame
+ self.children->select(type = '3069').map hoistPortNode();
+}
+
+mapping inout Node::hoistPortNode() {
+ self.parentNode().parentNode().children += self;
+
+ // Add the height of the name label to account for the placement in the frame
+ // instead of the structure compartment
+ var loc = self.layoutConstraint.oclAsType(Location);
+ loc.y := loc.y + 20;
+}
/****** Connector Labels ******/
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/transform/RSAToPapyrus.qvto b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/transform/RSAToPapyrus.qvto
index 73894771f25..2b9c756442d 100644
--- a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/transform/RSAToPapyrus.qvto
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/transform/RSAToPapyrus.qvto
@@ -8,7 +8,7 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- * Christian W. Damus - bugs 461980, 496653
+ * Christian W. Damus - bugs 461980, 496653, 497841
*****************************************************************************/
import org.eclipse.papyrus.m2m.qvto.UI;
import org.eclipse.papyrus.m2m.qvto.NotationTypes;
@@ -59,6 +59,14 @@ abstract mapping notation::View::toPapyrusView() : notation::View {
var sortedChildren := self.children->sortedBy(if isNameLabel() then -1 else 0 endif);
result.children := sortedChildren.map toNode();
result.type := self.getType();
+
+ // Adjust containment or other characteristics, as necessary, after attachment
+ result.children.map adjustNode();
+}
+
+/** Overridden/extended in specialized mappings to adjust newly attached nodes. */
+abstract mapping inout notation::Node::adjustNode() {
+ // Pass
}
/** A name label is a BasicDecorationNode of type 'Name' in RSA diagrams. */
@@ -91,8 +99,8 @@ abstract mapping Node::toPapyrusConnectorLabel() : Node {
var initY := self.layoutConstraint.oclAsType(Location).y;
if self.diagram.isHimetric() then {
- initX := initX.toPixels();
- initY := initY.toPixels();
+ initX := self.toPixels(initX);
+ initY := self.toPixels(initY);
} endif;
result.layoutConstraint := object Location {
@@ -276,10 +284,10 @@ mapping Bounds::toLayout(diagram : Diagram) : LayoutConstraint {
var bounds : Bounds := result.oclAsType(Bounds);
if diagram.isHimetric() then {
- bounds.x := self.x.toPixels();
- bounds.y := self.y.toPixels();
- if self.width > 0 then bounds.width := self.width.toPixels() endif;
- if self.height > 0 then bounds.height := self.height.toPixels() endif;
+ bounds.x := self.toPixels(self.x);
+ bounds.y := self.toPixels(self.y);
+ if self.width > 0 then bounds.width := self.toPixels(self.width) endif;
+ if self.height > 0 then bounds.height := self.toPixels(self.height) endif;
} else{
bounds.x := self.x;
bounds.y := self.y;
@@ -292,10 +300,6 @@ query View::isHimetric() : Boolean {
return self.diagram.measurementUnit = MeasurementUnit::Himetric
}
-query Integer::toPixels() : Integer{
- return self.div(25); //FIXME: Approx.
-}
-
mapping Anchor::toAnchor() : Anchor disjuncts
IdentityAnchor::toAnchor{
@@ -314,7 +318,7 @@ mapping IdentityAnchor::toAnchor() : Anchor {
var newId := if part1.oclIsInvalid() or part2.oclIsInvalid() then
self.id
else
- (part1.toPixels().toString())+':'+(part2.toPixels().toString())
+ (self.toPixels(part1).toString())+':'+(self.toPixels(part2).toString())
endif;
newId;
} else {
@@ -361,6 +365,14 @@ query View::getType(): String{
endif;
}
+query View::parent() : View {
+ return self.oclAsType(EObject).eContainer().oclAsType(View);
+}
+
+query Node::parentNode() : Node {
+ return self.oclAsType(EObject).eContainer().oclAsType(Node);
+}
+
query View::findElement() : Element {
return self.findAssociatedElement().oclAsType(Element);
}

Back to the top