Search in sources :

Example 16 with DialogBuilder

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

the class ExecutionErrorDialog method show.

public static void show(final ExecutionException e, final String title, final Project project) {
    if (e instanceof RunCanceledByUserException) {
        return;
    }
    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(JBUI.size(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();
}
Also used : RunCanceledByUserException(com.intellij.execution.RunCanceledByUserException) DialogBuilder(com.intellij.openapi.ui.DialogBuilder)

Example 17 with DialogBuilder

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

the class EditContractIntention method invoke.

@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
    final PsiMethod method = getTargetMethod(project, editor, file);
    assert method != null;
    Contract existingAnno = AnnotationUtil.findAnnotationInHierarchy(method, Contract.class);
    String oldContract = existingAnno == null ? null : existingAnno.value();
    boolean oldPure = existingAnno != null && existingAnno.pure();
    JBTextField contractText = new JBTextField(oldContract);
    JCheckBox pureCB = createPureCheckBox(oldPure);
    DialogBuilder builder = createDialog(project, contractText, pureCB);
    contractText.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            String error = getErrorMessage(contractText.getText(), method);
            builder.setOkActionEnabled(error == null);
            builder.setErrorText(error, contractText);
        }
    });
    if (builder.showAndGet()) {
        updateContract(method, contractText.getText(), pureCB.isSelected());
    }
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) JBTextField(com.intellij.ui.components.JBTextField) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) DocumentEvent(javax.swing.event.DocumentEvent) Contract(org.jetbrains.annotations.Contract)

Example 18 with DialogBuilder

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

the class EditContractIntention method createDialog.

private static DialogBuilder createDialog(@NotNull Project project, JBTextField contractText, JCheckBox pureCB) {
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(Messages.configureMessagePaneUi(new JTextPane(), ourPrompt), BorderLayout.NORTH);
    panel.add(contractText, BorderLayout.CENTER);
    panel.add(pureCB, BorderLayout.SOUTH);
    DialogBuilder builder = new DialogBuilder(project).setNorthPanel(panel).title("Edit Method Contract");
    builder.setPreferredFocusComponent(contractText);
    return builder;
}
Also used : DialogBuilder(com.intellij.openapi.ui.DialogBuilder)

Example 19 with DialogBuilder

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

the class ApkEditor method selectApkAndCompare.

@Override
public void selectApkAndCompare() {
    FileChooserDescriptor desc = new FileChooserDescriptor(true, false, false, false, false, false);
    desc.withFileFilter(file -> ApkFileSystem.EXTENSIONS.contains(file.getExtension()));
    VirtualFile file = FileChooser.chooseFile(desc, myProject, null);
    if (file == null) {
        // user canceled
        return;
    }
    VirtualFile newApk = ApkFileSystem.getInstance().getRootByLocal(file);
    assert newApk != null;
    DialogBuilder builder = new DialogBuilder(myProject);
    builder.setTitle(myRoot.getName() + " vs " + newApk.getName());
    ApkDiffParser parser = new ApkDiffParser(myRoot, newApk);
    ApkDiffPanel panel = new ApkDiffPanel(parser);
    builder.setCenterPanel(panel.getContainer());
    builder.setPreferredFocusComponent(panel.getPreferredFocusedComponent());
    builder.show();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ApkDiffPanel(com.android.tools.idea.apk.viewer.diff.ApkDiffPanel) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ApkDiffParser(com.android.tools.idea.apk.viewer.diff.ApkDiffParser) DialogBuilder(com.intellij.openapi.ui.DialogBuilder)

Example 20 with DialogBuilder

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

the class DialogUtil method createDialog.

/**
     * 创建普通对话框
     * @param message
     * @param okText
     * @param cancelText
     * @return
     */
public static boolean createDialog(String message, String okText, String cancelText) {
    DialogBuilder builder = new DialogBuilder();
    builder.setTitle("Dialog Message");
    builder.resizable(false);
    builder.setCenterPanel(new JLabel(message, Messages.getInformationIcon(), SwingConstants.CENTER));
    builder.addOkAction().setText(okText);
    builder.addCancelAction().setText(cancelText);
    builder.setButtonsAlignment(SwingConstants.CENTER);
    return builder.show() == 0;
}
Also used : DialogBuilder(com.intellij.openapi.ui.DialogBuilder)

Aggregations

DialogBuilder (com.intellij.openapi.ui.DialogBuilder)33 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