Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Why is saveState(IMemento) in IViewPart only called on shutdown?
Why is saveState(IMemento) in IViewPart only called on shutdown? [message #302181] Fri, 14 April 2006 15:47 Go to next message
Eclipse UserFriend
Originally posted by: eclipse.bettsockentraeger.de

Hello,

I created a view and saved its state in the saveState(IMemento) method
of IViewPart. The method is called upon workbench shutdown and
everything works beautifully but when I close the view manually the
method is not called and the state is not saved and can't be restored
upon startup or creation of the view.

SO how can I call the method on closeing of my view so that the state is
preserved?

Thanks for any help

Regards
Stefan
Re: Why is saveState(IMemento) in IViewPart only called on shutdown? [message #302193 is a reply to message #302181] Sat, 15 April 2006 19:01 Go to previous messageGo to next message
Darin Swanson is currently offline Darin SwansonFriend
Messages: 2386
Registered: July 2009
Senior Member
You need to wire it up yourself....we logged a bug report about this some
time ago...I forget the state of it.

See the Debug Display for an example within Eclipse.
Especially
org.eclipse.jdt.internal.debug.ui.display.DisplayView#perspe ctiveChanged

HTH
Darins

"Stefan Langer" <eclipse@bettsockentraeger.de> wrote in message
news:e1og2t$lig$1@utils.eclipse.org...
> Hello,
>
> I created a view and saved its state in the saveState(IMemento) method of
> IViewPart. The method is called upon workbench shutdown and everything
> works beautifully but when I close the view manually the method is not
> called and the state is not saved and can't be restored upon startup or
> creation of the view.
>
> SO how can I call the method on closeing of my view so that the state is
> preserved?
>
> Thanks for any help
>
> Regards
> Stefan
Re: Why is saveState(IMemento) in IViewPart only called on shutdown? [message #302215 is a reply to message #302181] Mon, 17 April 2006 12:35 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

saveState(IMemento) is about saving view state across sessions. The
user shuts down eclipse, and the user expects to see his views when he
restarts eclipse. The workbench uses saveState(*)/restoreState(*) for that.

When a user closes a view, he deliberatly closed it. It's gone. When
the user shows the view again, it comes up in it's default state.


You have 2 options. Option 1 is to implement ISaveablePart, and when
the view is closed it will get its methods like isDirty() and doSave(*)
called. Of course if you mark your view as dirty, a little '*' appears
in the tab title in 3.2 :-)

Option 2 is to use DialogSettings to persist view information.

Save your view information in the plugin state location.

Later,
PW


Re: Why is saveState(IMemento) in IViewPart only called on shutdown? [message #306177 is a reply to message #302215] Mon, 24 July 2006 19:18 Go to previous messageGo to next message
Guru Nagarajan is currently offline Guru NagarajanFriend
Messages: 45
Registered: July 2009
Member
How do I use DialogSettings to persist view Information? Any pointers is
much appreciated.
Paul Webster wrote:
> saveState(IMemento) is about saving view state across sessions. The
> user shuts down eclipse, and the user expects to see his views when he
> restarts eclipse. The workbench uses saveState(*)/restoreState(*) for
> that.
>
> When a user closes a view, he deliberatly closed it. It's gone. When
> the user shows the view again, it comes up in it's default state.
>
>
> You have 2 options. Option 1 is to implement ISaveablePart, and when
> the view is closed it will get its methods like isDirty() and doSave(*)
> called. Of course if you mark your view as dirty, a little '*' appears
> in the tab title in 3.2 :-)
>
> Option 2 is to use DialogSettings to persist view information.
>
> Save your view information in the plugin state location.
>
> Later,
> PW
Re: Why is saveState(IMemento) in IViewPart only called on shutdown? [message #306181 is a reply to message #306177] Mon, 24 July 2006 20:17 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You want to create your DialogSettings object, fill it with information,
and then save it ... there's a #save(Writer) method.

You can persist the DialogSettings file in your plugin state location
.... start from Plugin#getStateLocation().

Later,
PW


Re: Why is saveState(IMemento) in IViewPart only called on shutdown? [message #306184 is a reply to message #306181] Mon, 24 July 2006 21:43 Go to previous messageGo to next message
Guru Nagarajan is currently offline Guru NagarajanFriend
Messages: 45
Registered: July 2009
Member
Paul Webster wrote:
> You want to create your DialogSettings object, fill it with information,
> and then save it ... there's a #save(Writer) method.
>
> You can persist the DialogSettings file in your plugin state location
> ... start from Plugin#getStateLocation().
>
> Later,
> PW
>
>
Thanks Paul. I would like to store Objects vs. Strings or primitives.
Re: Why is saveState(IMemento) in IViewPart only called on shutdown? [message #306226 is a reply to message #306184] Tue, 25 July 2006 19:49 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
Guru Nagarajan wrote:

> Thanks Paul. I would like to store Objects vs. Strings or primitives.

You can do this.
Serialize your objects into file located in Plugin#getStateLocation().


Konstantin Scheglov,
Google, Inc.
Re: Why is saveState(IMemento) in IViewPart only called on shutdown? [message #306228 is a reply to message #306226] Tue, 25 July 2006 20:49 Go to previous message
Guru Nagarajan is currently offline Guru NagarajanFriend
Messages: 45
Registered: July 2009
Member
Konstantin Scheglov wrote:
> Guru Nagarajan wrote:
>
>> Thanks Paul. I would like to store Objects vs. Strings or primitives.
>
> You can do this.
> Serialize your objects into file located in Plugin#getStateLocation().
Do you have a sample for this.
Previous Topic:Arrange Items In an Import Wizard other than alphabetical
Next Topic:Eclipse 3.3?
Goto Forum:
  


Current Time: Fri May 10 19:16:56 GMT 2024

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

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

Back to the top