拦截Eclipse e4平台异常 [英] Intercepting Eclipse e4 platform exceptions

查看:71
本文介绍了拦截Eclipse e4平台异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Eclipse RCP 3.x,可以创建定制的AbstractStatusHandler来拦截平台异常。一种方法是,像这样重写ApplicationWorkbenchAdvisor类中的getWorkbenchErrorHandler()方法:

Using Eclipse RCP 3.x, it is possible to create a custom AbstractStatusHandler to intercept platform exceptions. One way to do this, is to override the getWorkbenchErrorHandler() method in the ApplicationWorkbenchAdvisor class like this:

    @Override
    public synchronized AbstractStatusHandler getWorkbenchErrorHandler()
    {
        if (m_errorHandler == null)
        {
            m_errorHandler = new MyWorkbenchErrorHandler(this);
        }
        return m_errorHandler;
    }

在Eclipse论坛,stackoverflow和Lars Vogel中进行了大量研究之后Eclipse 4书,我无法找到使用e4的等效方法。

After doing a lot of research in Eclipse forums, stackoverflow and in the Lars Vogel Eclipse 4 book, I have not been able to find an equivalent way to do this using e4.

任何帮助将不胜感激。

推荐答案

您可以将我们自己的 IEventLoopAdvisor 放入上下文中。一个好地方是在生命周期处理程序中的 @PostContructCreate 上。

You can put our own IEventLoopAdvisor into the context. A good place to do this is on @PostContructCreate in your life cycle handler.

context.set(IEventLoopAdvisor.class, new IEventLoopAdvisor() {
        @Override
        public void eventLoopException(Throwable exception) {
            ... handle exception here ...
        }

        ...
    });

如果上下文中没有 IEventLoopAdvisor 该平台将使用默认值。您可以在 PartRenderingEngine (在编写第1102行时)中看到平台的操作方式:

If there is no IEventLoopAdvisor in the context the platform will use a default. You can see how the platform does this in PartRenderingEngine (at the time of writing on line 1102):

< a href = http://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ ui / internal / workbench / swt / PartRenderingEngine.java rel = nofollow> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.e4。 ui.workbench.swt / src / org / eclipse / e4 / ui / internal / workbench / swt / PartRenderingEngine.java

这篇关于拦截Eclipse e4平台异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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