Changeset 14432 in josm for trunk/src/org/openstreetmap/josm/gui/history/OpenChangesetPopupMenu.java
- Timestamp:
- 2018-11-20T00:09:48+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/history/OpenChangesetPopupMenu.java
r14248 r14432 10 10 import java.util.Arrays; 11 11 import java.util.List; 12 import java.util.Objects; 12 13 13 14 import javax.swing.AbstractAction; … … 18 19 import org.openstreetmap.josm.data.StructUtils; 19 20 import org.openstreetmap.josm.data.StructUtils.StructEntry; 21 import org.openstreetmap.josm.data.osm.PrimitiveId; 20 22 import org.openstreetmap.josm.spi.preferences.Config; 21 23 import org.openstreetmap.josm.tools.ImageProvider; … … 33 35 * 34 36 * @param changesetId the changeset id 37 * @param primitiveId the primitive id 38 * @since 14432 35 39 */ 36 public OpenChangesetPopupMenu(final long changesetId ) {40 public OpenChangesetPopupMenu(final long changesetId, final PrimitiveId primitiveId) { 37 41 StructUtils.getListOfStructs(Config.getPref(), "history-dialog.tools", DEFAULT_ENTRIES, ChangesetViewerEntry.class) 38 42 .stream() 39 .map(entry -> entry.toAction(changesetId)) 43 .map(entry -> entry.toAction(changesetId, primitiveId)) 44 .filter(Objects::nonNull) 40 45 .forEach(this::add); 41 46 } … … 58 63 new ChangesetViewerEntry(tr("Open {0}", "achavi (Augmented OSM Change Viewer)"), "https://overpass-api.de/achavi/?changeset={0}"), 59 64 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}"), 61 67 new ChangesetViewerEntry(tr("Open {0}", "WhoDidIt (OSM Changeset Analyzer)"), 62 68 "http://simon04.dev.openstreetmap.org/whodidit/index.html?changeset={0}&show=1") … … 70 76 @StructEntry 71 77 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 */ 73 84 @StructEntry 74 85 public String url; … … 81 92 82 93 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); 85 96 } 86 97 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; 89 106 } 90 107 }
Note:
See TracChangeset
for help on using the changeset viewer.