[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform] When and how do you save perspectives in Europa?

The following code used to work:

public class ChronosWorkbenchAdvisor extends WorkbenchAdvisor {

	private static final String PERSPECTIVE_ID = "com.ngms.ad.chronos.gui.perspective";

	public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
			IWorkbenchWindowConfigurer configurer) {
		return new ChronosWorkbenchWindowAdvisor(configurer);
	}

	public String getInitialWindowPerspectiveId() {
		return PERSPECTIVE_ID;
	}

	public boolean preShutdown() {
		// Save the perspective
		IWorkbenchPage page = getWorkbenchConfigurer().getWorkbench()
				.getActiveWorkbenchWindow().getWorkbench()
				.getActiveWorkbenchWindow().getActivePage();
		 page.savePerspective();
		// Save the workspace
		try {
			ResourcesPlugin.getWorkspace().save(true, null);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return super.preShutdown();
	}
}

Now I can only run the program with a clean workspace otherwise I get a null from Display.getCurrent() the next time I start. I tracked down the root of the problem, which is in the page.savePerspective() call in the above code. 
Why this doesn't work anymore I don't know. Where are you saving your perspectives?
Thanks in advance.