Search in sources :

Example 1 with EditInspectionToolsSettingsAction

use of com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction in project intellij-community by JetBrains.

the class EditSettingsAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final InspectionResultsView view = getView(e);
    InspectionProfileImpl inspectionProfile = view.getCurrentProfile();
    if (view.isSingleInspectionRun()) {
        InspectionToolWrapper tool = ObjectUtils.notNull(inspectionProfile.getInspectionTool(ObjectUtils.notNull(inspectionProfile.getSingleTool()), view.getProject()));
        JComponent panel = tool.getTool().createOptionsPanel();
        if (panel != null) {
            final DialogBuilder builder = new DialogBuilder().title(InspectionsBundle.message("inspection.tool.window.inspection.dialog.title", tool.getDisplayName())).centerPanel(panel);
            builder.removeAllActions();
            builder.addOkAction();
            if (view.isRerunAvailable()) {
                builder.addActionDescriptor(new DialogBuilder.DialogActionDescriptor(InspectionsBundle.message("inspection.action.rerun"), 'R') {

                    @Override
                    protected Action createAction(DialogWrapper dialogWrapper) {
                        return new AbstractAction() {

                            @Override
                            public void actionPerformed(ActionEvent e) {
                                view.rerun();
                                dialogWrapper.close(DialogWrapper.OK_EXIT_CODE);
                            }
                        };
                    }
                });
            }
            builder.show();
        } else {
            Messages.showInfoMessage(view.getProject(), InspectionsBundle.message("inspection.tool.window.dialog.no.options", tool.getDisplayName()), InspectionsBundle.message("inspection.tool.window.dialog.title"));
        }
    } else {
        final InspectionToolWrapper toolWrapper = view.getTree().getSelectedToolWrapper(false);
        if (toolWrapper != null) {
            //do not search for dead code entry point tool
            final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName());
            if (key != null) {
                if (new EditInspectionToolsSettingsAction(key).editToolSettings(view.getProject(), inspectionProfile)) {
                    view.updateCurrentProfile();
                }
                return;
            }
        }
        final String[] path = view.getTree().getSelectedGroupPath();
        if (EditInspectionToolsSettingsAction.editSettings(view.getProject(), inspectionProfile, (c) -> {
            if (path != null) {
                c.selectInspectionGroup(path);
            }
        })) {
            view.updateCurrentProfile();
        }
    }
}
Also used : InspectionProfileImpl(com.intellij.codeInspection.ex.InspectionProfileImpl) EditInspectionToolsSettingsAction(com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction) ActionEvent(java.awt.event.ActionEvent) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) HighlightDisplayKey(com.intellij.codeInsight.daemon.HighlightDisplayKey) InspectionResultsView(com.intellij.codeInspection.ui.InspectionResultsView) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) EditInspectionToolsSettingsAction(com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) InspectionToolWrapper(com.intellij.codeInspection.ex.InspectionToolWrapper)

Example 2 with EditInspectionToolsSettingsAction

use of com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction in project intellij-community by JetBrains.

the class EmptyIntentionInspectionQuickFixTest method testLowPriority.

public void testLowPriority() throws Exception {
    configureByFile(getBasePath() + "/LowPriority.java");
    List<IntentionAction> emptyActions = getAvailableActions();
    int i = 0;
    for (; i < emptyActions.size(); i++) {
        final IntentionAction intentionAction = emptyActions.get(i);
        if ("Make 'i' not final".equals(intentionAction.getText())) {
            break;
        }
        if (intentionAction instanceof EmptyIntentionAction) {
            fail("Low priority action prior to quick fix");
        }
    }
    assertTrue(i < emptyActions.size());
    for (; i < emptyActions.size(); i++) {
        if (emptyActions.get(i) instanceof EditInspectionToolsSettingsAction) {
            return;
        }
    }
    fail("Missed inspection setting action");
}
Also used : EmptyIntentionAction(com.intellij.codeInsight.intention.EmptyIntentionAction) IntentionAction(com.intellij.codeInsight.intention.IntentionAction) EmptyIntentionAction(com.intellij.codeInsight.intention.EmptyIntentionAction) EditInspectionToolsSettingsAction(com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction)

Aggregations

EditInspectionToolsSettingsAction (com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction)2 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)1 EmptyIntentionAction (com.intellij.codeInsight.intention.EmptyIntentionAction)1 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)1 InspectionProfileImpl (com.intellij.codeInspection.ex.InspectionProfileImpl)1 InspectionToolWrapper (com.intellij.codeInspection.ex.InspectionToolWrapper)1 InspectionResultsView (com.intellij.codeInspection.ui.InspectionResultsView)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 DialogBuilder (com.intellij.openapi.ui.DialogBuilder)1 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)1 ActionEvent (java.awt.event.ActionEvent)1