Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » How to assign a value to a slot in an objectDiagram?
How to assign a value to a slot in an objectDiagram? [message #628624] Thu, 02 September 2010 09:47
Chica is currently offline ChicaFriend
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?


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());;

Class transition = (Class) m.getMember("Transition");
InstanceSpecification trInstance = (InstanceSpecificationImpl) m.createPackagedElement("transition", UMLPackage.eINSTANCE.getInstanceSpecification());;
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());;
System.out.println("spec: " + (asInstance.getSpecification()));

Slot tgtSlot = assoInstance.createSlot();

// 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);
Previous Topic:Problem applying stereotype
Next Topic:How to create an association(link) on an object diagram programmatically?
Goto Forum:

Current Time: Fri Apr 20 20:35:56 GMT 2018

Powered by FUDForum. Page generated in 0.01917 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software