Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/Diagram.qvto')
-rw-r--r--deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/Diagram.qvto213
1 files changed, 213 insertions, 0 deletions
diff --git a/deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/Diagram.qvto b/deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/Diagram.qvto
new file mode 100644
index 00000000000..f88e9680aea
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/Diagram.qvto
@@ -0,0 +1,213 @@
+--Author Manel Fredj-CEA LIST
+library Diagram;
+
+import ClassDiagNodes;
+import StateDiagNodes;
+import ProfileDiagNodes;
+import ClassAndProfileDiagEdges;
+import CompositeDiagNodes;
+import StateDiagEdges;
+import CompositeDiagEdges;
+
+--import VisualIDs;
+import NotationQueries;
+import GeneralMappingsandHelpers;
+
+modeltype di uses 'http://www.eclipse.org/papyrus/0.7.0/sashdi';
+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';
+
+
+mapping di2::Diagram::diagram2diagram() : notation::Diagram inherits di2::GraphElement::element2View
+{
+ --the id is set automatically
+ --assign type
+ type := self.getDiagramtype();
+ --assign name
+ name := self.name;
+
+ --assign element
+ measurementUnit := notation::MeasurementUnit::Pixel;
+
+ --transform contained nodes and edges
+
+ if (type = ClassDiagram_P2) then {
+ children := setChildrenForClassDiagram(self.contained);
+ edges := setEdgesForClassAndProfileDiagram(self.contained);
+ } endif;
+ if (type = ProfileDiagram_P2) then {
+ children := setChildrenForProfileDiagram(self.contained);
+ edges := setEdgesForClassAndProfileDiagram(self.contained);
+ } endif;
+ if (type = CompositeStructure_P2) then {
+ children := setChildrenForCompositeDiagram(self.contained);
+ edges := setEdgesForCompositeDiagram(self.contained);
+ } endif;
+ if (type = StateMachineDiagram_P2) then {
+ children := setChildrenForStateDiagram(self.contained);
+ edges := setEdgesForStateDiagram(self.contained);
+ } endif;
+
+ --Set Style of diagram
+ if (type != null) then {
+ styles := setStylesForDiagram();
+ } endif;
+}
+
+
+--------------------------------------------------------------
+--converting a composite diagram
+helper setChildrenForCompositeDiagram(in contained:OrderedSet(di2::DiagramElement)) : OrderedSet(notation::Node)
+{
+ var setOfChildren:OrderedSet(notation::Node);
+ var child:notation::Node;
+ var itsParent: notation::Shape;
+ contained ->forEach (node|node.oclIsTypeOf(di2::GraphNode)) {
+ --case of containing a class
+ if (node.oclAsType(di2::GraphNode).getElement().oclIsTypeOf(uml::Class) ) then {
+ child := node.oclAsType(di2::GraphNode).map compositeDiagNode2Shape();
+ setOfChildren += child;
+ } endif;
+ --case of containing a port : map the potr and attach it to the semantic parent
+ if (node.oclAsType(di2::GraphNode).getElement().oclIsTypeOf(uml::Port) ) then {
+ child := node.oclAsType(di2::GraphNode).map compositeDiagPort2Shape();
+ var temp: di2::DiagramElement:=node.oclAsType(di2::GraphNode).getSemanticParent();
+ itsParent:= temp.oclAsType(di2::GraphNode).resolveone (notation::Shape);
+ --add the child to the semantic parent
+ itsParent.children+= child;
+ } endif;
+ };
+
+ return setOfChildren;
+}
+
+------------------------------------------------------------
+--converting a class diagram
+helper setChildrenForClassDiagram (in contained:OrderedSet(di2::DiagramElement)) : OrderedSet(notation::Node)
+{
+ var setOfChildren:OrderedSet(notation::Node);
+ var child:notation::Node;
+ contained ->forEach (node|node.oclIsTypeOf(di2::GraphNode)) {
+ child := node.oclAsType(di2::GraphNode).map classDiagNode2Shape();
+ setOfChildren += child;
+ };
+
+ return setOfChildren;
+}
+
+------------------------------------------------------------
+--converting a profile diagram
+helper setChildrenForProfileDiagram (in contained:OrderedSet(di2::DiagramElement)) : OrderedSet(notation::Node)
+{
+ var setOfChildren:OrderedSet(notation::Node);
+ var child:notation::Node;
+ contained ->forEach (node|node.oclIsTypeOf(di2::GraphNode)) {
+ child := node.oclAsType(di2::GraphNode).map profileDiagNode2Shape();
+ setOfChildren += child;
+ };
+
+ return setOfChildren;
+}
+
+--converting a state diagram
+helper setChildrenForStateDiagram (in contained:OrderedSet(di2::DiagramElement)) : OrderedSet(notation::Node)
+{
+ var setOfChildren:OrderedSet(notation::Node);
+ var child:notation::Node;
+ contained ->forEach (node|node.oclIsTypeOf(di2::GraphNode)) {
+ child := node.oclAsType(di2::GraphNode).map stateDiagNode2Shape();
+ setOfChildren += child;
+ };
+
+ return setOfChildren;
+}
+
+helper setEdgesForClassAndProfileDiagram (in contained : OrderedSet(di2::DiagramElement)) : OrderedSet (notation::Edge)
+{
+ var setofEdges : OrderedSet(notation::Edge);
+ var edge : notation::Edge;
+ contained->forEach (node|node.oclIsTypeOf(di2::GraphEdge)) {
+ edge := node.oclAsType(di2::GraphEdge).map classAndProfileDiagEdge2Edge();
+ setofEdges += edge;
+ };
+ contained->forEach (composite|composite.oclIsTypeOf(di2::GraphNode)) {
+ composite.oclAsType(di2::GraphNode).contained->forEach (elem|elem.oclIsTypeOf(di2::GraphEdge)) {
+ edge := elem.oclAsType(di2::GraphEdge).map classAndProfileDiagEdge2Edge();
+ setofEdges += edge;
+ };
+ composite.oclAsType(di2::GraphNode).contained->forEach (prop|prop.oclIsTypeOf(di2::GraphNode)) {
+ prop.oclAsType(di2::GraphNode).contained->forEach (connect|connect.oclIsTypeOf(di2::GraphEdge)) {
+ edge := connect.oclAsType(di2::GraphEdge).map classAndProfileDiagEdge2Edge();
+ setofEdges += edge;
+ };
+ };
+ };
+
+ return setofEdges;
+}
+
+helper setEdgesForCompositeDiagram (in contained : OrderedSet(di2::DiagramElement)) : OrderedSet (notation::Edge)
+{
+ var setofEdges : OrderedSet(notation::Edge);
+ var edge : notation::Edge;
+ contained->forEach (node|node.oclIsTypeOf(di2::GraphEdge)) {
+ edge := node.oclAsType(di2::GraphEdge).map compositeDiagEdge2Edge();
+ setofEdges += edge;
+ };
+ contained->forEach (composite|composite.oclIsTypeOf(di2::GraphNode)) {
+ composite.oclAsType(di2::GraphNode).contained->forEach (elem|elem.oclIsTypeOf(di2::GraphEdge)) {
+ edge := elem.oclAsType(di2::GraphEdge).map compositeDiagEdge2Edge();
+ setofEdges += edge;
+ };
+ composite.oclAsType(di2::GraphNode).contained->forEach (prop|prop.oclIsTypeOf(di2::GraphNode)) {
+ prop.oclAsType(di2::GraphNode).contained->forEach (connect|connect.oclIsTypeOf(di2::GraphEdge)) {
+ edge := connect.oclAsType(di2::GraphEdge).map compositeDiagEdge2Edge();
+ setofEdges += edge;
+ };
+ };
+ };
+
+ return setofEdges;
+}
+
+helper setEdgesForStateDiagram (in contained : OrderedSet(di2::DiagramElement)) : OrderedSet (notation::Edge)
+{
+ var setofEdges : OrderedSet(notation::Edge);
+ var edge : notation::Edge;
+ contained->forEach (node|node.oclIsTypeOf(di2::GraphEdge)) {
+ edge := node.oclAsType(di2::GraphEdge).map stateDiagEdge2Edge();
+ setofEdges += edge;
+ };
+ contained->forEach (composite|composite.oclIsTypeOf(di2::GraphNode)) {
+ composite.oclAsType(di2::GraphNode).contained->forEach (elem|elem.oclIsTypeOf(di2::GraphEdge)) {
+ edge := elem.oclAsType(di2::GraphEdge).map stateDiagEdge2Edge();
+ setofEdges += edge;
+ };
+ composite.oclAsType(di2::GraphNode).contained->forEach (prop|prop.oclIsTypeOf(di2::GraphNode)) {
+ prop.oclAsType(di2::GraphNode).contained->forEach (connect|connect.oclIsTypeOf(di2::GraphEdge)) {
+ edge := connect.oclAsType(di2::GraphEdge).map stateDiagEdge2Edge();
+ setofEdges += edge;
+ };
+ };
+ };
+
+ return setofEdges;
+}
+
+--------------------------------
+--Helpers related to a diagram
+helper setStylesForDiagram() : OrderedSet (notation::Style)
+{
+ --<styles xmi:type="notation:DiagramStyle""/>
+
+ var setofStyles : OrderedSet(notation::Style);
+ var style := object notation::DiagramStyle {
+ --the id is set automatically
+ };
+
+ setofStyles := OrderedSet{style};
+
+ return setofStyles;
+} \ No newline at end of file

Back to the top