问题
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!
回答1:
Have you tried the 'Restore editor state on statup'?
回答2:
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.
来源:https://stackoverflow.com/questions/5337036/in-eclipse-how-to-close-the-open-fileseditors-when-exiting-without-auto-load