Overriding a command name in another plugin [message #499667] |
Mon, 23 November 2009 11:29  |
Eclipse User |
|
|
|
We are trying to debug a problem which involves overriding the name of a command in another plugin, in our RCP application. I want to understand the correct mechanism to override the name of the command when a new plugin is loaded.
Basically, we have a common plugin which defines a command, and its name is internationalized in the plugin.properties file in the same common plugin, something like this:
In the common plugin's plugin.xml:
<extension point="org.eclipse.ui.commands">
<command
id="com.x.y.z.abc"
name="%abc.TITLE">
</command>
</extension>
In the common plugin's plugin.properties:
abc.TITLE = Perform Operation
This command is then normally displayed in the menu system as "Perform Operation".
We have another plugin, which is optionally loaded by customers during the installation process. When this plugin is loaded, the need is to change the displayed name to something else (while the internal functionality executed is the same). So, what has been done is to re-define the command again in the optional plugin, something like this:
In the optional plugin's plugin.xml:
<extension point="org.eclipse.ui.commands">
<command
id="com.x.y.z.abc"
name="%abc.TITLE">
</command>
</extension>
In the optional plugin's plugin.properties:
abc.TITLE = Perform Transaction
However, this mechanism does not seem to work consistently. During development, when using Eclipse, the application shows "Perform Transaction" when the optional plugin is loaded, but in the installed environment, it still shows "Perform Operation". Even in the development environment, it does exhibit the behavior sometimes.
My question is if this is the correct way to override the command name in the optional plugin, and if not, what should be done?
|
|
|
|
|
Re: Overriding a command name in another plugin [message #499903 is a reply to message #499733] |
Tue, 24 November 2009 08:56  |
Eclipse User |
|
|
|
The MenuItem itself usually isn't instantiated until the submenu is about to show. But I wouldn't think that would matter (unless you have menus with removeAllWhenShown set).
When the CommandContributionItem is added the active handler is given a chance to update its label. When a new handler becomes active, it is also given the change to update all registered CommandContributionItems.
If the text needs to be updated at some other event, then org.eclipse.ui.commands.ICommandService.refreshElements(Stri ng, Map) needs to be called.
PW
|
|
|
Powered by
FUDForum. Page generated in 0.07246 seconds