Eclipse 检查处理程序中菜单项的状态
如何在处理程序“执行”方法中按语法检查作为菜单项提供的命令是否已选中/未选中(如果为复选框类型)、已选中或未选中(如果为单选按钮类型)。 请参阅此处的快照。查看此博客: 因此,首先确保您的命令具有适当的样式:Eclipse 检查处理程序中菜单项的状态,eclipse,eclipse-plugin,eclipse-rcp,rcp,Eclipse,Eclipse Plugin,Eclipse Rcp,Rcp,如何在处理程序“执行”方法中按语法检查作为菜单项提供的命令是否已选中/未选中(如果为复选框类型)、已选中或未选中(如果为单选按钮类型)。 请参阅此处的快照。查看此博客: 因此,首先确保您的命令具有适当的样式: <extension point="org.eclipse.ui.menus"> <menuContribution locationURI="..."> <command commandId="org.eclipse.example.comman
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="...">
<command commandId="org.eclipse.example.command.toggle"
style="toggle" />
</menuContribution>
</extension>
也可以考虑看看Or.Eclipse。U.Hall。Huffl。 希望这有帮助。
我找到了解决方案, 在处理程序执行方法中添加了此代码public Object execute(ExecutionEvent event) throws ExecutionException {
Event selEvent = (Event) event.getTrigger();
MenuItem item = (MenuItem) selEvent.widget;
System.Out.Println(item.getSelection());
return null;
}
谢谢你的回答。我已经按照专业语法创建了这个命令。我现在有了解决办法。代码如下(我已将此代码段添加到我的处理程序执行方法中)[Code]公共对象执行(ExecutionEvent事件)抛出ExecutionException{event selEvent=(event)event.getTrigger();MenuItem item=(MenuItem)selEvent.widget;System.Out.Println(item.getSelection());返回null;}
public Object execute(ExecutionEvent event) throws ExecutionException {
Event selEvent = (Event) event.getTrigger();
MenuItem item = (MenuItem) selEvent.widget;
System.Out.Println(item.getSelection());
return null;
}