Hello everyone,
I am handling a project where there are multiple perspectives (close to 15). So when a perspective is opened by the user the corresponding code executed.
E.g. the name Perspective.java is handling the code for perspective 1 and has mainview ,views1 and views2.
When I open perspective 1, Perspective.java executes code in
public void createInitialLayout(IPageLayout layout)
section is executed.
Now after a few operation I close perspective with an event and close all the views with hideView directive. Now next time when I open perspective 1, Perspective.java code is ignored and i get the views which are in the old state (i.e. the constructor is not executed). I want the perspective to open as if it is opening for the first time everytime. How to handle this.
code for opening the perspective is
IPerspectiveDescriptor desc = PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId(id);
if (desc != null) {
setText(desc.getLabel());
setImageDescriptor(desc.getImageDescriptor());
}
try {
PlatformUI.getWorkbench().showPerspective(id, window);
} catch (WorkbenchException e) {
MessageDialog.openError(window.getShell(), "Error",
"Error opening perspective:" + e.getMessage());
}catch (Exception e) {
MessageDialog.openError(window.getShell(), "Error",
"Error opening perspective:" + e.getMessage());
}