Read the content of a class diagram ???

Read the content of a class diagram ???

Postby Guest » Fri Sep 17, 2004 4:26 pm

Hi,
i need to do a little plugin for read the elements of a class diagram.
The model only has one diagram (the class diagram) and the diagram only has classes and subclases.

How can i do for read the elements (Clases and generalizations) of that diagram???
Guest
 

Re: Read the content of a class diagram ???

Postby [gw] Thorsten Sturm » Mon Sep 20, 2004 9:32 am

The diagram is a simple tree where each node represents something shown in it. In order to get the content of the diagram, get the diagram itself (use ModelElementAccessory.getDiagrams(...)) and then its content (Diagram.getContained()).

By iterating over the resulting list, you will see all top-level presentation elements. Any presentation element has either a SimpleTypeInfo or a SemanticModelBridge attached. If there is a SemanticModelBridge (in fact, it should be a Uml1SemanticModelBridge), use Uml1SemanticModelBridge.getElement() to retrieve the model element attached.

If you recurse on the on the element you received by getContained(), you can get any model element represented in the diagram.

Please be aware that there is a difference between model elements and elements in the diagrams. Model elements are of type Element or ModelElement (they build the semantic structure of your model), while elements in diagrams are of type DiagramElement (they build the presentation of model elements).

Thorsten
Thorsten Sturm
[gw] Thorsten Sturm
 
Posts: 185
Joined: Sat Jan 18, 2003 10:03 am

Re: Read the content of a class diagram ???

Postby Guest » Mon Sep 20, 2004 5:32 pm

Are there any difference between using:
"PoseidonProjectConnector.getDiagrams"
and:
"ModelElementAccessory.getDiagrams(...))" ??

I cant use (really i dont know how to use) ModelElementAccessory class. How to get the param ModelElement that the functions need?
Guest
 

Re: Read the content of a class diagram ???

Postby [gw] Thorsten Sturm » Tue Sep 21, 2004 8:36 am

With PoseidonProjectConnector.getDiagrams(..) you receive all diagrams that are defined in the project. ModelElementAccessory.getDiagrams(...) will give you all diagrams that are owned by the provided model element. It is meant to be in cases where you have a model element (e.g. a class) and need to access the diagrams owned by it.

Basically, the ModelElementAccessory needs a specific model element and retrieves information about it. A model element you can always get is the model. Simply use PoseidonProjectConnector.getModel().

Thorsten
Thorsten Sturm
[gw] Thorsten Sturm
 
Posts: 185
Joined: Sat Jan 18, 2003 10:03 am


Return to Plug-Ins

Who is online

Users browsing this forum: No registered users and 1 guest

cron