Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

From IStructuredSelection to a list of uml.kernel.Element?

5 views
Skip to first unread message

Jean-Claude

unread,
May 4, 2006, 2:39:03 PM5/4/06
to

Hello

I would like to get a list of selected uml elements from my plug-in.
As an input I have a selection of type IStructuredSelection.
I did not find a way to get the corresponding uml.kernel.Element s

Should I go via com.tssap.selena.model.elements.Reference? com.tssap.selena.model.elements.Element?

Cheers,

Jean-Claude

ElenaA

unread,
May 5, 2006, 4:49:47 AM5/5/06
to
Hi Jean-Claude,

the following code works for me:


if (selection instanceof IStructuredSelection) {
Object object = ((IStructuredSelection) selection).getFirstElement();
if (object != null) {
EObject selectedEObject = (EObject)
Platform.getAdapterManager().getAdapter(object, EObject.class);
if (selectedEObject instanceof Element) {
Element selectedElement = (Element) selectedEObject;
System.out.println("it is "+
selectedElement.getPropertyValue("$metaclass"));
}
}

where EObject is org.eclipse.emf.ecore.EObject, and Element is
com.borland.tg.emfapi.uml.kernel.Element


Best,
Lena

"Jean-Claude" <jcan...@alineo.com> wrote in message
news:445a4a47$1...@newsgroups.borland.com...

Jean-Claude

unread,
May 6, 2006, 1:01:55 PM5/6/06
to

Thanks Lena!
0 new messages