Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-ui-dev] command enablement in view toolbar

Hi Pawel,

On Wed, Feb 3, 2010 at 5:17 PM, Pawel Piech <pawel.piech@xxxxxxxxxxxxx> wrote:
> Hi,
> I'm trying to use a commands in a view toolbar and I have a problem with
> enablement.  My command's enablement should depend on the view in which it
> appears, but the command handler is global so it changes whenever the active
> part changes.  This makes the command look broken when my view is not the
> active part.

I think there's 2 parts to this problem, the fact that the command has
one active handler and the global state.

If you activate your handler  in your view, then when your view is not
active the tool item will be disabled.  If you have multiple views
that contribute that handler, then the visible tool items in all of
the views will reflect the state of the active view (and its handler).

If you contribute through the plugin.xml, then you only have one
handler but you depend on variable sources (activePart, for example)
or your own data to determine your handlers state, and then you're
back to all visible tool items will reflect that state.

In 3.x you can only get the behaviour you want by providing one
command per view and the matching handler at the Workbench Window
level (as opposed to activating it against the view site

At the workbench window level we record the set of
IEvaluationReferences that apply to that window.  When a second window
becomes active we stop processing changes (and for most coolbar items,
they stop changing enabled/disabled).  When the first window becomes
active we lift the restriction.

The same pattern could be adapted for the view toolbar items so they
would maintain their last state when their view is not the active
view.  That would be an enhancement request.

> I've searched through the bugs a bit and I've only found one reference to
> this problem in bug 180203 comment #11.  Is there a bug specifically for
> this problem and has it been fixed?

I had a quick look and could not find a bug, although it's been
discussed many times on the forums.


Paul Webster
Hi floor.  Make me a sammich! - GIR

Back to the top