Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Eclipse Plugin: Accessing the Package Explorer?
Eclipse Plugin: Accessing the Package Explorer? [message #902983] Tue, 21 August 2012 14:04 Go to next message
Thorsten Beinhorn is currently offline Thorsten BeinhornFriend
Messages: 2
Registered: August 2012
Junior Member
Hi all,

I'm writing a little Eclipse plugin featuring some menu extensions for projects.
I've already deployed some context menus to the Package Explorer but now I want to add custom actions to the main toolbar. As said above these should be project-related.

Using the SelectionService to get the currently selected project is OK, but if I drill down into a project (Package Explorer->Go into...) the project isn't selected anymore.

My question: is it possible to get the current position or even the root object of the Package Explorer? In other words: how can I access the content of the original Package Explorer?

Best regards,
Thorsten
Re: Eclipse Plugin: Accessing the Package Explorer? [message #903744 is a reply to message #902983] Sat, 25 August 2012 11:44 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
I'd think this can be solved by these measures:
- if the selection is on any IJavaElement simply navigate up the parent chain until you find the IJavaProject, and/or:
- if an IJavaProject is selected remember this project until an UpAction reverses the Go Into state (check org.eclipse.ui.views.framelist.UpAction if you can listen to the property event which it fires).

Only if the above doesn't help, you may need to use the internal class org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart, which has static methods to obtain an instance and accessors like getViewPartInput(). Perhaps, there's a way to copy that behavior using public API only, have a look at the implementation.

HTH,
Stephan
Re: Eclipse Plugin: Accessing the Package Explorer? [message #903882 is a reply to message #903744] Mon, 27 August 2012 06:03 Go to previous message
Thorsten Beinhorn is currently offline Thorsten BeinhornFriend
Messages: 2
Registered: August 2012
Junior Member
Hi Stephan,

Thanks for your help! Meanwhile I've implemented a solution using the PackageExplorerPart. But this is not so good because it's hard-linked to a specific view (not ProjectExplorer/ResourceNavigator). Therefor I've had to handle all of the resource views. Unfortunately, the ResourceExplorer seems to be outdated.

I'll implement your solution (process memory/UpAction). It looks straightforward. And I think I'll add a small control (menu bar) to display the currently rembered project as well.

Thanks and regards,
Thorsten
Previous Topic:Copyright Issue
Next Topic:Eclipse juno and tomcat6 interface problem
Goto Forum:
  


Current Time: Thu Apr 25 19:35:02 GMT 2024

Powered by FUDForum. Page generated in 0.04092 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top