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;
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();
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) {
}, 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));
+
}
}
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;
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);
}
+++ /dev/null
-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() : "");
- }
-}