Skip to main content

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 #556671] Thu, 02 September 2010 09:47 Go to next message
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);
Re: How to assign a value to a slot in an objectDiagram? [message #628996 is a reply to message #556671] Sat, 25 September 2010 17:06 Go to previous message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
What is the value you want to assign?

If you already have the value you can just add it to the collection of values of the slot:

ValueSpecification newValue - ...;

if you don't, you can create it using #createValue().


Previous Topic:Problem adding comment
Next Topic:How to create sequence diagram using java
Goto Forum:

Current Time: Mon Jun 25 00:54:16 GMT 2018

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

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

Back to the top