在eclipse中为下拉菜单填充CommandContributionItem

时间:2012-11-05 10:21:33

标签: java eclipse eclipse-plugin eclipse-rcp

我可以按照以下方式以编程方式创建CommandContributionItem

CommandContributionItemParameter param = new CommandContributionItemParameter(serviceLocator, id, commandId, CommandContributionItem.STYLE_PUSH);
CommandContributionItem item = new CommandContributionItem(this);

如果我将样式CommandContributionItem.STYLE_PUSH更改为CommandContributionItem.STYLE_PULLDOWN,那么我可以在工具栏中创建下拉菜单而不是按钮。

现在我的问题是如何将items填入此ContributionItemCommandContributionItem对象上已存在填充方法,但我想将其他CommandContributionItem个对象输入为menu items。我该怎么做?

1 个答案:

答案 0 :(得分:0)

  1. 添加菜单贡献:

    工具栏:org.eclipse.ui.main.toolbar后添加=

  2. 在上面工具栏下的下拉菜单中添加您想要显示的命令。 E.g新的下拉菜单。如果直接单击按钮,它将引导您进入新向导。否则,您可以单击向下箭头。

    假设thise命令的ID为:com.org.new.mywizard

  3. 使用

    添加其他菜单内容

    location uri as:menu:com.org.new.mywizard

  4. 4.现在,您想要在下拉列表中添加哪些命令,请在上述菜单提供下添加

相关问题