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.intellij.debugger.actions.ForceEarlyReturnAction.java

License:Apache License

private static void showError(final Project project, final String message) {
    ApplicationManager.getApplication()/*  w w  w  .j  ava 2 s  . com*/
            .invokeLater(() -> Messages.showMessageDialog(project, message,
                    UIUtil.removeMnemonic(ActionsBundle.actionText("Debugger.ForceEarlyReturn")),
                    Messages.getErrorIcon()), ModalityState.any());
}

From source file:com.intellij.debugger.actions.PopFrameAction.java

License:Apache License

public void actionPerformed(AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    StackFrameProxyImpl stackFrame = getStackFrameProxy(e);
    if (stackFrame == null) {
        return;/*from w  w w .  j av  a2s .  c  o  m*/
    }
    try {
        DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
        DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
        if (debugProcess == null) {
            return;
        }
        debugProcess.getManagerThread()
                .schedule(debugProcess.createPopFrameCommand(debuggerContext, stackFrame));
    } catch (NativeMethodException e2) {
        Messages.showMessageDialog(project, DebuggerBundle.message("error.native.method.exception"),
                ActionsBundle.actionText(DebuggerActions.POP_FRAME), Messages.getErrorIcon());
    } catch (InvalidStackFrameException ignored) {
    } catch (VMDisconnectedException vde) {
    }
}

From source file:com.intellij.debugger.ui.breakpoints.JavaFieldBreakpointType.java

License:Apache License

@Nullable
@Override/*  ww  w  .  j  ava  2  s  .com*/
public XLineBreakpoint<JavaFieldBreakpointProperties> addBreakpoint(final Project project,
        JComponent parentComponent) {
    final Ref<XLineBreakpoint> result = Ref.create(null);
    AddFieldBreakpointDialog dialog = new AddFieldBreakpointDialog(project) {
        protected boolean validateData() {
            final String className = getClassName();
            if (className.length() == 0) {
                Messages.showMessageDialog(project,
                        DebuggerBundle.message("error.field.breakpoint.class.name.not.specified"),
                        DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon());
                return false;
            }
            final String fieldName = getFieldName();
            if (fieldName.length() == 0) {
                Messages.showMessageDialog(project,
                        DebuggerBundle.message("error.field.breakpoint.field.name.not.specified"),
                        DebuggerBundle.message("add.field.breakpoint.dialog.title"), Messages.getErrorIcon());
                return false;
            }
            PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(className,
                    GlobalSearchScope.allScope(project));
            if (psiClass != null) {
                final PsiFile psiFile = psiClass.getContainingFile();
                Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
                if (document != null) {
                    PsiField field = psiClass.findFieldByName(fieldName, true);
                    if (field != null) {
                        final int line = document.getLineNumber(field.getTextOffset());
                        ApplicationManager.getApplication().runWriteAction(new Runnable() {
                            @Override
                            public void run() {
                                XLineBreakpoint<JavaFieldBreakpointProperties> fieldBreakpoint = XDebuggerManager
                                        .getInstance(project).getBreakpointManager().addLineBreakpoint(
                                                JavaFieldBreakpointType.this, psiFile.getVirtualFile().getUrl(),
                                                line, new JavaFieldBreakpointProperties(fieldName, className));
                                result.set(fieldBreakpoint);
                            }
                        });
                        return true;
                    } else {
                        Messages.showMessageDialog(project,
                                DebuggerBundle.message("error.field.breakpoint.field.not.found", className,
                                        fieldName, fieldName),
                                CommonBundle.getErrorTitle(), Messages.getErrorIcon());
                    }
                }
            } else {
                Messages.showMessageDialog(
                        project, DebuggerBundle.message("error.field.breakpoint.class.sources.not.found",
                                className, fieldName, className),
                        CommonBundle.getErrorTitle(), Messages.getErrorIcon());
            }
            return false;
        }
    };
    dialog.show();
    return result.get();
}

From source file:com.intellij.debugger.ui.ExportDialog.java

License:Apache License

protected void doOKAction() {
    String path = myTfFilePath.getText();
    File file = new File(path);
    if (file.isDirectory()) {
        Messages.showMessageDialog(myProject,
                DebuggerBundle.message("error.threads.export.dialog.file.is.directory"),
                DebuggerBundle.message("threads.export.dialog.title"), Messages.getErrorIcon());
    } else if (file.exists()) {
        int answer = Messages.showYesNoDialog(myProject,
                DebuggerBundle.message("error.threads.export.dialog.file.already.exists", path),
                DebuggerBundle.message("threads.export.dialog.title"), Messages.getQuestionIcon());
        if (answer == 0) {
            super.doOKAction();
        }//from   ww w  . j  ava 2  s .c om
    } else {
        super.doOKAction();
    }
}

From source file:com.intellij.debugger.ui.InstanceFilterEditor.java

License:Apache License

protected ClassFilter createFilter(String pattern) {
    try {/*from ww  w.j a v a2s.c  om*/
        Long.parseLong(pattern);
        return super.createFilter(pattern);
    } catch (NumberFormatException e) {
        Messages.showMessageDialog(this,
                DebuggerBundle.message("add.instance.filter.dialog.error.numeric.value.expected"),
                DebuggerBundle.message("add.instance.filter.dialog.title"), Messages.getErrorIcon());
        return null;
    }
}

From source file:com.intellij.designer.propertyTable.PropertyTable.java

License:Apache License

private static void showInvalidInput(Exception e) {
    Throwable cause = e.getCause();
    String message = cause == null ? e.getMessage() : cause.getMessage();

    if (message == null || message.length() == 0) {
        message = "No message";
    }//from   ww w  .  j a v  a  2s  . com

    Messages.showMessageDialog(formatErrorGettingValueMesage(message), "Invalid Input",
            Messages.getErrorIcon());
}

From source file:com.intellij.diagnostic.ITNReporter2.java

License:Apache License

private static boolean doSubmit(final IdeaLoggingEvent event, final Component parentComponent,
        final Consumer<SubmittedReportInfo> callback, final ErrorBean errorBean, final String description) {
    final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);

    final ErrorReportConfigurable errorReportConfigurable = ErrorReportConfigurable.getInstance();
    if (!errorReportConfigurable.KEEP_ITN_PASSWORD && !StringUtil.isEmpty(errorReportConfigurable.ITN_LOGIN)
            && StringUtil.isEmpty(errorReportConfigurable.getPlainItnPassword())) {
        final JetBrainsAccountDialog dlg = new JetBrainsAccountDialog(parentComponent);
        dlg.show();/*from ww w. j a  v a 2  s  .c  om*/
        if (!dlg.isOK()) {
            return false;
        }
    }

    errorBean.setDescription(description);
    errorBean.setMessage(event.getMessage());

    if (previousExceptionThreadId != 0) {
        errorBean.setPreviousException(previousExceptionThreadId);
    }

    Throwable t = event.getThrowable();
    if (t != null) {
        final PluginId pluginId = IdeErrorsDialog.findPluginId(t);
        if (pluginId != null) {
            final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
            if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) {
                errorBean.setPluginName(ideaPluginDescriptor.getName());
                errorBean.setPluginVersion(ideaPluginDescriptor.getVersion());
            }
        }
    }

    Object data = event.getData();

    if (data instanceof AbstractMessage) {
        errorBean.setAssigneeId(((AbstractMessage) data).getAssigneeId());
    }

    if (data instanceof LogMessageEx) {
        errorBean.setAttachments(((LogMessageEx) data).getAttachments());
    }

    @NonNls
    String login = errorReportConfigurable.ITN_LOGIN;
    @NonNls
    String password = errorReportConfigurable.getPlainItnPassword();
    if (login.trim().length() == 0 && password.trim().length() == 0) {
        login = "idea_anonymous";
        password = "guest";
    }

    ErrorReportSender.sendError(project, login, password, errorBean, new Consumer<Integer>() {
        @SuppressWarnings({ "AssignmentToStaticFieldFromInstanceMethod" })
        @Override
        public void consume(Integer threadId) {
            previousExceptionThreadId = threadId;
            wasException = true;
            final SubmittedReportInfo reportInfo = new SubmittedReportInfo(URL_HEADER + threadId,
                    String.valueOf(threadId), SubmittedReportInfo.SubmissionStatus.NEW_ISSUE);
            callback.consume(reportInfo);
            ApplicationManager.getApplication().invokeLater(new Runnable() {
                @Override
                public void run() {
                    StringBuilder text = new StringBuilder();
                    final String url = IdeErrorsDialog.getUrl(reportInfo, true);
                    IdeErrorsDialog.appendSubmissionInformation(reportInfo, text, url);
                    text.append(".");
                    if (reportInfo.getStatus() != SubmittedReportInfo.SubmissionStatus.FAILED) {
                        text.append("<br/>").append(DiagnosticBundle.message("error.report.gratitude"));
                    }

                    NotificationType type = reportInfo
                            .getStatus() == SubmittedReportInfo.SubmissionStatus.FAILED ? NotificationType.ERROR
                                    : NotificationType.INFORMATION;
                    NotificationListener listener = url != null
                            ? new NotificationListener.UrlOpeningListener(true)
                            : null;
                    ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT,
                            XmlStringUtil.wrapInHtml(text), type, listener).setImportant(false).notify(project);
                }
            });
        }
    }, new Consumer<Exception>() {
        @Override
        public void consume(final Exception e) {
            ApplicationManager.getApplication().invokeLater(new Runnable() {
                @Override
                public void run() {
                    String msg;
                    if (e instanceof NoSuchEAPUserException) {
                        msg = DiagnosticBundle.message("error.report.authentication.failed");
                    } else if (e instanceof InternalEAPException) {
                        msg = DiagnosticBundle.message("error.report.posting.failed", e.getMessage());
                    } else {
                        msg = DiagnosticBundle.message("error.report.sending.failure");
                    }
                    if (e instanceof UpdateAvailableException) {
                        String message = DiagnosticBundle.message("error.report.new.eap.build.message",
                                e.getMessage());
                        showMessageDialog(parentComponent, project, message, CommonBundle.getWarningTitle(),
                                Messages.getWarningIcon());
                        callback.consume(new SubmittedReportInfo(null, "0",
                                SubmittedReportInfo.SubmissionStatus.FAILED));
                    } else if (showYesNoDialog(parentComponent, project, msg, ReportMessages.ERROR_REPORT,
                            Messages.getErrorIcon()) != 0) {
                        callback.consume(new SubmittedReportInfo(null, "0",
                                SubmittedReportInfo.SubmissionStatus.FAILED));
                    } else {
                        if (e instanceof NoSuchEAPUserException) {
                            final JetBrainsAccountDialog dialog;
                            if (parentComponent.isShowing()) {
                                dialog = new JetBrainsAccountDialog(parentComponent);
                            } else {
                                dialog = new JetBrainsAccountDialog(project);
                            }
                            dialog.show();
                        }
                        ApplicationManager.getApplication().invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                doSubmit(event, parentComponent, callback, errorBean, description);
                            }
                        });
                    }
                }
            });
        }
    });
    return true;
}

From source file:com.intellij.diagnostic.OutOfMemoryDialog.java

License:Apache License

public OutOfMemoryDialog(MemoryKind memoryKind) {
    super(false);
    myMemoryKind = memoryKind;/*from  w ww .  j a  v a 2  s  .  c  om*/
    setTitle(DiagnosticBundle.message("diagnostic.out.of.memory.title"));

    myMessageLabel.setIcon(Messages.getErrorIcon());
    myMessageLabel.setText(DiagnosticBundle.message("diagnostic.out.of.memory.error",
            memoryKind == MemoryKind.HEAP ? VMOptions.XMX_OPTION_NAME
                    : memoryKind == MemoryKind.PERM_GEN ? VMOptions.PERM_GEN_OPTION_NAME
                            : VMOptions.CODE_CACHE_OPTION_NAME,
            ApplicationNamesInfo.getInstance().getProductName()));

    File file = VMOptions.getWriteFile();
    final String path = file != null ? file.getPath() : null;
    if (path != null) {
        mySettingsFileHintLabel
                .setText(DiagnosticBundle.message("diagnostic.out.of.memory.willBeSavedTo", path));
    } else {
        mySettingsFileHintLabel.setVisible(false);
    }

    myIgnoreAction = new AbstractAction(DiagnosticBundle.message("diagnostic.out.of.memory.ignore")) {
        public void actionPerformed(ActionEvent e) {
            save();
            close(0);
        }
    };

    myShutdownAction = new AbstractAction(DiagnosticBundle.message("diagnostic.out.of.memory.shutdown")) {
        public void actionPerformed(ActionEvent e) {
            save();
            System.exit(0);
        }
    };
    myShutdownAction.putValue(DialogWrapper.DEFAULT_ACTION, true);

    configControls(VMOptions.XMX_OPTION_NAME, VMOptions.readXmx(), memoryKind == MemoryKind.HEAP,
            myHeapSizeLabel, myHeapSizeField, myHeapUnitsLabel, myHeapCurrentValueLabel);

    configControls(VMOptions.PERM_GEN_OPTION_NAME, VMOptions.readMaxPermGen(),
            memoryKind == MemoryKind.PERM_GEN, myPermGenSizeLabel, myPermGenSizeField, myPermGenUnitsLabel,
            myPermGenCurrentValueLabel);

    configControls(VMOptions.CODE_CACHE_OPTION_NAME, VMOptions.readCodeCache(),
            memoryKind == MemoryKind.CODE_CACHE, myCodeCacheSizeLabel, myCodeCacheSizeField,
            myCodeCacheUnitsLabel, myCodeCacheCurrentValueLabel);

    init();
}

From source file:com.intellij.execution.ExecutableValidator.java

License:Apache License

private int showMessage(@Nullable Component parentComponent) {
    String okText = "Fix it";
    String cancelText = CommonBundle.getCancelButtonText();
    Icon icon = Messages.getErrorIcon();
    String title = myNotificationErrorTitle;
    String description = myNotificationErrorDescription;
    return parentComponent != null
            ? Messages.showOkCancelDialog(parentComponent, description, title, okText, cancelText, icon)
            : Messages.showOkCancelDialog(myProject, description, title, okText, cancelText, icon);
}

From source file:com.intellij.execution.impl.RunDialog.java

License:Apache License

@Override
protected void doOKAction() {
    try {//from   w w  w  .j  a v a 2s  . c o  m
        myConfigurable.apply();
    } catch (ConfigurationException e) {
        Messages.showMessageDialog(myProject, e.getMessage(),
                ExecutionBundle.message("invalid.data.dialog.title"), Messages.getErrorIcon());
        return;
    }
    super.doOKAction();
}