在Eclipse中,如何在下次启动时自动加载时关闭打开的文件(编辑器) [英] In Eclipse, how to close the open files(editors) when exiting without auto-load in next startup

查看:576
本文介绍了在Eclipse中,如何在下次启动时自动加载时关闭打开的文件(编辑器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个问题让我困扰了好几天。想在这里找到答案...感谢前进!



我在Eclipse中开发了一个插件。当它启动时,它会打开最后退出的文件(我们开发的特定编辑器)。我想知道我是否可以在代码中禁用此自动启动?



BTW,我尝试过选项Window-> Preferences-> General-> Editors-> Close editors


$ b


解决方案

如果您已经创建了自己的 WorkbenchAdvisor (如果您正在创建RCP应用程序),则可以访问可更改此属性的工作台配置程序:

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

对于非R​​CP应用程序(即:只是一个插件),它不是建议这样做,因为它是影响所有编辑的全局设置。仍然可以做到这一点:

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

如果要手动执行,可以按照 Eclipse在哪里保存要在启动时打开的文件列表? 删除工作台用于存储此信息的文件。


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!

解决方案

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.

这篇关于在Eclipse中,如何在下次启动时自动加载时关闭打开的文件(编辑器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆