Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Hooks for Eclipse shutdown and startup
Hooks for Eclipse shutdown and startup [message #303768] Mon, 22 May 2006 14:44 Go to next message
Eclipse UserFriend
Hi,

I have created my own editors within Eclipse. When Eclipse shuts down I need
a hook to store all my currently open editors and when Eclipse start up
again, I would like to reopen the previously open editors. Could you please
let me know how to hook my funtionality to the Eclipse shutdown and startup
processes?

Should I use shutdown() method of my plugin? Or should I use
Runtime.getRuntime().addShutdownHook( myHookClass )?

Thanks,
Rashmy
Re: Hooks for Eclipse shutdown and startup [message #303769 is a reply to message #303768] Mon, 22 May 2006 16:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

That will be done automatically by Eclipse. When it shuts down it
remembers all of the open editors (unless the user told Eclipse to shut
them all first before shutting down) and then will reopen the editors
the next time the workspace is started.

Rashmy wrote:
> Hi,
>
> I have created my own editors within Eclipse. When Eclipse shuts down I need
> a hook to store all my currently open editors and when Eclipse start up
> again, I would like to reopen the previously open editors. Could you please
> let me know how to hook my funtionality to the Eclipse shutdown and startup
> processes?
>
> Should I use shutdown() method of my plugin? Or should I use
> Runtime.getRuntime().addShutdownHook( myHookClass )?
>
> Thanks,
> Rashmy
>
>

--
Thanks,
Rich Kulp
Re: Hooks for Eclipse shutdown and startup [message #303771 is a reply to message #303769] Mon, 22 May 2006 17:26 Go to previous messageGo to next message
Eclipse UserFriend
No, the editor I created extends EditorPart. I think I have to create a
momento and store the editor to be reopened later. But what I am looking for
is a hook to the shutdown and statup functions of Eclipse.

Thanks,
Rashmy

"Rich Kulp" <richkulp@us.NO_SPAM.ibm.com> wrote in message
news:e4t8is$3h9$1@utils.eclipse.org...
> That will be done automatically by Eclipse. When it shuts down it
> remembers all of the open editors (unless the user told Eclipse to shut
> them all first before shutting down) and then will reopen the editors
> the next time the workspace is started.
>
> Rashmy wrote:
> > Hi,
> >
> > I have created my own editors within Eclipse. When Eclipse shuts down I
need
> > a hook to store all my currently open editors and when Eclipse start up
> > again, I would like to reopen the previously open editors. Could you
please
> > let me know how to hook my funtionality to the Eclipse shutdown and
startup
> > processes?
> >
> > Should I use shutdown() method of my plugin? Or should I use
> > Runtime.getRuntime().addShutdownHook( myHookClass )?
> >
> > Thanks,
> > Rashmy
> >
> >
>
> --
> Thanks,
> Rich Kulp
Re: Hooks for Eclipse shutdown and startup [message #303772 is a reply to message #303771] Mon, 22 May 2006 17:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

No. That's not true. It's done through the IEditorInput. If it returns a
persistable (through editorInput.getPersistable()) then the editor will
be saved.

It doesn't actually go through the editor, it goes the input. For
example by default the IFileEditorInput is persistable, so if your
editor takes an IFileEditorInput then it will persist automatically.

If you are creating your own special IEditorInputs, then it needs to
return an IPersistable to persist. The persistable persists through
mementos.


--
Thanks,
Rich Kulp
Re: Hooks for Eclipse shutdown and startup [message #303791 is a reply to message #303772] Tue, 23 May 2006 09:02 Go to previous messageGo to next message
Eclipse UserFriend
Rich,

Here is what I do - I have created an editor in which I embed a form to
display information of an object in the memory.
I did try persisting the XXXEditorInput that I create. But when eclipse is
launched back again, it is unable to restore the input. In my
XXEditorInputFactory.createElement(), I have to get the same object from
memory. But I think the project(or the plugin) that loads this object into
the memory is not yet created. It looks like Eclipse restores the editor
before loading my project in the runtime workbench. Hence I wanted a hook to
create the editor after the project loading is completed and Eclipse has
restored everything for startup.

Thanks,
Rashmy


"Rich Kulp" <richkulp@us.NO_SPAM.ibm.com> wrote in message
news:e4tc5f$1n1$1@utils.eclipse.org...
> No. That's not true. It's done through the IEditorInput. If it returns a
> persistable (through editorInput.getPersistable()) then the editor will
> be saved.
>
> It doesn't actually go through the editor, it goes the input. For
> example by default the IFileEditorInput is persistable, so if your
> editor takes an IFileEditorInput then it will persist automatically.
>
> If you are creating your own special IEditorInputs, then it needs to
> return an IPersistable to persist. The persistable persists through
> mementos.
>
>
> --
> Thanks,
> Rich Kulp
Re: Hooks for Eclipse shutdown and startup [message #303804 is a reply to message #303791] Tue, 23 May 2006 13:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

There isn't any. Your XXXEditorInputFactory should handle your plugin
not being started yet. I'm not sure how you get this "object" but it
should be done through your plugin. And a class in your plugin should be
able to be called from the the factory and it should see if the object
is created yet. If not it should create it. You need to work in lazy
manner and create as needed because you can't control the order.

--
Thanks,
Rich Kulp
Re: Hooks for Eclipse shutdown and startup [message #303809 is a reply to message #303804] Tue, 23 May 2006 13:14 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

You might want to take a look at
org.eclipse.ui.part.FilEditInputFactory.create(memento). This gives a
good example of going to the plugin and getting the object in question.
That way the plugin will be loaded and active when needed.

Rich Kulp wrote:
> There isn't any. Your XXXEditorInputFactory should handle your plugin
> not being started yet. I'm not sure how you get this "object" but it
> should be done through your plugin. And a class in your plugin should be
> able to be called from the the factory and it should see if the object
> is created yet. If not it should create it. You need to work in lazy
> manner and create as needed because you can't control the order.
>

--
Thanks,
Rich Kulp
Previous Topic:Is it possible to add properties to "plugin.properties" file at runtime??
Next Topic:How to resource a string without introducing a plugin class?
Goto Forum:
  


Current Time: Fri Oct 24 02:54:43 EDT 2025

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

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

Back to the top