在Eclipse中,您可以使用菜单贡献来添加将调用命令的工具栏按钮和菜单。除了以编程方式调用onclick命令之外,是否有任何方法可以对普通swt按钮执行此操作?将Eclipse命令绑定/绑定到swt按钮
3
A
回答
5
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IHandlerService handlerService = (IHandlerService) getSite()
.getService(IHandlerService.class);
try {
handlerService.executeCommand("my command id", null);
} catch (Exception ex) {
throw new RuntimeException("command with id \"my command id\" not found");
}
}
});
2
不需要。您必须侦听按钮事件并以编程方式调用该命令。
0
您可以在视图或向导一样,使用CommandContributionItems:
CommandContributionItemParameter param = new CommandContributionItemParameter(getSite(),
"myCommand", "com.voo.myCommand", CommandContributionItem.STYLE_PUSH);
param.label = "My Label";
CommandContributionItem item = new CommandContributionItem(param);
item.fill(parent);
相关问题
- 1. 如何将按钮命令绑定到主窗口命令
- 2. 将按钮绑定到GridView
- 3. 绑定切换按钮,两个命令
- 4. 按钮命令绑定不起作用
- 5. TextBox和按钮 - 绑定和命令
- 6. 将命令绑定到窗口标题栏的X按钮
- 7. wpf usercontrol,将按钮的命令参数绑定到父usercontrol
- 8. 将命令绑定到ListView中的按钮与Caliburn.Micro
- 9. SilverLight - 将命令绑定到控件模板中的按钮
- 10. 使用mvvm将命令绑定到Silverlight 4中的按钮
- 11. 将按钮绑定到Alt按键?
- 12. WPF C#按钮绑定和文本框到按钮绑定
- 13. 绑定命令到MenuItem
- 14. 将ViewModel命令绑定到WPF DataGrid
- 15. WPF:将ContextMenu绑定到MVVM命令
- 16. 将ComboBoxItem绑定到WPF中的命令?
- 17. 将命令绑定到WPF中的ComboBoxItem
- 18. 使用HierarchicalDataTemplate将命令绑定到MenuItem
- 19. 非命令的Eclipse键绑定
- 20. MVVM命令绑定
- 21. WPF绑定命令
- 22. WPF命令绑定
- 23. SWT文本字段设置和RCP命令绑定到密钥
- 24. 绑定到该按钮的命令被触发两次
- 25. 按钮命令不会绑定到UserControll类
- 26. 无法将功能绑定到按钮
- 27. WPF单选按钮选定的值命令绑定
- 28. WPF自定义按钮的命令绑定不起作用
- 29. 数据绑定和绑定按钮
- 30. Java + Jgoodies绑定:单选按钮绑定
其他方式来获得处理服务。 IHandlerService handlerService =(IHandlerService)PlatformUI.getWorkbench()。getService(IHandlerService.class); – 2017-06-08 07:33:45