flavio.donze
flavio.donze

Reputation: 8100

Command menu contribution adds parameter names to the label

I have the following menuContribution, adding one command to the context menu of a Tree. There are two technical parameters expand and useSelection.

<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>

This shows up in the Tree as follows:
context menu with parameter appended

Any idea how to get rid of the parameter names in the label?

I could set the label attribute on the command but then I would have redundant labels (supporting four UI languages, trying to prevent redundancy).

Upvotes: 1

Views: 186

Answers (1)

R&#252;diger Herrmann
R&#252;diger Herrmann

Reputation: 21005

You need to provide a label attribute, otherwise this default label will be used. For localization, use %label in the attribute value and provide plugin.properties files for each language (but I guess you know that already). From what I know that's as good as it gets.

Alternatively, you can create menu contributions programmatically, providing an ExtensionContributionFactory. Within the createContributionItems() method you should be able to create contribution items from the desired commands while re-using the command names as labels. This will, of course, activate your plug-ins as soon as the menu is shown.

Upvotes: 1

Related Questions