Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » [Kepler] saveState and restoreState of WorkbenchAdvisor not called
[Kepler] saveState and restoreState of WorkbenchAdvisor not called [message #1067398] Mon, 08 July 2013 13:59 Go to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello,

I recently upgraded my RCP application from Indigo to Kepler but I'm not able to save and restore some custom information about my application.

I have put breakpoints in the saveState and restoreState (overridden) methods of my ApplicationWorkbenchAdvisor but those breakpoints are never reached.

I made sure that the saveStateAndRestore flag is set to true in the initialize method:
	@Override
	public void initialize(IWorkbenchConfigurer configurer) {
		super.initialize(configurer);
		configurer.setSaveAndRestore(true);
	}


Is this a bug introduced recently or am I missing something ?

Thank you
Cédric
Re: [Kepler] saveState and restoreState of WorkbenchAdvisor not called [message #1067571 is a reply to message #1067398] Tue, 09 July 2013 11:44 Go to previous message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
I had a look at the Eclipse source code for the Workbench and from Indigo to Kepler, saving workbench state is completely different.

In Indigo:
	private IStatus saveState(IMemento memento) {
		MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK,
				WorkbenchMessages.Workbench_problemsSaving, null);

		// Save the version number.
		memento.putString(IWorkbenchConstants.TAG_VERSION, VERSION_STRING[1]);

		// Save how many plug-ins were loaded while restoring the workbench
		if (progressCount != -1) {
			memento.putInteger(IWorkbenchConstants.TAG_PROGRESS_COUNT,
					progressCount);
		}

		// Save the advisor state.
		IMemento advisorState = memento
				.createChild(IWorkbenchConstants.TAG_WORKBENCH_ADVISOR);
		result.add(getAdvisor().saveState(advisorState));

		// Save the workbench windows.
		IWorkbenchWindow[] windows = getWorkbenchWindows();
		for (int nX = 0; nX < windows.length; nX++) {
			WorkbenchWindow window = (WorkbenchWindow) windows[nX];
			IMemento childMem = memento
					.createChild(IWorkbenchConstants.TAG_WINDOW);
			result.merge(window.saveState(childMem));
		}
		result.add(getEditorHistory().saveState(
				memento.createChild(IWorkbenchConstants.TAG_MRU_LIST)));
		return result;
	}


So there you can see that the workbench advisor gets invoked to save the state.

In Kepler:
	private IStatus saveWorkbenchState(IMemento memento) {
		MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK,
				WorkbenchMessages.Workbench_problemsSaving, null);

		// TODO: Currently we store the editors history only. Add more if needed

		result.add(getEditorHistory().saveState(
				memento.createChild(IWorkbenchConstants.TAG_MRU_LIST)));
		return result;
	}


Where did the rest of the code suddenly disappear ?? Why was everything removed there, except for editors MRU list ? Or did I miss something ?
Previous Topic:SavePerspectiveAction does not work in eclipse 4.2
Next Topic:IWorkbenchPage.getPartState() always returns RESTORED
Goto Forum:
  


Current Time: Tue Mar 19 02:30:36 GMT 2024

Powered by FUDForum. Page generated in 0.02122 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top