示例#1
0
 private static List<String> getMacrosFromExistingNotifications(Project project) {
   List<String> notified = ContainerUtil.newArrayList();
   NotificationsManager manager = NotificationsManager.getNotificationsManager();
   for (final UnknownMacroNotification notification :
       manager.getNotificationsOfType(UnknownMacroNotification.class, project)) {
     notified.addAll(notification.getMacros());
   }
   return notified;
 }
  private void showErrorNotification(boolean hasErrors) {
    NotificationsManager manager = NotificationsManager.getNotificationsManager();
    ErrorsFoundNotification[] notifications =
        manager.getNotificationsOfType(ErrorsFoundNotification.class, myProject);

    if (hasErrors) {
      // do not show notification if it is already shown
      if (notifications.length == 0) {
        new ErrorsFoundNotification(myProject).notify(myProject.isDefault() ? null : myProject);
      }
    } else {
      // expire notification
      for (ErrorsFoundNotification notification : notifications) {
        notification.expire();
      }
    }
  }
  private static boolean ensureCouldCloseIfUnableToSave(@NotNull final Project project) {
    final ProjectImpl.UnableToSaveProjectNotification[] notifications =
        NotificationsManager.getNotificationsManager()
            .getNotificationsOfType(ProjectImpl.UnableToSaveProjectNotification.class, project);
    if (notifications.length == 0) return true;

    final String fileNames = StringUtil.join(notifications[0].getFileNames(), "\n");

    final String msg =
        String.format(
            "%s was unable to save some project files,\nare you sure you want to close this project anyway?",
            ApplicationNamesInfo.getInstance().getProductName());
    return Messages.showDialog(
            project,
            msg,
            "Unsaved Project",
            "Read-only files:\n\n" + fileNames,
            new String[] {"Yes", "No"},
            0,
            1,
            Messages.getWarningIcon())
        == 0;
  }