Search in sources :

Example 21 with DialogBuilder

use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.

the class FileTypeConfigurable method editPattern.

private void editPattern(@Nullable final String item) {
    final FileType type = myRecognizedFileType.getSelectedFileType();
    if (type == null)
        return;
    final String title = item == null ? FileTypesBundle.message("filetype.edit.add.pattern.title") : FileTypesBundle.message("filetype.edit.edit.pattern.title");
    final Language oldLanguage = item == null ? null : myTempTemplateDataLanguages.findAssociatedFileType(item);
    final FileTypePatternDialog dialog = new FileTypePatternDialog(item, type, oldLanguage);
    final DialogBuilder builder = new DialogBuilder(myPatterns);
    builder.setPreferredFocusComponent(dialog.getPatternField());
    builder.setCenterPanel(dialog.getMainPanel());
    builder.setTitle(title);
    builder.showModal(true);
    if (builder.getDialogWrapper().isOK()) {
        final String pattern = dialog.getPatternField().getText();
        if (StringUtil.isEmpty(pattern))
            return;
        final FileNameMatcher matcher = FileTypeManager.parseFromString(pattern);
        FileType registeredFileType = findExistingFileType(matcher);
        if (registeredFileType != null && registeredFileType != type) {
            if (registeredFileType.isReadOnly()) {
                Messages.showMessageDialog(myPatterns.myPatternsList, FileTypesBundle.message("filetype.edit.add.pattern.exists.error", registeredFileType.getDescription()), title, Messages.getErrorIcon());
                return;
            } else {
                if (Messages.OK == Messages.showOkCancelDialog(myPatterns.myPatternsList, FileTypesBundle.message("filetype.edit.add.pattern.exists.message", registeredFileType.getDescription()), FileTypesBundle.message("filetype.edit.add.pattern.exists.title"), FileTypesBundle.message("filetype.edit.add.pattern.reassign.button"), CommonBundle.getCancelButtonText(), Messages.getQuestionIcon())) {
                    myTempPatternsTable.removeAssociation(matcher, registeredFileType);
                    if (oldLanguage != null) {
                        myTempTemplateDataLanguages.removeAssociation(matcher, oldLanguage);
                    }
                    myReassigned.put(matcher, registeredFileType);
                } else {
                    return;
                }
            }
        }
        if (item != null) {
            final FileNameMatcher oldMatcher = FileTypeManager.parseFromString(item);
            myTempPatternsTable.removeAssociation(oldMatcher, type);
            if (oldLanguage != null) {
                myTempTemplateDataLanguages.removeAssociation(oldMatcher, oldLanguage);
            }
        }
        myTempPatternsTable.addAssociation(matcher, type);
        myTempTemplateDataLanguages.addAssociation(matcher, dialog.getTemplateDataLanguage());
        updateExtensionList();
        final int index = myPatterns.getListModel().indexOf(matcher.getPresentableString());
        if (index >= 0) {
            ScrollingUtil.selectItem(myPatterns.myPatternsList, index);
        }
        IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
            IdeFocusManager.getGlobalInstance().requestFocus(myPatterns.myPatternsList, true);
        });
    }
}
Also used : Language(com.intellij.lang.Language) DialogBuilder(com.intellij.openapi.ui.DialogBuilder)

Example 22 with DialogBuilder

use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.

the class MergeTool method showDialog.

private static void showDialog(MergeRequestImpl data) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("MergeTool - dialog");
    }
    DialogBuilder builder = new DialogBuilder(data.getProject());
    builder.setDimensionServiceKey(data.getGroupKey());
    builder.setTitle(data.getWindowTitle());
    Disposable parent = Disposer.newDisposable();
    builder.addDisposable(parent);
    MergePanel2 mergePanel = createMergeComponent(data, builder, parent);
    builder.setCenterPanel(mergePanel.getComponent());
    builder.setPreferredFocusComponent(mergePanel.getPreferredFocusedComponent());
    builder.setHelpId(data.getHelpId());
    int result = builder.show();
    MergeRequestImpl lastData = mergePanel.getMergeRequest();
    if (lastData != null) {
        lastData.setResult(result);
    }
}
Also used : Disposable(com.intellij.openapi.Disposable) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) MergePanel2(com.intellij.openapi.diff.impl.incrementalMerge.ui.MergePanel2)

Example 23 with DialogBuilder

use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.

the class FrameDiffTool method show.

public void show(DiffRequest request) {
    Collection hints = request.getHints();
    boolean shouldOpenDialog = shouldOpenDialog(hints);
    if (shouldOpenDialog) {
        final DialogBuilder builder = new DialogBuilder(request.getProject());
        DiffPanelImpl diffPanel = createDiffPanelIfShouldShow(request, builder.getWindow(), builder, true);
        if (diffPanel == null) {
            Disposer.dispose(builder);
            return;
        }
        final Runnable onOkRunnable = request.getOnOkRunnable();
        if (onOkRunnable != null) {
            builder.setOkOperation(() -> {
                builder.getDialogWrapper().close(0);
                onOkRunnable.run();
            });
        } else {
            builder.removeAllActions();
        }
        builder.setCenterPanel(diffPanel.getComponent());
        builder.setPreferredFocusComponent(diffPanel.getPreferredFocusedComponent());
        builder.setTitle(request.getWindowTitle());
        builder.setDimensionServiceKey(request.getGroupKey());
        new AnAction() {

            public void actionPerformed(final AnActionEvent e) {
                builder.getDialogWrapper().close(0);
            }
        }.registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent());
        showDiffDialog(builder, hints);
    } else {
        final FrameWrapper frameWrapper = new FrameWrapper(request.getProject(), request.getGroupKey());
        DiffPanelImpl diffPanel = createDiffPanelIfShouldShow(request, frameWrapper.getFrame(), frameWrapper, true);
        if (diffPanel == null) {
            Disposer.dispose(frameWrapper);
            return;
        }
        frameWrapper.setTitle(request.getWindowTitle());
        DiffUtil.initDiffFrame(diffPanel.getProject(), frameWrapper, diffPanel, diffPanel.getComponent());
        new AnAction() {

            public void actionPerformed(final AnActionEvent e) {
                frameWrapper.getFrame().dispose();
            }
        }.registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent());
        frameWrapper.show();
    }
}
Also used : CustomShortcutSet(com.intellij.openapi.actionSystem.CustomShortcutSet) DiffPanelImpl(com.intellij.openapi.diff.impl.DiffPanelImpl) Collection(java.util.Collection) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) FrameWrapper(com.intellij.openapi.ui.FrameWrapper) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 24 with DialogBuilder

use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.

the class MultiLevelDiffTool method show.

@Override
public void show(DiffRequest request) {
    Collection hints = request.getHints();
    boolean shouldOpenDialog = FrameDiffTool.shouldOpenDialog(hints);
    if (shouldOpenDialog) {
        final DialogBuilder builder = new DialogBuilder(request.getProject());
        final CompositeDiffPanel diffPanel = createPanel(request, builder.getWindow(), builder);
        if (diffPanel == null) {
            Disposer.dispose(builder);
            return;
        }
        final Runnable onOkRunnable = request.getOnOkRunnable();
        if (onOkRunnable != null) {
            builder.setOkOperation(() -> {
                builder.getDialogWrapper().close(0);
                onOkRunnable.run();
            });
        } else {
            builder.removeAllActions();
        }
        builder.setCenterPanel(diffPanel.getComponent());
        builder.setPreferredFocusComponent(diffPanel.getPreferredFocusedComponent());
        builder.setTitle(request.getWindowTitle());
        builder.setDimensionServiceKey(request.getGroupKey());
        new AnAction() {

            public void actionPerformed(final AnActionEvent e) {
                builder.getDialogWrapper().close(0);
            }
        }.registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent());
        diffPanel.setDiffRequest(request);
        FrameDiffTool.showDiffDialog(builder, hints);
    } else {
        final FrameWrapper frameWrapper = new FrameWrapper(request.getProject(), request.getGroupKey());
        final CompositeDiffPanel diffPanel = createPanel(request, frameWrapper.getFrame(), frameWrapper);
        if (diffPanel == null) {
            Disposer.dispose(frameWrapper);
            return;
        }
        frameWrapper.setTitle(request.getWindowTitle());
        diffPanel.setDiffRequest(request);
        DiffUtil.initDiffFrame(request.getProject(), frameWrapper, diffPanel, diffPanel.getComponent());
        new AnAction() {

            public void actionPerformed(final AnActionEvent e) {
                Disposer.dispose(frameWrapper);
            }
        }.registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent());
        frameWrapper.show();
    }
}
Also used : CustomShortcutSet(com.intellij.openapi.actionSystem.CustomShortcutSet) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) FrameWrapper(com.intellij.openapi.ui.FrameWrapper) CompositeDiffPanel(com.intellij.openapi.diff.impl.CompositeDiffPanel) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 25 with DialogBuilder

use of com.intellij.openapi.ui.DialogBuilder in project intellij-community by JetBrains.

the class XmlLanguageInjectionSupport method showInjectionUI.

@Nullable
private static BaseInjection showInjectionUI(final Project project, final BaseInjection xmlInjection) {
    final DialogBuilder builder = new DialogBuilder(project);
    final AbstractInjectionPanel panel;
    if (xmlInjection instanceof XmlTagInjection) {
        panel = new XmlTagPanel((XmlTagInjection) xmlInjection, project);
        builder.setHelpId("reference.settings.injection.language.injection.settings.xml.tag");
    } else if (xmlInjection instanceof XmlAttributeInjection) {
        panel = new XmlAttributePanel((XmlAttributeInjection) xmlInjection, project);
        builder.setHelpId("reference.settings.injection.language.injection.settings.xml.attribute");
    } else
        throw new AssertionError();
    panel.reset();
    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 xmlInjection.copy();
    }
    return null;
}
Also used : AbstractInjectionPanel(org.intellij.plugins.intelliLang.inject.config.ui.AbstractInjectionPanel) XmlTagPanel(org.intellij.plugins.intelliLang.inject.config.ui.XmlTagPanel) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) XmlAttributePanel(org.intellij.plugins.intelliLang.inject.config.ui.XmlAttributePanel) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

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