Re-initializing a Perspective
The following needs some editing
Tasks
1) Create a PerspectiveAdapter which implements IPerspectiveListener
2) Obtain a reference to the perspective’s IPageService
3) Instantiate the PerspectiveAdapter and add it as a PerspectiveListener to the IPageService
Packages: org.eclipse.ui
Create a PerspectiveAdapter which implements IPerspectiveListener
The perspectiveChanged method should reset the perspective with:
IWorkbenchPage.resetPerspective()
IWorkbenchPage is a method argument.
Obtain a reference to the perspective’s IPageService
Get a reference to the site with IWorkbenchPart.getSite(). ViewPart and EditorPart inherit this method.
Use: (IPageService) getSite().getService(IPageService.class)
Instantiate the PerspectiveAdapter and add it as a PerspectiveListener to the IPageService
IPageService.addPerspectiveListener(PerspectiveAdapter);
Workbench Site
A perspective will display multiple views and editors on a Workbench Site. Every so often, you may need to access the site for a given Workbench Part (which can be either an editor or a view). The following code shows one way to access the site:
private IWorkbenchPartSite getSite(){
return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite();
}