Changeset 32892 in osm for applications/editors/josm/plugins/wikipedia/src/org
- Timestamp:
- 2016-08-30T13:27:07+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/wikipedia/src/org/wikipedia
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaApp.java
r32891 r32892 83 83 return new WikidataEntry(name, null, latLon, null); 84 84 } else { 85 return new WikipediaEntry(wikipediaLang, name, name,latLon);85 return new WikipediaEntry(wikipediaLang, name, latLon); 86 86 } 87 87 }).collect(Collectors.toList()); -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/data/WikidataEntry.java
r32891 r32892 4 4 import org.openstreetmap.josm.data.coor.LatLon; 5 5 import org.openstreetmap.josm.data.osm.Tag; 6 import org.openstreetmap.josm.tools.AlphanumComparator; 6 7 import org.openstreetmap.josm.tools.CheckParameterUtil; 7 8 import org.openstreetmap.josm.tools.Utils; 8 9 import org.wikipedia.WikipediaApp; 9 10 11 import java.util.Comparator; 12 import java.util.Optional; 13 10 14 public class WikidataEntry extends WikipediaEntry { 11 15 16 public final String label; 12 17 public final String description; 13 18 14 19 public WikidataEntry(String id, String label, LatLon coordinate, String description) { 15 super("wikidata", id, label, coordinate); 20 super("wikidata", id, coordinate); 21 this.label = label; 16 22 this.description = description; 17 23 ensureValidWikidataId(id); … … 33 39 } 34 40 41 @Override 42 public String getSearchText() { 43 return Optional.ofNullable(label).orElse(article); 44 } 45 35 46 private static void ensureValidWikidataId(String id) { 36 47 CheckParameterUtil.ensureThat(WikipediaApp.WIKIDATA_PATTERN.matcher(id).matches(), "Invalid Wikidata ID given: " + id); 37 48 } 49 50 @Override 51 public int compareTo(WikipediaEntry o) { 52 if (o instanceof WikidataEntry) { 53 return Comparator 54 .<WikidataEntry, String>comparing(x -> x.label, AlphanumComparator.getInstance()) 55 .thenComparing(x -> x.article, AlphanumComparator.getInstance()) 56 .compare(this, ((WikidataEntry) o)); 57 } else { 58 return super.compareTo(o); 59 } 60 } 38 61 } -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/data/WikipediaEntry.java
r32891 r32892 8 8 import org.wikipedia.WikipediaApp; 9 9 10 import java.util.Comparator;11 10 import java.util.Objects; 12 11 import java.util.regex.Matcher; … … 17 16 public final String lang; 18 17 public final String article; 19 public final String label;20 18 public final LatLon coordinate; 21 19 private Boolean wiwosmStatus; 22 20 23 21 public WikipediaEntry(String lang, String article) { 24 this(lang, article, null , null);22 this(lang, article, null); 25 23 } 26 24 27 public WikipediaEntry(String lang, String article, String label,LatLon coordinate) {25 public WikipediaEntry(String lang, String article, LatLon coordinate) { 28 26 this.lang = lang; 29 27 this.article = article; 30 this.label = label;31 28 this.coordinate = coordinate; 32 29 } … … 90 87 } 91 88 89 public String getSearchText() { 90 return article; 91 } 92 92 93 @Override 93 94 public String toString() { … … 97 98 @Override 98 99 public int compareTo(WikipediaEntry o) { 99 return Comparator 100 .<WikipediaEntry, String>comparing(x -> x.label, AlphanumComparator.getInstance()) 101 .thenComparing(x -> x.article, AlphanumComparator.getInstance()) 102 .compare(this, o); 100 return AlphanumComparator.getInstance().compare(article, o.article); 103 101 } 104 102 -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/gui/WikipediaToggleDialog.java
r32891 r32892 11 11 import java.util.HashSet; 12 12 import java.util.List; 13 import java.util.Optional;14 13 import java.util.Set; 15 14 … … 79 78 Main.map.mapView.zoomTo(bbox); 80 79 } 81 final String search = Optional.ofNullable(entry.label).orElse(entry.article).replaceAll("\\(.*\\)", "");80 final String search = entry.getSearchText().replaceAll("\\(.*\\)", ""); 82 81 SearchAction.search(search, SearchAction.SearchMode.replace); 83 82 }
Note:
See TracChangeset
for help on using the changeset viewer.