Changeset 16596 in josm
- Timestamp:
- 2020-06-11T08:40:14+02:00 (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r16549 r16596 195 195 tagTable, editHelper::getDataKey, editHelper::getDataValues, 196 196 membershipTable, x -> (IRelation<?>) membershipData.getValueAt(x, 0), null); 197 private final TaginfoAction tagHistoryAction = taginfoAction.toTagHistoryAction(); 197 198 private final Collection<TaginfoAction> taginfoNationalActions = new ArrayList<>(); 198 199 private final PasteValueAction pasteValueAction = new PasteValueAction(); … … 457 458 tagMenu.addSeparator(); 458 459 tagMenu.add(helpTagAction); 460 tagMenu.add(tagHistoryAction); 459 461 tagMenu.add(taginfoAction); 460 462 tagMenu.addPopupMenuListener(new AbstractTag2LinkPopupListener() { -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TaginfoAction.java
r16275 r16596 27 27 28 28 private static final StringProperty TAGINFO_URL_PROP = new StringProperty("taginfo.url", "https://taginfo.openstreetmap.org/"); 29 private static final StringProperty TAG_HISTORY_URL_PROP = new StringProperty("taghistory.url", "https://taghistory.raifer.tech/#***"); 29 30 30 31 private final Supplier<Tag> tagSupplier; 31 32 private final Supplier<String> relationTypeSupplier; 32 private final String taginfoUrl; 33 protected final String taginfoUrl; 34 35 private TaginfoAction(String name, Supplier<Tag> tagSupplier, Supplier<String> relationTypeSupplier, String taginfoUrl) { 36 super(name); 37 this.tagSupplier = tagSupplier; 38 this.relationTypeSupplier = relationTypeSupplier; 39 this.taginfoUrl = taginfoUrl; 40 } 33 41 34 42 /** … … 85 93 Tag tag = tagSupplier.get(); 86 94 if (tag != null) { 87 openTaginfoForTag(tag, taginfoUrl);95 OpenBrowser.displayUrl(getTaginfoUrlForTag(tag)); 88 96 return; 89 97 } 90 98 String type = relationTypeSupplier.get(); 91 99 if (type != null) { 92 openTaginfoForRelationType(type, taginfoUrl);100 OpenBrowser.displayUrl(getTaginfoUrlForRelationType(type)); 93 101 } 94 102 } … … 98 106 taginfoUrl = TAGINFO_URL_PROP.get(); 99 107 } 100 return taginfoUrl.endsWith("/") ? taginfoUrl : taginfoUrl + '/'; 108 return withoutTrailingSlash(taginfoUrl); 109 } 110 111 private static String withoutTrailingSlash(String url) { 112 return Utils.strip(url, "/"); 101 113 } 102 114 … … 104 116 * Opens Taginfo for the given tag or key (if the tag value is null) 105 117 * @param tag the tag 106 * @param taginfoUrl Taginfo URL (may be null) 107 * @since 16275 118 * @since 16596 108 119 */ 109 public static void openTaginfoForTag(Tag tag, String taginfoUrl) { 110 taginfoUrl = getTaginfoUrl(taginfoUrl); 120 public String getTaginfoUrlForTag(Tag tag) { 111 121 if (tag.getValue().isEmpty()) { 112 OpenBrowser.displayUrl(taginfoUrl + "keys/" + tag.getKey());122 return taginfoUrl + "/keys/" + tag.getKey(); 113 123 } else { 114 OpenBrowser.displayUrl(taginfoUrl + "tags/" + tag.getKey() + '=' + Utils.encodeUrl(tag.getValue()).replaceAll("\\+", "%20"));124 return taginfoUrl + "/tags/" + tag.getKey() + '=' + Utils.encodeUrl(tag.getValue()).replaceAll("\\+", "%20"); 115 125 } 116 126 } … … 119 129 * Opens Taginfo for the given relation type 120 130 * @param type the relation type 121 * @param taginfoUrl Taginfo URL (may be null) 122 * @since 16275 131 * @since 16596 123 132 */ 124 public static void openTaginfoForRelationType(String type, String taginfoUrl) { 125 taginfoUrl = getTaginfoUrl(taginfoUrl); 126 OpenBrowser.displayUrl(taginfoUrl + "relations/" + type); 133 public String getTaginfoUrlForRelationType(String type) { 134 return taginfoUrl + "/relations/" + type; 135 } 136 137 /** 138 * Returns a new action which launches https://taghistory.raifer.tech/ for the given tag 139 * @return a new action 140 * @since 16596 141 */ 142 public TaginfoAction toTagHistoryAction() { 143 String url = withoutTrailingSlash(TAG_HISTORY_URL_PROP.get()); 144 return new TaginfoAction(tr("Go to OSM Tag History"), tagSupplier, relationTypeSupplier, url) { 145 @Override 146 public String getTaginfoUrlForTag(Tag tag) { 147 return String.join("/", taginfoUrl, tag.getKey(), tag.getValue()); 148 } 149 150 @Override 151 public String getTaginfoUrlForRelationType(String type) { 152 return null; 153 } 154 }; 127 155 } 128 156 } -
trunk/src/org/openstreetmap/josm/gui/history/TagInfoViewer.java
r16593 r16596 100 100 tagMenu.addSeparator(); 101 101 tagMenu.add(trackJosmAction(new HelpTagAction(table, tagKeyFn, tagValuesFn))); 102 tagMenu.add(trackJosmAction(new TaginfoAction(tr("Go to Taginfo"), table, tagKeyFn, tagValuesFn, null, null, null))); 102 TaginfoAction taginfoAction = new TaginfoAction(tr("Go to Taginfo"), table, tagKeyFn, tagValuesFn, null, null, null); 103 tagMenu.add(trackJosmAction(taginfoAction.toTagHistoryAction())); 104 tagMenu.add(trackJosmAction(taginfoAction)); 103 105 104 106 table.addMouseListener(new PopupMenuLauncher(tagMenu)); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/KeyedItem.java
r16417 r16596 214 214 popupMenu.add(tr("Key: {0}", key)).setEnabled(false); 215 215 popupMenu.add(new HelpTagAction(() -> tag)); 216 popupMenu.add(new TaginfoAction(() -> tag, () -> null)); 216 TaginfoAction taginfoAction = new TaginfoAction(() -> tag, () -> null); 217 popupMenu.add(taginfoAction.toTagHistoryAction()); 218 popupMenu.add(taginfoAction); 217 219 return popupMenu; 218 220 }
Note:
See TracChangeset
for help on using the changeset viewer.