inspection toolwindow: disable add as entry point action if all selected elements...
authorDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Wed, 15 Jun 2016 12:03:19 +0000 (15:03 +0300)
committerDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Wed, 15 Jun 2016 12:03:46 +0000 (15:03 +0300)
java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java

index 28f3a2e9dfce28652acf97cd135b98e655d656fc..69056e49d799af7e40e73011a579a861b3e1f041 100644 (file)
@@ -23,6 +23,7 @@ import com.intellij.codeInspection.ui.*;
 import com.intellij.codeInspection.util.RefFilter;
 import com.intellij.icons.AllIcons;
 import com.intellij.lang.annotation.HighlightSeverity;
+import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.Editor;
@@ -211,6 +212,20 @@ public class UnusedDeclarationPresentation extends DefaultInspectionToolPresenta
       super(InspectionsBundle.message("inspection.dead.code.entry.point.quickfix"), null, KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0), toolWrapper);
     }
 
+    @Override
+    public void update(AnActionEvent e) {
+      super.update(e);
+      if (e.getPresentation().isEnabledAndVisible()) {
+        final RefEntity[] elements = getInvoker(e).getTree().getSelectedElements();
+        for (RefEntity element : elements) {
+          if (!((RefElement) element).isEntry()) {
+            return;
+          }
+        }
+        e.getPresentation().setEnabled(false);
+      }
+    }
+
     @Override
     protected boolean applyFix(@NotNull RefEntity[] refElements) {
       final EntryPointsManager entryPointsManager = getEntryPointsManager();