简体   繁体   中英

Command activation in menu eclipse plugin

I'd like to make a menu in my View Menu to let the user choose how to display the view by choosing one of my menu entries.

So, I did add a menu contributing to my view, and added two commands in it of style "Radio", I put both command pointing on the same command name and added two differents values in it. I declared a new Command, a new Handler, and my handler works fine as I did put a sysout "Handler Executed" and everytime I open the menu in my view I the function "isEnabled" is being executed.

My problem is that, I can't click on my radios button and I've no idea of why. There is no warnings in my plugin.xml and I don't get the reason it refuse to work.

Commands proc "isEnabled" but it's impossible to select entries

Thank you in advance if you help me on it, I feel kind of stuck here :/

Here is my plugin.xml. Extension menu :

<menuContribution
            allPopups="false"
            locationURI="menu:fr.sumo.ui.view.MyView">
         <command
               commandId="fr.sumo.ui.handlers.ShowTreeViewerHandler"
               label="Command1"
               style="push">
            <parameter
                  name="fr.sumo.ui.commands.ShowTreeViewerHandler"
                  value="RuleTreeViewer">
            </parameter>
         </command>
         <command
               commandId="fr.sumo.ui.handlers.ShowTreeViewerHandler"
               label="Command2"
               style="push">
            <parameter
                  name="fr.sumo.ui.commands.ShowTreeViewerHandler"
                  value="FileTreeViewer">
            </parameter>
         </command>
      </menuContribution>

Extension of Commands :

<command
        id="fr.sumo.ui.handlers.ShowTreeViewerHandler"
        name="Show Rule TreeViewer">
     <commandParameter
           id="fr.sumo.ui.commands.ShowTreeViewerHandler"
           name="fr.sumo.ui.commands.ShowTreeViewerHandler">
     </commandParameter>
  </command>

Extension of handlers :

 <handler
        class="fr.sumo.ui.handler.ShowRuleTreeViewerHandler"
        commandId="fr.sumo.ui.handlers.ShowTreeViewerHandler">
 </handler>

So I finally found my answer which is a little bit obvious. In my handler class, the method isEnabled() was returning false that was the reason my items weren't clickable. Just had to turn it to true.

@Override
public boolean isEnabled() {
    System.out.println("isEnabled !");
    return false;
}

Thank you btw ppl who might have tryed to find the problem in my plugin.xml ^^

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM