Changeset 17903 in josm
- Timestamp:
- 2021-05-17T21:27:21+02:00 (3 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/history/History.java
r17887 r17903 192 192 /** 193 193 * Replies the history primitive which changed the given key. 194 * @param version the version194 * @param primitive the reference primitive (the history up to and including this primitive is considered) 195 195 * @param key the OSM key 196 * @param isLatest whether this relates to a not yet committed changeset 196 197 * @return the history primitive which changed the given key 197 198 */ 198 public HistoryOsmPrimitive getWhichChangedTag(long version, String key) { 199 HistoryOsmPrimitive primitive = getByVersion(version); 199 public HistoryOsmPrimitive getWhichChangedTag(HistoryOsmPrimitive primitive, String key, boolean isLatest) { 200 200 if (primitive == null) { 201 201 return null; 202 } else if (isLatest && !Objects.equals(getLatest().get(key), primitive.get(key))) { 203 return primitive; 202 204 } 203 205 for (int i = versions.indexOf(primitive); i > 0; i--) { -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r17890 r17903 714 714 */ 715 715 public Color getVersionColor(HistoryOsmPrimitive primitive) { 716 return dateScale.getColor( primitive.getInstant().toEpochMilli());716 return dateScale.getColor(isLatest(primitive) ? System.currentTimeMillis() : primitive.getInstant().toEpochMilli()); 717 717 } 718 718 } -
trunk/src/org/openstreetmap/josm/gui/history/TagTableCellRenderer.java
r17890 r17903 63 63 HistoryOsmPrimitive primitive = model.getWhichChangedTag(key); 64 64 if (primitive != null) { 65 text = "v" + primitive.getVersion();65 text = model.getVersionString(primitive); 66 66 tooltip = tr("Key ''{0}'' was changed in version {1}", key, primitive.getVersion()); 67 67 setBorder(BorderFactory.createMatteBorder(0, 0, 0, 2, model.getVersionColor(primitive))); -
trunk/src/org/openstreetmap/josm/gui/history/TagTableModel.java
r17890 r17903 93 93 if (primitive == null) 94 94 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(); 96 105 } 97 106 -
trunk/test/unit/org/openstreetmap/josm/io/OsmServerHistoryReaderTest.java
r17887 r17903 68 68 assertEquals(26368284, h.getLatest().getChangesetId()); 69 69 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()); 76 75 } 77 76
Note:
See TracChangeset
for help on using the changeset viewer.