Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Getting the IPartService from the Workbench...Getting null.
Getting the IPartService from the Workbench...Getting null. [message #336500] Wed, 17 June 2009 17:55 Go to next message
Alex Le is currently offline Alex LeFriend
Messages: 649
Registered: July 2009
Senior Member
Hi

I want to get the IPartService from the Workbench so that I can register
my class as an IPartListener. The following code does not seem to help,
'ps' (a.k.a part service) always returns null.

IWorkbench wb = Activator.getDefault().getWorkbench();
IPartService ps = (IPartService)wb.getService(IPartService.class);

Any tips? Thanks in advance.
Re: Getting the IPartService from the Workbench...Getting null. [message #336503 is a reply to message #336500] Wed, 17 June 2009 22:42 Go to previous messageGo to next message
Alex Le is currently offline Alex LeFriend
Messages: 649
Registered: July 2009
Senior Member
AL wrote:
> Hi
>
> I want to get the IPartService from the Workbench so that I can register
> my class as an IPartListener. The following code does not seem to help,
> 'ps' (a.k.a part service) always returns null.
>
> IWorkbench wb = Activator.getDefault().getWorkbench();
> IPartService ps = (IPartService)wb.getService(IPartService.class);
>
> Any tips? Thanks in advance.

Got it. Had to wait for my IEditorPart to be initialized by Eclipse's
text editing framework and I can get the IPartService from it.
Re: Getting the IPartService from the Workbench...Getting null. [message #336519 is a reply to message #336503] Thu, 18 June 2009 17:08 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

AL wrote:
>
> Got it. Had to wait for my IEditorPart to be initialized by Eclipse's
> text editing framework and I can get the IPartService from it.

You can also get it from a workbench window. From the javadoc:
"This service is not available globally, only from the workbench window
level down"

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Previous Topic:Debug UI: Entering debugger commands by hand?
Next Topic:navigator VS. project explorer
Goto Forum:
  


Current Time: Wed Jun 26 20:18:13 GMT 2024

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

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

Back to the top