Changeset 13522 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2018-03-13T01:07:46+01:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/HelpAction.java
r13521 r13522 10 10 import java.net.URISyntaxException; 11 11 import java.util.ArrayList; 12 import java.util.Arrays; 12 13 import java.util.List; 13 14 import java.util.Map; … … 76 77 String lang = LanguageInfo.getWikiLanguagePrefix(); 77 78 final List<URI> uris = new ArrayList<>(); 78 int row;79 79 if (tagTable.getSelectedRowCount() == 1) { 80 row = tagTable.getSelectedRow();80 int row = tagTable.getSelectedRow(); 81 81 String key = Utils.encodeUrl(tagKeySupplier.apply(row)); 82 82 Map<String, Integer> m = tagValuesSupplier.apply(row); 83 83 if (!m.isEmpty()) { 84 84 String val = Utils.encodeUrl(m.entrySet().iterator().next().getKey()); 85 86 uris.add(new URI(String.format("%s%sTag:%s=%s", base, lang, key, val))); 87 uris.add(new URI(String.format("%sTag:%s=%s", base, key, val))); 88 uris.add(new URI(String.format("%s%sKey:%s", base, lang, key))); 89 uris.add(new URI(String.format("%sKey:%s", base, key))); 90 uris.add(new URI(String.format("%s%sMap_Features", base, lang))); 91 uris.add(new URI(String.format("%sMap_Features", base))); 85 uris.addAll(getTagURIs(base, lang, key, val)); 92 86 } 93 87 } else if (membershipTable != null && membershipTable.getSelectedRowCount() == 1) { 94 row = membershipTable.getSelectedRow(); 95 String type = (memberValueSupplier.apply(row)).get("type"); 96 if (type != null) { 97 type = Utils.encodeUrl(type); 98 } 99 100 if (type != null && !type.isEmpty()) { 101 uris.add(new URI(String.format("%s%sRelation:%s", base, lang, type))); 102 uris.add(new URI(String.format("%sRelation:%s", base, type))); 103 } 104 105 uris.add(new URI(String.format("%s%sRelations", base, lang))); 106 uris.add(new URI(String.format("%sRelations", base))); 88 int row = membershipTable.getSelectedRow(); 89 uris.addAll(getRelationURIs(base, lang, memberValueSupplier.apply(row))); 107 90 } else { 108 91 // give the generic help page, if more than one element is selected 109 uris.add(new URI(String.format("%s%sMap_Features", base, lang))); 110 uris.add(new URI(String.format("%sMap_Features", base))); 92 uris.addAll(getGenericURIs(base, lang)); 111 93 } 112 94 … … 117 99 } 118 100 119 private void displayHelp(final List<URI> uris) { 101 /** 102 * Returns a list of URIs for the given key/value. 103 * @param base OSM wiki base URL 104 * @param lang Language prefix 105 * @param key Key 106 * @param val Value 107 * @return a list of URIs for the given key/value by order of relevance 108 * @throws URISyntaxException in case of internal error 109 * @since 13522 110 */ 111 public static List<URI> getTagURIs(String base, String lang, String key, String val) throws URISyntaxException { 112 return Arrays.asList( 113 new URI(String.format("%s%sTag:%s=%s", base, lang, key, val)), 114 new URI(String.format("%sTag:%s=%s", base, key, val)), 115 new URI(String.format("%s%sKey:%s", base, lang, key)), 116 new URI(String.format("%sKey:%s", base, key)), 117 new URI(String.format("%s%sMap_Features", base, lang)), 118 new URI(String.format("%sMap_Features", base)) 119 ); 120 } 121 122 /** 123 * Returns a list of URIs for the given relation. 124 * @param base OSM wiki base URL 125 * @param lang Language prefix 126 * @param rel Relation 127 * @return a list of URIs for the given relation by order of relevance 128 * @throws URISyntaxException in case of internal error 129 * @since 13522 130 */ 131 public static List<URI> getRelationURIs(String base, String lang, Relation rel) throws URISyntaxException { 132 List<URI> uris = new ArrayList<>(); 133 String type = rel.get("type"); 134 if (type != null) { 135 type = Utils.encodeUrl(type); 136 } 137 138 if (type != null && !type.isEmpty()) { 139 uris.add(new URI(String.format("%s%sRelation:%s", base, lang, type))); 140 uris.add(new URI(String.format("%sRelation:%s", base, type))); 141 } 142 143 uris.add(new URI(String.format("%s%sRelations", base, lang))); 144 uris.add(new URI(String.format("%sRelations", base))); 145 return uris; 146 } 147 148 /** 149 * Returns a list of generic URIs (Map Features). 150 * @param base OSM wiki base URL 151 * @param lang Language prefix 152 * @return a list of generic URIs (Map Features) 153 * @throws URISyntaxException in case of internal error 154 * @since 13522 155 */ 156 public static List<URI> getGenericURIs(String base, String lang) throws URISyntaxException { 157 return Arrays.asList( 158 new URI(String.format("%s%sMap_Features", base, lang)), 159 new URI(String.format("%sMap_Features", base)) 160 ); 161 } 162 163 /** 164 * Display help by searching the forst valid URI in the given list. 165 * @param uris list of URIs to test 166 * @since 13522 167 */ 168 public static void displayHelp(final List<URI> uris) { 120 169 try { 121 170 // find a page that actually exists in the wiki
Note:
See TracChangeset
for help on using the changeset viewer.