Eclipse rcp 工具栏中的无线电命令

Eclipse rcp 工具栏中的无线电命令,eclipse-rcp,Eclipse Rcp,我正在构建一个插件,以某种独特的风格显示图像。 想象一下你有一个彩色图像,你可以选择“黑白”或“深褐色”等样式 我的插件是这样的: <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> <plugin> <extension point="org.eclipse.ui.commands"> <command

我正在构建一个插件,以某种独特的风格显示图像。 想象一下你有一个彩色图像,你可以选择“黑白”或“深褐色”等样式

我的插件是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         point="org.eclipse.ui.commands">
      <command
            categoryId="fr.comp.app.category"
            defaultHandler="fr.comp.common.styles.impl.DefaultStyle"
            id="fr.comp.common.styles.defaultStyle"
            name="Default Style">
         <state
               class="org.eclipse.ui.handlers.RadioState"
               id="org.eclipse.ui.commands.radioState">
         </state>
      </command>
      <command
            categoryId="fr.comp.app.category"
            defaultHandler="fr.comp.common.styles.impl.SepiaStyle"
            id="fr.comp.common.styles.SepiaStyle"
            name="Print Style">
         <state
               class="org.eclipse.ui.handlers.RadioState"
               id="org.eclipse.ui.commands.radioState">
         </state>
      </command>
   </extension>
   <extension
         point="org.eclipse.ui.bindings">
      <key
            commandId="fr.comp.common.styles.defaultStyle"
            contextId="org.eclipse.ui.contexts.window"
            schemeId="fr.comp.app.scheme"
            sequence="F1">
      </key>
      <key
            commandId="fr.comp.common.styles.SepiaStyle"
            contextId="org.eclipse.ui.contexts.window"
            schemeId="fr.comp.app.scheme"
            sequence="F6">
      </key>
   </extension>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="toolbar:org.eclipse.ui.main.toolbar">
         <toolbar
               id="fr.comp.app.style.toolbar">
            <command
                  commandId="fr.comp.common.styles.defaultStyle"
                  icon="resources/default.png"
                  style="radio">
            </command>
            <command
                  commandId="fr.comp.common.styles.SepiaStyle"
                  icon="resources/sepia.png"
                  style="radio">
            </command>
         </toolbar>
      </menuContribution>
   </extension>
</plugin>
public Object execute(ExecutionEvent event) throws ExecutionException {

    // blabla change the style 
    final IStyleManager styleManager = MagicHub.getService(IStyleManager.class);
    // ... end blabla

    // change the state of the org.eclipse.ui.commands.radioState of the cmd
    Command command = event.getCommand();
    State state = command.getState(RadioState.STATE_ID);
    state.setValue(Boolean.TRUE);

    return null;
}
好的,现在我有了一个很好的工具栏,可以显示我的命令。 我可以单击它们,然后应用样式。 我也可以使用我的键绑定,而且样式也适用

但是,当我使用键绑定时,收音机按钮不能正确切换。 我做错了什么

顺便说一句:我的目标平台是开普勒