|
|
|
|
|
|
|
|
Re: Selection of a IJavaElement - determine the associated project [message #85554 is a reply to message #85453] |
Mon, 30 June 2003 15:53 |
Lars Ködderitzsch Messages: 31 Registered: July 2009 |
Member |
|
|
Hi Stefan,
thank you very much for your answer.
It will work, if the selection was made in the resource navigator, because
only resources are shown therein.
However, if the selection occurs in one of the java views (java browsing,
package explorer) the selected element is probably of IJavaElement.
A java element can deliver its associated java project, but im my case,
when the java element comes from an archive that is used in more than one
open project the returned java project is not always the project where the
selection occured.
Kind of complicated situation, huh?
Thanks again,
Lars
Stefan wrote:
> Hi !
> I don't know if this is correct way, but perhaps you could navigate
> the tree using :
> ISelection selection = wPart.getSite().getSelectionProvider.
> ().getSelection();
> if (selection instanceof StructuredSelection)
> {
> if (!ssel.isEmpty())
> {
> Object o = ssel.getFirstElement();
> if (o instanceof Project)
> {
> Project project = (Project) o;
> // use project as you like
> }
> else if (o instanceof Resource)
> {
> // if resource is selected
> // navigate the resource tree using getParent method
> // until you reach the Project or null (workspace root), but should
> // hit the project first
> }
> }
> I take only first resource that is selected, but it is possible,
> that there are multiple files selected in different projects.
> regards, Stefan
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03512 seconds