Search in sources :

Example 11 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 12 with DialogBuilder

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;
}
Also used : ComboBox(com.intellij.openapi.ui.ComboBox) ActionEvent(java.awt.event.ActionEvent) JBTextField(com.intellij.ui.components.JBTextField) DependencyOnPlugin(com.intellij.externalDependencies.DependencyOnPlugin) ActionListener(java.awt.event.ActionListener) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) Nullable(org.jetbrains.annotations.Nullable)

Example 13 with DialogBuilder

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();
}
Also used : ChangesBrowser(com.intellij.openapi.vcs.changes.ui.ChangesBrowser) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) CalledInAwt(org.jetbrains.annotations.CalledInAwt)

Example 14 with DialogBuilder

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;
}
Also used : BaseInjectionPanel(org.intellij.plugins.intelliLang.inject.config.ui.BaseInjectionPanel) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) Nullable(org.jetbrains.annotations.Nullable)

Example 15 with DialogBuilder

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;
}
Also used : MethodParameterPanel(org.intellij.plugins.intelliLang.inject.config.ui.MethodParameterPanel) AbstractInjectionPanel(org.intellij.plugins.intelliLang.inject.config.ui.AbstractInjectionPanel) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) BaseInjection(org.intellij.plugins.intelliLang.inject.config.BaseInjection)

Aggregations

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