|
Re: SWT Button as a command [message #892475 is a reply to message #892452] |
Thu, 28 June 2012 11:34 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
|
Hi Jan,
How to execute a command programmatically can be found here:
wiki.eclipse.org/Platform_Command_Framework#Executing_a_command_with_parameters
But by just invoking the command in i.e. a SelectionListener of the Button you would have manage the active and enabled state yourself.
The easiest solution for that is to use a Toolbarmanager, which is populated by the IMenuService :
IMenuService menuService = (IMenuService) PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getService(IMenuService.class);
ToolBar toolbar = new ToolBar(composite, SWT.NONE);
ToolBarManager tBManager = new ToolBarManager(toolbar);
menuService.populateContributionManager(tBManager,":::locationURI of your menuContribution:::");
tBManager.update(true);
Best regards,
Simon
[Updated on: Thu, 28 June 2012 11:36] Report message to a moderator
|
|
|
|
Re: SWT Button as a command [message #892497 is a reply to message #892452] |
Thu, 28 June 2012 13:10 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
|
Hi Jan,
this is correct
But please consider the update mechanism of the Command Contributions in a toolbar for which yuta kobayashi asked in the following post last friday...
www.eclipse.org/forums/index.php/t/365261/
In this post I described how to request an update concerning the state of the Contributions in a toolbar.
Best regards,
Simon
|
|
|
|
Powered by
FUDForum. Page generated in 0.04916 seconds