Search in sources :

Example 1 with DialogBuilder

use of com.intellij.openapi.ui.DialogBuilder in project freeline by alibaba.

the class FreelineUtil method checkInstall.

/**
     * 检查是否需要载入Freeline
     *
     * @param project
     * @return
     */
public static boolean checkInstall(@NotNull final Project project) {
    final FreelineStatus status = getFreelineStatus(project);
    if (GradleUtil.isSyncInProgress(project)) {
        NotificationUtils.errorMsgDialog("Waiting for sync project to complete");
        return false;
    }
    if (status.hasInitFreeline()) {
        return true;
    }
    if (status.getGradleBuildFiles().size() < 1) {
        NotificationUtils.errorMsgDialog("It's not an Android Gradle project Currently?");
        return false;
    }
    if (status.isExistClasspath() && status.isExistPlugin() && !status.isExistFreelineCore()) {
        NotificationUtils.errorNotification("Execute task initFreeline and download freeline dependencies...");
        initFreeline(project);
        return false;
    }
    if (DialogUtil.createDialog("Detected that you did not installFreeline Freeline, Whether installFreeline Automatically?", "Install Freeline Automatically", "Cancel")) {
        Module[] modules = ModuleManager.getInstance(project).getModules();
        List<Pair<Module, PsiFile>> selectModulesList = new ArrayList<Pair<Module, PsiFile>>();
        for (Module module : modules) {
            GradleBuildFile file = GradleBuildFile.get(module);
            if (file != null && !GradleUtil.isLibrary(file)) {
                selectModulesList.add(Pair.create(module, file.getPsiFile()));
            }
        }
        // 多个app模块的情况
        if (selectModulesList.size() > 1) {
            final DialogBuilder builder = new DialogBuilder();
            builder.setTitle("Install Freeline");
            builder.resizable(false);
            builder.setCenterPanel(new JLabel("There are multiple application modules, Please select the module to be installed Freeline.", Messages.getInformationIcon(), SwingConstants.CENTER));
            builder.addOkAction().setText("Cancel");
            for (final Pair<Module, PsiFile> pair : selectModulesList) {
                builder.addAction(new AbstractAction(":" + pair.first.getName()) {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE);
                        installFreeline(project, status, pair.getSecond());
                    }
                });
            }
            if (builder.show() > -1) {
                return false;
            }
        } else if (selectModulesList.size() == 1) {
            installFreeline(project, status, selectModulesList.get(0).getSecond());
        } else {
            NotificationUtils.errorMsgDialog("Can not found Application Module! Please Sync Project.");
            return false;
        }
    }
    return false;
}
Also used : GradleBuildFile(com.android.tools.idea.gradle.parser.GradleBuildFile) ActionEvent(java.awt.event.ActionEvent) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) Pair(com.intellij.openapi.util.Pair)

Example 2 with DialogBuilder

use of com.intellij.openapi.ui.DialogBuilder in project freeline by alibaba.

the class UsingReportAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent event) {
    final Project project = event.getProject();
    Module[] modules = ModuleManager.getInstance(project).getModules();
    List<Pair<Module, PsiFile>> selectModulesList = new ArrayList<Pair<Module, PsiFile>>();
    for (Module module : modules) {
        GradleBuildFile file = GradleBuildFile.get(module);
        if (file != null && !GradleUtil.isLibrary(file)) {
            selectModulesList.add(Pair.create(module, file.getPsiFile()));
        }
    }
    if (selectModulesList.size() > 1) {
        final DialogBuilder builder = new DialogBuilder();
        builder.setTitle("Freeline Reporter");
        builder.resizable(false);
        builder.setCenterPanel(new JLabel("There are multiple application modules, Please select the exact one.", Messages.getInformationIcon(), SwingConstants.CENTER));
        builder.addOkAction().setText("Cancel");
        for (final Pair<Module, PsiFile> pair : selectModulesList) {
            builder.addAction(new AbstractAction(":" + pair.first.getName()) {

                @Override
                public void actionPerformed(ActionEvent e) {
                    builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE);
                    report(project, pair.getSecond());
                }
            });
        }
        if (builder.show() > -1) {
        //return false;
        }
    } else if (selectModulesList.size() == 1) {
        report(project, selectModulesList.get(0).getSecond());
    }
}
Also used : GradleBuildFile(com.android.tools.idea.gradle.parser.GradleBuildFile) ActionEvent(java.awt.event.ActionEvent) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) ArrayList(java.util.ArrayList) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) Pair(com.intellij.openapi.util.Pair)

Example 3 with DialogBuilder

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

the class GroupList method showDialog.

public static String showDialog(PsiClass[] classes, JComponent component) {
    GroupList groupList = new GroupList(classes);
    DialogBuilder builder = new DialogBuilder(component);
    builder.setCenterPanel(groupList);
    builder.setPreferredFocusComponent(groupList.list);
    builder.setTitle("Choose Test Group");
    return builder.show() != 0 ? null : groupList.getSelected();
}
Also used : DialogBuilder(com.intellij.openapi.ui.DialogBuilder)

Example 4 with DialogBuilder

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

the class CCChangeCourseInfo method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    if (project == null) {
        return;
    }
    Course course = StudyTaskManager.getInstance(project).getCourse();
    if (course == null) {
        return;
    }
    CCNewProjectPanel panel = new CCNewProjectPanel(course.getName(), Course.getAuthorsString(course.getAuthors()), course.getDescription());
    setupLanguageLevels(course, panel);
    DialogBuilder builder = createChangeInfoDialog(project, panel);
    if (builder.showAndGet()) {
        course.setAuthorsAsString(panel.getAuthors());
        course.setName(panel.getName());
        course.setDescription(panel.getDescription());
        setVersion(course, panel);
        ProjectView.getInstance(project).refresh();
        ProjectInspectionProfileManager.getInstance(project).fireProfileChanged();
    }
}
Also used : Project(com.intellij.openapi.project.Project) Course(com.jetbrains.edu.learning.courseFormat.Course) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) CCNewProjectPanel(com.jetbrains.edu.coursecreator.ui.CCNewProjectPanel)

Example 5 with DialogBuilder

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

the class QuickMergeInteractionImpl method selectMergeVariant.

@NotNull
@Override
public QuickMergeContentsVariants selectMergeVariant() {
    QuickMergeWayOptionsPanel panel = new QuickMergeWayOptionsPanel();
    DialogBuilder builder = new DialogBuilder(myProject);
    builder.title("Select Merge Variant").centerPanel(panel.getMainPanel()).removeAllActions();
    panel.setWrapper(builder.getDialogWrapper());
    builder.show();
    return panel.getVariant();
}
Also used : DialogBuilder(com.intellij.openapi.ui.DialogBuilder) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

DialogBuilder (com.intellij.openapi.ui.DialogBuilder)32 ActionEvent (java.awt.event.ActionEvent)7 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)4 Project (com.intellij.openapi.project.Project)4 Module (com.intellij.openapi.module.Module)3 GradleBuildFile (com.android.tools.idea.gradle.parser.GradleBuildFile)2 Disposable (com.intellij.openapi.Disposable)2 AnAction (com.intellij.openapi.actionSystem.AnAction)2 CustomShortcutSet (com.intellij.openapi.actionSystem.CustomShortcutSet)2 EditorEx (com.intellij.openapi.editor.ex.EditorEx)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 FrameWrapper (com.intellij.openapi.ui.FrameWrapper)2 MultiLineLabel (com.intellij.openapi.ui.ex.MultiLineLabel)2 Pair (com.intellij.openapi.util.Pair)2 PsiFile (com.intellij.psi.PsiFile)2 JBTextField (com.intellij.ui.components.JBTextField)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 ApkDiffPanel (com.android.tools.idea.apk.viewer.diff.ApkDiffPanel)1 ApkDiffParser (com.android.tools.idea.apk.viewer.diff.ApkDiffParser)1