Esempio n. 1
0
  public static void notifyUnknownMacros(
      @NotNull TrackingPathMacroSubstitutor substitutor,
      @NotNull final Project project,
      @Nullable final String componentName) {
    final LinkedHashSet<String> macros =
        new LinkedHashSet<String>(substitutor.getUnknownMacros(componentName));
    if (macros.isEmpty()) {
      return;
    }

    UIUtil.invokeLaterIfNeeded(
        new Runnable() {
          @Override
          public void run() {
            macros.removeAll(getMacrosFromExistingNotifications(project));

            if (!macros.isEmpty()) {
              LOG.debug(
                  "Reporting unknown path macros " + macros + " in component " + componentName);
              String format = "<p><i>%s</i> %s undefined. <a href=\"define\">Fix it</a></p>";
              String productName = ApplicationNamesInfo.getInstance().getProductName();
              String content =
                  String.format(
                          format, StringUtil.join(macros, ", "), macros.size() == 1 ? "is" : "are")
                      + "<br>Path variables are used to substitute absolute paths "
                      + "in "
                      + productName
                      + " project files "
                      + "and allow project file sharing in version control systems.<br>"
                      + "Some of the files describing the current project settings contain unknown path variables "
                      + "and "
                      + productName
                      + " cannot restore those paths.";
              new UnknownMacroNotification(
                      "Load Error",
                      "Load error: undefined path variables",
                      content,
                      NotificationType.ERROR,
                      new NotificationListener() {
                        @Override
                        public void hyperlinkUpdate(
                            @NotNull Notification notification, @NotNull HyperlinkEvent event) {
                          ((ProjectEx) project).checkUnknownMacros(true);
                        }
                      },
                      macros)
                  .notify(project);
            }
          }
        });
  }