[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.rcp] 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...
Thanks in advance,
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>
...