Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » myEditorPart#saveState(IMemento) not being called
myEditorPart#saveState(IMemento) not being called [message #332454] Tue, 21 October 2008 20:12 Go to next message
Dave Orme is currently offline Dave OrmeFriend
Messages: 424
Registered: July 2009
Senior Member
I wanted to create a custom editor (where I supply both the EditorPart
and IEditorInput implementation) where Eclipse remembers what editors
are open and reopens them when the platform closes and reopens.

Searching the web found

http://dev.eclipse.org/newslists/news.eclpse.platform/msg631 07.html

which recommends having my editor implement the IPersistableEditor
interface.

After implementing this interface in my EditorPart (and making sure that
I called configurer.setSaveAndRestore(true)), the IPersistable#saveState
and IPersistableEditor#restoreState methods were never called.
(Verified using the debugger.)

I also found:

http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/m sg08987.html

but it appears to apply to the 2.2 api only and attempting to use it
also failed in new and interesting ways. :-)


What am I missing/What should I try next?


Thanks,

Dave Orme
Re: myEditorPart#saveState(IMemento) not being called [message #332477 is a reply to message #332454] Tue, 21 October 2008 23:20 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Those are the 2 main things you need.

Your editor must implement org.eclipse.ui.IPersistableEditor. your
IEditorInput must return an org.eclipse.ui.IPersistableElement. its
factory ID must match your org.eclipse.ui.IElementFactory, and you need
to use the org.eclipse.ui.elementFactories extension to link the ID to
the factory.

If you've done all the steps and it's still not working, maybe there's a
bug in the system (although this works for FileEditorInput, amongst
others). Maybe a bug against Eclipse Platform UI and a small test plugin.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Re: myEditorPart#saveState(IMemento) not being called [message #332487 is a reply to message #332477] Wed, 22 October 2008 15:06 Go to previous message
Dave Orme is currently offline Dave OrmeFriend
Messages: 424
Registered: July 2009
Senior Member
Thanks for your help, Paul.

I've tried this, and put System.out.printlns in the:

EditorInput#saveState
EditorInputFactory#createElement
Editor#saveState
Editor#restoreState

methods.

For the purposes of the example, my IEditorInput contains a String and
my Editor contains a Text widget. The "text" property of the Editor's
Text widget is data-bound to a property of the EditorInput. The editor
itself has no state that it persists--all of its state is persisted in
the IMemento in the IEditorInput.

Running the example, creating two editors, and typing "Editor 1" into
one and "Editor 2" into the second yields the following output when
shutting down and restarting the application:

Shutdown:>>>>>>>>>>>>>>>>>>>

EditorInput.saveState>>>> Editor 1
EditorInput.saveState>>>> Editor 2
EditorInput.saveState>>>> Editor 2
EditorInput.saveState>>>> Editor 1
EditorInput.saveState>>>> Editor 1
EditorInput.saveState>>>> Editor 2

Startup:>>>>>>>>>>>>>>>>>>>>

CreateElement>>>> Editor 1

and no editors are actually restored.

Notice also that Editor.saveState is never called.

I feel like there must be a "Doh!" somewhere, but am clueless as to
where...

Source code to my example is available at:

http://www.coconut-palm-software.com/~djo/org.eclipse.exampl es.saveditorstate.zip


Thanks in advance,

Dave Orme


On Tue, 2008-10-21 at 19:20 -0400, Paul Webster wrote:
> Those are the 2 main things you need.
>
> Your editor must implement org.eclipse.ui.IPersistableEditor. your
> IEditorInput must return an org.eclipse.ui.IPersistableElement. its
> factory ID must match your org.eclipse.ui.IElementFactory, and you need
> to use the org.eclipse.ui.elementFactories extension to link the ID to
> the factory.
>
> If you've done all the steps and it's still not working, maybe there's a
> bug in the system (although this works for FileEditorInput, amongst
> others). Maybe a bug against Eclipse Platform UI and a small test plugin.
>
> PW
>
>
Previous Topic:Handle ESC press to a whole shell as ENTER is handled with setDefaultButton
Next Topic:CVS: reverting to previous revision
Goto Forum:
  


Current Time: Thu Apr 25 12:56:10 GMT 2024

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

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

Back to the top