Search in sources :

Example 6 with DialogWrapper

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

the class EditSourceForDialogAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final Navigatable[] navigatableArray = e.getData(CommonDataKeys.NAVIGATABLE_ARRAY);
    if (navigatableArray != null && navigatableArray.length > 0) {
        ApplicationManager.getApplication().invokeLater(new Runnable() {

            public void run() {
                OpenSourceUtil.navigate(navigatableArray);
            }
        });
        DialogWrapper dialog = DialogWrapper.findInstance(mySourceComponent);
        if (dialog != null && dialog.isModal()) {
            dialog.doCancelAction();
        }
    }
}
Also used : DialogWrapper(com.intellij.openapi.ui.DialogWrapper) Navigatable(com.intellij.pom.Navigatable)

Example 7 with DialogWrapper

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

the class IntroduceVariableHandler method reportConflicts.

protected boolean reportConflicts(final MultiMap<PsiElement, String> conflicts, final Project project, IntroduceVariableSettings dialog) {
    ConflictsDialog conflictsDialog = new ConflictsDialog(project, conflicts);
    conflictsDialog.show();
    final boolean ok = conflictsDialog.isOK();
    if (!ok && conflictsDialog.isShowConflicts()) {
        if (dialog instanceof DialogWrapper)
            ((DialogWrapper) dialog).close(DialogWrapper.CANCEL_EXIT_CODE);
    }
    return ok;
}
Also used : ConflictsDialog(com.intellij.refactoring.ui.ConflictsDialog) DialogWrapper(com.intellij.openapi.ui.DialogWrapper)

Example 8 with DialogWrapper

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

the class XDebuggerEditorBase method showCodeFragmentEditor.

private void showCodeFragmentEditor(Component parent, XDebuggerEditorBase baseEditor) {
    DialogWrapper dialog = new DialogWrapper(parent, true) {

        CodeFragmentInputComponent inputComponent = new CodeFragmentInputComponent(baseEditor.getProject(), baseEditor.getEditorsProvider(), mySourcePosition, XExpressionImpl.changeMode(baseEditor.getExpression(), EvaluationMode.CODE_FRAGMENT), null, null);

        {
            setTitle("Edit");
            init();
        }

        @Nullable
        @Override
        protected String getDimensionServiceKey() {
            return "#xdebugger.code.fragment.editor";
        }

        @Nullable
        @Override
        protected JComponent createCenterPanel() {
            JPanel component = inputComponent.getMainComponent();
            component.setPreferredSize(JBUI.size(300, 200));
            return component;
        }

        @Override
        protected void doOKAction() {
            super.doOKAction();
            baseEditor.setExpression(inputComponent.getInputEditor().getExpression());
            JComponent component = baseEditor.getPreferredFocusedComponent();
            if (component != null) {
                IdeFocusManager.findInstance().requestFocus(component, false);
            }
        }

        @Nullable
        @Override
        public JComponent getPreferredFocusedComponent() {
            return inputComponent.getInputEditor().getPreferredFocusedComponent();
        }
    };
    dialog.show();
}
Also used : CodeFragmentInputComponent(com.intellij.xdebugger.impl.evaluate.CodeFragmentInputComponent) DialogWrapper(com.intellij.openapi.ui.DialogWrapper)

Example 9 with DialogWrapper

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

the class BinaryDiffTool method show.

public void show(final DiffRequest data) {
    final DiffContent current = data.getContents()[0];
    final DiffContent upToDate = data.getContents()[1];
    final Project project = data.getProject();
    if ((current instanceof FileContent && upToDate instanceof FileContent) || (current.getContentType() instanceof UIBasedFileType && upToDate.getContentType() instanceof UIBasedFileType)) {
        final VirtualFile src = current.getFile();
        final VirtualFile trg = upToDate.getFile();
        if (src != null && trg != null) {
            final PanelCreator creator = new PanelCreator(data);
            if (creator.isCanCreatePanel()) {
                new DialogWrapper(data.getProject()) {

                    public DiffPanel myPanel;

                    {
                        setModal(false);
                        init();
                    }

                    @Override
                    protected String getDimensionServiceKey() {
                        return "BinaryDiffDialog";
                    }

                    @NotNull
                    @Override
                    protected Action[] createActions() {
                        final Action close = getCancelAction();
                        close.putValue(Action.NAME, "&Close");
                        return new Action[] { close };
                    }

                    @Override
                    protected JComponent createCenterPanel() {
                        myPanel = creator.create(getWindow(), getDisposable(), BinaryDiffTool.this);
                        return myPanel.getComponent();
                    }
                }.show();
                return;
            } else {
                final DirDiffManager diffManager = DirDiffManager.getInstance(project);
                final DiffElement before = diffManager.createDiffElement(src);
                final DiffElement after = diffManager.createDiffElement(trg);
                if (before != null && after != null && diffManager.canShow(after, before)) {
                    diffManager.showDiff(before, after);
                    return;
                }
            }
        }
    }
    try {
        final boolean equal = Arrays.equals(current.getBytes(), upToDate.getBytes());
        Messages.showMessageDialog(equal ? DiffBundle.message("binary.files.are.identical.message") : DiffBundle.message("binary.files.are.different.message"), equal ? DiffBundle.message("files.are.identical.dialog.title") : DiffBundle.message("files.are.different.dialog.title"), Messages.getInformationIcon());
    } catch (IOException e) {
        LOG.error(e);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DiffElement(com.intellij.ide.diff.DiffElement) IOException(java.io.IOException) NotNull(org.jetbrains.annotations.NotNull) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) Project(com.intellij.openapi.project.Project) UIBasedFileType(com.intellij.openapi.fileTypes.UIBasedFileType)

Example 10 with DialogWrapper

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

the class FileDocumentManagerImpl method handleErrorsOnSave.

private void handleErrorsOnSave(@NotNull Map<Document, IOException> failures) {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        IOException ioException = ContainerUtil.getFirstItem(failures.values());
        if (ioException != null) {
            throw new RuntimeException(ioException);
        }
        return;
    }
    for (IOException exception : failures.values()) {
        LOG.warn(exception);
    }
    final String text = StringUtil.join(failures.values(), Throwable::getMessage, "\n");
    final DialogWrapper dialog = new DialogWrapper(null) {

        {
            init();
            setTitle(UIBundle.message("cannot.save.files.dialog.title"));
        }

        @Override
        protected void createDefaultActions() {
            super.createDefaultActions();
            myOKAction.putValue(Action.NAME, UIBundle.message(myOnClose ? "cannot.save.files.dialog.ignore.changes" : "cannot.save.files.dialog.revert.changes"));
            myOKAction.putValue(DEFAULT_ACTION, null);
            if (!myOnClose) {
                myCancelAction.putValue(Action.NAME, CommonBundle.getCloseButtonText());
            }
        }

        @Override
        protected JComponent createCenterPanel() {
            final JPanel panel = new JPanel(new BorderLayout(0, 5));
            panel.add(new JLabel(UIBundle.message("cannot.save.files.dialog.message")), BorderLayout.NORTH);
            final JTextPane area = new JTextPane();
            area.setText(text);
            area.setEditable(false);
            area.setMinimumSize(new Dimension(area.getMinimumSize().width, 50));
            panel.add(new JBScrollPane(area, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER);
            return panel;
        }
    };
    if (dialog.showAndGet()) {
        for (Document document : failures.keySet()) {
            reloadFromDisk(document);
        }
    }
}
Also used : IOException(java.io.IOException) Document(com.intellij.openapi.editor.Document) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) JBScrollPane(com.intellij.ui.components.JBScrollPane)

Aggregations

DialogWrapper (com.intellij.openapi.ui.DialogWrapper)37 Project (com.intellij.openapi.project.Project)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 ActionEvent (java.awt.event.ActionEvent)6 Nullable (org.jetbrains.annotations.Nullable)6 JBScrollPane (com.intellij.ui.components.JBScrollPane)5 ActionListener (java.awt.event.ActionListener)4 AnAction (com.intellij.openapi.actionSystem.AnAction)3 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)3 Document (com.intellij.openapi.editor.Document)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 MockDocument (com.intellij.mock.MockDocument)2 MockPsiFile (com.intellij.mock.MockPsiFile)2 javax.swing (javax.swing)2 HyperlinkEvent (javax.swing.event.HyperlinkEvent)2 NotNull (org.jetbrains.annotations.NotNull)2 AnnotationTargetUtil (com.intellij.codeInsight.AnnotationTargetUtil)1 DaemonCodeAnalyzer (com.intellij.codeInsight.daemon.DaemonCodeAnalyzer)1 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)1