Changeset 29033 in osm for applications
- Timestamp:
- 2012-12-04T21:48:34+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/wikipedia/src/org/wikipedia
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaApp.java
r28987 r29033 159 159 } 160 160 161 static Collection<WikipediaLangArticle> getInterwikiArticles(String wikipediaLang, String article) { 162 try { 163 Collection<WikipediaLangArticle> r = new ArrayList<WikipediaLangArticle>(); 164 final String url = "http://" + wikipediaLang + ".wikipedia.org/w/api.php" + 165 "?action=query" + 166 "&prop=langlinks" + 167 "&titles=" + article + 168 "&lllimit=500" + 169 "&format=xml"; 170 System.out.println("Wikipedia: GET " + url); 171 final Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new URL(url).openStream()); 172 final NodeList nodes = (NodeList) XPathFactory.newInstance().newXPath().compile("//ll").evaluate(xml, XPathConstants.NODESET); 173 for (int i = 0; i < nodes.getLength(); i++) { 174 final String lang = nodes.item(i).getAttributes().getNamedItem("lang").getTextContent(); 175 final String name = nodes.item(i).getTextContent(); 176 r.add(new WikipediaLangArticle(lang, name)); 177 } 178 return r; 179 } catch (Exception ex) { 180 throw new RuntimeException(ex); 181 } 182 } 183 161 184 static class WikipediaLangArticle { 162 185 -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaPlugin.java
r28247 r29033 2 2 package org.wikipedia; 3 3 4 import org.openstreetmap.josm.Main; 5 import org.openstreetmap.josm.gui.MainMenu; 4 6 import org.openstreetmap.josm.gui.MapFrame; 5 7 import org.openstreetmap.josm.plugins.Plugin; … … 11 13 super(info); 12 14 new WikipediaCopyTemplate(); 15 MainMenu.add(Main.main.menu.toolsMenu, new WikipediaAddNamesAction()); 13 16 } 14 17
Note:
See TracChangeset
for help on using the changeset viewer.