Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Maintaining state of an AbstractSourceProvider
Maintaining state of an AbstractSourceProvider [message #481068] Wed, 19 August 2009 13:49 Go to next message
Maarten Laurs is currently offline Maarten LaursFriend
Messages: 7
Registered: August 2009
Junior Member
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 #481111 is a reply to message #481068] Wed, 19 August 2009 16:28 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

In an RCP app if you want to save state and restore state, you can either have your ASP implementation interact with your activator to save state on Activator#stop(BundleContext) or try and retrieve the information on org.eclipse.ui.application.WorkbenchAdvisor.saveState(IMemen to) so you can write it out.

PW


Re: Maintaining state of an AbstractSourceProvider [message #481216 is a reply to message #481068] Thu, 20 August 2009 07:41 Go to previous messageGo to next message
Maarten Laurs is currently offline Maarten LaursFriend
Messages: 7
Registered: August 2009
Junior Member
Thanks for answering this, Paul.

I was under the impression that IMemento is there to maintain the state of widgets inside a ViewPart. But if I understand you correctly, you are saying that I can use it for much more than that. I can't seem to find much about this on the internet. Can you get into a bit more detail here?

I know how to use IMemento to store widget related things. But how would I address this object outside of a ViewPart context?
Re: Maintaining state of an AbstractSourceProvider [message #481834 is a reply to message #481216] Mon, 24 August 2009 13:50 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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


Previous Topic:Minimize Event on a View
Next Topic:Headless build on Windows using a Linux Galileo platform + Delta Pack
Goto Forum:
  


Current Time: Thu Apr 25 20:11:42 GMT 2024

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

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

Back to the top