Maintaining state of an AbstractSourceProvider [message #481068] |
Wed, 19 August 2009 09:49  |
Eclipse User |
|
|
|
I use an implementation of the ISourceProvider to maintain the state of certain variables that I would like to use in the Extensions and in my code.
The problem is that the state of these variables isn't maintained between sessions of the RCP application.
To resolve this, I tried serialization, but I gave up on this because I couldn't find a way to reregister the class in the application since classes of this sort are instantiated by the Eclipse RCP framework.
Any suggestions on how I might resolve this problem?
|
|
|
|
|
Re: Maintaining state of an AbstractSourceProvider [message #481834 is a reply to message #481216] |
Mon, 24 August 2009 09:50  |
Eclipse User |
|
|
|
IMemento is used to store state information. Most commonly, a view can store session data when the view is open and eclipse is stopped/restarted. This saveState/restoreState code is not called for simply closing the view and re-opening it, however.
RCP apps have an opportunity to also save/restore application state from their WorkbenchAdvisor. your application would have to find the information to save, or your producer of the information would have to post it somewhere useful the workbench advisor can find it. But it's up to you to figure out how to save your state to an IMemento
For example, a common pattern is to have a view save information in its activator, ex: Activator.getDefault().getInfoMap().put("useName", "Paul Webster").
In the Activator#stop(*) method, info map is written out to the plugin state location. In the Activator#start(*) method, the state location file is read and the info map is populated.
PW
|
|
|
Powered by
FUDForum. Page generated in 0.03256 seconds