| [news.eclipse.platform.rcp] Re: Synchronizing toggle state of Toolbar- and MenuItems |
Hi,
in my plugin.xml I have a certain command extension (org.eclipse.ui.commands) that is linked into two menuContributions: toolbar and menu (see below). Both menuContributions are of type 'toggle'.
How can I manage to keep the toggle state of these two items in sync (e.g. if the user toggles the state via the menu entry, the toolbar button must also change its state)?
Usually I would have expected such things should be done by the toolkit and not by the programmer...
Excerpt from plugin.xml:
...
<extension
point="org.eclipse.core.expressions.definitions">
<definition
id="EditorIsOpen">
<with
variable="activeEditor">
<instanceof
value="AbstractMyObjectEditor">
</instanceof>
</with>
</definition>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="EnableMaskCommand"
name="enable/disable Mask">
</command>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="toolbar:mainToolbar">
<command
commandId="EnableMaskCommand"
icon="icons/edit.png"
style="toggle">
<visibleWhen
checkEnabled="true">
<reference
definitionId="EditorIsOpen">
</reference>
</visibleWhen>
</command>
</menuContribution>
<menuContribution
locationURI="menu:edit">
<command
commandId="EnableMaskCommand"
label="enable/disable Mask"
style="toggle">
<visibleWhen
checkEnabled="true">
<reference
definitionId="EditorIsOpen">
</reference>
</visibleWhen>
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="EnableMaskHandler"
commandId="EnableMaskCommand">
</handler>
</extension>
PW
-- Paul Webster http://wiki.eclipse.org/Platform_Command_Framework http://wiki.eclipse.org/Command_Core_Expressions http://wiki.eclipse.org/Menu_Contributions http://wiki.eclipse.org/Menus_Extension_Mapping http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/workbench.htm