inspection toolwindow: disable add as entry point action if all selected elements are already EPs

This commit is contained in:
Dmitry Batkovich
2016-06-15 15:03:46 +03:00
parent 15deebc3d5
commit 6a279fb5c8
@@ -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();