Changeset 17903 in josm for trunk/src/org


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

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

Location:
trunk/src/org/openstreetmap/josm
Files:
4 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
Note: See TracChangeset for help on using the changeset viewer.