use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.
the class BuildArtifactsBeforeRunTaskProviderBase method configureTask.
public boolean configureTask(RunConfiguration runConfiguration, T task) {
final Artifact[] artifacts = ArtifactManager.getInstance(myProject).getArtifacts();
Set<ArtifactPointer> pointers = new THashSet<>();
for (Artifact artifact : artifacts) {
pointers.add(ArtifactPointerManager.getInstance(myProject).createPointer(artifact));
}
pointers.addAll(task.getArtifactPointers());
ArtifactChooser chooser = new ArtifactChooser(new ArrayList<>(pointers));
chooser.markElements(task.getArtifactPointers());
chooser.setPreferredSize(JBUI.size(400, 300));
DialogBuilder builder = new DialogBuilder(myProject);
builder.setTitle(CompilerBundle.message("build.artifacts.before.run.selector.title"));
builder.setDimensionServiceKey("#BuildArtifactsBeforeRunChooser");
builder.addOkAction();
builder.addCancelAction();
builder.setCenterPanel(chooser);
builder.setPreferredFocusComponent(chooser);
if (builder.show() == DialogWrapper.OK_EXIT_CODE) {
task.setArtifactPointers(chooser.getMarkedElements());
return true;
}
return false;
}
use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.
the class EditSettingsAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final InspectionResultsView view = getView(e);
InspectionProfileImpl inspectionProfile = view.getCurrentProfile();
if (view.isSingleInspectionRun()) {
InspectionToolWrapper tool = ObjectUtils.notNull(inspectionProfile.getInspectionTool(ObjectUtils.notNull(inspectionProfile.getSingleTool()), view.getProject()));
JComponent panel = tool.getTool().createOptionsPanel();
if (panel != null) {
final DialogBuilder builder = new DialogBuilder().title(InspectionsBundle.message("inspection.tool.window.inspection.dialog.title", tool.getDisplayName())).centerPanel(panel);
builder.removeAllActions();
builder.addOkAction();
if (view.isRerunAvailable()) {
builder.addActionDescriptor(new DialogBuilder.DialogActionDescriptor(InspectionsBundle.message("inspection.action.rerun"), 'R') {
@Override
protected Action createAction(DialogWrapper dialogWrapper) {
return new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
view.rerun();
dialogWrapper.close(DialogWrapper.OK_EXIT_CODE);
}
};
}
});
}
builder.show();
} else {
Messages.showInfoMessage(view.getProject(), InspectionsBundle.message("inspection.tool.window.dialog.no.options", tool.getDisplayName()), InspectionsBundle.message("inspection.tool.window.dialog.title"));
}
} else {
final InspectionToolWrapper toolWrapper = view.getTree().getSelectedToolWrapper(false);
if (toolWrapper != null) {
//do not search for dead code entry point tool
final HighlightDisplayKey key = HighlightDisplayKey.find(toolWrapper.getShortName());
if (key != null) {
if (new EditInspectionToolsSettingsAction(key).editToolSettings(view.getProject(), inspectionProfile)) {
view.updateCurrentProfile();
}
return;
}
}
final String[] path = view.getTree().getSelectedGroupPath();
if (EditInspectionToolsSettingsAction.editSettings(view.getProject(), inspectionProfile, (c) -> {
if (path != null) {
c.selectInspectionGroup(path);
}
})) {
view.updateCurrentProfile();
}
}
}
use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.
the class EnvironmentVariablesTextFieldWithBrowseButton method showParentEnvironmentDialog.
public static void showParentEnvironmentDialog(@NotNull Component parent) {
EnvVariablesTable table = new EnvVariablesTable();
table.setValues(convertToVariables(new TreeMap<>(new GeneralCommandLine().getParentEnvironment()), true));
table.getActionsPanel().setVisible(false);
DialogBuilder builder = new DialogBuilder(parent);
builder.setTitle(ExecutionBundle.message("environment.variables.system.dialog.title"));
builder.centerPanel(table.getComponent());
builder.addCloseButton();
builder.show();
}
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());
}
}
Aggregations