diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNodeInfo.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNodeInfo.java index 838d30aed099..b2103b13215c 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNodeInfo.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNodeInfo.java @@ -16,9 +16,15 @@ package com.intellij.codeInspection.ui; import com.intellij.codeInsight.daemon.HighlightDisplayKey; +import com.intellij.codeInspection.InspectionsBundle; import com.intellij.codeInspection.ex.DisableInspectionToolAction; import com.intellij.codeInspection.ex.InspectionProfileImpl; import com.intellij.codeInspection.ex.InspectionToolWrapper; +import com.intellij.ide.DataManager; +import com.intellij.openapi.actionSystem.ActionManager; +import com.intellij.openapi.actionSystem.ActionPlaces; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.profile.codeInspection.InspectionProjectProfileManager; @@ -50,7 +56,6 @@ public class InspectionNodeInfo extends JPanel { InspectionProfileImpl currentProfile = (InspectionProfileImpl)InspectionProjectProfileManager.getInstance(project).getProjectProfileImpl(); HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName()); - JButton button = new JButton(); boolean enabled = currentProfile.isToolEnabled(key); JPanel titlePanel = new JPanel(); @@ -83,11 +88,7 @@ public class InspectionNodeInfo extends JPanel { add(pane, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.VERTICAL, new JBInsets(0, 10, 0, 0), getFontMetrics(UIUtil.getLabelFont()).charWidth('f') * 110 - pane.getMinimumSize().width, 0)); - add(button, - new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, - new JBInsets(15, 9, 9, 0), 0, 0)); - button.setText((enabled ? "Disable" : "Enable") + " inspection"); - + JButton enableButton = new JButton((enabled ? "Disable" : "Enable") + " inspection"); new ClickListener() { @Override public boolean onClick(@NotNull MouseEvent event, int clickCount) { @@ -102,6 +103,28 @@ public class InspectionNodeInfo extends JPanel { }, project); return true; } - }.installOn(button); + }.installOn(enableButton); + + JButton runInspectionOnButton = new JButton(InspectionsBundle.message("run.inspection.on.file.intention.text")); + new ClickListener() { + @Override + public boolean onClick(@NotNull MouseEvent event, int clickCount) { + final AnAction action = ActionManager.getInstance().getAction("RunInspectionOn"); + action.actionPerformed(AnActionEvent.createFromDataContext(ActionPlaces.UNKNOWN, action.getTemplatePresentation(), + DataManager.getInstance().getDataContext(runInspectionOnButton))); + return true; + } + }.installOn(runInspectionOnButton); + + JPanel buttons = new JPanel(); + buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS)); + buttons.add(enableButton); + buttons.add(Box.createHorizontalStrut(JBUI.scale(3))); + buttons.add(runInspectionOnButton); + + add(buttons, + new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, + new JBInsets(15, 9, 9, 0), 0, 0)); + } } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java index 9c2a95244541..f03f0ee4215c 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -27,7 +27,6 @@ import com.intellij.codeInspection.offlineViewer.OfflineInspectionRVContentProvi import com.intellij.codeInspection.reference.RefElement; import com.intellij.codeInspection.reference.RefEntity; import com.intellij.codeInspection.ui.actions.ExportHTMLAction; -import com.intellij.codeInspection.ui.actions.InspectionsOptionsToolbarAction; import com.intellij.codeInspection.ui.actions.InvokeQuickFixAction; import com.intellij.diff.util.DiffUtil; import com.intellij.icons.AllIcons; @@ -317,7 +316,6 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren specialGroup.add(myGlobalInspectionContext.getUIOptions().createFilterResolvedItemsAction(this)); specialGroup.add(ActionManager.getInstance().getAction("EditInspectionSettings")); specialGroup.add(new InvokeQuickFixAction(this)); - specialGroup.add(new InspectionsOptionsToolbarAction(this)); return createToolbar(specialGroup); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InspectionsOptionsToolbarAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InspectionsOptionsToolbarAction.java deleted file mode 100644 index ff3c80f7db31..000000000000 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InspectionsOptionsToolbarAction.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.intellij.codeInspection.ui.actions; - -import com.intellij.codeInsight.daemon.HighlightDisplayKey; -import com.intellij.codeInspection.InspectionsBundle; -import com.intellij.codeInspection.ex.InspectionToolWrapper; -import com.intellij.codeInspection.ui.InspectionResultsView; -import com.intellij.icons.AllIcons; -import com.intellij.openapi.actionSystem.*; -import com.intellij.openapi.ui.popup.JBPopupFactory; -import com.intellij.openapi.ui.popup.ListPopup; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * User: anna - * Date: 11-Jan-2006 - */ -public class InspectionsOptionsToolbarAction extends AnAction { - private final InspectionResultsView myView; - - public InspectionsOptionsToolbarAction(final InspectionResultsView view) { - super(getToolOptions(null), getToolOptions(null), AllIcons.General.InspectionsOff); - myView = view; - } - - @Override - public void actionPerformed(AnActionEvent e) { - final ListPopup popup = JBPopupFactory.getInstance() - .createActionGroupPopup(getSelectedToolWrapper().getDisplayName(), - (ActionGroup)ActionManager.getInstance().getAction("InspectionsOptions"), - e.getDataContext(), - JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, - false); - InspectionResultsView.showPopup(e, popup); - } - - @Nullable - private InspectionToolWrapper getSelectedToolWrapper() { - return myView.getTree().getSelectedToolWrapper(); - } - - @Override - public void update(AnActionEvent e) { - if (!myView.isSingleToolInSelection()) { - e.getPresentation().setEnabled(false); - return; - } - InspectionToolWrapper toolWrapper = getSelectedToolWrapper(); - assert toolWrapper != null; - final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName()); - if (key == null) { - e.getPresentation().setEnabled(false); - } - e.getPresentation().setEnabled(true); - final String text = getToolOptions(toolWrapper); - e.getPresentation().setText(text); - e.getPresentation().setDescription(text); - } - - @NotNull - private static String getToolOptions(@Nullable final InspectionToolWrapper toolWrapper) { - return InspectionsBundle.message("inspections.view.options.title", toolWrapper != null ? toolWrapper.getDisplayName() : ""); - } -}