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();
}
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());
}
}
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;
}
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();
}
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;
}
Aggregations