Changeset 32704 in osm for applications/editors
- Timestamp:
- 2016-07-23T23:51:22+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/wikipedia/src/org/wikipedia
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikidataTagCellRenderer.java
r32691 r32704 70 70 protected JLabel renderValues(Collection<String> ids, JTable table, JLabel component) { 71 71 72 for (String id : ids) {73 if (!labelCache.containsKey(id)) {74 labelCache.put(id, Main.worker.submit(new LabelLoader(id, table)));75 }76 }72 ids.stream() 73 .filter(id -> !labelCache.containsKey(id)) 74 .forEach(id -> { 75 labelCache.put(id, Main.worker.submit(new LabelLoader(id, table))); 76 }); 77 77 78 78 final Collection<String> texts = new ArrayList<>(ids.size()); -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaAddNamesAction.java
r32687 r32704 15 15 import org.openstreetmap.josm.data.osm.DataSet; 16 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 import org.openstreetmap.josm.data.preferences.StringProperty;18 17 import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog; 19 import org.openstreetmap.josm.tools.LanguageInfo;20 18 21 19 public class WikipediaAddNamesAction extends JosmAction { … … 31 29 final WikipediaApp.WikipediaLangArticle wp = WikipediaApp.WikipediaLangArticle.parseTag("wikipedia", getWikipediaValue()); 32 30 List<String[]> tags = new ArrayList<>(); 33 for (WikipediaApp.WikipediaLangArticle i : WikipediaApp.getInterwikiArticles(wp.lang, wp.article)) { 34 if (useWikipediaLangArticle(i)) { 35 tags.add(new String[]{"name:" + i.lang, i.article}); 36 } 37 } 31 WikipediaApp.getInterwikiArticles(wp.lang, wp.article).stream() 32 .filter(this::useWikipediaLangArticle) 33 .map(i -> new String[]{"name:" + i.lang, i.article}) 34 .forEach(tags::add); 38 35 if (Main.isDebugEnabled()) { 39 36 Main.debug(tags.toString()); -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaApp.java
r32695 r32704 27 27 import javax.xml.parsers.DocumentBuilderFactory; 28 28 import javax.xml.parsers.ParserConfigurationException; 29 import javax.xml.xpath.XPathExpressionException;30 29 31 30 import org.openstreetmap.josm.Main; … … 33 32 import org.openstreetmap.josm.data.osm.OsmPrimitive; 34 33 import org.openstreetmap.josm.data.osm.Tag; 34 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 35 35 import org.openstreetmap.josm.tools.AlphanumComparator; 36 36 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 42 42 public final class WikipediaApp { 43 43 44 public static Pattern WIKIDATA_PATTERN = Pattern.compile("Q\\d+");44 public static final Pattern WIKIDATA_PATTERN = Pattern.compile("Q\\d+"); 45 45 private static final DocumentBuilder DOCUMENT_BUILDER = newDocumentBuilder(); 46 46 private static final XPath X_PATH = XPath.getInstance(); … … 141 141 static List<WikipediaEntry> getEntriesFromClipboard(final String wikipediaLang) { 142 142 return Pattern.compile("[\\n\\r]+") 143 .splitAsStream( Utils.getClipboardContent())143 .splitAsStream(ClipboardUtils.getClipboardStringContent()) 144 144 .map(x -> new WikipediaEntry(wikipediaLang, x)) 145 145 .collect(Collectors.toList()); … … 290 290 } 291 291 292 private static String getFirstField(Collection<String> languages, String field, Node entity) throws XPathExpressionException{292 private static String getFirstField(Collection<String> languages, String field, Node entity) { 293 293 return languages.stream() 294 294 .map(language -> X_PATH.evaluateString(language != null … … 302 302 static Collection<WikipediaLangArticle> getInterwikiArticles(String wikipediaLang, String article) { 303 303 try { 304 Collection<WikipediaLangArticle> r = new ArrayList<>();305 304 final String url = getSiteUrl(wikipediaLang) + "/w/api.php" + 306 305 "?action=query" + -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaCategorySearchDialog.java
r32687 r32704 5 5 6 6 import java.awt.Dimension; 7 import java.awt.event.ActionEvent;8 import java.awt.event.ActionListener;9 7 import java.util.Collections; 10 8 import java.util.List; … … 51 49 } 52 50 53 @Override54 protected void buttonAction(int buttonIndex, ActionEvent evt) {55 super.buttonAction(buttonIndex, evt);56 }57 58 51 private static class Selector extends WikiSearchTextResultListPanel<String> { 59 52 -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaCopyTemplate.java
r32691 r32704 18 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 19 import org.openstreetmap.josm.gui.MainMenu; 20 import org.openstreetmap.josm. tools.Utils;20 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 21 21 22 22 public class WikipediaCopyTemplate { … … 83 83 return; 84 84 } 85 Utils.copyToClipboard(pattern85 ClipboardUtils.copyString(pattern 86 86 .replace("{lat}", Double.toString(node.getCoor().lat())) 87 87 .replace("{lon}", Double.toString(node.getCoor().lon()))); -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaToggleDialog.java
r32687 r32704 186 186 protected void process(List<WikipediaEntry> chunks) { 187 187 model.clear(); 188 for (WikipediaEntry i : chunks) { 189 model.addElement(i); 190 } 188 chunks.forEach(model::addElement); 191 189 updateTitle(); 192 190 updateWikipediaArticles(); -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/XPath.java
r32695 r32704 19 19 public class XPath implements javax.xml.xpath.XPath { 20 20 private final javax.xml.xpath.XPath xPath; 21 private static XPath INSTANCE = new XPath(XPathFactory.newInstance().newXPath());21 private static final XPath INSTANCE = new XPath(XPathFactory.newInstance().newXPath()); 22 22 23 23 private XPath(javax.xml.xpath.XPath xPath) {
Note:
See TracChangeset
for help on using the changeset viewer.