Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 Tools » How to retrieve the current package?
How to retrieve the current package? [message #518604] Thu, 04 March 2010 10:42 Go to next message
Itamar is currently offline Itamar
Messages: 39
Registered: November 2009
Member
Hello !

I am trying to create a new view in Eclipse that - like the Outline view - is sensitive to the current selection, but should analyze elements in a UML class diagram.

I managed to register a new ISelectionListener to catch any SelectionChangeEvent that the UML editor publishes.

I can get the publisher (an instance of org.eclipse.uml2.diagram.clazz.part.UMLDiagramEditor), and the published selection (a StructuredSelection containing instances of org.eclipse.uml2.diagram.clazz.edit.parts.*).

However, I cannot find any way to retrieve the currently-edited package (an instance of org.eclipse.uml2.uml.* ?).

I'd appreciate any help Smile
Re: How to retrieve the current package? [message #523187 is a reply to message #518604] Thu, 25 March 2010 09:13 Go to previous message
Itamar is currently offline Itamar
Messages: 39
Registered: November 2009
Member
Well, I found the answer myself.

In a nutshell - use getAdapter(Element.class) on the selected objects, and then use getNearestPackage() to get their owning package.

In a tutorial - https://svn.cs.bgu.ac.il/trac/benzaita/wiki/HowTo_GetSelecte dUMLElement
Re: How to retrieve the current package? [message #625588 is a reply to message #518604] Thu, 25 March 2010 09:13 Go to previous message
Itamar is currently offline Itamar
Messages: 39
Registered: November 2009
Member
Well, I found the answer myself.

In a nutshell - use getAdapter(Element.class) on the selected objects, and then use getNearestPackage() to get their owning package.

In a tutorial - https://svn.cs.bgu.ac.il/trac/benzaita/wiki/HowTo_GetSelecte dUMLElement
Previous Topic:Stereotype in Sequence diagram not displayed
Next Topic:UML2Tools for EMF 2.6/Eclipse 3.6?
Goto Forum:
  


Current Time: Sat Aug 23 05:27:59 EDT 2014

Powered by FUDForum. Page generated in 0.01665 seconds