コード例 #1
0
 private static List<String> filterPlugins(
     final PersistencePreferencesBean prefs, final Collection<String> excludePlugins) {
   final List<String> result = new ArrayList<String>();
   for (final String plugin : prefs.getPlugins()) {
     if (!excludePlugins.contains(plugin)) {
       result.add(plugin);
     }
   }
   return result;
 }
コード例 #2
0
  @Nullable
  public static PersistencePreferencesBean doImport(
      final Component owner, final Document document) {
    final Element profile = document.getRootElement();
    final Element rules = profile.getChild("rules");
    if (rules == null) {
      Messages.showErrorDialog(
          owner, "The file format is invalid. No rules element found.", "Invalid File");
      return null;
    }

    final Map<String, Set<String>> detectorsShortNameByBugPatternType =
        createIndexDetectorsShortNameByBugPatternType();

    final PersistencePreferencesBean ret = new PersistencePreferencesBean();
    for (final Set<String> detectorsShortName : detectorsShortNameByBugPatternType.values()) {
      for (final String detectorShortName : detectorsShortName) {
        ret.getDetectors().put(detectorShortName, "false");
      }
    }

    final List ruleList = rules.getChildren("rule");
    for (final Object child : ruleList) {
      if (child instanceof Element) {
        final Element rule = (Element) child;
        final Element repositoryKey = rule.getChild("repositoryKey");
        final Element key = rule.getChild("key");
        if (repositoryKey != null && "findbugs".equals(repositoryKey.getValue()) && key != null) {
          final String bugPatternType = key.getValue();
          final Set<String> detectorsShortName =
              detectorsShortNameByBugPatternType.get(bugPatternType);
          if (detectorsShortName != null) {
            for (final String detectorShortName : detectorsShortName) {
              ret.getDetectors().put(detectorShortName, "true");
            }
          } else {
            LOGGER.warn("Unknown bug pattern type: " + bugPatternType);
          }
        }
      }
    }
    return ret;
  }