Example usage for com.intellij.openapi.ui DialogBuilder setButtonsAlignment

List of usage examples for com.intellij.openapi.ui DialogBuilder setButtonsAlignment

Introduction

In this page you can find the example usage for com.intellij.openapi.ui DialogBuilder setButtonsAlignment.

Prototype

public void setButtonsAlignment(
            @MagicConstant(intValues = { SwingConstants.CENTER, SwingConstants.RIGHT }) int alignment) 

Source Link

Usage

From source file:com.intellij.execution.util.ExecutionErrorDialog.java

License:Apache License

public static void show(final ExecutionException e, final String title, final Project project) {
    if (e instanceof RunCanceledByUserException) {
        return;/* w w  w.j a v a2s .com*/
    }

    if (ApplicationManager.getApplication().isUnitTestMode()) {
        throw new RuntimeException(e.getLocalizedMessage());
    }
    final String message = e.getMessage();
    if (message == null || message.length() < 100) {
        Messages.showErrorDialog(project, message == null ? "exception was thrown" : message, title);
        return;
    }
    final DialogBuilder builder = new DialogBuilder(project);
    builder.setTitle(title);
    final JTextArea textArea = new JTextArea();
    textArea.setEditable(false);
    textArea.setForeground(UIUtil.getLabelForeground());
    textArea.setBackground(UIUtil.getLabelBackground());
    textArea.setFont(UIUtil.getLabelFont());
    textArea.setText(message);
    textArea.setWrapStyleWord(false);
    textArea.setLineWrap(true);
    final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(textArea);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    final JPanel panel = new JPanel(new BorderLayout(10, 0));
    panel.setPreferredSize(new Dimension(500, 200));
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.add(new JLabel(Messages.getErrorIcon()), BorderLayout.WEST);
    builder.setCenterPanel(panel);
    builder.setButtonsAlignment(SwingConstants.CENTER);
    builder.addOkAction();
    builder.show();
}