How to capture perspective changes? [message #662332] |
Wed, 30 March 2011 05:32  |
Eclipse User |
|
|
|
Hello,
I am working on a new perspective called MyPerspective, next to existing perspectives like Java, Debugger, CVS, etc.
Question: how can I intercept if the user clicks on the MyPerspective button (or selects the MyPerspective item in the Perspective dialog list), in other words: how can I intercept that MyPerspective gets activated?
Likewise: how can I intercept that MyPerspective gets deactivated?
I need to know this in order to be able to carry out file loading during both events.
Thanks in advance.
|
|
|
|
Re: How to capture perspective changes? [message #662352 is a reply to message #662350] |
Wed, 30 March 2011 06:50  |
Eclipse User |
|
|
|
BTW: discovered that you can ommit the Earlystartup class altogether if you generated an Activator class during setup of the plugin using the plugin wizard.
To achieve the same result (capturing perspective change) implement the start method like this:
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
System.out.println("start plugin");
final IWorkbenchWindow workbenchWindow =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (workbenchWindow != null) {
workbenchWindow.addPerspectiveListener(new
PerspectiveAdapter() {
/*
* (non-Javadoc)
*
* @seeorg.eclipse.ui.PerspectiveAdapter#
* perspectiveActivated (org.eclipse.ui.IWorkbenchPage,
* org.eclipse.ui.IPerspectiveDescriptor)
*/
@Override
public void perspectiveActivated(IWorkbenchPage page,
IPerspectiveDescriptor perspectiveDescriptor) {
super.perspectiveActivated(page, perspectiveDescriptor);
System.err.println("activator --> " + perspectiveDescriptor.getId());
}
});
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.03596 seconds