Eclipse RCP:抑制透视栏的上下文菜单
我想隐藏在 rcp 应用程序中右键单击透视工具栏时显示的上下文菜单。 澄清一下,我确实希望显示透视栏和快捷方式,但我不希望弹出上下文菜单。 所有透视工具栏 api 似乎都是内部的。
谢谢。
I would like to suppress the context menu that shows when right clicking on the perspective tool bar in an rcp application. To clarify, I do want the perspective bar and shortcuts to show, but I do not want the context menu to pop up. All perspective tool bar api seems to be internal.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以试试这个
You can try this
正如您所提到的,PerspectiveSwitcher 的上下文菜单是在工作台框架的内部类中深入创建的。 您无法阻止它的创建,也无法获得对 PerspectiveSwitcher 的引用来以某种方式抑制菜单,而无需大量使用内部类和大量重新实现现有功能。
因此,简单地说,恕我直言,上下文菜单似乎并不意味着被抑制。
解决您的问题的最简单和最干净的方法是抑制整个透视栏,并实现您自己的。 有公共 API 用于查询现有透视图 (IWorkbench.getPerspectiveRegistry) 和切换透视图 (IWorkbenchPage.setPerspective),您只需编写 UI 代码即可。
The context menu of the PerspectiveSwitcher is created deeply in the internal classes of the workbench framework, as you mentioned. You cannot prevent it from beeing created, neither can you get a reference to the PerspectiveSwitcher to suppress the menu somehow, without heavy use of internal classes and a lot of reimplementing existing functionality.
So, to put it simple, IMHO it seems the context menu is not meant to be suppressed.
The easiest and cleanest way to solve your problem would be to suppress the whole perspective bar, and implement your own. There is public API for querying the existing perspectives (IWorkbench.getPerspectiveRegistry) and switching perspectives (IWorkbenchPage.setPerspective), all you need to code is the UI.