In Eclipse, how to close the open files(editors) when exiting without auto-load in next startup

和自甴很熟 提交于 2020-01-25 19:22:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!