【问题标题】:Intellij idea plugin development : plugin not enabled on right click on projectIntellij idea 插件开发:右键单击项目时未启用插件
【发布时间】:2014-06-13 21:27:54
【问题描述】:

我在 intellij idea 中开发了一个插件,右键单击项目我得到了该插件名称,但它总是被禁用。如何启用该插件。这是我的 plugin.xml 代码:

    <actions>
       <group id="GenerateCRUDAction.GenerateCRUD" text="_GenerateCRUD" description="GenerateCRUD" popup="true">
           <action id="generateCrud" class="com.im.ui.crud.GenerateCrudAction" text="generateCrud"
                   description="generateCrud action">
           </action>
           <add-to-group group-id="ProjectViewPopupMenuRunGroup" anchor="last"/>
       </group>
   </actions>

【问题讨论】:

    标签: java plugins intellij-plugin intellij-13


    【解决方案1】:

    您必须在您的操作的update() 方法中启用演示,您应该在哪里检查输入是否对您的案例有效。

    @Override
    public void update(@NotNull AnActionEvent e) {
    
        final Presentation presentation = e.getPresentation();
        final Project project = e.getProject();
    
        if (project == null) {
            presentation.setEnabledAndVisible(false);
            return;
        }
        presentation.setEnabledAndVisible(true);
    }
    

    您可以查看Eclipser 插件的源代码,您可以在其中找到详细的实现示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-03
      • 1970-01-01
      • 1970-01-01
      • 2014-07-13
      • 2018-04-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多