[commands] Unwanted deactivations of menus [message #889321] |
Tue, 19 June 2012 05:54 |
Daniel Krügler Messages: 853 Registered: July 2009 |
Senior Member |
|
|
In our RCP product I try to use commands as much as possible, but I
found that there is at least one situation where actions are still used
because they behave more conveniently here: If we have a view that
contains a tree viewer, typically this view will provide a "collapse
all" action in the view toolbar (a similar example is a "refresh" or
"expand all" action at that location).
Originally I found it astonishing that all these actions are provided as
Actions by the standard Eclipse views (Package Explorer, Navigator, ..),
so I wanted to use the public CollapseAllHandler taking advantage of the
predefined command id "org.eclipse.ui.navigate.collapseAll" via
programmatic activation through the IHandlerService. This works, but it
causes an very obvious visual difference compared to equivalent
contributions provided by Actions: Unless the view is not the currently
active part, the toolbar item will be disabled. This is so, because I
queried the IHandlerService from the view site, therefore this site is
not active when the view is not active. One could try to fix this by
using a "wider"
service locator (like the workbench window site), but that will directly
lead to a handler conflict, if there is a second view that tries to use
the same approach.
I wonder how the effects of actions can be realized with a command-based
approach: This example nicely shows, that from a user's perspective the
tool bar item should be enabled irrespective whether the view is active
or not.
I have not find good alternatives so far, so I'm asking others for their
suggestions.
I'm aware that I could associate a user-defined special command id with
the CollapseAllHandle, but then I have the disadvantage that I cannot
inherit the pre-declared command image (or key binding), so this seems
not like a good solution for me. Accepting the current state (disabled
when view is not active) is also no choice for me: Users complain about
this.
Any ideas?
Thanks & Greetings from Bremen,
Daniel Krügler
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03624 seconds