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

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

Introduction

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

Prototype

@NotNull
    public static Icon getErrorIcon() 

Source Link

Usage

From source file:com.anecdote.ideaplugins.commitlog.GenerateCommentAction.java

License:Apache License

public void actionPerformed(AnActionEvent e) {
    CheckinProjectPanel panel = (CheckinProjectPanel) e.getData(CheckinProjectPanel.PANEL_KEY);
    JTextArea commentEditor = e.getData(CHANGES_BAR_COMMENT_EDITOR_DATA_KEY);
    if (panel != null || commentEditor != null) {
        final Project project = panel != null ? panel.getProject()
                : DataKeys.PROJECT.getData(e.getDataContext());
        if (project != null) {
            int confirmation = Messages.showDialog(project, "Generate commit comment?         ",
                    "Confirm Generate Comment", new String[] { GENERATE, CommonBundle.getCancelButtonText() },
                    0, Messages.getQuestionIcon());
            if (confirmation == 0) {
                CommitLogProjectComponent projectComponent = project
                        .getComponent(CommitLogProjectComponent.class);
                String commitMessage;
                Collection<File> files;
                if (panel != null) {
                    commitMessage = panel.getCommitMessage();
                    files = panel.getFiles();
                } else {
                    commitMessage = commentEditor.getText();
                    LocalChangeList changeList = e.getData(SELECTED_CHANGE_LIST_DATA_KEY);
                    if (changeList == null) {
                        return;
                    }/*from   ww  w.ja  v a2  s .c om*/
                    ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
                    files = new HashSet<File>();
                    for (Change change : changeList.getChanges()) {
                        FilePath filepath = ChangesUtil.getFilePath(change);
                        files.add(filepath.getIOFile());
                    }
                }
                CommitLogBuilder commitLogBuilder = CommitLogBuilder.createCommitLogBuilder(
                        projectComponent.getTextualCommitCommentTemplate(), commitMessage, project, files);
                try {
                    String commitLog = commitLogBuilder.buildCommitLog(new Date());
                    if (panel != null) {
                        panel.setCommitMessage(commitLog);
                    } else {
                        commentEditor.setText(commitLog);
                        commentEditor.requestFocusInWindow();
                    }
                } catch (CommitLogTemplateParser.TextTemplateParserException e1) {
                    int result = Messages.showDialog(project,
                            "Error parsing Comment Template :\n" + e1.getMessage()
                                    + "\n\nEdit Comment Template now?",
                            "Error Generating Comment",
                            new String[] { CommonBundle.getYesButtonText(), CommonBundle.getNoButtonText() }, 0,
                            Messages.getErrorIcon());
                    if (result == 0) {
                        projectComponent.setFocusCommentTemplateEditor(true);
                        ShowSettingsUtil.getInstance().editConfigurable(project, projectComponent);
                    }
                }
            }
        }
    }
}

From source file:com.antoine.ideaplugin.greenrobot.ShowUsagesAction.java

License:Apache License

static void chooseAmbiguousTargetAndPerform(@NotNull final Project project, final Editor editor,
        @NotNull PsiElementProcessor<PsiElement> processor) {
    if (editor == null) {
        Messages.showMessageDialog(project, FindBundle.message("find.no.usages.at.cursor.error"),
                CommonBundle.getErrorTitle(), Messages.getErrorIcon());
    } else {/* w  w w. ja va  2  s  .  c  o m*/
        int offset = editor.getCaretModel().getOffset();
        boolean chosen = GotoDeclarationAction.chooseAmbiguousTarget(editor, offset, processor,
                FindBundle.message("find.usages.ambiguous.title", "crap"), null);
        if (!chosen) {
            ApplicationManager.getApplication().invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (editor.isDisposed() || !editor.getComponent().isShowing())
                        return;
                    HintManager.getInstance().showErrorHint(editor,
                            FindBundle.message("find.no.usages.at.cursor.error"));
                }
            }, project.getDisposed());
        }
    }
}

From source file:com.armhold.wicketsource.WicketSourceApplicationComponent.java

License:Apache License

private void initListenerAndSocket() {
    final int port = getPort();

    try {//from   ww w.  j a  va  2 s  .  c o  m
        serverSocket = new ServerSocket();
        serverSocket.bind(new InetSocketAddress("localhost", port));
        log.info("WicketSource plugin listening on port: " + port);
    } catch (IOException e) {
        ApplicationManager.getApplication().invokeLater(new Runnable() {
            public void run() {
                Messages.showMessageDialog("WicketSource plugin: can't bind to port: " + port,
                        "WicketSource Plugin Error", Messages.getErrorIcon());
            }
        });

        return;
    }

    Listener messageNotifier = new Listener(serverSocket);
    listener = new Thread(messageNotifier);
    listener.start();
}

From source file:com.atlassian.theplugin.idea.autoupdate.NewVersionCheckModalTask.java

License:Apache License

public void run(@NotNull ProgressIndicator indicator) {
    newVersion = null;/*w w w  .j  a v a 2s. c  o m*/
    setCancelText("Stop");
    indicator.setText("Connecting...");
    indicator.setFraction(0);
    indicator.setIndeterminate(true);
    final ConnectionWrapper checkerThread = new ConnectionWrapper(new UpdateServerConnection(), null,
            "atlassian-idea-plugin New version checker");
    checkerThread.start();
    while (checkerThread.getConnectionState() == ConnectionWrapper.ConnectionState.NOT_FINISHED) {
        try {
            if (indicator.isCanceled()) {
                checkerThread.setInterrupted();
                //t.interrupt();
                break;
            } else {
                Thread.sleep(CHECK_CANCEL_INTERVAL);
            }
        } catch (InterruptedException e) {
            PluginUtil.getLogger().info(e.getMessage());
        }
    }

    switch (checkerThread.getConnectionState()) {
    case FAILED:
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                com.intellij.openapi.ui.Messages.showMessageDialog(parentWindow,
                        checkerThread.getErrorMessage(), "Error occured when contacting update server",
                        Messages.getErrorIcon());
            }
        });
        break;
    case INTERUPTED:
        PluginUtil.getLogger().debug("Cancel was pressed during the upgrade process");
        break;
    case NOT_FINISHED:
        break;
    case SUCCEEDED:
        if (newVersion != null) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    try {
                        new NewVersionConfirmHandler(parentWindow, config).doAction(newVersion, showConfigPath);
                    } catch (ThePluginException e) {
                        com.intellij.openapi.ui.Messages.showMessageDialog(parentWindow, e.getMessage(),
                                "Error retrieving new version", Messages.getErrorIcon());
                    }
                }
            });
        } else {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    com.intellij.openapi.ui.Messages.showMessageDialog(parentWindow,
                            "You have the latest version (" + PluginUtil.getInstance().getVersion() + ")",
                            "Version checked", Messages.getInformationIcon());
                }
            });
        }
        break;
    default:
        PluginUtil.getLogger()
                .info("Unexpected thread state: " + checkerThread.getConnectionState().toString());
    }
}

From source file:com.atlassian.theplugin.idea.ui.DialogWithDetails.java

License:Apache License

protected Icon getIcon() {
    return Messages.getErrorIcon();
}

From source file:com.cleverCloud.cleverIdea.vcs.CleverCheckoutProvider.java

License:Open Source License

@Override
public void doCheckout(@NotNull Project project, @Nullable Listener listener) {
    if (!GitUtils.testGitExecutable(project))
        return;/*from w ww . ja va 2 s  .c om*/
    BasicAction.saveAll();

    List<Application> applicationList;
    CcApi ccApi = CcApi.getInstance(project);
    ccApi.login();

    applicationList = getApplicationsFromOrga(project);

    if (applicationList == null || applicationList.size() == 0) {
        Messages.showMessageDialog(
                "No application is currently linked with you application. Impossible to clone and create a project.",
                "No Application Available", Messages.getErrorIcon());
        return;
    }

    final CleverClone dialog = new CleverClone(project, applicationList);
    if (!dialog.showAndGet())
        return;

    final VirtualFile destinationParent = LocalFileSystem.getInstance()
            .findFileByIoFile(new File(dialog.getParentDirectory()));
    if (destinationParent == null)
        return;

    final String sourceRepositoryURL = dialog.getRepositoryUrl();
    final String directoryName = dialog.getDirectoryName();
    final String parentDirectory = dialog.getParentDirectory();

    Git git = ServiceManager.getService(Git.class);
    GitCheckoutProvider.clone(project, git, listener, destinationParent, sourceRepositoryURL, directoryName,
            parentDirectory);
}

From source file:com.google.cloud.tools.intellij.debugger.ProjectRepositoryValidator.java

License:Apache License

private void unstash(final @NotNull Project project, @NotNull final Ref<StashInfo> targetStash,
        @NotNull final VirtualFile root) {
    if (repoState.getSourceRepository() == null || repoState.getOriginalBranchName() == null
            || (!repoState.getOriginalBranchName()
                    .equals(repoState.getSourceRepository().getCurrentBranchName())
                    && !repoState.getOriginalBranchName()
                            .equals(repoState.getSourceRepository().getCurrentRevision()))) {
        Messages.showErrorDialog(/*from  ww w. j a va 2  s . co m*/
                GctBundle.getString("clouddebug.erroroncheckout", repoState.getOriginalBranchName()), "Error");
        return;
    }
    final GitLineHandler handler = new GitLineHandler(project, root, GitCommand.STASH);
    handler.addParameters("apply");
    handler.addParameters("--index");
    addStashParameter(project, handler, targetStash.get().getStash());
    final AtomicBoolean conflict = new AtomicBoolean();

    handler.addLineListener(new GitLineHandlerAdapter() {
        @Override
        public void onLineAvailable(String line, Key outputType) {
            if (line.contains("Merge conflict")) {
                conflict.set(true);
            }
        }
    });
    GitUntrackedFilesOverwrittenByOperationDetector untrackedFilesDetector = new GitUntrackedFilesOverwrittenByOperationDetector(
            root);
    GitLocalChangesWouldBeOverwrittenDetector localChangesDetector = new GitLocalChangesWouldBeOverwrittenDetector(
            root, MERGE);
    handler.addLineListener(untrackedFilesDetector);
    handler.addLineListener(localChangesDetector);

    AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
    try {
        final Ref<GitCommandResult> result = Ref.create();
        ProgressManager.getInstance()
                .run(new Task.Modal(handler.project(), GitBundle.getString("unstash.unstashing"), false) {
                    @Override
                    public void run(@NotNull final ProgressIndicator indicator) {
                        indicator.setIndeterminate(true);
                        handler.addLineListener(new GitHandlerUtil.GitLineHandlerListenerProgress(indicator,
                                handler, "stash", false));
                        Git git = ServiceManager.getService(Git.class);
                        result.set(git
                                .runCommand(new Computable.PredefinedValueComputable<GitLineHandler>(handler)));
                    }
                });

        ServiceManager.getService(project, GitPlatformFacade.class).hardRefresh(root);
        GitCommandResult res = result.get();
        if (conflict.get()) {
            Messages.showDialog(GctBundle.getString("clouddebug.unstashmergeconflicts"), "Merge Conflicts",
                    new String[] { "Ok" }, 0, Messages.getErrorIcon());

        } else if (untrackedFilesDetector.wasMessageDetected()) {
            GitUntrackedFilesHelper.notifyUntrackedFilesOverwrittenBy(project, root,
                    untrackedFilesDetector.getRelativeFilePaths(), "unstash", null);
        } else if (localChangesDetector.wasMessageDetected()) {
            LocalChangesWouldBeOverwrittenHelper.showErrorDialog(project, root, "unstash",
                    localChangesDetector.getRelativeFilePaths());
        } else if (!res.success()) {
            GitUIUtil.showOperationErrors(project, handler.errors(), handler.printableCommandLine());
        } else if (res.success()) {
            ProgressManager.getInstance().run(new Task.Modal(project,
                    GctBundle.getString("clouddebug.removestashx", targetStash.get().getStash()), false) {
                @Override
                public void run(@NotNull ProgressIndicator indicator) {
                    if (project == null) {
                        return;
                    }
                    final GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.STASH);
                    h.addParameters("drop");
                    addStashParameter(project, h, targetStash.get().getStash());
                    try {
                        h.run();
                        h.unsilence();
                    } catch (final VcsException ex) {
                        ApplicationManager.getApplication().invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                GitUIUtil.showOperationError(project, ex, h.printableCommandLine());
                            }
                        });
                    }
                }
            });

        }
    } finally {
        DvcsUtil.workingTreeChangeFinished(project, token);
    }
}

From source file:com.google.errorprone.intellij.ErrorProneIdeaCompiler.java

License:Open Source License

public boolean checkCompiler(final CompileScope scope) {
    final Module[] modules = scope.getAffectedModules();
    final Set<Sdk> checkedJdks = new HashSet<Sdk>();
    for (final Module module : modules) {
        final Sdk jdk = ModuleRootManager.getInstance(module).getSdk();
        if (jdk == null || checkedJdks.contains(jdk)) {
            continue;
        }//from  ww  w  . j a  v a 2s .c o m
        checkedJdks.add(jdk);
        final SdkTypeId sdkType = jdk.getSdkType();
        if (!(sdkType instanceof JavaSdkType)) {
            continue;
        }
        final VirtualFile homeDirectory = jdk.getHomeDirectory();
        if (homeDirectory == null) {
            //noinspection DialogTitleCapitalization
            Messages.showMessageDialog(myProject, ErrorProneIdeaBundle.jdkHomeNotFoundMessage(jdk),
                    ErrorProneIdeaBundle.compilerName(), Messages.getErrorIcon());
            return false;
        }
        final String vmExecutablePath = ((JavaSdkType) sdkType).getVMExecutablePath(jdk);
        if (vmExecutablePath == null) {
            Messages.showMessageDialog(myProject,
                    ErrorProneIdeaBundle.message("error-prone.error.vm.executable.missing", jdk.getName()),
                    ErrorProneIdeaBundle.compilerName(), Messages.getErrorIcon());
            return false;
        }
        final String toolsJarPath = ((JavaSdkType) sdkType).getToolsPath(jdk);
        if (toolsJarPath == null) {
            Messages.showMessageDialog(myProject,
                    ErrorProneIdeaBundle.message("error-prone.error.tools.jar.missing", jdk.getName()),
                    ErrorProneIdeaBundle.compilerName(), Messages.getErrorIcon());
            return false;
        }
        final String versionString = jdk.getVersionString();
        if (versionString == null) {
            Messages.showMessageDialog(myProject,
                    ErrorProneIdeaBundle.message("error-prone.error.unknown.jdk.version", jdk.getName()),
                    ErrorProneIdeaBundle.compilerName(), Messages.getErrorIcon());
            return false;
        }

        if (CompilerUtil.isOfVersion(versionString, "1.0")) {
            Messages.showMessageDialog(myProject,
                    ErrorProneIdeaBundle.message("error-prone.error.1_0_compilation.not.supported"),
                    ErrorProneIdeaBundle.compilerName(), Messages.getErrorIcon());
            return false;
        }
    }

    return true;
}

From source file:com.google.gct.idea.debugger.ProjectRepositoryValidator.java

License:Apache License

private void unstash(final @NotNull Project project, @NotNull final Ref<StashInfo> targetStash,
        @NotNull final VirtualFile root) {
    if (myRepoState.getSourceRepository() == null || myRepoState.getOriginalBranchName() == null
            || (!myRepoState.getOriginalBranchName()
                    .equals(myRepoState.getSourceRepository().getCurrentBranchName())
                    && !myRepoState.getOriginalBranchName()
                            .equals(myRepoState.getSourceRepository().getCurrentRevision()))) {
        Messages.showErrorDialog(/*from w  w  w  . j a  v  a 2 s. co m*/
                GctBundle.getString("clouddebug.erroroncheckout", myRepoState.getOriginalBranchName()),
                "Error");
        return;
    }
    final GitLineHandler handler = new GitLineHandler(project, root, GitCommand.STASH);
    handler.addParameters("apply");
    handler.addParameters("--index");
    addStashParameter(project, handler, targetStash.get().getStash());
    final AtomicBoolean conflict = new AtomicBoolean();

    handler.addLineListener(new GitLineHandlerAdapter() {
        @Override
        public void onLineAvailable(String line, Key outputType) {
            if (line.contains("Merge conflict")) {
                conflict.set(true);
            }
        }
    });
    GitUntrackedFilesOverwrittenByOperationDetector untrackedFilesDetector = new GitUntrackedFilesOverwrittenByOperationDetector(
            root);
    GitLocalChangesWouldBeOverwrittenDetector localChangesDetector = new GitLocalChangesWouldBeOverwrittenDetector(
            root, MERGE);
    handler.addLineListener(untrackedFilesDetector);
    handler.addLineListener(localChangesDetector);

    AccessToken token = DvcsUtil.workingTreeChangeStarted(project);
    try {
        final Ref<GitCommandResult> result = Ref.create();
        ProgressManager.getInstance()
                .run(new Task.Modal(handler.project(), GitBundle.getString("unstash.unstashing"), false) {
                    @Override
                    public void run(@NotNull final ProgressIndicator indicator) {
                        indicator.setIndeterminate(true);
                        handler.addLineListener(new GitHandlerUtil.GitLineHandlerListenerProgress(indicator,
                                handler, "stash", false));
                        Git git = ServiceManager.getService(Git.class);
                        result.set(git
                                .runCommand(new Computable.PredefinedValueComputable<GitLineHandler>(handler)));
                    }
                });

        ServiceManager.getService(project, GitPlatformFacade.class).hardRefresh(root);
        GitCommandResult res = result.get();
        if (conflict.get()) {
            Messages.showDialog(GctBundle.getString("clouddebug.unstashmergeconflicts"), "Merge Conflicts",
                    new String[] { "Ok" }, 0, Messages.getErrorIcon());

        } else if (untrackedFilesDetector.wasMessageDetected()) {
            UntrackedFilesNotifier.notifyUntrackedFilesOverwrittenBy(project, root,
                    untrackedFilesDetector.getRelativeFilePaths(), "unstash", null);
        } else if (localChangesDetector.wasMessageDetected()) {
            LocalChangesWouldBeOverwrittenHelper.showErrorDialog(project, root, "unstash",
                    localChangesDetector.getRelativeFilePaths());
        } else if (!res.success()) {
            GitUIUtil.showOperationErrors(project, handler.errors(), handler.printableCommandLine());
        } else if (res.success()) {
            ProgressManager.getInstance().run(new Task.Modal(project,
                    GctBundle.getString("clouddebug.removestashx", targetStash.get().getStash()), false) {
                @Override
                public void run(@NotNull ProgressIndicator indicator) {
                    if (myProject == null) {
                        return;
                    }
                    final GitSimpleHandler h = new GitSimpleHandler(myProject, root, GitCommand.STASH);
                    h.addParameters("drop");
                    addStashParameter(project, h, targetStash.get().getStash());
                    try {
                        h.run();
                        h.unsilence();
                    } catch (final VcsException ex) {
                        ApplicationManager.getApplication().invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                GitUIUtil.showOperationError(myProject, ex, h.printableCommandLine());
                            }
                        });
                    }
                }
            });

        }
    } finally {
        DvcsUtil.workingTreeChangeFinished(project, token);
    }
}

From source file:com.google.idea.blaze.base.ide.NewBlazePackageDialog.java

License:Open Source License

private void showErrorDialog(@NotNull String message) {
    String title = CommonBundle.getErrorTitle();
    Icon icon = Messages.getErrorIcon();
    Messages.showMessageDialog(component, message, title, icon);
}