Eclipse RCP:如何配置透视菜单?
我需要完全控制透视菜单。
我已经侵入平台以禁用上下文菜单:
private void disablePerspectiveToolbarMenu() {
PerspectiveBarManager perspectiveBarManager =
((WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow()).getPerspectiveBar();
if (perspectiveBarManager!=null){
ToolBar toolBar = perspectiveBarManager.getControl();
Listener[] listeners = toolBar.getListeners(SWT.MenuDetect);
if (listeners != null){
for (Listener listener : listeners){
toolBar.removeListener(SWT.MenuDetect, listener);
}
}
}
}
但我还需要控制视角菜单的默认内容。有一个始终存在的选项可以访问透视列表外壳。我需要从菜单中删除该选项。
遗憾的是透视菜单完全不受用户控制。我只需要将视角添加到菜单中,仅此而已!
谢谢。
I need to have total control of the perspective menu.
I already hacked into the platform to disable the CONTEXT menu:
private void disablePerspectiveToolbarMenu() {
PerspectiveBarManager perspectiveBarManager =
((WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow()).getPerspectiveBar();
if (perspectiveBarManager!=null){
ToolBar toolBar = perspectiveBarManager.getControl();
Listener[] listeners = toolBar.getListeners(SWT.MenuDetect);
if (listeners != null){
for (Listener listener : listeners){
toolBar.removeListener(SWT.MenuDetect, listener);
}
}
}
}
But i need also to control the default contents of the PERSPECTIVE MENU. There is one option that is always present that gives access to a Perspective List Shell. I need to remove that option from the menu.
It's a shame that the perspective menu is totally out of user control. I just need to have the perspectives added to the menu, and nothing more!
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有 3 个潜在选项可以删除“其他”:
设置
org.eclipse.ui.IWorkbenchPreferenceConstants.SHOW_OTHER_IN_PERSPECTIVE_MENU
在 RCP 应用程序中将首选项设置为
false
。这可以通过在您的产品定义中包含plugin_customization.ini
文件来完成。修补 RCP 应用程序中的工作台。
看看
org.eclipse.ui.internal.PerspectiveBarNewContributionItem
和
org.eclipse.ui.actions.ContributionItemFactory.PERSPECTIVES_SHORTLIST
RCP 应用程序中的透视栏。
相反,创建一个透视栏
使用 org.eclipse.ui.menus,
工具栏和 openPerspective
命令。
There are 3 potential options to get rid of Other:
Set the
org.eclipse.ui.IWorkbenchPreferenceConstants.SHOW_OTHER_IN_PERSPECTIVE_MENU
preference to
false
in your RCP app. This can be done by including aplugin_customization.ini
file with your product definition.Patch the workbench in your RCP app.
Have a look at
org.eclipse.ui.internal.PerspectiveBarNewContributionItem
and
org.eclipse.ui.actions.ContributionItemFactory.PERSPECTIVES_SHORTLIST
perspective bar in your RCP app.
Instead, create a perspective bar
using org.eclipse.ui.menus, a
toolbar, and the openPerspective
command.
我做了一些研究,但解决方案并没有像我预期的那样工作。最后我发现了我的错误。
要在plugin_customization.ini中设置属性,我尝试过:
但这不是正确的表示法!请参阅我最终添加到plugin_customization.xml中的正确解决方案
因此,指定属性的接口或类的名称不是符号的一部分!
I did some research and the solution did not work as I expected it. Finally I found my mistake.
To set the property in the plugin_customization.ini I tried:
but this is not the correct notation!!! Please see the correct solution I added finally to the plugin_customization.xml
So the name of the interface or the class specifying the property ist not part of the notation!