0

a problem troubled me for several days. Would like to find the answer here... Thanks ahead!

I developed a plugin in Eclipse. When it starts up, it will open the files (with specific editors we developed) left at the last exiting. I wonder whether I can disable this auto-starting in code?

BTW, I have tried the option "Window->Preferences->General->Editors->Close editors automatically", however, with useless result.

Thanks for your advices!

2 Answers2

1

If you're already creating your own WorkbenchAdvisor (if you're creating an RCP application), you have access to the workbench configurer which can change this property:

public void initialize (IWorkbenchConfigurer configurer) {
    super.initialize (configurer);
    getWorkbenchConfigurer ().setSaveAndRestore (false);
}

For a non-RCP application (ie: just a plugin), it's not recommended to do this since it is a global setting that will affect all editors. It can still be done though:

public void disableReopenEditors () {
    String pref = org.eclipse.ui.IWorkbenchPreferenceConstants.CLOSE_EDITORS_ON_EXIT;
    PlatformUI.getPreferenceStore().setValue(pref, true);
}

If you want to do it manually, you can follow Where does Eclipse save the list of files to open on startup? to delete the file the workbench uses to store this information.

Community
  • 1
  • 1
Krease
  • 15,805
  • 8
  • 54
  • 86
1

Have you tried the 'Restore editor state on statup'?

nanda
  • 24,458
  • 13
  • 71
  • 90
  • Yes, but it doesn't works. The function of "Restore editor state on startup" is to restore the cursor state/position for the active page. However, the files are all opened already. – user3597717 Mar 17 '11 at 09:32