2011-02-03 18 views
0

私はトグルメニューオプションを使用しようとしていますが、おそらく間違いをしています。次のコードで作成されたトグルメニュー項目と私はロード後に初めて、このオプションをクリックすると、それが正常に動作しますが、私は戻って古い状態にそれを切り替えるにはもう一度クリックしたときに、私は次のエラーを取得:Eclipseプラグイン:toggle menuコマンドがハンドラを見つけることができません

org.eclipse.core.commands.NotHandledException: There is no handler to execute for command my.commands.compileAutomatically 
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:485) 
    at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508) 
    at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169) 
    .... 

メニュー:

<command 
    commandId="my.commands.compileAutomatically" 
    label="Compile Automatically" 
    style="toggle"> 
</command> 

コマンド:

<command 
    defaultHandler="my.handlers.CompileAutomaticallyHandler" 
    id="my.commands.compileAutomatically" 
    name="Compile Automatically"> 
    <state 
     class="org.eclipse.ui.handlers.RegistryToggleState:true" 
     id="org.eclipse.ui.commands.toggleState"> 
    </state> 
</command> 

ハンドラ:

public class CompileAutomaticallyHandler extends AbstractHandler { 

    @Override 
    public Object execute(ExecutionEvent event) throws ExecutionException { 
     Command command = event.getCommand(); 
     boolean oldValue = HandlerUtil.toggleCommandState(command); 
     System.out.println(oldValue); 
     return null; 
    } 
} 

誰かが、現在のメニュー状態に関係なく、ハンドラが見つかったコードが間違っていることを理解するのに役立つでしょうか?
ありがとう

答えて

0

CompileAutomaticallyHandlerでisHandled()をオーバーライドしてfalseを返します。

関連する問題