Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Save and Restore Workbench State(Saving and restoring workbench state, such as open views and editors.)
Save and Restore Workbench State [message #990622] Thu, 13 December 2012 13:40 Go to next message
Timo Rohrberg is currently offline Timo RohrbergFriend
Messages: 31
Registered: September 2011
Location: Karlsruhe
Member
Hello everybody,

in my RCP 3.x-based Client-/Server-Application, I need to save the workbench state (e.g. open view and editors, window position and size, ...) for the current user and transfer it to the server. There it is persisted until the user returns. Then the workbench state is restored and the user finds the complete application in the state as he/she left it.

Currently, I achieve this by a quite ugly hack: Right after workbench shutdown (WorkbenchAdvisor.postShutdown()), I read the workbench.xml file from the .metadata/.plugins/org.eclipse.ui.workbench folder in the workspace and transfer it to the server. When the user returns, that file is restored within the WorkbenchAdvisor.preStartup() method.

Unfortunately, after switching to the RCP 4 platform, that workbench.xml file does not exist anymore. The workbench state is now stored in the workbench.xmi file in the .metadata/.plugins/org.eclipse.e4.workbench folder.

Of course, I could apply the same approach as I did so far and save/restore that workbench.xmi file. But somehow this seems to be a strange approach to me anyways... With the new model based workbench, I was hoping there is another, more intuitive approach...

Do you have any hints?

Thank you very much
Timo
Re: Save and Restore Workbench State [message #990665 is a reply to message #990622] Thu, 13 December 2012 13:46 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5487
Registered: July 2009
Senior Member
Hi,

Yes you can, we demonstrated something similar at EclipseCon NA 2012
where we stored the model in a CDO-Repository.

The model loading and saving is encapsulated in a class you can overrule
when launching by passing -modelResourceHandler bundleclass://....

The class you pass in there has to implement IModelResourceHandler (you
can take a look at the default implementation in
org.eclipse.e4.ui.internal.workbench.ResourceHandler) to see how we are
persisting and creating the model by default.

Tom

Am 13.12.12 14:40, schrieb Timo Rohrberg:
> Hello everybody,
>
> in my RCP 3.x-based Client-/Server-Application, I need to save the
> workbench state (e.g. open view and editors, window position and size,
> ...) for the current user and transfer it to the server. There it is
> persisted until the user returns. Then the workbench state is restored
> and the user finds the complete application in the state as he/she left it.
>
> Currently, I achieve this by a quite ugly hack: Right after workbench
> shutdown (WorkbenchAdvisor.postShutdown()), I read the workbench.xml
> file from the .metadata/.plugins/org.eclipse.ui.workbench folder in the
> workspace and transfer it to the server. When the user returns, that
> file is restored within the WorkbenchAdvisor.preStartup() method.
>
> Unfortunately, after switching to the RCP 4 platform, that workbench.xml
> file does not exist anymore. The workbench state is now stored in the
> workbench.xmi file in the .metadata/.plugins/org.eclipse.e4.workbench
> folder.
>
> Of course, I could apply the same approach as I did so far and
> save/restore that workbench.xmi file. But somehow this seems to be a
> strange approach to me anyways... With the new model based workbench, I
> was hoping there is another, more intuitive approach...
>
> Do you have any hints?
>
> Thank you very much
> Timo
Re: Save and Restore Workbench State [message #990860 is a reply to message #990665] Fri, 14 December 2012 14:57 Go to previous messageGo to next message
Timo Rohrberg is currently offline Timo RohrbergFriend
Messages: 31
Registered: September 2011
Location: Karlsruhe
Member
Hello Thomas,

do you have any resources (slides, demo projects, howtos, ...) that explain what you did and how to setup?

I appreciate any hint to documentation.

Thank you very much.
Timo
Re: Save and Restore Workbench State [message #1420364 is a reply to message #990622] Tue, 09 September 2014 22:46 Go to previous message
Sean Smith is currently offline Sean SmithFriend
Messages: 6
Registered: September 2014
Junior Member
Would I go about Save and Restoring Workbench State while the application is running (ie I want users to be able to export and import their current workbench settings like layouts and perspectives to a server or database dynamically, without resetting the program state.)
Previous Topic:display order of menu items changed when migrated to Eclipse Luna
Next Topic:How to launch CSS Spy for my RCP?
Goto Forum:
  


Current Time: Mon Dec 22 00:09:07 GMT 2014

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

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