How to add perspective change listener in e4 RCP application?

半世苍凉 提交于 2019-12-08 09:29:09

问题


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()

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

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


回答1:


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

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!)

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



来源:https://stackoverflow.com/questions/38966882/how-to-add-perspective-change-listener-in-e4-rcp-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!