Example usage for com.intellij.openapi.ui Messages showOkCancelDialog

List of usage examples for com.intellij.openapi.ui Messages showOkCancelDialog

Introduction

In this page you can find the example usage for com.intellij.openapi.ui Messages showOkCancelDialog.

Prototype

@OkCancelResult
@Deprecated
public static int showOkCancelDialog(@NotNull Component parent, String message,
        @Nls(capitalization = Nls.Capitalization.Title) String title, Icon icon) 

Source Link

Usage

From source file:org.jetbrains.idea.svn.dialogs.CopiesPanel.java

License:Apache License

private void updateList(@NotNull final List<WCInfo> infoList,
        @NotNull final List<WorkingCopyFormat> supportedFormats) {
    myPanel.removeAll();//  w w w  .ja v a 2s .  c o m
    final Insets nullIndent = new Insets(1, 3, 1, 0);
    final GridBagConstraints gb = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE, new Insets(2, 2, 0, 0), 0, 0);
    gb.insets.left = 4;
    myPanel.add(myRefreshLabel, gb);
    gb.insets.left = 1;

    final LocalFileSystem lfs = LocalFileSystem.getInstance();
    final Insets topIndent = new Insets(10, 3, 0, 0);
    for (final WCInfo wcInfo : infoList) {
        final Collection<WorkingCopyFormat> upgradeFormats = getUpgradeFormats(wcInfo, supportedFormats);

        final VirtualFile vf = lfs.refreshAndFindFileByIoFile(new File(wcInfo.getPath()));
        final VirtualFile root = (vf == null) ? wcInfo.getVcsRoot() : vf;

        final JEditorPane editorPane = new JEditorPane(UIUtil.HTML_MIME, "");
        editorPane.setEditable(false);
        editorPane.setFocusable(true);
        editorPane.setBackground(UIUtil.getPanelBackground());
        editorPane.setOpaque(false);
        editorPane.addHyperlinkListener(new HyperlinkListener() {
            @Override
            public void hyperlinkUpdate(HyperlinkEvent e) {
                if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    if (CONFIGURE_BRANCHES.equals(e.getDescription())) {
                        if (!checkRoot(root, wcInfo.getPath(), " invoke Configure Branches"))
                            return;
                        BranchConfigurationDialog.configureBranches(myProject, root, true);
                    } else if (FIX_DEPTH.equals(e.getDescription())) {
                        final int result = Messages.showOkCancelDialog(myVcs.getProject(),
                                "You are going to checkout into '" + wcInfo.getPath()
                                        + "' with 'infinity' depth.\n"
                                        + "This will update your working copy to HEAD revision as well.",
                                "Set Working Copy Infinity Depth", Messages.getWarningIcon());
                        if (result == Messages.OK) {
                            // update of view will be triggered by roots changed event
                            SvnCheckoutProvider.checkout(myVcs.getProject(), new File(wcInfo.getPath()),
                                    wcInfo.getRootUrl(), SVNRevision.HEAD, SVNDepth.INFINITY, false, null,
                                    wcInfo.getFormat());
                        }
                    } else if (CHANGE_FORMAT.equals(e.getDescription())) {
                        changeFormat(wcInfo, upgradeFormats);
                    } else if (MERGE_FROM.equals(e.getDescription())) {
                        if (!checkRoot(root, wcInfo.getPath(), " invoke Merge From"))
                            return;
                        mergeFrom(wcInfo, root, editorPane);
                    } else if (CLEANUP.equals(e.getDescription())) {
                        if (!checkRoot(root, wcInfo.getPath(), " invoke Cleanup"))
                            return;
                        new CleanupWorker(new VirtualFile[] { root }, myVcs.getProject(),
                                "action.Subversion.cleanup.progress.title").execute();
                    }
                }
            }

            private boolean checkRoot(VirtualFile root, final String path, final String actionName) {
                if (root == null) {
                    Messages.showWarningDialog(myProject, "Invalid working copy root: " + path,
                            "Can not " + actionName);
                    return false;
                }
                return true;
            }
        });
        editorPane.setBorder(null);
        editorPane.setText(formatWc(wcInfo, upgradeFormats));

        final JPanel copyPanel = new JPanel(new GridBagLayout());

        final GridBagConstraints gb1 = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST,
                GridBagConstraints.NONE, nullIndent, 0, 0);
        gb1.insets.top = 1;
        gb1.gridwidth = 3;

        gb.insets = topIndent;
        gb.fill = GridBagConstraints.HORIZONTAL;
        ++gb.gridy;

        final JPanel contForCopy = new JPanel(new BorderLayout());
        contForCopy.add(copyPanel, BorderLayout.WEST);
        myPanel.add(contForCopy, gb);

        copyPanel.add(editorPane, gb1);
        gb1.insets = nullIndent;
    }

    myPanel.revalidate();
    myPanel.repaint();
}

From source file:org.jetbrains.idea.svn.integrate.QuickMergeInteractionImpl.java

License:Apache License

private boolean prompt(final String question) {
    return Messages.showOkCancelDialog(myProject, question, myTitle, Messages.getQuestionIcon()) == Messages.OK;
}

From source file:org.jetbrains.idea.svn.treeConflict.MergeFromTheirsResolver.java

License:Apache License

public void execute() {
    int ok = Messages.showOkCancelDialog(myVcs.getProject(),
            (myChange.isMoved()/*from  w w  w .j  a  v a2s.  com*/
                    ? SvnBundle.message("confirmation.resolve.tree.conflict.merge.moved", myOldPresentation,
                            myNewPresentation)
                    : SvnBundle.message("confirmation.resolve.tree.conflict.merge.renamed", myOldPresentation,
                            myNewPresentation)),
            TreeConflictRefreshablePanel.TITLE, Messages.getQuestionIcon());
    if (Messages.OK != ok)
        return;

    FileDocumentManager.getInstance().saveAllDocuments();
    //final String name = "Merge changes from theirs for: " + myOldPresentation;

    final Continuation fragmented = Continuation.createFragmented(myVcs.getProject(), false);
    fragmented.addExceptionHandler(VcsException.class, new Consumer<VcsException>() {
        @Override
        public void consume(VcsException e) {
            myWarnings.add(e);
            if (e.isWarning()) {
                return;
            }
            AbstractVcsHelper.getInstance(myVcs.getProject()).showErrors(myWarnings,
                    TreeConflictRefreshablePanel.TITLE);
        }
    });

    final List<TaskDescriptor> tasks = new SmartList<TaskDescriptor>();
    if (SVNNodeKind.DIR.equals(myDescription.getNodeKind())) {
        tasks.add(new PreloadChangesContentsForDir());
    } else {
        tasks.add(new PreloadChangesContentsForFile());
    }
    tasks.add(new ConvertTextPaths());
    tasks.add(new PatchCreator());
    tasks.add(new SelectPatchesInApplyPatchDialog());
    tasks.add(new SelectBinaryFiles());

    fragmented.run(tasks);
}

From source file:org.jetbrains.idea.svn.treeConflict.TreeConflictRefreshablePanel.java

License:Apache License

private ActionListener createRight(final SVNTreeConflictDescription description) {
    return new ActionListener() {
        @Override//from w  w w.ja v a2  s.  com
        public void actionPerformed(ActionEvent e) {
            int ok = Messages.showOkCancelDialog(myVcs.getProject(),
                    "Accept theirs for " + filePath(myPath) + "?", TITLE, Messages.getQuestionIcon());
            if (Messages.OK != ok)
                return;
            FileDocumentManager.getInstance().saveAllDocuments();
            final Paths paths = getPaths(description);
            ProgressManager.getInstance().run(new VcsBackgroundTask<SVNTreeConflictDescription>(
                    myVcs.getProject(), "Accepting theirs for: " + filePath(paths.myMainPath),
                    BackgroundFromStartOption.getInstance(), Collections.singletonList(description), true) {
                @Override
                protected void process(SVNTreeConflictDescription d) throws VcsException {
                    new SvnTreeConflictResolver(myVcs, paths.myMainPath, myCommittedRevision,
                            paths.myAdditionalPath).resolveSelectTheirsFull(d);
                }

                @Override
                public void onSuccess() {
                    super.onSuccess();
                    if (executedOk()) {
                        VcsBalloonProblemNotifier.showOverChangesView(myProject,
                                "Theirs accepted for " + filePath(paths.myMainPath), MessageType.INFO);
                    }
                }
            });
        }
    };
}

From source file:org.jetbrains.idea.svn.treeConflict.TreeConflictRefreshablePanel.java

License:Apache License

private ActionListener createLeft(final SVNTreeConflictDescription description) {
    return new ActionListener() {
        @Override//from  w  w w.  ja v a  2 s  .  co  m
        public void actionPerformed(ActionEvent e) {
            int ok = Messages.showOkCancelDialog(myVcs.getProject(),
                    "Accept yours for " + filePath(myPath) + "?", TITLE, Messages.getQuestionIcon());
            if (Messages.OK != ok)
                return;
            FileDocumentManager.getInstance().saveAllDocuments();
            final Paths paths = getPaths(description);
            ProgressManager.getInstance().run(new VcsBackgroundTask<SVNTreeConflictDescription>(
                    myVcs.getProject(), "Accepting yours for: " + filePath(paths.myMainPath),
                    BackgroundFromStartOption.getInstance(), Collections.singletonList(description), true) {
                @Override
                protected void process(SVNTreeConflictDescription d) throws VcsException {
                    new SvnTreeConflictResolver(myVcs, paths.myMainPath, myCommittedRevision,
                            paths.myAdditionalPath).resolveSelectMineFull(d);
                }

                @Override
                public void onSuccess() {
                    super.onSuccess();
                    if (executedOk()) {
                        VcsBalloonProblemNotifier.showOverChangesView(myProject,
                                "Yours accepted for " + filePath(paths.myMainPath), MessageType.INFO);
                    }
                }
            });
        }
    };
}

From source file:org.jetbrains.jet.plugin.refactoring.safeDelete.KotlinSafeDeleteProcessor.java

License:Apache License

@Nullable
private static Collection<? extends PsiElement> checkParametersInMethodHierarchy(
        @NotNull PsiParameter parameter) {
    PsiMethod method = (PsiMethod) parameter.getDeclarationScope();
    int parameterIndex = method.getParameterList().getParameterIndex(parameter);

    Set<PsiElement> parametersToDelete = collectParametersToDelete(method, parameterIndex);
    if (parametersToDelete.size() > 1) {
        if (ApplicationManager.getApplication().isUnitTestMode()) {
            return parametersToDelete;
        }//from  w  ww .  j  a  v a 2 s.co m

        String message = JetBundle.message("delete.param.in.method.hierarchy",
                JetRefactoringUtil.formatJavaOrLightMethod(method));
        int exitCode = Messages.showOkCancelDialog(parameter.getProject(), message,
                IdeBundle.message("title.warning"), Messages.getQuestionIcon());
        if (exitCode == Messages.OK) {
            return parametersToDelete;
        } else {
            return null;
        }
    }

    return parametersToDelete;
}

From source file:org.jetbrains.kotlin.idea.refactoring.JetRefactoringUtil.java

License:Apache License

@Nullable
public static Collection<? extends PsiElement> checkParametersInMethodHierarchy(
        @NotNull PsiParameter parameter) {
    PsiMethod method = (PsiMethod) parameter.getDeclarationScope();

    Set<PsiElement> parametersToDelete = collectParametersHierarchy(method, parameter);
    if (parametersToDelete.size() > 1) {
        if (ApplicationManager.getApplication().isUnitTestMode()) {
            return parametersToDelete;
        }/* www.j  a v a2 s .com*/

        String message = KotlinBundle.message("delete.param.in.method.hierarchy",
                formatJavaOrLightMethod(method));
        int exitCode = Messages.showOkCancelDialog(parameter.getProject(), message,
                IdeBundle.message("title.warning"), Messages.getQuestionIcon());
        if (exitCode == Messages.OK) {
            return parametersToDelete;
        } else {
            return null;
        }
    }

    return parametersToDelete;
}

From source file:org.jetbrains.plugins.groovy.annotator.intentions.dynamic.DynamicToolWindowWrapper.java

License:Apache License

private boolean removeDynamicElement(DefaultMutableTreeNode child, boolean isShowDialog, int rowsCount) {
    Object namedElement = child.getUserObject();

    if (!(namedElement instanceof DNamedElement))
        return false;

    if (isShowDialog) {
        int result;
        if (rowsCount > 1) {
            result = Messages.showOkCancelDialog(myBigPanel,
                    GroovyBundle.message("are.you.sure.to.delete.elements", String.valueOf(rowsCount)),
                    GroovyBundle.message("dynamic.element.deletion"), Messages.getQuestionIcon());

        } else {//  w ww.j ava  2  s  .c  o m
            result = Messages.showOkCancelDialog(myBigPanel,
                    GroovyBundle.message("are.you.sure.to.delete.dynamic.property",
                            ((DNamedElement) namedElement).getName()),
                    GroovyBundle.message("dynamic.property.deletion"), Messages.getQuestionIcon());
        }

        if (result != DialogWrapper.OK_EXIT_CODE)
            return false;
    }

    removeNamedElement(((DNamedElement) namedElement));

    return true;
}

From source file:org.jetbrains.plugins.groovy.doc.GenerateGroovyDocDialog.java

License:Apache License

private boolean checkDir(String dirName, String dirPrefix) {
    if (dirName == null || dirName.trim().length() == 0) {
        Messages.showMessageDialog(myProject,
                GroovyDocBundle.message("groovydoc.generate.0.directory.not.specified", dirPrefix),
                CommonBundle.getErrorTitle(), Messages.getErrorIcon());
        return false;
    }//ww  w.ja va2 s  .  c o m

    File dir = new File(dirName);
    if (dir.exists()) {
        if (!dir.isDirectory()) {
            showError(GroovyDocBundle.message("groovydoc.generate.not.a.directory", dirName));
            return false;
        }
    } else {
        int choice = Messages.showOkCancelDialog(myProject,
                GroovyDocBundle.message("groovydoc.generate.directory.not.exists", dirName),
                GroovyDocBundle.message("groovydoc.generate.message.title"), Messages.getWarningIcon());
        if (choice != 0)
            return false;
        if (!dir.mkdirs()) {
            showError(GroovyDocBundle.message("groovydoc.generate.directory.creation.failed", dirName));
            return false;
        }
    }
    return true;
}

From source file:org.jetbrains.plugins.groovy.refactoring.introduce.constant.GrIntroduceConstantDialog.java

License:Apache License

@Override
protected void doOKAction() {
    final String targetClassName = getTargetClassName();

    if (myDefaultTargetClass == null || !targetClassName.isEmpty()
            && !Comparing.strEqual(targetClassName, myDefaultTargetClass.getQualifiedName())) {
        final Module module = ModuleUtilCore.findModuleForPsiElement(myContext.getPlace());
        JavaPsiFacade facade = JavaPsiFacade.getInstance(myContext.getProject());
        PsiClass newClass = facade.findClass(targetClassName,
                GlobalSearchScope.projectScope(myContext.getProject()));

        if (newClass == null && Messages.showOkCancelDialog(myContext.getProject(),
                GroovyRefactoringBundle.message("class.does.not.exist.in.the.module"),
                IntroduceConstantHandler.REFACTORING_NAME, Messages.getErrorIcon()) != OK_EXIT_CODE) {
            return;
        }//  www  . j  a  v  a 2  s  . c  om
        myTargetClassInfo = new TargetClassInfo(targetClassName,
                myContext.getPlace().getContainingFile().getContainingDirectory(), module,
                myContext.getProject());
    } else {
        myTargetClassInfo = new TargetClassInfo(myDefaultTargetClass);
    }

    JavaRefactoringSettings.getInstance().INTRODUCE_CONSTANT_VISIBILITY = getVisibilityModifier();

    RecentsManager.getInstance(myContext.getProject()).registerRecentEntry(RECENTS_KEY, targetClassName);

    super.doOKAction();
}