Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/GeneralMappingsandHelpers.qvto')
-rw-r--r--deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/GeneralMappingsandHelpers.qvto136
1 files changed, 136 insertions, 0 deletions
diff --git a/deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/GeneralMappingsandHelpers.qvto b/deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/GeneralMappingsandHelpers.qvto
new file mode 100644
index 00000000000..becc23eefc9
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/GeneralMappingsandHelpers.qvto
@@ -0,0 +1,136 @@
+--Author Manel Fredj-CEA LIST
+library GeneralMappings;
+
+import Converter.Utils.ConverterLibs;
+import NotationQueries;
+
+
+modeltype di2 uses 'http://www.papyrusuml.org/di2';
+modeltype notation uses 'http://www.eclipse.org/gmf/runtime/1.0.2/notation';
+modeltype ecore uses 'http://www.eclipse.org/emf/2002/Ecore';
+modeltype uml uses 'http://www.eclipse.org/uml2/2.1.0/UML';
+
+
+-------------------------------------------------------------------------------------------------------------------------
+---------------------------------------- Generic Mappings ---------------------------------------
+-------------------------------------------------------------------------------------------------------------------------
+abstract mapping di2::GraphElement::element2View() : notation::View
+{
+ --assign visibility attribute (it seems that this is not supported by Papyrus MDT
+ -- if false, diagram is visible but has no contents
+ --visible := self.isVisible;
+ visible := true;
+
+ element := self.getElement().oclAsType(ecore::EObject);
+}
+
+
+mapping di2::GraphEdge::edge2Connector() : notation::Connector inherits di2::GraphElement::element2View
+{
+ lineColor := self.borderColor.rgb2int();
+}
+
+mapping di2::GraphNode::node2Shape() : notation::Shape inherits di2::GraphElement::element2View
+{
+ --assign colors and bounds
+ lineColor := self.borderColor.rgb2int();
+ fillColor := self.backgroundColor.rgb2int();
+ fontColor := self.fontColor.rgb2int();
+
+ layoutConstraint := object notation::Bounds {
+ var size : notation::Size := self.oclAsType(di2::GraphNode).size.map dimension2Size();
+
+ var relativeLocation: notation::Location :=null;
+
+ var location : notation::Location := self.position.map point2Location();
+ x := location.x;
+ y := location.y;
+ width := size.width;
+ height := size.height;
+ if (self.container.oclIsTypeOf(di2::GraphNode)) then {
+ // correct position (why necessary??) of nested items
+ y := y - 20;
+ } endif;
+ }
+}
+
+-------------------------------------------------------------------------------------------------------------------------
+---------------------------------------- Mappings ---------------------------------------
+-------------------------------------------------------------------------------------------------------------------------
+
+mapping di2::Dimension::dimension2Size() : notation::Size
+{
+ width := self.dimensionGetWidth();
+ height := self.dimensionGetHeight();
+}
+
+-- transformation mapping dimension into location
+mapping di2::Point::point2Location() : notation::Location
+{
+ x := self.pointGetX();
+ y := self.pointGetY();
+
+}
+
+-------------------------------------------------------------------------------------------------------------------------
+---------------------------------------- Helpers ---------------------------------------
+-------------------------------------------------------------------------------------------------------------------------
+
+
+--Set EAnnotation: not specific to a diagram (it is used in class diagram and composite diagram)
+--------------------------------
+helper setEAnnotations() : OrderedSet (ecore::EAnnotation)
+{
+ -- first eAnnotation
+ var eAnnot1 := object ecore::EAnnotation {
+ --the id is set automatically
+ --eAnnot1.eModelElement:=self.resolveone(notation::Node);
+ source := "ShadowFigure";
+ details := object ecore::EStringToStringMapEntry {
+ key := "ShadowFigure_Value";
+ value := "false";
+ };
+ };
+
+ -- second annotation
+ var eAnnot2 := object ecore::EAnnotation {
+ --the id is set automatically
+ source := "displayNameLabelIcon";
+ details := object ecore::EStringToStringMapEntry {
+ key := "displayNameLabelIcon_value";
+ value := "false";
+ };
+ };
+
+ -- third annotation
+ var eAnnot3 := object ecore::EAnnotation {
+ -- the id is set automatically
+ source := "QualifiedName";
+ details := object ecore::EStringToStringMapEntry {
+ key := "QualifiedNameDepth";
+ value := "1000";
+ };
+ };
+
+ -- add the set of annotations to the node
+ return OrderedSet {
+ eAnnot1, eAnnot2, eAnnot3
+ };
+}
+
+--suppresses showing type information for an element (used for associations by default)
+helper noTypeEAnnotation() : OrderedSet (ecore::EAnnotation)
+{
+ var eAnnotationNoType := object ecore::EAnnotation {
+ --the id is set automatically
+ --eAnnot1.eModelElement:=self.resolveone(notation::Node);
+ source := "CustomAppearance_Annotation";
+ details := object ecore::EStringToStringMapEntry {
+ key := "CustomAppearance_MaskValue";
+ value := "14";
+ };
+ };
+ return OrderedSet {
+ eAnnotationNoType
+ };
+} \ No newline at end of file

Back to the top