在Eclipse RCP 4中关闭零件时的自定义消息 [英] Custom message when closing a part in Eclipse RCP 4

查看:103
本文介绍了在Eclipse RCP 4中关闭零件时的自定义消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有以下问题:

在我们的Eclipse RCP 4应用程序中,有多个部分,并且这些部分是可关闭的。当用户关闭零件时,应该有一个自定义弹出窗口(取决于某些内部零件状态),该弹出窗口询问用户他是否真的要关闭零件。
在Eclipse RCP 4中似乎不那么容易实现,或者我们只是完全监督了一些事情。
我只是简要介绍一下我们尝试过的事情:

In our Eclipse RCP 4 application there are multiple parts and the parts are closable. When the user is closing a part there should be a custom pop-up (depending on some internal part state) which is asking the user if he really wants to close the part or not. It seems to be not that easy to implement in Eclipse RCP 4 or we have just totally overseen something. I'll just give you a short brieifing about the things we tried:


  • 在部分。尽管问题出在,但我们不希望出现这种标准的日食保存对话框。

  • public int hintToToSaveOnClose():这似乎很有希望,但对于Eclipse 4而言却不是,或者有没有办法以这种方式集成它?比较: http:// e- rcp.blogspot.de/2007/09/prevent-that-rcp-editor-is-closed.html

  • 我们最后的尝试是集成自定义部件侦听器,简单示例如下所示:

  • Use dirtable with a @persist method in the part. Though the problem is, we don't want this standard eclipse save dialog. So is there a way to override this?
  • public int promptToSaveOnClose(): This seemed to be promising but not for Eclipse 4 or is there a way to integrate it that way? Compare: http://e-rcp.blogspot.de/2007/09/prevent-that-rcp-editor-is-closed.html
  • Our last try was to integrate a custom part listener, simple example shown in the following:

partService.addPartListener(new IPartListener() {           
   public void partVisible(MPart part) {                
   }

    public void partHidden(MPart part) {
        partService.showPart(part, PartState.ACTIVATE);
    }

    public void partDeactivated(MPart part) {

    }

    public void partBroughtToTop(MPart part) {

    }

    public void partActivated(MPart part) {

    }
});


问题在于我们正在遇到一个连续的循环。类似的内容在此处的最后一条注释中发布:在Eclipse编辑器中检测选项卡关闭

The problem with this was we are running into a continuous loop. Something similar is posted over here in the last comment: Detect tab close in Eclipse editor

所以我可以写更多有关此问题的信息,但是我认为目前就足够了。如果您需要更多输入,请给我一个提示。
感谢您的帮助。

So I could write some more about this problem, but I think that's enough for the moment. If you need some more input just give me a hint. Thanks for helping.

推荐答案

保存提示由 ISaveHandler 在包含 MPart MWindow 上下文中注册。您可以编写自己的 ISaveHandler 并将其设置在窗口上下文中以替换默认值。

The save prompt is generated by the ISaveHandler registered in the context of the MWindow containing the MPart. You can write your own ISaveHandler and set it in the window context to replace the default.

您可能还希望还要在窗口上下文中查看 IWindowCloseHandler

You might also want to look at the IWindowCloseHandler also in the window context.

这篇关于在Eclipse RCP 4中关闭零件时的自定义消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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