Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 06:14 Go to next message
heaad  is currently offline heaad Friend
Messages: 1
Registered: July 2011
Junior Member
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 06:18]

Report message to a moderator

Re: how to define enabledwhen of a self instantiated command ? [message #698069 is a reply to message #695153] Mon, 18 July 2011 17:58 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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 Apr 25 07:26:44 GMT 2024

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

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

Back to the top