Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()(Sometimes active page is null on creating view)
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() [message #494644] Sun, 01 November 2009 16:52 Go to next message
Raffaele Gambelli is currently offline Raffaele Gambelli
Messages: 27
Registered: July 2009
Junior Member
Hi all

I would like to know why sometimes active page is null and so I'm not able to call findView method...

In particular, I would like that some of my views in the same perspective registered as listner to another view for some property changing.

And so, in the createPartControl method of each listner view I call:
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().findView(....)

Then, if I close my rcp, when restart it, each view that does that call throws nullPointer because activePage is null.

In your opinion, which should be the exact initial moment to get active page for a view?

Thanks in advance and best regards
Re: PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() [message #494650 is a reply to message #494644] Sun, 01 November 2009 19:34 Go to previous messageGo to next message
Remy Suen is currently offline Remy Suen
Messages: 462
Registered: July 2009
Senior Member
On Sun, 01 Nov 2009 11:52:08 -0500, Raffaele Gambelli wrote:
> Then, if I close my rcp, when restart it, each view that does that call
> throws nullPointer because activePage is null.

When do you call this code? In the constructor? Why don't you use getSite
().getPage() instead?

Regards,
Remy
Re: PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() [message #494678 is a reply to message #494644] Mon, 02 November 2009 07:50 Go to previous messageGo to next message
T. Wilhelm is currently offline T. Wilhelm
Messages: 129
Registered: July 2009
Senior Member
You can also let your ViewPart implement IPartListener and get the active page in the method partOpened(). Dont forget to implement an if clause to check if the part which was opened is this part:

 /*
  * (non-Javadoc)
  * 
  * @see
  * org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
  */
@Override
public void partOpened( IWorkbenchPart part) {
    if (part == this) {
      // here you can get your active page
    }
}


Greetz
Thomas
Re: PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() [message #495128 is a reply to message #494650] Tue, 03 November 2009 21:06 Go to previous message
Raffaele Gambelli is currently offline Raffaele Gambelli
Messages: 27
Registered: July 2009
Junior Member
Thanks guys!

getSite() works, I always have thinked that it was the same as PlatformUI().... but I was wrong!

Thanks Thomas for your hint.

Best regards
Raffaele
Previous Topic:SWT EVENTS CAPTURING IN LINUX
Next Topic:Building Eclipse RCP applications using Buckminster and Hudson
Goto Forum:
  


Current Time: Sat Oct 25 13:38:32 GMT 2014

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

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