命令菜单贡献将参数名称添加到标签

Command menu contribution adds parameter names to the label

我有以下 menuContribution,将一个命令添加到 Tree 的上下文菜单中。有两个技术参数expanduseSelection.

<menuContribution
    locationURI="popup:com.softmodeler.ui.editors.StructureCompareEditor?after=additions">
 <command
       commandId="softmodeler.cmd.refreshViewer"
       id="softmodeler.cmd.refreshViewer"
       style="push">
    <parameter
          name="expand"
          value="1">
    </parameter>
    <parameter
          name="useSelection"
          value="true">
    </parameter>
 </command>
</menuContribution>

这在 Tree 中显示如下:

知道如何删除标签中的参数名称吗?

我可以在 command 上设置 label 属性,但那样我会有冗余标签(支持四种 UI 语言,试图防止冗余)。

您需要提供标签属性,否则将使用此默认标签。对于本地化,在属性值中使用 %label 并为每种语言提供 plugin.properties 文件(但我猜你已经知道了)。据我所知,这已经是最好的了。

或者,您可以通过编程方式创建菜单贡献,提供 ExtensionContributionFactory。在 createContributionItems() 方法中,您应该能够从所需命令创建贡献项,同时将命令名称重新用作标签。当然,这会在显示菜单后立即激活您的插件。