Eclipse RCP:如何获取“显示视图”菜单而不是一个对话框 [英] Eclipse RCP: how to get Show View menu instead of a dialog

查看:127
本文介绍了Eclipse RCP:如何获取“显示视图”菜单而不是一个对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经添加到我的观点的 org.eclipse.ui.menus

I've added to my perspective's org.eclipse.ui.menus

<command
      commandId="org.eclipse.ui.views.showView"
      style="pulldown">
</command>

显示视图项目添加到主菜单,但这个项目不是一个菜单(如在Eclipse窗口菜单中)。而是按它显示一个对话框,我可以在其中选择一个视图。如何获取菜单?

This adds Show View item to main menu, but this item is not a menu (as in the Eclipse Window menu). Instead pressing it shows a dialog where I can select a view. How do I get a menu instead?

推荐答案

您必须创建ContributionItem类,如下所示:

You have to create ContributionItem class like below:

public class MyShowViewContributionItem extends org.eclipse.ui.internal.ShowViewMenu {
    public MyShowViewContributionItem() {
        this("om.myplugin.myShowViewId");
    }
    public MyShowViewContributionItem(String id) {
        super(org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow(), id);
    }
}

然后在你的plugin.xml中 org.eclipse.ui.menus extension:

then in your plugin.xml org.eclipse.ui.menus extension:

    <menu
          label="My Show View">
       <dynamic
             class="com.myplugin.MyShowViewContributionItem"
             id="com.myplugin.myShowViewId">
       </dynamic>
    </menu>

干杯,
最高

这篇关于Eclipse RCP:如何获取“显示视图”菜单而不是一个对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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