Changeset 14432 in josm


Ignore:
Timestamp:
2018-11-20T00:09:48+01:00 (5 years ago)
Author:
Don-vip
Message:

fix #17000 - add link to OSM History Viewer (pewu)

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDetailPanel.java

    r14121 r14432  
    5353 * This panel displays the properties of the currently selected changeset in the
    5454 * {@link ChangesetCacheManager}.
    55  *
     55 * @since 2689
    5656 */
    5757public class ChangesetDetailPanel extends JPanel implements PropertyChangeListener, ChangesetAware {
     
    347347        public void actionPerformed(ActionEvent evt) {
    348348            if (currentChangeset != null)
    349                 new OpenChangesetPopupMenu(currentChangeset.getId()).show(btnOpenChangesetPopupMenu);
     349                new OpenChangesetPopupMenu(currentChangeset.getId(), null).show(btnOpenChangesetPopupMenu);
    350350        }
    351351
  • trunk/src/org/openstreetmap/josm/gui/history/OpenChangesetPopupMenu.java

    r14248 r14432  
    1010import java.util.Arrays;
    1111import java.util.List;
     12import java.util.Objects;
    1213
    1314import javax.swing.AbstractAction;
     
    1819import org.openstreetmap.josm.data.StructUtils;
    1920import org.openstreetmap.josm.data.StructUtils.StructEntry;
     21import org.openstreetmap.josm.data.osm.PrimitiveId;
    2022import org.openstreetmap.josm.spi.preferences.Config;
    2123import org.openstreetmap.josm.tools.ImageProvider;
     
    3335     *
    3436     * @param changesetId the changeset id
     37     * @param primitiveId the primitive id
     38     * @since 14432
    3539     */
    36     public OpenChangesetPopupMenu(final long changesetId) {
     40    public OpenChangesetPopupMenu(final long changesetId, final PrimitiveId primitiveId) {
    3741        StructUtils.getListOfStructs(Config.getPref(), "history-dialog.tools", DEFAULT_ENTRIES, ChangesetViewerEntry.class)
    3842                .stream()
    39                 .map(entry -> entry.toAction(changesetId))
     43                .map(entry -> entry.toAction(changesetId, primitiveId))
     44                .filter(Objects::nonNull)
    4045                .forEach(this::add);
    4146    }
     
    5863            new ChangesetViewerEntry(tr("Open {0}", "achavi (Augmented OSM Change Viewer)"), "https://overpass-api.de/achavi/?changeset={0}"),
    5964            new ChangesetViewerEntry(tr("Open {0}", "OSMCha (OSM Changeset Analyzer)"), "https://osmcha.mapbox.com/changesets/{0}"),
    60             new ChangesetViewerEntry(tr("Open {0}", "OSM History Viewer"), "http://osmhv.openstreetmap.de/changeset.jsp?id={0}"),
     65            new ChangesetViewerEntry(tr("Open {0}", "OSM History Viewer (osmrmhv)"), "http://osmhv.openstreetmap.de/changeset.jsp?id={0}"),
     66            new ChangesetViewerEntry(tr("Open {0}", "OSM History Viewer (Pewu)"), "https://pewu.github.io/osm-history/#/{1}/{2}"),
    6167            new ChangesetViewerEntry(tr("Open {0}", "WhoDidIt (OSM Changeset Analyzer)"),
    6268                    "http://simon04.dev.openstreetmap.org/whodidit/index.html?changeset={0}&show=1")
     
    7076        @StructEntry
    7177        public String name;
    72         /** Templated service url. <code>{0}</code> will be replaced by changeset id */
     78        /**
     79         * Templated service url.
     80         * <code>{0}</code> will be replaced by changeset id
     81         * <code>{1}</code> will be replaced by object type (node, way, relation)
     82         * <code>{2}</code> will be replaced by object id
     83         */
    7384        @StructEntry
    7485        public String url;
     
    8192
    8293        ChangesetViewerEntry(String name, String url) {
    83             this.name = name;
    84             this.url = url;
     94            this.name = Objects.requireNonNull(name);
     95            this.url = Objects.requireNonNull(url);
    8596        }
    8697
    87         Action toAction(final long changesetId) {
    88             return new OpenBrowserAction(name, MessageFormat.format(this.url, Long.toString(changesetId)));
     98        Action toAction(final long changesetId, PrimitiveId primitiveId) {
     99            if (primitiveId != null) {
     100                return new OpenBrowserAction(name, MessageFormat.format(url,
     101                        Long.toString(changesetId), primitiveId.getType().getAPIName(), Long.toString(primitiveId.getUniqueId())));
     102            } else if (url.contains("{0}")) {
     103                return new OpenBrowserAction(name, MessageFormat.format(url, Long.toString(changesetId)));
     104            }
     105            return null;
    89106        }
    90107    }
  • trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java

    r14273 r14432  
    2929import org.openstreetmap.josm.data.osm.Changeset;
    3030import org.openstreetmap.josm.data.osm.OsmPrimitive;
     31import org.openstreetmap.josm.data.osm.PrimitiveId;
    3132import org.openstreetmap.josm.data.osm.User;
    3233import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive;
     
    6869    private JTextArea texChangesetSource;
    6970    private JTextArea texChangesetImageryUsed;
     71    private PrimitiveId primitiveId;
    7072
    7173    protected static JTextArea buildTextArea(String tooltip) {
     
    117119        arrowButton.addActionListener(action -> {
    118120            if (changesetDialogAction.id != null) { // fix #15444, #16097
    119                 final OpenChangesetPopupMenu popupMenu = new OpenChangesetPopupMenu(changesetDialogAction.id);
     121                final OpenChangesetPopupMenu popupMenu = new OpenChangesetPopupMenu(changesetDialogAction.id, primitiveId);
    120122                popupMenu.insert(changesetDialogAction, 0);
    121123                ((AbstractButton) popupMenu.getComponent(0)).setText(tr("Open Changeset Manager"));
     
    223225        if (primitive != null) {
    224226            Changeset cs = primitive.getChangeset();
    225             update(cs, model.isLatest(primitive), primitive.getTimestamp(), primitive.getVersion());
     227            update(cs, model.isLatest(primitive), primitive.getTimestamp(), primitive.getVersion(), primitive.getPrimitiveId());
    226228        }
    227229    }
     
    233235     */
    234236    public void update(final OsmPrimitive primitive, final boolean isLatest) {
    235         update(Changeset.fromPrimitive(primitive), isLatest, primitive.getTimestamp(), primitive.getVersion());
     237        update(Changeset.fromPrimitive(primitive), isLatest, primitive.getTimestamp(), primitive.getVersion(), primitive.getPrimitiveId());
    236238    }
    237239
     
    242244     * @param timestamp the timestamp
    243245     * @param version the version of the primitive
     246     * @param id the id and type of the primitive
     247     * @since 14432
    244248     */
    245     public void update(final Changeset cs, final boolean isLatest, final Date timestamp, final long version) {
     249    public void update(final Changeset cs, final boolean isLatest, final Date timestamp, final long version, final PrimitiveId id) {
    246250        lblInfo.setText(getInfoText(timestamp, version, isLatest));
     251        primitiveId = id;
    247252
    248253        if (!isLatest && cs != null) {
Note: See TracChangeset for help on using the changeset viewer.