Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » how to define enabledwhen of a self instantiated command ?
how to define enabledwhen of a self instantiated command ? [message #695153] Mon, 11 July 2011 02:14 Go to next message
Eclipse UserFriend
hi,

I define a coolbar in my view using this code :

// define a CommandContributionItem
IWorkbenchWindow window = getSite().getWorkbenchWindow() ;
CommandContributionItemParameter p = new CommandContributionItemParameter(
window, "",
"myCommandID",
SWT.PUSH);


CommandContributionItem contributionItem = new CommandContributionItem( p );

// I define coolbar in my view
CoolBar coolBar = new CoolBar( coolBarContainer, SWT.FLAT );

final IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);

// add my CommandContributionItem to the toolbar
toolbar.add( contributionItem ) ;

ToolBarContributionItem toolBarContributionItem = new ToolBarContributionItem( toolbar, "model") ;

toolBarContributionItem.fill(coolBar, 0) ;


In the same view ,there is a TreeViewer , the command should be enabled if and only if a certain type of node of the TreeViewer is selected.

how to define the enabledwhen of the command ?

thanks!


[Updated on: Mon, 11 July 2011 02:18] by Moderator

Re: how to define enabledwhen of a self instantiated command ? [message #698069 is a reply to message #695153] Mon, 18 July 2011 13:58 Go to previous message
Eclipse UserFriend
Where is your handler defined for that command? In the plugin.xml, it's org.eclipse.ui.handlers that defines an enabledWhen clause for a handler. If it was activated programmatically in your view, it's your handler that contols its enabled state.

PW
Previous Topic:Key binding with command framework in a dialog
Next Topic:handle EditorActions
Goto Forum:
  


Current Time: Thu Jul 03 15:05:04 EDT 2025

Powered by FUDForum. Page generated in 0.03746 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top