如何阻止Eclipse编辑器关闭RCP [英] How do I stop an Eclipse Editor from closing in an RCP

查看:165
本文介绍了如何阻止Eclipse编辑器关闭RCP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用基于Eclipse的RCP。我们需要防止其中一个已打开的编辑器被用户关闭。



所需的行为是:


  1. 用户单击编辑器窗口中的X或CTRL + W

  2. ,弹出一个对话框,弹出如下界面:如果关闭此编辑器,活动会停止,你想要吗?

  3. 如果他们点击是,它会关闭,如果否,它保持打开。

哦,是的,这可以吗?



谢谢,
gk

解决方案

您可以使用 org.eclipse.ui.ISaveablePart2 ,更多特别是方法 promptToSaveOnClose()



然而,正如这个线程


只有当编辑器关闭时编辑器很脏,才会显示。


查看此 SaveableHelper中的示例.java 源文件



另请参阅文章 防止RCP编辑器关闭 ,这说明了方法工作:




I am working on an Eclipse based RCP. We have a need to prevent one of the opened editors from being closed by the user.

The desired behavior is:

  1. the user clicks the X in the editor window or "CTRL+W"
  2. a dialog pops up saying: "If you close this editor, your activity will stop. Do you want to?"
  3. if they click yes, it closes, if no, it stays open.

Oh yeah, and is this even possible?

Thanks, gk

解决方案

You could use a org.eclipse.ui.ISaveablePart2, more specifically the method promptToSaveOnClose().

However, as said in this thread,

it will only be shown if the editor is dirty at the time it is closed.

See an example in this SaveableHelper.java source file.

See also the article Prevent that a RCP Editor is closed, which explains how this method works:

这篇关于如何阻止Eclipse编辑器关闭RCP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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