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(String message,
        @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon) 

Source Link

Document

Use this method only if you do not know project or component

Usage

From source file:org.sonar.ide.idea.autoupdate.PluginDownloader.java

License:Open Source License

private void promptShutdownAndShutdown() {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        public void run() {
            String title = "IDEA shutdown";
            String message = "Sonar Plugin has been installed succssfully.\n"
                    + "IntelliJ IDEA needs to be restarted to activate the plugin.\n"
                    + "Would you like to shutdown IntelliJ IDEA now?";
            int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon());
            if (answer == DialogWrapper.OK_EXIT_CODE) {
                // TODO maybe restart?
                ApplicationManager.getApplication().exit();
            }//from   w ww  . j  av a  2  s.co  m
        }
    });
}

From source file:org.sonar.ide.idea.autoupdate.PluginDownloader.java

License:Open Source License

public static void checkUpdate() {
    final PluginId pluginId = PluginManager.getPluginByClassName(VersionInfo.class.getName());
    final IdeaPluginDescriptor pluginDescriptor = PluginManager.getPlugin(pluginId);
    if (pluginDescriptor == null) {
        // should never happen
        return;//from  ww w.  ja v a2s  .  co  m
    }
    final VersionInfo versionInfo = VersionInfo.getLatestPluginVersion();
    if (versionInfo != null && !pluginDescriptor.getVersion().equals(versionInfo.getVersion())) {
        ApplicationManager.getApplication().invokeLater(new Runnable() {
            public void run() {
                String title = "New Sonar Plugin";
                String message = "New Sonar Plugin version " + versionInfo.getVersion() + " is available.\n"
                        + "Do you want to upgrade from " + pluginDescriptor.getVersion() + "?";
                int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon());
                if (answer == DialogWrapper.OK_EXIT_CODE) {
                    new PluginDownloader().run(versionInfo);
                }
            }
        });
    }
}