diff options
Diffstat (limited to 'deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/ClassDiagNodes.qvto')
-rw-r--r-- | deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/ClassDiagNodes.qvto | 658 |
1 files changed, 658 insertions, 0 deletions
diff --git a/deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/ClassDiagNodes.qvto b/deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/ClassDiagNodes.qvto new file mode 100644 index 00000000000..8c7168fa8fd --- /dev/null +++ b/deprecated/org.eclipse.papyrus.conversion.di2todi/TransfoQvtoDi2toDi/ClassDiagNodes.qvto @@ -0,0 +1,658 @@ +--Author Manel Fredj-CEA LIST +library HelpersClassDiagram; + + +import ClassDiagVisualIDs; +import NotationQueries; +import GeneralMappingsandHelpers; + + +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::GraphNode::classDiagNode2Shape() : notation::Shape inherits di2::GraphNode::node2Shape +{ + eAnnotations := setEAnnotations (); + + if (self.getElement().oclIsTypeOf(uml::Class)) then { + type := VisualId_Class; + children := setChildrenForClass(self); + styles := setStylesForClass(); + } endif; + if (self.getElement().oclIsTypeOf(uml::Comment)) then { + type := VisualId_Comment; + children := setChildrenForComment(); + } endif; + if (self.getElement().oclIsTypeOf(uml::Profile)) then { + type := VisualId_Profile; + children := setChildrenForProfile(self); + } endif; + if (self.getElement().oclIsTypeOf(uml::Stereotype)) then { + type := VisualId_Stereotype; + children := setChildrenForStereotype(); + } endif; + if (self.getElement().oclIsTypeOf(uml::Package)) then { + type := VisualId_Package; + children := setChildrenForPackage(self); + } endif; + if (self.getElement().oclIsTypeOf(uml::Enumeration)) then { + type := VisualId_Enum; + children := setChildrenForEnum(self); + } endif; + if (self.getElement().oclIsTypeOf(uml::Interface)) then { + type := VisualId_Interface; + children := setChildrenForInterface(self); + } endif; + if (self.getElement().oclIsTypeOf(uml::PrimitiveType)) then { + type := VisualId_PrimitiveType; + children := setChildrenForPrimitiveType(self); + } endif; + if (self.getElement().oclIsTypeOf(uml::DataType)) then { + type := VisualId_DataType; + children := setChildrenForDataType(self); + } endif; + if (self.getElement().oclIsTypeOf(uml::Model)) then { + type := VisualId_Package; + } endif; + if (self.getElement().oclIsTypeOf(uml::Component)) then { + type := VisualId_Component; + children := setChildrenForComponent(self); + } endif; + if (self.getElement().oclIsTypeOf(uml::RedefinableTemplateSignature)) then { + type := VisualId_RedefinableTemplateSig; + children := setChildrenForRedefinableTemplateSignature(self); + } endif; +} + + +--for a class +--first argument is related to the contained operations which are integrated in the third child, i.e. the +--basic compartment typed 7018 +helper setChildrenForClass (in node:di2::GraphNode) : OrderedSet(notation::Node) +{ + -- first child + var child1 := object notation::DecorationNode { + type := VisualId_Class_Label; + --the id is set automatically + }; + + -- second child + var child2 := object notation::BasicCompartment { + type:=VisualId_Class_Attributes; + --the id is set automatically + --set the properties + children := setAttributesForClass(node); + var style1 := object notation::SortingStyle { + --the id is set automatically + }; + var style2 := object notation::FilteringStyle { + --the id is set automatically + }; + styles := OrderedSet { + style1, style2 + }; + layoutConstraint:=object notation::Bounds {}; + }; + + -- third child includes operations + var child3 := object notation::BasicCompartment { + type := VisualId_Class_Operations; + --the id is set automatically + --set the operations + children := setOperationsForClass(node); + --set the styles + var style1 := object notation::SortingStyle { + --the id is set automatically + }; + var style2 := object notation::FilteringStyle { + --the id is set automatically + }; + styles := OrderedSet { + style1, style2 + }; + layoutConstraint := object notation::Bounds {}; + }; + + -- fourth child + var child4 := object notation::BasicCompartment { + type := VisualId_Class_UseCase; + --the id is set automatically + var style1 := object notation::SortingStyle { + --the id is set automatically + }; + var style2 := object notation::FilteringStyle { + --the id is set automatically + }; + styles := OrderedSet { + style1, + style2 + }; + layoutConstraint := object notation::Bounds {}; + }; + + return OrderedSet { + child1, child2, child3, child4 + }; +} + + + +--for a ForRedefinableTemplateSignature + +helper setChildrenForRedefinableTemplateSignature (in node:di2::GraphNode) : OrderedSet(notation::Node) +{ + var containedCTP:= object notation::DecorationNode { + type:=VisualId_ContainerofCTP; + + children:= setClassifierTemplateParameters(node); + + var style1 := object notation::SortingStyle { + }; + var style2 := object notation::FilteringStyle { + }; + styles := OrderedSet { + style1, style2 + }; + layoutConstraint:=object notation::Bounds {}; + + }; + var containedCTPs : OrderedSet(notation::Node); + containedCTPs += containedCTP; + return containedCTPs; +} + +helper setClassifierTemplateParameters(in node:di2::GraphNode):OrderedSet (notation::Node){ + var CTPShapes : OrderedSet(notation::Shape); + var containedCTPs : OrderedSet(ecore::EObject) := node.getClassifierTemplateParameter(); + containedCTPs->forEach (CTP) { + -- <children xmi:type="notation:Shape" type="3031" fontHeight="8" lineColor="0"> + -- <element xmi:type="uml:ClassifierTemplateParameter" href="model.uml#_tisGcNxYEd-VL4dXZB1kyw"/> + -- <layoutConstraint xmi:type="notation:Location" /> + -- </children> + + var CTPShape := object notation::Shape { + type := VisualId_ClassifierTemplateParameter; + element := CTP; + layoutConstraint := object notation::Location {}; + }; + + CTPShapes += CTPShape; + }; + + return CTPShapes; +} + +--for a primitive type +helper setChildrenForPrimitiveType (in node:di2::GraphNode) : OrderedSet(notation::Node) +{ + -- <children xmi:type="notation:DecorationNode" xmi:id="_i40XxNMjEd-9-ci4J3MfKg" type="5020"/> + -- <children xmi:type="notation:DecorationNode" xmi:id="_i40XxdMjEd-9-ci4J3MfKg" type="7009"> + -- <layoutConstraint xmi:type="notation:Bounds" xmi:id="_i40XxtMjEd-9-ci4J3MfKg"/> + -- </children> + + -- first child + var child1 := object notation::DecorationNode { + type := VisualId_PrimitiveTypeChild; + --the id is set automatically + }; + + --add the set of children to the node + return OrderedSet { + child1 + }; +} + +--for a data type +helper setChildrenForDataType (in node:di2::GraphNode) : OrderedSet(notation::Node) +{ + -- first child + var child1 := object notation::DecorationNode { + type := "5035"; + --the id is set automatically + }; + + -- second child + var child2 := object notation::BasicCompartment { + type := "7020"; + --the id is set automatically + --set the operations + children := setAttributesForClass(node); + var style1 := object notation::SortingStyle { + --the id is set automatically + }; + var style2 := object notation::FilteringStyle { + --the id is set automatically + }; + styles := OrderedSet { + style1, style2 + }; + layoutConstraint:=object notation::Bounds {}; + }; + + -- third child includes operations + var child3 := object notation::BasicCompartment { + type := "7021"; + --the id is set automatically + --set the operations + children := setOperationsForClass(node); + --set the styles + var style1 := object notation::SortingStyle { + --the id is set automatically + }; + var style2 := object notation::FilteringStyle { + --the id is set automatically + }; + styles := OrderedSet { + style1, style2 + }; + layoutConstraint := object notation::Bounds {}; + }; + --add the set of children to the node + return OrderedSet { + child1, child2, child3 + }; +} + +--for an interface +helper setChildrenForInterface (in node:di2::GraphNode) : OrderedSet(notation::Node) +{ + -- first child + var child1 := object notation::DecorationNode { + type := "5011"; + }; + + -- second child + var child2 := object notation::BasicCompartment { + type := "7006"; + --the id is set automatically + --set the operations + children := setAttributesForClass(node); + var style1 := object notation::SortingStyle { + --the id is set automatically + }; + var style2 := object notation::FilteringStyle { + --the id is set automatically + }; + styles := OrderedSet { + style1, style2 + }; + layoutConstraint:=object notation::Bounds {}; + }; + + -- third child includes operations + var child3 := object notation::BasicCompartment { + type := "7007"; + --the id is set automatically + --set the operations + children := setOperationsForClass(node); + --set the styles + var style1 := object notation::SortingStyle { + --the id is set automatically + }; + var style2 := object notation::FilteringStyle { + --the id is set automatically + }; + styles := OrderedSet { + style1, style2 + }; + layoutConstraint := object notation::Bounds {}; + }; + + -- third child includes operations + var child4 := object notation::BasicCompartment { + type := "7008"; + --the id is set automatically + --set the operations + --children := setOperationsForClass(node); + --set the styles + var style1 := object notation::SortingStyle { + --the id is set automatically + }; + var style2 := object notation::FilteringStyle { + --the id is set automatically + }; + styles := OrderedSet { + style1, style2 + }; + layoutConstraint := object notation::Bounds {}; + }; + + --add the set of children to the node + return OrderedSet { + child1, child2, child3, child4 + }; +} + +--for an enumeration +helper setChildrenForEnum (in node : di2::GraphNode) : OrderedSet(notation::Node) +{ + -- first child + var child1 := object notation::DecorationNode { + type := VisualId_Enum_Label; + --the id is set automatically + }; + + -- second child + var child2 := object notation::BasicCompartment { + type := VisualId_Enum_Literals; + --set the literals + children := getLiterals(node); + var style1 := object notation::SortingStyle { }; + var style2 := object notation::FilteringStyle { }; + styles := OrderedSet { + style1, style2 + }; + layoutConstraint := object notation::Bounds {}; + --the id is set automatically + }; + + --add the set of children to the node + return OrderedSet { + child1, child2 + }; +} + + +helper setStylesForClass() : OrderedSet(notation::Style) +{ + var style:=object notation::HintedDiagramLinkStyle { + --the id is set automatically + }; + + return OrderedSet{style}; +} + + +--reusable Helpers +helper setOperations(in node:di2::GraphNode,in VisualId:String): OrderedSet(notation::Node) +{ + var operationsShape : OrderedSet(notation::Node); + var containedOp : OrderedSet(ecore::EObject) := node.getOperations(); + containedOp->forEach (operation) { + var operationShape := object notation::Shape { + --an operation is typed 3013 + type := VisualId; + --fontHeight="8"; + --lineColor="0"; + element := operation; + layoutConstraint := object notation::Location{}; + }; + + operationsShape += operationShape; + }; + + return operationsShape; +} + +helper setAttributes(in node : di2::GraphNode, in VisualId:String) : OrderedSet(notation::Node) +{ + var attributesShape : OrderedSet(notation::Node); + var attributes : OrderedSet(ecore::EObject) := node.getProperties(); + attributes->forEach (attribute) { + var attributeShape := object notation::Shape { + -- an attribute is type 3012 + type := VisualId; + --fontName="Sans Serif"; + --lineColor="0"; + element := attribute; + layoutConstraint := object notation::Location{}; + }; + attributesShape += attributeShape; + }; + + return attributesShape; +} + +--in containedOp:OrderedSet(ecore::EObject) +helper setOperationsForClass(in node:di2::GraphNode): OrderedSet(notation::Node) +{ + return setOperations(node,VisualId_Class_Operation); +} + +--in containedAttr:OrderedSet (ecore::EObject) +helper setAttributesForClass(in node : di2::GraphNode) : OrderedSet(notation::Node) +{ + return setAttributes(node,VisualId_Class_Attribute); +} + +--for Enumeration +--in containedAttr:OrderedSet (ecore::EObject) +helper getLiterals(in node : di2::GraphNode) : OrderedSet(notation::Node) +{ + var enumLiteralsShape : OrderedSet(notation::Node); + var enumLiterals : OrderedSet(ecore::EObject) := node.getEnumLiterals(); + enumLiterals->forEach (enumLiteral) { + var enumLiteralShape := object notation::Shape { + -- an attribute is typed 3017 + type := VisualId_EnumLiteral; + --fontName="Sans Serif"; + --lineColor="0"; + element := enumLiteral; + layoutConstraint := object notation::Location{}; + }; + enumLiteralsShape += enumLiteralShape; + }; + + return enumLiteralsShape; +} + +--for a component +helper setChildrenForComponent (in node:di2::GraphNode) : OrderedSet(notation::Node) +{ + -- first child + var child1 := object notation::DecorationNode { + type := VisualId_Component_child1; + --the id is set automatically + }; + + -- second child + var child2 := object notation::BasicCompartment { + type := VisualId_Component_child2; + --the id is set automatically + --set the properties + children := setAttributesForComponent(node); + var style1 := object notation::SortingStyle { + --the id is set automatically + }; + var style2 := object notation::FilteringStyle { + --the id is set automatically + }; + styles := OrderedSet { + style1, style2 + }; + layoutConstraint := object notation::Bounds {}; + }; + + -- third child + var child3 := object notation::BasicCompartment { + type := VisualId_Component_child3; + --the id is set automatically + --set the operations + children := setOperationsForComponent(node); + var style1 := object notation::SortingStyle { + --the id is set automatically + }; + var style2 := object notation::FilteringStyle { + --the id is set automatically + }; + styles := OrderedSet { + style1, style2 + }; + layoutConstraint := object notation::Bounds {}; + }; + + -- fourth child + var child4 := object notation::BasicCompartment { + type := VisualId_Component_child4; + --the id is set automatically + var style1 := object notation::SortingStyle { + --the id is set automatically + }; + var style2 := object notation::FilteringStyle { + --the id is set automatically + }; + styles := OrderedSet { + style1, style2 + }; + layoutConstraint := object notation::Bounds {}; + }; + + return OrderedSet { + child1, child2,child3,child4 + }; +} + +--in containedOp:OrderedSet(ecore::EObject) +helper setOperationsForComponent(in node:di2::GraphNode): OrderedSet(notation::Node) +{ + return setOperations(node,VisualId_Component_Operation); +} + +--in containedAttr:OrderedSet (ecore::EObject) +helper setAttributesForComponent(in node : di2::GraphNode) : OrderedSet(notation::Node) +{ + return setAttributes(node, VisualId_Component_Attribute); +} + + +--for a stereotype +helper setChildrenForStereotype() : OrderedSet(notation::Node) +{ + -- first child + var child1 := object notation::DecorationNode { + type := VisualId_Stereotype_child1; + --the id is set automatically + }; + + -- second child + var child2 := object notation::BasicCompartment { + type := VisualId_Stereotype_child2; + --the id is set automatically + var style1 := object notation::SortingStyle { + --the id is set automatically + }; + var style2 := object notation::FilteringStyle { + --the id is set automatically + }; + styles := OrderedSet { + style1, style2 + }; + layoutConstraint := object notation::Bounds {}; + + }; + + -- third child + var child3 := object notation::BasicCompartment { + type := VisualId_Stereotype_child3; + --the id is set automatically + var style1 := object notation::SortingStyle { + --the id is set automatically + }; + var style2 := object notation::FilteringStyle { + --the id is set automatically + }; + styles := OrderedSet { + style1, style2 + }; + layoutConstraint := object notation::Bounds {}; + }; + + -- fourth child + var child4 := object notation::BasicCompartment { + type := VisualId_Stereotype_child4; + --the id is set automatically + var style1 := object notation::SortingStyle { + --the id is set automatically + }; + var style2 := object notation::FilteringStyle { + --the id is set automatically + }; + styles := OrderedSet { + style1, style2 + }; + layoutConstraint := object notation::Bounds {}; + }; + + return OrderedSet { + child1, child2, child3, child4 + }; +} + + +--for a profile in a class diagram +helper setChildrenForProfile (in node : di2::GraphNode) : OrderedSet(notation::Node) +{ + -- first child + var child1 := object notation::DecorationNode { + type := VisualId_Profile_child1; + --the id is set automatically + }; + + -- second child + var child2 := object notation::DecorationNode { + type := VisualId_Profile_child2; + children := addStereotypestoProfile(node); + layoutConstraint := object notation::Bounds {}; + --the id is set automatically + }; + + --add the set of children to the node + return OrderedSet {child1, child2}; +} + +--stereotype +helper addStereotypestoProfile (in node : di2::GraphNode) : OrderedSet(notation::Node) +{ + + var SetofStereotypes : OrderedSet(notation::Node); + node.contained->forEach (elem|elem.oclIsTypeOf(di2::GraphNode)) { + if (elem.oclAsType(di2::GraphNode).getElement().oclIsTypeOf(uml::Stereotype))then{ + --create a new stereotype + var stereo:notation::Shape:=elem.oclAsType(di2::GraphNode).map classDiagNode2Shape(); + SetofStereotypes += stereo; + } endif; + }; + + return SetofStereotypes; +} + +--for a package +helper setChildrenForPackage (in node:di2::GraphNode) : OrderedSet(notation::Node) +{ + -- first child + var child1 := object notation::DecorationNode { + type := VisualId_Package_Label; + --the id is set automatically + }; + + -- second child + var child2 := object notation::DecorationNode { + type := VisualId_Package_Label2; + var containedElements : OrderedSet(di2::GraphNode) := node.getSubElementsOfPackage(); + containedElements->forEach (containedElement) { + var shape : notation::Shape ::= containedElement.map classDiagNode2Shape(); + children += shape; + }; + }; + + return OrderedSet { + child1, child2 + }; +} + + +--Helpers related to a Comment +-------------------------------- + +helper setChildrenForComment () : OrderedSet(notation::Node) +{ + -- <children xmi:type="notation:DecorationNode" xmi:id="_OVAHGNhVEd-Fo-h2aSJB1A" type="5038"/> + var child1 := object notation::DecorationNode { + type:=VisualId_Comment_Child; + + }; + return OrderedSet {child1}; +}
\ No newline at end of file |