开发者

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

开发者 https://www.devze.com 2023-02-17 04:23 出处:网络
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 develo

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 wheth开发者_StackOverflower 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!


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号