Changeset 32624 in osm for applications/editors/josm/plugins/wikipedia/src/org
- Timestamp:
- 2016-07-10T22:56:50+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/wikipedia/src/org/wikipedia
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaApp.java
r32614 r32624 96 96 (double) xpathLon.evaluate(node, XPathConstants.NUMBER)); 97 97 if ("wikidata".equals(wikipediaLang)) { 98 entries.add(new WikidataEntry(name, latLon, null));98 entries.add(new WikidataEntry(name, null, latLon)); 99 99 } else { 100 entries.add(new WikipediaEntry( name, wikipediaLang, name, latLon100 entries.add(new WikipediaEntry(wikipediaLang, name, name, latLon 101 101 )); 102 102 } … … 109 109 final List<WikipediaEntry> entriesWithLabel = new ArrayList<>(nodes.getLength()); 110 110 for (WikipediaEntry entry : entries) { 111 entriesWithLabel.add(new WikidataEntry(entry.wikipediaArticle, entry.coordinate, labels.get(entry.wikipediaArticle)));111 entriesWithLabel.add(new WikidataEntry(entry.wikipediaArticle, labels.get(entry.wikipediaArticle), entry.coordinate)); 112 112 } 113 113 return entriesWithLabel; … … 134 134 while (scanner.hasNext()) { 135 135 final String article = scanner.next().trim().replace("_", " "); 136 entries.add(new WikipediaEntry( article,wikipediaLang, article));136 entries.add(new WikipediaEntry(wikipediaLang, article)); 137 137 } 138 138 return entries; … … 149 149 @Override 150 150 public WikipediaEntry apply(String x) { 151 return new WikipediaEntry( x,wikipediaLang, x);151 return new WikipediaEntry(wikipediaLang, x); 152 152 } 153 153 })); … … 409 409 static class WikipediaEntry implements Comparable<WikipediaEntry> { 410 410 411 final String name;411 final String label; 412 412 final String wikipediaLang, wikipediaArticle; 413 413 final LatLon coordinate; 414 414 private Boolean wiwosmStatus; 415 415 416 public WikipediaEntry(String name,String wikipediaLang, String wikipediaArticle) {417 this( name, wikipediaLang, wikipediaArticle, null);418 } 419 420 public WikipediaEntry(String name, String wikipediaLang, String wikipediaArticle, LatLon coordinate) {421 this. name = name;416 WikipediaEntry(String wikipediaLang, String wikipediaArticle) { 417 this(wikipediaLang, wikipediaArticle, null, null); 418 } 419 420 WikipediaEntry(String wikipediaLang, String wikipediaArticle, String label, LatLon coordinate) { 421 this.label = label; 422 422 this.wikipediaLang = wikipediaLang; 423 423 this.wikipediaArticle = wikipediaArticle; … … 442 442 443 443 public String getLabelText() { 444 return name;444 return wikipediaArticle; 445 445 } 446 446 447 447 @Override 448 448 public String toString() { 449 return name;449 return wikipediaArticle; 450 450 } 451 451 452 452 @Override 453 453 public int compareTo(WikipediaEntry o) { 454 return AlphanumComparator.getInstance().compare( name, o.name);454 return AlphanumComparator.getInstance().compare(label, o.label); 455 455 } 456 456 } … … 458 458 static class WikidataEntry extends WikipediaEntry { 459 459 460 WikidataEntry(String id, LatLon coordinate, String label) {461 super( label, "wikidata", id, coordinate);460 WikidataEntry(String id, String label, LatLon coordinate) { 461 super("wikidata", id, label, coordinate); 462 462 ensureValidWikidataId(id); 463 463 } … … 470 470 @Override 471 471 public String getLabelText() { 472 return getLabelText( name, wikipediaArticle);472 return getLabelText(label, wikipediaArticle); 473 473 } 474 474 -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaToggleDialog.java
r32610 r32624 43 43 import org.openstreetmap.josm.tools.LanguageInfo; 44 44 import org.openstreetmap.josm.tools.OpenBrowser; 45 import org.openstreetmap.josm.tools.Utils; 45 46 import org.wikipedia.WikipediaApp.WikipediaEntry; 46 47 … … 78 79 Main.map.mapView.zoomTo(bbox); 79 80 } 80 SearchAction.search(entry.name.replaceAll("\\(.*\\)", ""), SearchAction.SearchMode.replace); 81 final String search = Utils.firstNonNull(entry.label, entry.wikipediaArticle).replaceAll("\\(.*\\)", ""); 82 SearchAction.search(search, SearchAction.SearchMode.replace); 81 83 } 82 84 }
Note:
See TracChangeset
for help on using the changeset viewer.