/**
   * Populates the conflict resolver with one tag collection
   *
   * @param tagsForAllPrimitives the tag collection
   * @param sourceStatistics histogram of tag source, number of primitives of each type in the
   *     source
   * @param targetStatistics histogram of paste targets, number of primitives of each type in the
   *     paste target
   */
  public void populate(
      TagCollection tagsForAllPrimitives,
      Map<OsmPrimitiveType, Integer> sourceStatistics,
      Map<OsmPrimitiveType, Integer> targetStatistics) {
    mode = Mode.RESOLVING_ONE_TAGCOLLECTION_ONLY;
    tagsForAllPrimitives =
        tagsForAllPrimitives == null ? new TagCollection() : tagsForAllPrimitives;
    sourceStatistics = sourceStatistics == null ? new HashMap<>() : sourceStatistics;
    targetStatistics = targetStatistics == null ? new HashMap<>() : targetStatistics;

    // init the resolver
    //
    allPrimitivesResolver
        .getModel()
        .populate(tagsForAllPrimitives, tagsForAllPrimitives.getKeysWithMultipleValues());
    allPrimitivesResolver.getModel().prepareDefaultTagDecisions();

    // prepare the dialog with one tag resolver
    pnlTagResolver.removeAll();
    pnlTagResolver.add(allPrimitivesResolver, BorderLayout.CENTER);

    statisticsModel.reset();
    StatisticsInfo info = new StatisticsInfo();
    info.numTags = tagsForAllPrimitives.getKeys().size();
    info.sourceInfo.putAll(sourceStatistics);
    info.targetInfo.putAll(targetStatistics);
    statisticsModel.append(info);
    validate();
  }
  /**
   * Populate the tag conflict resolver with tags for each type of primitives
   *
   * @param tagsForNodes the tags belonging to nodes in the paste source
   * @param tagsForWays the tags belonging to way in the paste source
   * @param tagsForRelations the tags belonging to relations in the paste source
   * @param sourceStatistics histogram of tag source, number of primitives of each type in the
   *     source
   * @param targetStatistics histogram of paste targets, number of primitives of each type in the
   *     paste target
   */
  public void populate(
      TagCollection tagsForNodes,
      TagCollection tagsForWays,
      TagCollection tagsForRelations,
      Map<OsmPrimitiveType, Integer> sourceStatistics,
      Map<OsmPrimitiveType, Integer> targetStatistics) {
    tagsForNodes = (tagsForNodes == null) ? new TagCollection() : tagsForNodes;
    tagsForWays = (tagsForWays == null) ? new TagCollection() : tagsForWays;
    tagsForRelations = (tagsForRelations == null) ? new TagCollection() : tagsForRelations;
    if (tagsForNodes.isEmpty() && tagsForWays.isEmpty() && tagsForRelations.isEmpty()) {
      populate(null, null, null);
      return;
    }
    tpResolvers.removeAll();
    initResolver(OsmPrimitiveType.NODE, tagsForNodes, targetStatistics);
    initResolver(OsmPrimitiveType.WAY, tagsForWays, targetStatistics);
    initResolver(OsmPrimitiveType.RELATION, tagsForRelations, targetStatistics);

    pnlTagResolver.removeAll();
    pnlTagResolver.add(tpResolvers, BorderLayout.CENTER);
    mode = Mode.RESOLVING_TYPED_TAGCOLLECTIONS;
    validate();
    statisticsModel.reset();
    if (!tagsForNodes.isEmpty()) {
      StatisticsInfo info = new StatisticsInfo();
      info.numTags = tagsForNodes.getKeys().size();
      int numTargets =
          targetStatistics.get(OsmPrimitiveType.NODE) == null
              ? 0
              : targetStatistics.get(OsmPrimitiveType.NODE);
      if (numTargets > 0) {
        info.sourceInfo.put(OsmPrimitiveType.NODE, sourceStatistics.get(OsmPrimitiveType.NODE));
        info.targetInfo.put(OsmPrimitiveType.NODE, numTargets);
        statisticsModel.append(info);
      }
    }
    if (!tagsForWays.isEmpty()) {
      StatisticsInfo info = new StatisticsInfo();
      info.numTags = tagsForWays.getKeys().size();
      int numTargets =
          targetStatistics.get(OsmPrimitiveType.WAY) == null
              ? 0
              : targetStatistics.get(OsmPrimitiveType.WAY);
      if (numTargets > 0) {
        info.sourceInfo.put(OsmPrimitiveType.WAY, sourceStatistics.get(OsmPrimitiveType.WAY));
        info.targetInfo.put(OsmPrimitiveType.WAY, numTargets);
        statisticsModel.append(info);
      }
    }
    if (!tagsForRelations.isEmpty()) {
      StatisticsInfo info = new StatisticsInfo();
      info.numTags = tagsForRelations.getKeys().size();
      int numTargets =
          targetStatistics.get(OsmPrimitiveType.RELATION) == null
              ? 0
              : targetStatistics.get(OsmPrimitiveType.RELATION);
      if (numTargets > 0) {
        info.sourceInfo.put(
            OsmPrimitiveType.RELATION, sourceStatistics.get(OsmPrimitiveType.RELATION));
        info.targetInfo.put(OsmPrimitiveType.RELATION, numTargets);
        statisticsModel.append(info);
      }
    }

    for (int i = 0; i < getNumResolverTabs(); i++) {
      if (!getResolver(i).getModel().isResolvedCompletely()) {
        tpResolvers.setSelectedIndex(i);
        break;
      }
    }
  }