Page NullPointerException when trying to register a listener [message #6986] |
Mon, 16 June 2008 08:21 |
Eclipse User |
|
|
|
Originally posted by: franzi483.web.de
Hello!
I am writing a plug-in for Eclipse, and I want to register a
PartListener which implements IPartListener2 when a particular view of
my plug-in is created.
I try to achieve this by the following code:
createPartControl(Composite c) {
...
IWorkbenchWindow workbenchWindow;
IWorkbenchPage page;
IWorkbench wbench = PlatformUI.getWorkbench();
workbenchWindow = wbench.getActiveWorkbenchWindow();
page = workbenchWindow.getActivePage();
if (partListener == null) {
partListener = new PartListener();
page.addPartListener(partListener);
}
...
}
But it always returns me a NullPointerException in the line
page.addPartListener as page is null.
I've tried the same code in the plugin initialization (in method
start(BundleContext b)). There it randomly shows a NullPointerException.
Any idea why the page is null?
Thank you in advance for any advice.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03990 seconds