Accessing design elements does not work

Accessing design elements does not work

Postby zsoca » Tue Nov 15, 2005 5:44 pm

Hello!

There was already a topic on this question, and I copied tha code snipplet from there. However, it does not retreive the classes of the class diagram.
Could somebody please give me a hint?

void preprocess() {
DefaultListModel tlm;
try {
final PoseidonProject currentProject = PoseidonProjectConnector.getCurrentProject();
UmlProject up;
if (currentProject instanceof UmlProject) {
up = (UmlProject )currentProject;
final Collection allElements = up.getUml1SmFactory().getCorePackage().getModelElement().refAllOfClass();
Iterator it = allElements.iterator();
tlm = new DefaultListModel();
while (it.hasNext()) {
final UmlClass ucl = (UmlClass)it.next();
tlm.addElement(ucl.getName());
}
clist.setModel(tlm);
}
}
catch (Exception e) { ...
Zsolt Balanyi
zsoca
 
Posts: 1
Joined: Wed Nov 02, 2005 2:42 pm
Location: Paderborn

Re: Accessing design elements does not work

Postby [gw] Matthias Köster » Mon Jan 16, 2006 2:56 pm

Hi,

Since i didn't find the quoted topic, i can't check if that was already wrong. But with getCorePackage().getModelElement () you get all instances derived from Modelelement and ModelElement is the base class of all UML classes. So i think you will get a ClassCastException with the code below.

If you are only interested in UmlClass change getCorePackage().getModelElement() to getCorePackage().getUmlClass(), then your code should work without throwing an exception.

Regards,
Matthias K?ster, Gentleware AG
Matthias Köster [Gentleware]
[gw] Matthias Köster
 
Posts: 196
Joined: Sat Jan 18, 2003 10:00 am


Return to Plug-Ins

Who is online

Users browsing this forum: No registered users and 1 guest

cron