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 intellij-community by JetBrains.
the class ExternalDependenciesConfigurable method editPluginDependency.
@Nullable
private DependencyOnPlugin editPluginDependency(@NotNull JComponent parent, @NotNull final DependencyOnPlugin original) {
List<String> pluginIds = new ArrayList<>(getPluginNameByIdMap().keySet());
if (!original.getPluginId().isEmpty() && !pluginIds.contains(original.getPluginId())) {
pluginIds.add(original.getPluginId());
}
Collections.sort(pluginIds, (o1, o2) -> getPluginNameById(o1).compareToIgnoreCase(getPluginNameById(o2)));
final ComboBox pluginChooser = new ComboBox(ArrayUtilRt.toStringArray(pluginIds), 250);
pluginChooser.setRenderer(new ListCellRendererWrapper<String>() {
@Override
public void customize(JList list, String value, int index, boolean selected, boolean hasFocus) {
setText(getPluginNameById(value));
}
});
new ComboboxSpeedSearch(pluginChooser) {
@Override
protected String getElementText(Object element) {
return getPluginNameById((String) element);
}
};
pluginChooser.setSelectedItem(original.getPluginId());
final JBTextField minVersionField = new JBTextField(StringUtil.notNullize(original.getMinVersion()));
final JBTextField maxVersionField = new JBTextField(StringUtil.notNullize(original.getMaxVersion()));
final JBTextField channelField = new JBTextField(StringUtil.notNullize(original.getChannel()));
minVersionField.getEmptyText().setText("<any>");
minVersionField.setColumns(10);
maxVersionField.getEmptyText().setText("<any>");
maxVersionField.setColumns(10);
channelField.setColumns(10);
JPanel panel = FormBuilder.createFormBuilder().addLabeledComponent("Plugin:", pluginChooser).addLabeledComponent("Minimum version:", minVersionField).addLabeledComponent("Maximum version:", maxVersionField).addLabeledComponent("Channel:", channelField).getPanel();
final DialogBuilder dialogBuilder = new DialogBuilder(parent).title("Required Plugin").centerPanel(panel);
dialogBuilder.setPreferredFocusComponent(pluginChooser);
pluginChooser.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialogBuilder.setOkActionEnabled(!StringUtil.isEmpty((String) pluginChooser.getSelectedItem()));
}
});
if (dialogBuilder.show() == DialogWrapper.OK_EXIT_CODE) {
return new DependencyOnPlugin(((String) pluginChooser.getSelectedItem()), StringUtil.nullize(minVersionField.getText().trim()), StringUtil.nullize(maxVersionField.getText().trim()), StringUtil.nullize(channelField.getText().trim()));
}
return null;
}
use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.
the class VcsDiffUtil method showChangesDialog.
@CalledInAwt
public static void showChangesDialog(@NotNull Project project, @NotNull String title, @NotNull List<Change> changes) {
DialogBuilder dialogBuilder = new DialogBuilder(project);
dialogBuilder.setTitle(title);
dialogBuilder.setActionDescriptors(new DialogBuilder.CloseDialogAction());
final ChangesBrowser changesBrowser = new ChangesBrowser(project, null, changes, null, false, true, null, ChangesBrowser.MyUseCase.COMMITTED_CHANGES, null);
changesBrowser.setChangesToDisplay(changes);
dialogBuilder.setCenterPanel(changesBrowser);
dialogBuilder.setPreferredFocusComponent(changesBrowser.getPreferredFocusedComponent());
dialogBuilder.setDimensionServiceKey("VcsDiffUtil.ChangesDialog");
dialogBuilder.showNotModal();
}
use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.
the class AbstractLanguageInjectionSupport method showDefaultInjectionUI.
@Nullable
protected static BaseInjection showDefaultInjectionUI(final Project project, BaseInjection injection) {
final BaseInjectionPanel panel = new BaseInjectionPanel(injection, project);
panel.reset();
final DialogBuilder builder = new DialogBuilder(project);
LanguageInjectionSupport support = InjectorUtils.findInjectionSupport(injection.getSupportId());
if (support instanceof AbstractLanguageInjectionSupport) {
builder.setHelpId(((AbstractLanguageInjectionSupport) support).getHelpId());
}
builder.addOkAction();
builder.addCancelAction();
builder.setDimensionServiceKey("#org.intellij.plugins.intelliLang.inject.config.ui.BaseInjectionDialog");
builder.setCenterPanel(panel.getComponent());
builder.setTitle(EditInjectionSettingsAction.EDIT_INJECTION_TITLE);
builder.setOkOperation(() -> {
try {
panel.apply();
builder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE);
} catch (Exception e) {
final Throwable cause = e.getCause();
final String message = e.getMessage() + (cause != null ? "\n " + cause.getMessage() : "");
Messages.showErrorDialog(project, message, "Unable to Save");
}
});
if (builder.show() == DialogWrapper.OK_EXIT_CODE) {
return injection;
}
return null;
}
use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.
the class JavaLanguageInjectionSupport method showInjectionUI.
private static BaseInjection showInjectionUI(final Project project, final MethodParameterInjection methodParameterInjection) {
final AbstractInjectionPanel panel = new MethodParameterPanel(methodParameterInjection, project);
panel.reset();
final DialogBuilder builder = new DialogBuilder(project);
builder.setHelpId("reference.settings.injection.language.injection.settings.java.parameter");
builder.addOkAction();
builder.addCancelAction();
builder.setCenterPanel(panel.getComponent());
builder.setTitle(EditInjectionSettingsAction.EDIT_INJECTION_TITLE);
builder.setOkOperation(() -> {
panel.apply();
builder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE);
});
if (builder.show() == DialogWrapper.OK_EXIT_CODE) {
return new BaseInjection(methodParameterInjection.getSupportId()).copyFrom(methodParameterInjection);
}
return null;
}
Aggregations