views:

341

answers:

3

Is there a plugin for Eclipse which would automatically save the eclipse workspace every say 5 minutes in the background because every time eclipse crashes the entire workspace layout reverts or open files gets lost, and it is quite annoying at this point.

A: 

To save the layout, just change everything the way you like and then restart. Eclipse won't corrupt its prefs after a crash, so this should work. As an additional step, you can save the current perspective under a different name and export the prefs to a file. You can then load this file in case of a disaster.

I don't have a solution for the lost files issue, though.

Aaron Digulla
It sounds like this is the exact opposite of the solution the OP is looking for. He wants to save his workspace without having to close Eclipse.
Matt Ball
/agree with Bears will eat you. Aside from not restarting I don't want to restart eclipse every time I open a file either so I don't have to re-open everything, etc. The layout is the least of my problems as I obviously already am in the habit of do layout, restart, because of this issue. Its just annoying to have to go from scratch every time eclipse crashes (1-2 times per day)
Dmitriy Likhten
You just have to do this once. As I said, I have no solution for "keep files open" but closing eclipse once will at least preserve the layout of the perspectives.
Aaron Digulla
+2  A: 

Windows -> Preferences -> General -> Workspace
There is a box for the "Workspace save interval". But I am not sure that this is the thing you're looking for.

Simon
Based on my experiences with Eclipse crashes losing my workspace, I don't think this will do it.
Matt Ball
This does not work, always been every 5 minutes but there were no workspace saves done ever except on exit.
Dmitriy Likhten
Open a bug report.
Aaron Digulla
A: 

I'm not aware of any Eclipse plugins that do this, but for devs familiar with Eclipse plugin development it shouldn't be too hard to create a plugin that does this. Example code and info from here:

It is possible for your plug-in to explicitly request a workspace save or snapshot. If you are writing an RCP Application, you are responsible for minimally invoking save before shutdown. The following example saves the workspace:

final MultiStatus status = new MultiStatus(...);
IRunnableWithProgress runnable = new IRunnableWithProgress() {
   public void run(IProgressMonitor monitor) {
      try {
         IWorkspace ws = ResourcesPlugin.getWorkspace();
         status.merge(ws.save(true, monitor));
      } catch (CoreException e) {
         status.merge(e.getStatus());
      }
   }
};
new ProgressMonitorDialog(null).run(false, false, runnable);
if (!status.isOK())
   ErrorDialog.openError(...);
Matt Ball