Bug 371707

Summary: Hook into saving of workbench state to perform additional tasks (e.g. storing state in remote database)
Product: [Eclipse Project] Platform Reporter: Timo Rohrberg <timo.rohrberg>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: allan.beharry, remy.suen, timo.rohrberg
Version: 3.7.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Timo Rohrberg CLA 2012-02-16 03:00:41 EST
Build Identifier: M20110909-1335

Eclipse provides an automatic way to save the workbench state, e.g. size and position of views, editors, etc. This feature is activated by returning "true" in the IWorkbenchConfigurer.setSaveAndRestore() method. Within the Workbench its state is recored in the private recordWorkbenchState() method and then written to a workbench.xml file within the busyClose() method.

Since we have a Client/Server application, we would like to hook into this saving procedure to transfer the recorded workbench state into a remote database. Our idea is to provide a hook, listener, or similar to achieve this. After the call of recordWorkbenchSate() all information is available and could be transferred anywhere else before or after saveMementoToFile() is called.

Do you have any ideas or is there any other provided way to achieve that goal?

Reproducible: Always

Steps to Reproduce:
1. Run any Eclipse RCP application with IWorkbenchConfigurer.setSaveAndRestore() set to true.
2. Configure user interface (e.g. open views, change their size, etc.)
3. Close Eclipse RCP application.
4. State will automatically be saved into workbench.xml.
5. Try to hook that saving procedure to also save state somewhere else, e.g. remote database.
Comment 1 Paul Webster CLA 2012-02-16 07:15:52 EST
In 3.x the workbench.xml is an internal implementation detail.  It doesn't exist in 4.2, for example.

But if you did want to save it, probably org.eclipse.ui.IWorkbenchListener.postShutdown(IWorkbench) would be the best place, because by then it would be written out.  Also it is read during creating the first workbench.  You might be able to replace it in org.eclipse.ui.application.WorkbenchAdvisor.preStartup() though.

In 4.x, workbench.xml has been replaced by the model.  I know that people working with the CDO project have managed to save the model to a server and reload it.

PW