Question

I have Developed one plugin in intellij idea, on right click on project I am getting that plugin name but it is always disable. How can I enable that plugin. This is my plugin.xml code :

    <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>
Was it helpful?

Solution

You have to enable presentation in update() method of your action, where should you check whether the input is valid for your case.

@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);
}

You can check the source code of Eclipser plugin, where you will find an elaborate example of the implementation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top