Search in sources :

Example 16 with DialogWrapper

use of com.intellij.openapi.ui.DialogWrapper 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 17 with DialogWrapper

use of com.intellij.openapi.ui.DialogWrapper in project intellij-community by JetBrains.

the class EntryPointsManagerImpl method createConfigureClassPatternsButton.

public static JButton createConfigureClassPatternsButton() {
    final JButton configureClassPatterns = new JButton("Code patterns...");
    configureClassPatterns.setHorizontalAlignment(SwingConstants.LEFT);
    configureClassPatterns.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final Project project = ProjectUtil.guessCurrentProject(configureClassPatterns);
            final EntryPointsManagerBase entryPointsManagerBase = getInstance(project);
            final ArrayList<ClassPattern> list = new ArrayList<>();
            for (ClassPattern pattern : entryPointsManagerBase.getPatterns()) {
                list.add(new ClassPattern(pattern));
            }
            final ClassPatternsPanel panel = new ClassPatternsPanel(list);
            new DialogWrapper(entryPointsManagerBase.myProject) {

                {
                    init();
                    setTitle("Configure Code Patterns");
                }

                @Nullable
                @Override
                protected JComponent createCenterPanel() {
                    return panel;
                }

                @Override
                protected void doOKAction() {
                    final String error = panel.getValidationError(project);
                    if (error != null) {
                        Messages.showErrorDialog(panel, error);
                        return;
                    }
                    final LinkedHashSet<ClassPattern> patterns = entryPointsManagerBase.getPatterns();
                    patterns.clear();
                    patterns.addAll(list);
                    DaemonCodeAnalyzer.getInstance(entryPointsManagerBase.myProject).restart();
                    super.doOKAction();
                }
            }.show();
        }
    });
    return configureClassPatterns;
}
Also used : ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) Project(com.intellij.openapi.project.Project) ActionListener(java.awt.event.ActionListener)

Example 18 with DialogWrapper

use of com.intellij.openapi.ui.DialogWrapper in project intellij-community by JetBrains.

the class EntryPointsManagerImpl method configureAnnotations.

@Override
public void configureAnnotations() {
    final List<String> list = new ArrayList<>(ADDITIONAL_ANNOTATIONS);
    final List<String> writeList = new ArrayList<>(myWriteAnnotations);
    final JPanel listPanel = SpecialAnnotationsUtil.createSpecialAnnotationsListControl(list, "Mark as entry point if annotated by", true);
    Condition<PsiClass> applicableToField = psiClass -> {
        Set<PsiAnnotation.TargetType> annotationTargets = AnnotationTargetUtil.getAnnotationTargets(psiClass);
        return annotationTargets != null && annotationTargets.contains(PsiAnnotation.TargetType.FIELD);
    };
    final JPanel writtenAnnotationsPanel = SpecialAnnotationsUtil.createSpecialAnnotationsListControl(writeList, "Mark field as implicitly written if annotated by", false, applicableToField);
    new DialogWrapper(myProject) {

        {
            init();
            setTitle("Configure Annotations");
        }

        @Override
        protected JComponent createCenterPanel() {
            final JPanel panel = new JPanel(new VerticalFlowLayout());
            panel.add(listPanel);
            panel.add(writtenAnnotationsPanel);
            return panel;
        }

        @Override
        protected void doOKAction() {
            ADDITIONAL_ANNOTATIONS.clear();
            ADDITIONAL_ANNOTATIONS.addAll(list);
            myWriteAnnotations.clear();
            myWriteAnnotations.addAll(writeList);
            DaemonCodeAnalyzer.getInstance(myProject).restart();
            super.doOKAction();
        }
    }.show();
}
Also used : SpecialAnnotationsUtil(com.intellij.codeInspection.util.SpecialAnnotationsUtil) ActionListener(java.awt.event.ActionListener) PersistentStateComponent(com.intellij.openapi.components.PersistentStateComponent) Set(java.util.Set) DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer) ProjectUtil(com.intellij.openapi.project.ProjectUtil) ActionEvent(java.awt.event.ActionEvent) AnnotationTargetUtil(com.intellij.codeInsight.AnnotationTargetUtil) ArrayList(java.util.ArrayList) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout) Nullable(org.jetbrains.annotations.Nullable) PsiClass(com.intellij.psi.PsiClass) List(java.util.List) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) State(com.intellij.openapi.components.State) PsiAnnotation(com.intellij.psi.PsiAnnotation) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) Element(org.jdom.Element) LinkedHashSet(java.util.LinkedHashSet) Condition(com.intellij.openapi.util.Condition) javax.swing(javax.swing) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) ArrayList(java.util.ArrayList) PsiClass(com.intellij.psi.PsiClass) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) PsiAnnotation(com.intellij.psi.PsiAnnotation) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout)

Example 19 with DialogWrapper

use of com.intellij.openapi.ui.DialogWrapper in project android by JetBrains.

the class RenameCaptureFileAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();
    VirtualFile virtualFile = e.getData(CommonDataKeys.VIRTUAL_FILE);
    DialogWrapper dialog = new RenameDialog(project, virtualFile);
    dialog.show();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) DialogWrapper(com.intellij.openapi.ui.DialogWrapper)

Example 20 with DialogWrapper

use of com.intellij.openapi.ui.DialogWrapper in project android by JetBrains.

the class GenerateSignedApkAction method checkFacet.

private static boolean checkFacet(@NotNull AndroidFacet facet) {
    final CheckModulePanel panel = new CheckModulePanel();
    panel.updateMessages(facet);
    final boolean hasError = panel.hasError();
    if (hasError || panel.hasWarnings()) {
        DialogWrapper dialog = new DialogWrapper(facet.getModule().getProject()) {

            {
                if (!hasError) {
                    setOKButtonText("Continue");
                }
                init();
            }

            @NotNull
            @Override
            protected Action[] createActions() {
                if (hasError) {
                    return new Action[] { getOKAction() };
                }
                return super.createActions();
            }

            @Override
            protected JComponent createCenterPanel() {
                return panel;
            }
        };
        dialog.setTitle(hasError ? CommonBundle.getErrorTitle() : CommonBundle.getWarningTitle());
        dialog.show();
        return !hasError && dialog.isOK();
    }
    return true;
}
Also used : CheckModulePanel(org.jetbrains.android.exportSignedPackage.CheckModulePanel) AnAction(com.intellij.openapi.actionSystem.AnAction) DialogWrapper(com.intellij.openapi.ui.DialogWrapper)

Aggregations

DialogWrapper (com.intellij.openapi.ui.DialogWrapper)37 Project (com.intellij.openapi.project.Project)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 ActionEvent (java.awt.event.ActionEvent)6 Nullable (org.jetbrains.annotations.Nullable)6 JBScrollPane (com.intellij.ui.components.JBScrollPane)5 ActionListener (java.awt.event.ActionListener)4 AnAction (com.intellij.openapi.actionSystem.AnAction)3 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)3 Document (com.intellij.openapi.editor.Document)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 MockDocument (com.intellij.mock.MockDocument)2 MockPsiFile (com.intellij.mock.MockPsiFile)2 javax.swing (javax.swing)2 HyperlinkEvent (javax.swing.event.HyperlinkEvent)2 NotNull (org.jetbrains.annotations.NotNull)2 AnnotationTargetUtil (com.intellij.codeInsight.AnnotationTargetUtil)1 DaemonCodeAnalyzer (com.intellij.codeInsight.daemon.DaemonCodeAnalyzer)1 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)1