Changeset 6555 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2013-12-28T22:46:44+01:00 (11 years ago)
Author:
Don-vip
Message:

fix #4183 - split number of conflicts in conflict-list header depending on nodes, ways and relations

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java

    r6175 r6555  
    1212import java.util.concurrent.CopyOnWriteArrayList;
    1313
     14import org.openstreetmap.josm.data.osm.Node;
    1415import org.openstreetmap.josm.data.osm.OsmPrimitive;
     16import org.openstreetmap.josm.data.osm.Relation;
     17import org.openstreetmap.josm.data.osm.Way;
    1518import org.openstreetmap.josm.tools.CheckParameterUtil;
     19import org.openstreetmap.josm.tools.Predicate;
     20import org.openstreetmap.josm.tools.Utils;
    1621
    1722/**
     
    3742    private CopyOnWriteArrayList<IConflictListener> listeners;
    3843
     44    private static class FilterPredicate implements Predicate<Conflict<? extends OsmPrimitive>> {
     45
     46        private final Class<? extends OsmPrimitive> c;
     47       
     48        public FilterPredicate(Class<? extends OsmPrimitive> c) {
     49            this.c = c;
     50        }
     51
     52        @Override
     53        public boolean evaluate(Conflict<? extends OsmPrimitive> conflict) {
     54            return conflict != null && c.isInstance(conflict.getMy());
     55        }
     56    }
     57   
     58    private static final FilterPredicate NODE_FILTER_PREDICATE = new FilterPredicate(Node.class);
     59    private static final FilterPredicate WAY_FILTER_PREDICATE = new FilterPredicate(Way.class);
     60    private static final FilterPredicate RELATION_FILTER_PREDICATE = new FilterPredicate(Relation.class);
     61
    3962    /**
    4063     * Constructs a new {@code ConflictCollection}.
     
    281304    }
    282305
     306    /**
     307     * Adds all conflicts from another collection.
     308     * @param other The other collection of conflicts to add
     309     */
    283310    public void add(ConflictCollection other) {
    284311        for (Conflict<?> c : other) {
     
    329356        return conflicts.toString();
    330357    }
     358
     359    /**
     360     * Returns the list of conflicts involving nodes.
     361     * @return The list of conflicts involving nodes.
     362     * @since 6555
     363     */
     364    public final Collection<Conflict<? extends OsmPrimitive>> getNodeConflicts() {
     365        return Utils.filter(conflicts, NODE_FILTER_PREDICATE);
     366    }
     367
     368    /**
     369     * Returns the list of conflicts involving nodes.
     370     * @return The list of conflicts involving nodes.
     371     * @since 6555
     372     */
     373    public final Collection<Conflict<? extends OsmPrimitive>> getWayConflicts() {
     374        return Utils.filter(conflicts, WAY_FILTER_PREDICATE);
     375    }
     376
     377    /**
     378     * Returns the list of conflicts involving nodes.
     379     * @return The list of conflicts involving nodes.
     380     * @since 6555
     381     */
     382    public final Collection<Conflict<? extends OsmPrimitive>> getRelationConflicts() {
     383        return Utils.filter(conflicts, RELATION_FILTER_PREDICATE);
     384    }
    331385}
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java

    r6248 r6555  
    203203            public void run() {
    204204                model.fireContentChanged();
    205                 updateTitle(conflicts.size());
     205                updateTitle();
    206206            }
    207207        });
    208208    }
    209209
    210     private void updateTitle(int conflictsCount) {
     210    private void updateTitle() {
     211        int conflictsCount = conflicts.size();
    211212        if (conflictsCount > 0) {
    212             setTitle(tr("Conflicts: {0} unresolved", conflicts.size()));
     213            setTitle(tr("Conflicts: {0} unresolved", conflicts.size()) +
     214                    " ("+tr("Rel.:{0} / Ways:{1} / Nodes:{2}",
     215                            conflicts.getRelationConflicts().size(),
     216                            conflicts.getWayConflicts().size(),
     217                            conflicts.getNodeConflicts().size())+")");
    213218        } else {
    214219            setTitle(tr("Conflict"));
Note: See TracChangeset for help on using the changeset viewer.