Search in sources :

Example 1 with BaseInjectionPanel

use of org.intellij.plugins.intelliLang.inject.config.ui.BaseInjectionPanel 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)

Aggregations

DialogBuilder (com.intellij.openapi.ui.DialogBuilder)1 BaseInjectionPanel (org.intellij.plugins.intelliLang.inject.config.ui.BaseInjectionPanel)1 Nullable (org.jetbrains.annotations.Nullable)1