How to assign a value to a slot in an objectDiagram? [message #556671] |
Thu, 02 September 2010 09:47 |
Chica Messages: 6 Registered: September 2010 |
Junior Member |
|
|
Hi everyone,
I'm trying to create an object diagram, so I menage to create the instances of the classes but I can't actually link them.
I create slots and set the instances in the slots (take a look at the code), but I don't know how to assign the value of the slot?
Any ideas?
Thanks,
chica
Class abstractState = (Class) m.getMember("AbstractState");
Property otProperty = abstractState.getOwnedAttribute("outgoingTransition", null);
Association asso = otProperty.getAssociation();
InstanceSpecification assoInstance = (InstanceSpecificationImpl) m.createPackagedElement("asso", UMLPackage.eINSTANCE.getInstanceSpecification());;
assoInstance.getClassifiers().add(asso);
Class transition = (Class) m.getMember("Transition");
InstanceSpecification trInstance = (InstanceSpecificationImpl) m.createPackagedElement("transition", UMLPackage.eINSTANCE.getInstanceSpecification());;
trInstance.getClassifiers().add(transition);
Property trProperty = abstractState.getOwnedAttribute("source", null);
// Slot srcSlot = assoInstance.createSlot();
// srcSlot.setDefiningFeature(trProperty);
// srcSlot.setOwningInstance(trInstance);
InstanceSpecification asInstance = (InstanceSpecificationImpl) m.createPackagedElement("abState", UMLPackage.eINSTANCE.getInstanceSpecification());;
asInstance.getClassifiers().add(abstractState);
System.out.println("spec: " + (asInstance.getSpecification()));
Slot tgtSlot = assoInstance.createSlot();
tgtSlot.setDefiningFeature(otProperty);
tgtSlot.setOwningInstance(asInstance);
// create the diagram
Diagram d = UMLModeler.getUMLDiagramHelper().createDiagram(m, UMLDiagramKind.OBJECT_LITERAL);
d.setName("My Object diagram_6");
Node vv1 = UMLModeler.getUMLDiagramHelper().createNode(d,asInstance);
Node vv2 = UMLModeler.getUMLDiagramHelper().createNode(d,trInstance);
Node vv3 = UMLModeler.getUMLDiagramHelper().createNode(d,assoInstance);
// layout the diagram
UMLModeler.getUMLDiagramHelper().layoutNodes(d.getChildren() , LayoutType.RADIAL);
UMLModeler.getUMLDiagramHelper().openDiagramEditor(d);
|
|
|
|
Powered by
FUDForum. Page generated in 0.03132 seconds