如何在e4 RCP应用程序中添加透视图更改侦听器? [英] How to add perspective change listener in e4 RCP application?

查看:68
本文介绍了如何在e4 RCP应用程序中添加透视图更改侦听器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在E4 RCP应用程序上工作,需要检测透视图何时被更改或切换,因此我需要添加侦听器。以前在eclipse 3x中,我曾经像下面的代码那样做。

I am currently working on a E4 RCP application where I need to detect when ever perspective is chnaged or switched so I need to add listener .Previously in eclipse 3x i used to do like below code .

PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener()

但是此代码在E4中不起作用,因为platformui在E4中不是必需的。

But this code will not work in E4 as platformui is not acessible in E4.

我尝试在网络上搜索,但在下面遇到教程。 http://www.vogella.com/tutorials/Eclipse4ModelEvents/article.html#exercise_perspective_switch
是否有其他方法可以使用,而不必听完整的 @EventTopic(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT)且仅听视角变化

I tried searching on web and I came across below tutorial. http://www.vogella.com/tutorials/Eclipse4ModelEvents/article.html#exercise_perspective_switch Is there any other way available without listening to whole @EventTopic(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT) and only listening to only perspective change

推荐答案

在执行此操作的源代码中,我看不到透视切换的任何特定事件( org.eclipse .e4.ui.internal.workbench.PartServiceImpl )。

I don't see any specific events for perspective switch in the source code that does this (org.eclipse.e4.ui.internal.workbench.PartServiceImpl).

EPartService <应该调用code> addPartListener ,但是我认为 UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT 可能是更好的选择。代码监听这样的事件是正常的(主要问题是确定也监听哪个事件!)

The EPartService addPartListener should be called but I think the UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT is probably the better option. It is normal for code to be listening to events like this (the main problem being working out which one to listen too!)

旧的视角已更改的监听器是在Eclipse中实现的4通过收听 UIEvents.EventTags.ELEMENT 事件。

The old perspective changed listener is implemented in Eclipse 4 by listening to the UIEvents.EventTags.ELEMENT event.

这篇关于如何在e4 RCP应用程序中添加透视图更改侦听器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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