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

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

Introduction

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

Prototype

String NO_BUTTON

To view the source code for com.intellij.openapi.ui Messages NO_BUTTON.

Click Source Link

Document

Use {code #getNoButton() } instead

Usage

From source file:com.android.tools.idea.uibuilder.property.NlIdPropertyItem.java

License:Apache License

@Override
public void setValue(Object value) {
    String newId = value != null ? stripIdPrefix(value.toString()) : "";
    String oldId = getValue();/*from   ww w .  j  a va  2s .c o  m*/
    XmlTag tag = getTag();

    if (ourRefactoringChoice != REFACTOR_NO && oldId != null && !oldId.isEmpty() && !newId.isEmpty()
            && !oldId.equals(newId) && tag != null && tag.isValid()) {
        // Offer rename refactoring?
        XmlAttribute attribute = tag.getAttribute(SdkConstants.ATTR_ID, SdkConstants.ANDROID_URI);
        if (attribute != null) {
            Module module = getModel().getModule();
            Project project = module.getProject();
            XmlAttributeValue valueElement = attribute.getValueElement();
            if (valueElement != null && valueElement.isValid()) {
                // Exact replace only, no comment/text occurrence changes since it is non-interactive
                ValueResourceElementWrapper wrapper = new ValueResourceElementWrapper(valueElement);
                RenameProcessor processor = new RenameProcessor(project, wrapper, NEW_ID_PREFIX + newId,
                        false /*comments*/, false /*text*/);
                processor.setPreviewUsages(false);
                // Do a quick usage search to see if we need to ask about renaming
                UsageInfo[] usages = processor.findUsages();
                if (usages.length > 0) {
                    int choice = ourRefactoringChoice;
                    if (choice == REFACTOR_ASK) {
                        DialogBuilder builder = createDialogBuilder(project);
                        builder.setTitle("Update Usages?");
                        JPanel panel = new JPanel(new BorderLayout()); // UGH!
                        JLabel label = new JLabel("<html>" + "Update usages as well?<br>"
                                + "This will update all XML references and Java R field references.<br>"
                                + "<br>" + "</html>");
                        panel.add(label, BorderLayout.CENTER);
                        JBCheckBox checkBox = new JBCheckBox("Don't ask again during this session");
                        panel.add(checkBox, BorderLayout.SOUTH);
                        builder.setCenterPanel(panel);
                        builder.setDimensionServiceKey("idPropertyDimension");
                        builder.removeAllActions();

                        DialogBuilder.CustomizableAction yesAction = builder.addOkAction();
                        yesAction.setText(Messages.YES_BUTTON);

                        builder.addActionDescriptor(dialogWrapper -> new AbstractAction(Messages.NO_BUTTON) {
                            @Override
                            public void actionPerformed(ActionEvent actionEvent) {
                                dialogWrapper.close(DialogWrapper.NEXT_USER_EXIT_CODE);
                            }
                        });
                        builder.addCancelAction();
                        int exitCode = builder.show();

                        choice = exitCode == DialogWrapper.OK_EXIT_CODE ? REFACTOR_YES
                                : exitCode == DialogWrapper.NEXT_USER_EXIT_CODE ? REFACTOR_NO
                                        : ourRefactoringChoice;

                        //noinspection AssignmentToStaticFieldFromInstanceMethod
                        ourRefactoringChoice = checkBox.isSelected() ? choice : REFACTOR_ASK;

                        if (exitCode == DialogWrapper.CANCEL_EXIT_CODE) {
                            return;
                        }
                    }

                    if (choice == REFACTOR_YES) {
                        processor.run();
                        return;
                    }
                }
            }
        }
    }

    super.setValue(!StringUtil.isEmpty(newId) ? NEW_ID_PREFIX + newId : null);
}

From source file:com.intellij.dvcs.branch.DvcsTaskHandler.java

License:Apache License

@Override
public TaskInfo startNewTask(@NotNull final String taskName) {
    List<R> repositories = myRepositoryManager.getRepositories();
    List<R> problems = ContainerUtil.filter(repositories, new Condition<R>() {
        @Override/*  www  . j av a  2  s . c  om*/
        public boolean value(R repository) {
            return hasBranch(repository, taskName);
        }
    });
    MultiMap<String, String> map = new MultiMap<String, String>();
    if (!problems.isEmpty()) {
        if (ApplicationManager.getApplication().isUnitTestMode() || Messages.showDialog(myProject,
                "<html>The following repositories already have specified " + myBranchType + "<b>" + taskName
                        + "</b>:<br>" + StringUtil.join(problems, "<br>") + ".<br>"
                        + "Do you want to checkout existing " + myBranchType + "?",
                myBranchType + " Already Exists", new String[] { Messages.YES_BUTTON, Messages.NO_BUTTON }, 0,
                Messages.getWarningIcon(),
                new DialogWrapper.PropertyDoNotAskOption("git.checkout.existing.branch")) == 0) {
            checkout(taskName, problems, null);
            fillMap(taskName, problems, map);
        }
    }
    repositories.removeAll(problems);
    if (!repositories.isEmpty()) {
        checkoutAsNewBranch(taskName, repositories);
    }

    fillMap(taskName, repositories, map);
    return new TaskInfo(map);
}

From source file:com.microsoft.alm.plugin.idea.git.ui.pullrequest.VcsPullRequestsModel.java

License:Open Source License

/**
 * Gets the selected pull request and tries to set its state to ABANDONED
 * Runs on a background thread and notifies user upon completion
 *//*from   w w w.jav  a 2 s .  c o m*/
public void abandonSelectedPullRequest() {
    if (isTfGitRepository()) {
        final ServerContext context = TfGitHelper.getSavedServerContext(gitRepository);

        final Task.Backgroundable abandonPullRequestTask = new Task.Backgroundable(project,
                TfPluginBundle.message(TfPluginBundle.KEY_VCS_PR_TITLE)) {
            boolean abandonPR;

            @Override
            public void run(final ProgressIndicator indicator) {
                final GitPullRequest pullRequest = getSelectedPullRequest();
                if (pullRequest != null) {
                    final String prLink = getPullRequestWebLink(context.getGitRepository().getRemoteUrl(),
                            pullRequest.getPullRequestId());
                    final int prId = pullRequest.getPullRequestId();

                    //prompt user for confirmation
                    IdeaHelper.runOnUIThread(new Runnable() {
                        @Override
                        public void run() {
                            abandonPR = IdeaHelper.showConfirmationDialog(project,
                                    TfPluginBundle.message(TfPluginBundle.KEY_VCS_PR_ABANDON_CONFIRMATION,
                                            prId),
                                    TfPluginBundle.message(TfPluginBundle.KEY_VCS_PR_TITLE), Icons.VSLogo,
                                    Messages.YES_BUTTON, Messages.NO_BUTTON);
                        }
                    }, true, indicator.getModalityState());

                    if (abandonPR) {
                        try {
                            final GitPullRequest pullRequestToUpdate = new GitPullRequest();
                            pullRequestToUpdate.setStatus(PullRequestStatus.ABANDONED);
                            final GitPullRequest pr = context.getGitHttpClient().updatePullRequest(
                                    pullRequestToUpdate, pullRequest.getRepository().getId(),
                                    pullRequest.getPullRequestId());

                            if (pr != null && pr.getStatus() == PullRequestStatus.ABANDONED) {
                                //success
                                notifyOperationStatus(true, TfPluginBundle
                                        .message(TfPluginBundle.KEY_VCS_PR_ABANDON_SUCCEEDED, prLink, prId));
                            } else {
                                logger.warn(
                                        "abandonSelectedPullRequest: pull request status not ABANDONED as expected. Actual status = {}",
                                        pr != null ? pr.getStatus() : "null");
                                notifyOperationStatus(false, TfPluginBundle
                                        .message(TfPluginBundle.KEY_VCS_PR_ABANDON_FAILED, prLink, prId));
                            }
                        } catch (Throwable t) {
                            logger.warn("abandonSelectedPullRequest: Unexpected exception", t);
                            notifyOperationStatus(false, TfPluginBundle
                                    .message(TfPluginBundle.KEY_VCS_PR_ABANDON_FAILED, prLink, prId));
                        }
                    }
                } else {
                    //no pull request selected
                    notifyOperationStatus(false,
                            TfPluginBundle.message(TfPluginBundle.KEY_VCS_PR_ABANDON_FAILED_NO_SELECTION));
                }
            }
        };

        if (context != null) {
            abandonPullRequestTask.queue();
        }
    }
}

From source file:org.cordovastudio.editors.designer.propertyTable.properties.IdProperty.java

License:Apache License

@Override
public void setValue(@NotNull final RadViewComponent component, final Object value) throws Exception {
    final String newId = value != null ? value.toString() : "";

    IdManager idManager = IdManager.get(component);
    final String oldId = component.getId();

    if (ourRefactoringChoice != REFACTOR_NO && oldId != null && !oldId.isEmpty() && !newId.isEmpty()
            && !oldId.equals(newId) && component.getTag().isValid()) {
        // Offer rename refactoring?
        XmlTag tag = component.getTag();
        XmlAttribute attribute = tag.getAttribute(ATTR_ID, CORDOVASTUDIO_URI);
        if (attribute != null) {
            Module module = RadModelBuilder.getModule(component);
            if (module != null) {
                XmlAttributeValue valueElement = attribute.getValueElement();
                if (valueElement != null && valueElement.isValid()) {
                    final Project project = module.getProject();
                    // Exact replace only, no comment/text occurrence changes since it is non-interactive
                    RenameProcessor processor = new RenameProcessor(project, valueElement, newId,
                            false /*comments*/, false /*text*/);
                    processor.setPreviewUsages(false);
                    // Do a quick usage search to see if we need to ask about renaming
                    UsageInfo[] usages = processor.findUsages();
                    if (usages.length > 0) {
                        int choice = ourRefactoringChoice;
                        if (choice == REFACTOR_ASK) {
                            DialogBuilder builder = new DialogBuilder(project);
                            builder.setTitle("Update Usages?");
                            JPanel panel = new JPanel(new BorderLayout()); // UGH!
                            JLabel label = new JLabel("<html>" + "Update usages as well?<br>"
                                    + "This will update all XML references and Java R field references.<br>"
                                    + "<br>" + "</html>");
                            panel.add(label, BorderLayout.CENTER);
                            JBCheckBox checkBox = new JBCheckBox("Don't ask again during this session");
                            panel.add(checkBox, BorderLayout.SOUTH);
                            builder.setCenterPanel(panel);
                            builder.setDimensionServiceKey("idPropertyDimension");
                            builder.removeAllActions();

                            DialogBuilder.CustomizableAction yesAction = builder.addOkAction();
                            yesAction.setText(Messages.YES_BUTTON);

                            builder.addActionDescriptor(new DialogBuilder.ActionDescriptor() {
                                @Override
                                public Action getAction(final DialogWrapper dialogWrapper) {
                                    return new AbstractAction(Messages.NO_BUTTON) {
                                        @Override
                                        public void actionPerformed(ActionEvent actionEvent) {
                                            dialogWrapper.close(DialogWrapper.NEXT_USER_EXIT_CODE);
                                        }
                                    };//ww  w .j  a  v a2s.  com
                                }
                            });
                            builder.addCancelAction();
                            int exitCode = builder.show();

                            choice = exitCode == DialogWrapper.OK_EXIT_CODE ? REFACTOR_YES
                                    : exitCode == DialogWrapper.NEXT_USER_EXIT_CODE ? REFACTOR_NO
                                            : ourRefactoringChoice;

                            if (!checkBox.isSelected()) {
                                ourRefactoringChoice = REFACTOR_ASK;
                            } else {
                                ourRefactoringChoice = choice;
                            }

                            if (exitCode == DialogWrapper.CANCEL_EXIT_CODE) {
                                return;
                            }
                        }

                        if (choice == REFACTOR_YES) {
                            processor.run();
                            // Fall through to also set the value in the layout editor property; otherwise we'll be out of sync
                        }
                    }
                }
            }
        }
    }

    if (idManager != null) {
        idManager.removeComponent(component, false);
    }

    //noinspection ConstantConditions
    super.setValue(component, value);

    if (idManager != null) {
        idManager.addComponent(component);
    }
}

From source file:org.moe.designer.propertyTable.IdProperty.java

License:Apache License

@Override
public void setValue(@NotNull final RadViewComponent component, final Object value) throws Exception {
    final String newId = value != null ? value.toString() : "";

    final String oldId = component.getId();

    if (ourRefactoringChoice != REFACTOR_NO && oldId != null && !oldId.isEmpty() && !newId.isEmpty()
            && !oldId.equals(newId) && component.getTag().isValid()) {
        // Offer rename refactoring?
        XmlTag tag = component.getTag();
        XmlAttribute attribute = tag.getAttribute(SdkConstants.ATTR_ID, SdkConstants.ANDROID_URI);
        if (attribute != null) {
            Module module = RadModelBuilder.getModule(component);
            if (module != null) {
                XmlAttributeValue valueElement = attribute.getValueElement();
                if (valueElement != null && valueElement.isValid()) {
                    final Project project = module.getProject();
                    // Exact replace only, no comment/text occurrence changes since it is non-interactive
                    RenameProcessor processor = new RenameProcessor(project, valueElement, newId,
                            false /*comments*/, false /*text*/);
                    processor.setPreviewUsages(false);
                    // Do a quick usage search to see if we need to ask about renaming
                    UsageInfo[] usages = processor.findUsages();
                    if (usages.length > 0) {
                        int choice = ourRefactoringChoice;
                        if (choice == REFACTOR_ASK) {
                            DialogBuilder builder = new DialogBuilder(project);
                            builder.setTitle("Update Usages?");
                            JPanel panel = new JPanel(new BorderLayout()); // UGH!
                            JLabel label = new JLabel("<html>" + "Update usages as well?<br>"
                                    + "This will update all XML references and Java R field references.<br>"
                                    + "<br>" + "</html>");
                            panel.add(label, BorderLayout.CENTER);
                            JBCheckBox checkBox = new JBCheckBox("Don't ask again during this session");
                            panel.add(checkBox, BorderLayout.SOUTH);
                            builder.setCenterPanel(panel);
                            builder.setDimensionServiceKey("idPropertyDimension");
                            builder.removeAllActions();

                            DialogBuilder.CustomizableAction yesAction = builder.addOkAction();
                            yesAction.setText(Messages.YES_BUTTON);

                            builder.addActionDescriptor(new DialogBuilder.ActionDescriptor() {
                                @Override
                                public Action getAction(final DialogWrapper dialogWrapper) {
                                    return new AbstractAction(Messages.NO_BUTTON) {
                                        @Override
                                        public void actionPerformed(ActionEvent actionEvent) {
                                            dialogWrapper.close(DialogWrapper.NEXT_USER_EXIT_CODE);
                                        }
                                    };/*  www  . ja  v a2  s.com*/
                                }
                            });
                            builder.addCancelAction();
                            int exitCode = builder.show();

                            choice = exitCode == DialogWrapper.OK_EXIT_CODE ? REFACTOR_YES
                                    : exitCode == DialogWrapper.NEXT_USER_EXIT_CODE ? REFACTOR_NO
                                            : ourRefactoringChoice;

                            if (!checkBox.isSelected()) {
                                ourRefactoringChoice = REFACTOR_ASK;
                            } else {
                                ourRefactoringChoice = choice;
                            }

                            if (exitCode == DialogWrapper.CANCEL_EXIT_CODE) {
                                return;
                            }
                        }

                        if (choice == REFACTOR_YES) {
                            processor.run();
                            // Fall through to also set the value in the layout editor property; otherwise we'll be out of sync
                        }
                    }
                }
            }
        }
    }

    //noinspection ConstantConditions
    super.setValue(component, value);
}