Changeset 17903 in josm


Ignore:
Timestamp:
2021-05-17T21:27:21+02:00 (3 years ago)
Author:
simon04
Message:

see #20879 - History browser: display version "*" if tag change has not been committed

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/history/History.java

    r17887 r17903  
    192192    /**
    193193     * Replies the history primitive which changed the given key.
    194      * @param version the version
     194     * @param primitive the reference primitive (the history up to and including this primitive is considered)
    195195     * @param key the OSM key
     196     * @param isLatest whether this relates to a not yet committed changeset
    196197     * @return the history primitive which changed the given key
    197198     */
    198     public HistoryOsmPrimitive getWhichChangedTag(long version, String key) {
    199         HistoryOsmPrimitive primitive = getByVersion(version);
     199    public HistoryOsmPrimitive getWhichChangedTag(HistoryOsmPrimitive primitive, String key, boolean isLatest) {
    200200        if (primitive == null) {
    201201            return null;
     202        } else if (isLatest && !Objects.equals(getLatest().get(key), primitive.get(key))) {
     203            return primitive;
    202204        }
    203205        for (int i = versions.indexOf(primitive); i > 0; i--) {
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

    r17890 r17903  
    714714     */
    715715    public Color getVersionColor(HistoryOsmPrimitive primitive) {
    716         return dateScale.getColor(primitive.getInstant().toEpochMilli());
     716        return dateScale.getColor(isLatest(primitive) ? System.currentTimeMillis() : primitive.getInstant().toEpochMilli());
    717717    }
    718718}
  • trunk/src/org/openstreetmap/josm/gui/history/TagTableCellRenderer.java

    r17890 r17903  
    6363                HistoryOsmPrimitive primitive = model.getWhichChangedTag(key);
    6464                if (primitive != null) {
    65                     text = "v" + primitive.getVersion();
     65                    text = model.getVersionString(primitive);
    6666                    tooltip = tr("Key ''{0}'' was changed in version {1}", key, primitive.getVersion());
    6767                    setBorder(BorderFactory.createMatteBorder(0, 0, 0, 2, model.getVersionColor(primitive)));
  • trunk/src/org/openstreetmap/josm/gui/history/TagTableModel.java

    r17890 r17903  
    9393        if (primitive == null)
    9494            return null;
    95         return model.getHistory().getWhichChangedTag(primitive.getVersion(), key);
     95        return model.getHistory().getWhichChangedTag(primitive, key, model.isLatest(primitive));
     96    }
     97
     98    /**
     99     * Returns a version string for the given primitive, {@code "*"} if it is {@linkplain HistoryBrowserModel#isLatest is latest}.
     100     * @param primitive the history primitive
     101     * @return a version string for the given primitive
     102     */
     103    public String getVersionString(HistoryOsmPrimitive primitive) {
     104        return model.isLatest(primitive) ? "*" : "v" + primitive.getVersion();
    96105    }
    97106
  • trunk/test/unit/org/openstreetmap/josm/io/OsmServerHistoryReaderTest.java

    r17887 r17903  
    6868        assertEquals(26368284, h.getLatest().getChangesetId());
    6969        assertEquals(Instant.ofEpochMilli(1414429134000L), h.getLatest().getInstant());
    70         System.out.println(h.getByVersion(14).keySet());
    71         assertEquals(11, h.getWhichChangedTag(14, "bicycle").getVersion());
    72         assertEquals(1, h.getWhichChangedTag(10, "bicycle").getVersion());
    73         assertEquals(5, h.getWhichChangedTag(14, "created_by").getVersion());
    74         assertEquals(2, h.getWhichChangedTag(4, "created_by").getVersion());
    75         assertEquals(1, h.getWhichChangedTag(1, "highway").getVersion());
     70        assertEquals(11, h.getWhichChangedTag(h.getByVersion(14), "bicycle", false).getVersion());
     71        assertEquals(1, h.getWhichChangedTag(h.getByVersion(10), "bicycle", false).getVersion());
     72        assertEquals(5, h.getWhichChangedTag(h.getByVersion(14), "created_by", false).getVersion());
     73        assertEquals(2, h.getWhichChangedTag(h.getByVersion(4), "created_by", false).getVersion());
     74        assertEquals(1, h.getWhichChangedTag(h.getByVersion(1), "highway", false).getVersion());
    7675    }
    7776
Note: See TracChangeset for help on using the changeset viewer.