简体   繁体   English

菜单eclipse插件中的命令激活

[英]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. 我声明了一个新的命令,一个新的处理程序,并且我的处理程序工作正常,因为我确实将sysout设置为“ Handler Executed”,并且每次在视图中打开菜单时,都会执行“ isEnabled”功能。

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. 我的plugin.xml中没有警告,我不知道它拒绝工作的原因。

Commands proc "isEnabled" but it's impossible to select entries 命令proc“ isEnabled”,但无法选择条目

Thank you in advance if you help me on it, I feel kind of stuck here :/ 如果您能帮助我,请先谢谢您,我感觉有点卡在这里:/

Here is my plugin.xml. 这是我的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. 在我的处理程序类中,方法isEnabled()返回false ,这是我的项目不可点击的原因。 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 ^^ 谢谢btw ppl,谁可能尝试在我的plugin.xml中查找问题^^

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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