Example usage for com.intellij.openapi.ui Messages showErrorDialog

List of usage examples for com.intellij.openapi.ui Messages showErrorDialog

Introduction

In this page you can find the example usage for com.intellij.openapi.ui Messages showErrorDialog.

Prototype

public static void showErrorDialog(@Nullable Component component, String message,
            @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title) 

Source Link

Usage

From source file:consulo.google.appengine.server.ui.GoogleAppEngineAccountDialog.java

License:Apache License

@Override
protected void doOKAction() {
    final String email = getEmail();
    if (myConfiguration != null) {
        myConfiguration.setEmail(email);
    } else {//from   ww w.  ja  va 2 s .c om
        PropertiesComponent.getInstance(myProject).setValue(EMAIL_KEY, email);
    }
    if (myRememberPasswordCheckBox.isSelected()) {
        try {
            PasswordSafe.getInstance().storePassword(myProject, GoogleAppEngineAccountDialog.class,
                    getPasswordKey(email), getPassword());
        } catch (PasswordSafeException e) {
            Messages.showErrorDialog(myProject, "Cannot store password: " + e.getMessage(),
                    CommonBundle.getErrorTitle());
            return;
        }
    }
    super.doOKAction();
}

From source file:de.bewalt.intellij.plugin.psl.UpdateModulesFromPsfAction.java

License:Apache License

/**
 * Implement this method to provide your action handler.
 *
 * @param event Carries information on the invocation place
 *///from w  ww. jav  a  2s .c o m
@Override
public void actionPerformed(AnActionEvent event) {
    boolean isAModuleCheckedOut = false;
    CompositeOperation operation = new CompositeOperation();

    XmlFile xmlFile = (XmlFile) LangDataKeys.PSI_FILE.getData(event.getDataContext());

    Project project = event.getProject();

    if (project == null || xmlFile == null) {
        // this should not happen
        return;
    }

    XmlDocument document = xmlFile.getDocument();
    if (document == null) {
        Messages.showErrorDialog(project, "Invalid project set file", "Can't Update Modules");
        return;
    }
    XmlTag rootTag = document.getRootTag();
    if (rootTag == null) {
        Messages.showErrorDialog(project, "Invalid project set file", "Can't Update Modules");
        return;
    }
    for (XmlTag xmlTag : rootTag.getSubTags()) {
        if (xmlTag.getLocalName().equals("provider")) {
            String idAttributeValue = xmlTag.getAttributeValue("id", null);
            if (idAttributeValue != null && !idAttributeValue.equals("org.eclipse.team.cvs.core.cvsnature")) {
                Messages.showErrorDialog(project, "Unsupported provider in project set file",
                        "Can't Update Modules");
                return;
            } else {
                for (XmlTag projectTag : xmlTag.getSubTags()) {
                    if (projectTag.getLocalName().equals("project")) {
                        String projectReference = projectTag.getAttributeValue("reference", null);
                        ProjectReference reference = new ProjectReference(projectReference);

                        UpdateSettings settings = createSettings(reference);

                        Module module = getModule(project, reference);
                        if (module != null) {
                            ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
                            VirtualFile[] roots = rootManager.getContentRoots();
                            FilePath[] files = new FilePath[roots.length];

                            for (int i = 0; i < roots.length; i++) {
                                VirtualFile root = roots[i];
                                files[i] = FilePathImpl.create(root);
                            }

                            operation.addOperation(new UpdateOperation(files, settings, project));
                        } else {
                            if (reference.connection.indexOf('@') < 0) {
                                Messages.showErrorDialog(project,
                                        "For initial check out of modules you need to define a user in the project set file CVS root configurations",
                                        "Can't check out module " + reference.remoteModuleName);
                            } else {
                                VirtualFile baseDir = project.getBaseDir();
                                final CvsApplicationLevelConfiguration config = CvsApplicationLevelConfiguration
                                        .getInstance();
                                final KeywordSubstitutionWrapper substitution = KeywordSubstitutionWrapper
                                        .getValue(config.CHECKOUT_KEYWORD_SUBSTITUTION);
                                CvsRootConfiguration environment = config
                                        .getConfigurationForCvsRoot(reference.connection);

                                CheckoutProjectOperation checkoutProjectOperation = new CheckoutProjectOperation(
                                        new String[] { reference.remoteModuleName },
                                        new ModifiedCvsEnvironmentProxy(environment,
                                                new SimpleRevision(reference.stickyTag)),
                                        false, new File(baseDir.getCanonicalPath()), reference.localModuleName,
                                        true, substitution == null ? null : substitution.getSubstitution());

                                operation.addOperation(checkoutProjectOperation);
                                isAModuleCheckedOut = true;
                            }
                        }
                    }
                }
            }
        }
    }

    try {
        CvsVcs2.executeOperation("Update from project set file", operation, project);

        if (isAModuleCheckedOut) {
            Messages.showInfoMessage(project,
                    "Please run import module action to recognize the newly checked out modules.",
                    "New Modules Were Checked Out");
        }
    } catch (VcsException e) {
        Messages.showErrorDialog(project, "Error while updating: " + e.getMessage(), "Update Error");
    }
}

From source file:de.fu_berlin.inf.dpp.intellij.ui.util.SafeDialogUtils.java

License:Open Source License

public static void showError(final String message, final String title) {
    UIUtil.invokeAndWaitIfNeeded(new Runnable() {
        @Override/*from www  . j a va2 s  .  co  m*/
        public void run() {
            Messages.showErrorDialog(saros.getProject(), message, title);
        }
    });
}

From source file:de.fu_berlin.inf.dpp.intellij.ui.util.SafeDialogUtils.java

License:Open Source License

public static void showError(final Component component, final String message, final String title) {
    UIUtil.invokeAndWaitIfNeeded(new Runnable() {
        @Override//from   www.  ja  va 2  s.  c o  m
        public void run() {
            Messages.showErrorDialog(component, message, title);
        }
    });
}

From source file:defrac.intellij.action.create.MultiPlatformCreateAction.java

License:Apache License

@Nullable
protected static PsiFile createFileFromTemplate(@Nullable String name, @NotNull FileTemplate template,
        @NotNull PsiDirectory dir, @Nullable String defaultTemplateProperty,
        @NotNull final DefracPlatform platform, @NotNull final Set<DefracPlatform> enabledPlatforms) {
    if (name != null) {
        final CreateFileAction.MkDirs mkdirs = new CreateFileAction.MkDirs(name, dir);
        name = mkdirs.newName;//from   ww  w.  ja v a2s  .  c o m
        dir = mkdirs.directory;
    }

    PsiElement element;
    Project project = dir.getProject();

    try {
        final Properties properties = FileTemplateManager.getInstance(project).getDefaultProperties();

        //minus one for generic
        final boolean isAllPlatforms = enabledPlatforms.size() == (DefracPlatform.values().length - 1);

        for (final DefracPlatform enabledPlatform : enabledPlatforms) {
            properties.setProperty(getPlatformKey(enabledPlatform), Boolean.TRUE.toString());
        }

        if (isAllPlatforms) {
            properties.setProperty(PLATFORM_ALL, Boolean.TRUE.toString());
        }

        element = FileTemplateUtil.createFromTemplate(template, name, properties, dir);

        final PsiFile psiFile = element.getContainingFile();
        final VirtualFile virtualFile = psiFile.getVirtualFile();

        if (virtualFile != null) {
            if (platform.isGeneric()) {
                FileEditorManager.getInstance(project).openFile(virtualFile, true);
            }

            if (defaultTemplateProperty != null) {
                PropertiesComponent.getInstance(project).setValue(defaultTemplateProperty, template.getName());
            }

            return psiFile;
        }
    } catch (final ParseException parseException) {
        Messages.showErrorDialog(project, "Error parsing Velocity template: " + parseException.getMessage(),
                "Create File from Template");
        return null;
    } catch (final IncorrectOperationException incorrectOperation) {
        throw incorrectOperation;
    } catch (final Exception exception) {
        LOG.error(exception);
    }

    return null;
}

From source file:git4idea.actions.GitCheckout.java

License:Apache License

@Override
protected void perform(@NotNull Project project, GitVcs vcs, @NotNull List<VcsException> exceptions,
        @NotNull VirtualFile[] affectedFiles) throws VcsException {
    saveAll();/*  w w  w.  j a v a 2  s. c om*/

    final VirtualFile[] roots = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(vcs);
    List<GitBranch> branches;

    for (VirtualFile root : roots) {
        GitCommand command = new GitCommand(project, vcs.getSettings(), root);
        branches = command.branchList();

        String[] branchesList = new String[branches.size()];
        String selectedBranch = null;
        int i = 0;
        for (GitBranch b : branches) {
            branchesList[i++] = b.getName();
            if (selectedBranch == null || b.isActive())
                selectedBranch = b.getName();
        }

        String branchName = Messages.showEditableChooseDialog("Select branch to checkout", "Checkout Branch",
                Messages.getQuestionIcon(), branchesList, selectedBranch, new GitBranchNameValidator());

        if (branchName == null)
            return;
        selectedBranch = null;
        for (GitBranch b : branches) {
            if (branchName.equals(b.getName())) {
                selectedBranch = branchName;
            }
        }

        String[] args = new String[1];
        if (selectedBranch != null) {
            args[0] = selectedBranch;
        } else {
            args[0] = branchName;
        }

        GitCommandRunnable cmdr = new GitCommandRunnable(project, vcs.getSettings(), root);
        cmdr.setCommand(GitCommand.CHECKOUT_CMD);
        cmdr.setArgs(args);

        ProgressManager manager = ProgressManager.getInstance();
        //TODO: make this async so the git command output can be seen in the version control window as it happens...
        manager.runProcessWithProgressSynchronously(cmdr, "Checkout " + args[0], false, project);

        VcsException ex = cmdr.getException();
        if (ex != null)
            Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git checkout'");
    }
}

From source file:git4idea.actions.GitClone.java

License:Apache License

@Override
public void perform(@NotNull Project project, GitVcs vcs, @NotNull List<VcsException> exceptions,
        @NotNull VirtualFile[] affectedFiles) throws VcsException {
    saveAll();//w w w.j  a v  a  2 s . com

    // TODO: implement remote repository login/password - setup remote repos in Git config,
    // TODO: then just reference repo name here
    final String src_repo = Messages.showInputDialog(project, "Specify source repository URL", "clone",
            Messages.getQuestionIcon());
    if (src_repo == null)
        return;

    FileChooserDescriptor fcd = new FileChooserDescriptor(false, true, false, false, false, false);
    fcd.setShowFileSystemRoots(true);
    fcd.setTitle("Destination Directory");
    fcd.setDescription("Select destination directory for clone.");
    fcd.setHideIgnored(false);
    VirtualFile[] files = FileChooser.chooseFiles(project, fcd, null);
    if (files.length != 1 || files[0] == null) {
        return;
    }

    final Map<VirtualFile, List<VirtualFile>> roots = GitUtil.sortFilesByVcsRoot(project, affectedFiles);
    for (VirtualFile root : roots.keySet()) {
        GitCommandRunnable cmdr = new GitCommandRunnable(project, vcs.getSettings(), root);
        cmdr.setCommand(GitCommand.CLONE_CMD);
        cmdr.setArgs(new String[] { src_repo, files[0].getPath() });

        ProgressManager manager = ProgressManager.getInstance();
        //TODO: make this async so the git command output can be seen in the version control window as it happens...
        manager.runProcessWithProgressSynchronously(cmdr, "Cloning source repo " + src_repo, false, project);

        VcsException ex = cmdr.getException();
        if (ex != null) {
            Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git clone'");
            break;
        }
    }

    VcsDirtyScopeManager mgr = VcsDirtyScopeManager.getInstance(project);
    for (VirtualFile file : affectedFiles) {
        mgr.fileDirty(file);
        file.refresh(true, true);
    }
}

From source file:git4idea.actions.GitFetch.java

License:Apache License

@Override
protected void perform(@NotNull Project project, GitVcs vcs, @NotNull List<VcsException> exceptions,
        @NotNull VirtualFile[] affectedFiles) throws VcsException {
    saveAll();//from   w w w.  j av a2s  .  co  m

    final VirtualFile[] roots = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(vcs);
    for (VirtualFile root : roots) {
        GitCommand command = new GitCommand(project, vcs.getSettings(), root);

        String initialValue = null;
        List<GitBranch> rbranches = command.branchList(true);
        if (rbranches != null && rbranches.size() > 0) {
            initialValue = command.remoteRepoURL(rbranches.get(0));
        }
        String repoURL = Messages.showInputDialog(project,
                "Enter remote repository URL to fetch (empty for default):", "Fetch URL",
                Messages.getQuestionIcon(), initialValue, null);

        GitCommandRunnable cmdr = new GitCommandRunnable(project, vcs.getSettings(), root);
        cmdr.setCommand(GitCommand.FETCH_CMD);
        cmdr.setArgs(new String[] { repoURL });

        ProgressManager manager = ProgressManager.getInstance();
        manager.runProcessWithProgressSynchronously(cmdr, "Fetching from " + repoURL, false, project);

        VcsException ex = cmdr.getException();
        if (ex != null) {
            Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git fetch'");
            return;
        }

        cmdr.setArgs(new String[] { "--tags", repoURL });
        manager.runProcessWithProgressSynchronously(cmdr, "Updating tags from " + repoURL, false, project);
        ex = cmdr.getException();
        if (ex != null) {
            Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git fetch --tags'");
            return;
        }
    }
}

From source file:git4idea.actions.GitMerge.java

License:Apache License

@Override
protected void perform(@NotNull Project project, GitVcs vcs, @NotNull List<VcsException> exceptions,
        @NotNull VirtualFile[] affectedFiles) throws VcsException {
    saveAll();/*from ww w  .j a  v  a 2s  .  c  om*/

    final VirtualFile[] roots = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(vcs);
    List<GitBranch> branches;

    for (VirtualFile root : roots) {
        GitCommand command = new GitCommand(project, vcs.getSettings(), root);
        String currBranch = command.currentBranch();
        branches = command.branchList();
        String[] branchesList = new String[branches.size()];
        GitBranch selectedBranch = null;
        int i = 0;
        for (GitBranch b : branches) {
            branchesList[i++] = b.getName();
            if (!b.isActive() && selectedBranch == null)
                selectedBranch = b;
        }

        if (selectedBranch == null)
            return;

        int branchNum = Messages.showChooseDialog("Select branch to merge into this one (" + currBranch + ")",
                "Merge Branch", branchesList, selectedBranch.getName(), Messages.getQuestionIcon());
        if (branchNum < 0)
            return;

        selectedBranch = branches.get(branchNum);

        GitCommandRunnable cmdr = new GitCommandRunnable(project, vcs.getSettings(), root);
        cmdr.setCommand(GitCommand.MERGE_CMD);
        cmdr.setArgs(new String[] { selectedBranch.getName() });

        ProgressManager manager = ProgressManager.getInstance();
        //TODO: make this async so the git command output can be seen in the version control window as it happens...
        manager.runProcessWithProgressSynchronously(cmdr, "Merging branch " + selectedBranch.getName(), false,
                project);

        VcsException ex = cmdr.getException();
        if (ex != null) {
            Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git merge'");
            return;
        }
    }
}

From source file:git4idea.actions.GitPull.java

License:Apache License

@Override
protected void perform(@NotNull Project project, GitVcs vcs, @NotNull List<VcsException> exceptions,
        @NotNull VirtualFile[] affectedFiles) throws VcsException {
    saveAll();//from w ww  .ja  va  2  s  .com

    final VirtualFile[] roots = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(vcs);
    for (VirtualFile root : roots) {
        GitCommand command = new GitCommand(project, vcs.getSettings(), root);

        String initialValue = null;
        List<GitBranch> rbranches = command.branchList(true);
        if (rbranches != null && rbranches.size() > 0) {
            initialValue = command.remoteRepoURL(rbranches.get(0));
        }
        String repoURL = Messages.showInputDialog(project,
                "Enter remote repository URL to pull/merge (empty for default):", "Pull URL",
                Messages.getQuestionIcon(), initialValue, null);

        GitCommandRunnable cmdr = new GitCommandRunnable(project, vcs.getSettings(), root);
        cmdr.setCommand(GitCommand.FETCH_CMD);
        cmdr.setArgs(new String[] { repoURL });

        ProgressManager manager = ProgressManager.getInstance();
        manager.runProcessWithProgressSynchronously(cmdr, "Fetching from " + repoURL, false, project);

        VcsException ex = cmdr.getException();
        if (ex != null) {
            Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git fetch'");
            return;
        }

        cmdr.setArgs(new String[] { "--tags", repoURL });
        manager.runProcessWithProgressSynchronously(cmdr, "Updating tags from " + repoURL, false, project);
        ex = cmdr.getException();
        if (ex != null) {
            Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git fetch --tags'");
            return;
        }

        List<GitBranch> branches = command.branchList();
        String[] branchesList = new String[branches.size()];
        GitBranch selectedBranch = null;
        int i = 0;
        for (GitBranch b : branches) {
            if (!b.isActive() && selectedBranch == null)
                selectedBranch = b;
            branchesList[i++] = b.getName();
        }

        if (selectedBranch == null)
            selectedBranch = branches.get(0);

        int branchNum = Messages.showChooseDialog(
                "Select branch to merge into this one(" + command.currentBranch() + ")", "Merge Branch",
                branchesList, selectedBranch.getName(), Messages.getQuestionIcon());
        if (branchNum < 0) {
            return;
        }

        selectedBranch = branches.get(branchNum);
        cmdr.setCommand(GitCommand.MERGE_CMD);
        cmdr.setArgs(new String[] { selectedBranch.getName() });
        //TODO: make this async so the git command output can be seen in the version control window as it happens...
        manager.runProcessWithProgressSynchronously(cmdr, "Merging branch " + selectedBranch.getName(), false,
                project);
        ex = cmdr.getException();
        if (ex != null) {
            Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git merge'");
        }
    }
}