[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform] enabledWhen for handlers and editors
|
I am having a heck of a time trying to get a the main toolbar state to
change when state in an editor changes. I have the same handler being
used in the editor's context menu and it works fine (probably because
the enabledWhen expression is evaluated every time the context menu is
displayed.
This is the fragment from the plugin.xml for this particular menu/handler:
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar
id="org.kdr.portfolio.toolbar">
<command
commandId="org.kdr.risk.command.portfolio.save"
icon="icons/save.gif"
id="org.kdr.risk.toolbar.main.portfolio.save"
mnemonic="%action.save.mnemonic"
style="push"
tooltip="%portfolio.save.tooltip">
<visibleWhen
checkEnabled="false">
<and>
<reference
definitionId="org.kdr.risk.definition.portfolio.editor">
</reference>
</and>
</visibleWhen>
</command>
</toolbar>
</menuContribution>
----------------------------------------------------------------------------
<handler
class="org.kdr.ui.handler.SaveHandler"
commandId="org.kdr.risk.command.portfolio.save">
<activeWhen>
<or>
<reference
definitionId="org.kdr.risk.definition.portfolio.view">
</reference>
<reference
definitionId="org.kdr.risk.definition.portfolio.editor">
</reference>
</or>
</activeWhen>
<enabledWhen>
<and>
<reference
definitionId="org.kdr.risk.definition.portfolio.security.delete">
</reference>
<reference
definitionId="org.kdr.risk.definition.portfolio.editor">
</reference>
<reference
definitionId="org.kdr.risk.definition.portfolio.dirty">
</reference>
</and>
</enabledWhen>
</handler>
All conditions used referenced expressions so the can (and are) reused.
All of the expressions are firing correctly (i.e. initial state of the
toolbar button is correct for the possible state scenarios). However,
when the state of the editor changes, it appears that the handler
expressions are not being re-evaluated. All controls on the editor (an
RCP form) have listeners registered to invoke comparison of the control
state vs. the model's state. No state is saved to the model until the
"Save" button is pressed. Hence the need for the toolbar button. If a
difference between the model and control is found a property change
event is fired (i.e.
firePropertyChange(IWorkbenchPartConstants.PROP_DIRTY)). Is there some
other notification mechanism I should be using to cause the handler's
enabledWhen expression to re-evaluate?
Any and all help would be appreciated.
Thanks,
Karl