Home » Eclipse Projects » Rich Client Platform (RCP) » Menu items added by <dynamic> provider cannot be disabled(When I try to disable menu items added by a dynamic provider, instead of being "greyed" out, they are never visible. )
|
Re: Menu items added by <dynamic> provider cannot be disabled [message #654371 is a reply to message #654265] |
Tue, 15 February 2011 12:51 |
|
On 02/14/2011 02:52 PM, Max wrote:
>
> 3. That still didn't work, so I tried out using a different command for
> the items that shouldn't be enabled. My different command's handler was
> simple:
>
> public class DisabledHandler extends AbstractHandler {
>
provide a "disabled" handler how? Commands have handlers, and the
handlers are responsible for the enabled state. The active handler for
that command (and there can only be one handler active for a command at
a given time) determines the state by calling setBaseEnabled(*) so that
state change events are generated. The state applies to everywhere that
Command is used.
I created 2 commands, one with an enabled handler and one with a
disabled handler. Then I used "dynamic" to add CCIs to a submenu:
protected IContributionItem[] getContributionItems() {
CommandContributionItemParameter p1 = new CommandContributionItemParameter(
locator, "one", "z.ex.cmpd.en",
CommandContributionItem.STYLE_PUSH);
CommandContributionItemParameter p2 = new CommandContributionItemParameter(
locator, "two", "z.ex.cmpd.dis",
CommandContributionItem.STYLE_PUSH);
CommandContributionItemParameter p3 = new CommandContributionItemParameter(
locator, "three", "z.ex.cmpd.en",
CommandContributionItem.STYLE_PUSH);
CommandContributionItemParameter p4 = new CommandContributionItemParameter(
locator, "four", "z.ex.cmpd.dis",
CommandContributionItem.STYLE_PUSH);
CommandContributionItemParameter p5 = new CommandContributionItemParameter(
locator, "five", "z.ex.cmpd.en",
CommandContributionItem.STYLE_PUSH);
IContributionItem[] items = new IContributionItem[] {
new CommandContributionItem(p1),
new CommandContributionItem(p2),
new CommandContributionItem(p3),
new CommandContributionItem(p4),
new CommandContributionItem(p5), };
return items;
}
This worked fine, and the z.ex.cmpd.dis menu entries were disabled. Is
there anything in your error log? Or barring that, step through an
update(String) of one of your disabled CommandContributionItem.
PW
--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
| | |
Goto Forum:
Current Time: Tue Sep 24 07:14:55 GMT 2024
Powered by FUDForum. Page generated in 0.03339 seconds
|