|
|
|
Re: Problems with command expressions and enableWhen, activeWhen [message #495828 is a reply to message #495827] |
Fri, 06 November 2009 10:25 |
|
Be careful, you have to do that for all F5 Handlers. Did you check which handler will be executed when your view is closed? Is it still the one where you added the activeWhen and EnabledWhen expression?
The problem is often that a menu entry won´t be grayed out because there is a handler which is always active (because an enabledWhen and activeWhen expression was not declared).
Like mentioned before make a System.out.println() in your execute Method and check which handler will be executed if the view has no Focus or was already closed.
Greetz
Thomas
|
|
|
|
|
|
Re: Problems with command expressions and enableWhen, activeWhen [message #495868 is a reply to message #495865] |
Fri, 06 November 2009 13:15 |
|
Hmm no i have same contextId and for me it works... but maybe its because of the CR. Did you try it with something else, i.e. F5 ?
I´m not sure but CR is very special and i wouldn´t be surprised if something going wrong there...
If this also doesnt work, the scheme id could also be the problem. We defined our own scheme id, so maybe try that.
Greetz
Thomas
|
|
|
|
|
Re: Problems with command expressions and enableWhen, activeWhen [message #496843 is a reply to message #496171] |
Wed, 11 November 2009 14:30 |
|
Bjoern Berg wrote on Mon, 09 November 2009 04:25 |
If I don't use a defaultHandler I can use activeWhen and enabledWhen to manipulate the state of a command (e.g. grayed out)?!
Björn
|
That's mostly it. Just a quick note on activeWhen and enabledWhen.
A command can only have one active handler at a time. That's where activeWhen comes in. Those expressions are evaluated on all handlers for a command (like copy) and the output is a 2 or 3 handlers that can be active. Then they are prioritized (based on a system like the numbers in org.eclipse.ui.ISources). Then one is picked.
That handler can then be enabled or disabled, and that determines the state of the command.
If no handler is picked (because none were candidates or because 2 or more had the same, highest priority) then the command is disabled.
So to recap: Use activeWhen to determine when your handler should be the behaviour for a command. Then use enabledWhen to determine if it is enabled/disabled.
PW
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
|
Powered by
FUDForum. Page generated in 0.04835 seconds