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

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

Introduction

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

Prototype

@YesNoResult
public static int showYesNoDialog(@Nullable Project project, String message,
        @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @NotNull String yesText,
        @NotNull String noText, @Nullable Icon icon, @Nullable DialogWrapper.DoNotAskOption doNotAskOption) 

Source Link

Usage

From source file:com.android.tools.idea.run.AndroidRunConfigurationBase.java

License:Apache License

private boolean promptAndKillSession(@NotNull Executor executor, Project project, AndroidSessionInfo info) {
    String previousExecutor = info.getExecutorId();
    String currentExecutor = executor.getId();

    if (ourKillLaunchOption.isToBeShown()) {
        String msg, noText;//www .  j a  va  2s. c o  m
        if (previousExecutor.equals(currentExecutor)) {
            msg = String.format(
                    "Restart App?\nThe app is already running. Would you like to kill it and restart the session?");
            noText = "Cancel";
        } else {
            msg = String.format("To switch from %1$s to %2$s, the app has to restart. Continue?",
                    previousExecutor, currentExecutor);
            noText = "Cancel " + currentExecutor;
        }

        String title = "Launching " + getName();
        String yesText = "Restart " + getName();
        if (Messages.NO == Messages.showYesNoDialog(project, msg, title, yesText, noText,
                AllIcons.General.QuestionDialog, ourKillLaunchOption)) {
            return false;
        }
    }

    LOG.info("Disconnecting existing session of the same launch configuration");
    killSession(info);
    return true;
}