Java Code Examples for com.intellij.openapi.application.ex.ApplicationEx#isRestartCapable()

The following examples show how to use com.intellij.openapi.application.ex.ApplicationEx#isRestartCapable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluginManagerConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void apply() throws ConfigurationException {
  final String applyMessage = myPluginManagerMain.apply();
  if (applyMessage != null) {
    throw new ConfigurationException(applyMessage);
  }

  if (myPluginManagerMain.isRequireShutdown()) {
    final ApplicationEx app = (ApplicationEx)Application.get();

    int response = app.isRestartCapable() ? showRestartIDEADialog() : showShutDownIDEADialog();
    if (response == Messages.YES) {
      app.restart(true);
    }
    else {
      myPluginManagerMain.ignoreChanges();
    }
  }
}
 
Example 2
Source File: PluginManagerMain.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void notifyPluginsWereUpdated(final String title, final Project project) {
  final ApplicationEx app = (ApplicationEx)Application.get();
  final boolean restartCapable = app.isRestartCapable();
  String message = restartCapable
                   ? IdeBundle.message("message.idea.restart.required", ApplicationNamesInfo.getInstance().getFullProductName())
                   : IdeBundle.message("message.idea.shutdown.required", ApplicationNamesInfo.getInstance().getFullProductName());
  message += "<br><a href=";
  message += restartCapable ? "\"restart\">Restart now" : "\"shutdown\">Shutdown";
  message += "</a>";
  new NotificationGroup("Plugins Lifecycle Group", NotificationDisplayType.STICKY_BALLOON, true)
          .createNotification(title, XmlStringUtil.wrapInHtml(message), NotificationType.INFORMATION, new NotificationListener() {
            @Override
            public void hyperlinkUpdate(@Nonnull Notification notification, @Nonnull HyperlinkEvent event) {
              notification.expire();
              if (restartCapable) {
                app.restart(true);
              }
              else {
                app.exit(true, true);
              }
            }
          }).notify(project);
}
 
Example 3
Source File: PluginManagerConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static void shutdownOrRestartApp(String title) {
  final ApplicationEx app = (ApplicationEx)Application.get();
  int response = app.isRestartCapable() ? showRestartIDEADialog(title) : showShutDownIDEADialog(title);
  if (response == Messages.YES) app.restart(true);
}