Changeset 33541 in osm for applications/editors/josm/plugins
- Timestamp:
- 2017-08-26T02:51:22+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/wikipedia
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wikipedia/build.xml
r32680 r33541 5 5 <property name="commit.message" value="Commit message"/> 6 6 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 7 <property name="plugin.main.version" value="1 0580"/>7 <property name="plugin.main.version" value="12663"/> 8 8 <property name="plugin.canloadatruntime" value="true"/> 9 9 -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaApp.java
r33288 r33541 34 34 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 35 35 import org.openstreetmap.josm.tools.HttpClient; 36 import org.openstreetmap.josm.tools.Logging; 36 37 import org.openstreetmap.josm.tools.Utils; 37 38 import org.w3c.dom.Document; … … 193 194 status.put(x[0], "1".equals(x[1])); 194 195 } else { 195 Main.error("Unknown element " + line);196 Logging.error("Unknown element " + line); 196 197 } 197 198 }); … … 483 484 return DocumentBuilderFactory.newInstance().newDocumentBuilder(); 484 485 } catch (ParserConfigurationException e) { 485 Main.warn("Cannot create DocumentBuilder");486 Main.warn(e);486 Logging.warn("Cannot create DocumentBuilder"); 487 Logging.warn(e); 487 488 throw new RuntimeException(e); 488 489 } -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaPlugin.java
r32888 r33541 2 2 package org.wikipedia; 3 3 4 import org.openstreetmap.josm.Main; 4 import javax.swing.JMenu; 5 6 import org.openstreetmap.josm.gui.MainApplication; 5 7 import org.openstreetmap.josm.gui.MainMenu; 6 8 import org.openstreetmap.josm.gui.MapFrame; … … 19 21 super(info); 20 22 new WikipediaCopyTemplate(); 21 MainMenu.add(Main.main.menu.dataMenu, new WikipediaAddNamesAction()); 22 MainMenu.add(Main.main.menu.dataMenu, new FetchWikidataAction()); 23 MainMenu.add(Main.main.menu.dataMenu, new WikidataItemSearchDialog.Action()); 23 JMenu dataMenu = MainApplication.getMenu().dataMenu; 24 MainMenu.add(dataMenu, new WikipediaAddNamesAction()); 25 MainMenu.add(dataMenu, new FetchWikidataAction()); 26 MainMenu.add(dataMenu, new WikidataItemSearchDialog.Action()); 24 27 } 25 28 -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/actions/FetchWikidataAction.java
r33075 r33541 23 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; 24 24 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 25 import org.openstreetmap.josm.gui.MainApplication; 25 26 import org.openstreetmap.josm.gui.Notification; 26 27 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 27 28 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 29 import org.openstreetmap.josm.tools.Logging; 28 30 import org.openstreetmap.josm.tools.MultiMap; 29 31 import org.openstreetmap.josm.tools.Utils; … … 45 47 return; 46 48 } 47 Main .worker.submit(new Fetcher(ds.getSelected()));49 MainApplication.worker.submit(new Fetcher(ds.getSelected())); 48 50 } 49 51 … … 99 101 protected void finish() { 100 102 if (!canceled && !commands.isEmpty()) { 101 Main .main.undoRedo.add(commands.size() == 1 ? commands.get(0) : new SequenceCommand(tr("Add Wikidata"), commands));103 MainApplication.undoRedo.add(commands.size() == 1 ? commands.get(0) : new SequenceCommand(tr("Add Wikidata"), commands)); 102 104 } 103 105 if (!canceled && !notFound.isEmpty()) { … … 140 142 } else { 141 143 final WikipediaEntry article = new WikipediaEntry(lang, wikipedia); 142 Main.warn(tr("No Wikidata ID found for: {0}", article));144 Logging.warn(tr("No Wikidata ID found for: {0}", article)); 143 145 notFound.add(article); 144 146 } -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/actions/WikipediaAddNamesAction.java
r33075 r33541 16 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 17 import org.openstreetmap.josm.io.remotecontrol.AddTagsDialog; 18 import org.openstreetmap.josm.tools.Logging; 18 19 import org.wikipedia.WikipediaApp; 19 20 import org.wikipedia.data.WikipediaEntry; … … 35 36 .map(i -> new String[]{"name:" + i.lang, i.article}) 36 37 .forEach(tags::add); 37 if ( Main.isDebugEnabled()) {38 Main.debug(tags.toString());38 if (Logging.isDebugEnabled()) { 39 Logging.debug(tags.toString()); 39 40 } 40 41 AddTagsDialog.addTags(tags.toArray(new String[tags.size()][]), "Wikipedia", getLayerManager().getEditDataSet().getSelected()); -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/actions/WikipediaCopyTemplate.java
r32888 r33541 18 18 import org.openstreetmap.josm.data.osm.Node; 19 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; 20 import org.openstreetmap.josm.gui.MainApplication; 20 21 import org.openstreetmap.josm.gui.MainMenu; 21 22 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; … … 34 35 35 36 public WikipediaCopyTemplate() { 36 JosmAction previous = Main .main.menu.copyCoordinates;37 JosmAction previous = MainApplication.getMenu().copyCoordinates; 37 38 for (final CoordCopyTemplateEntry templateEntry : TEMPLATE_ENTRIES) { 38 39 CoordCopyTemplate t = new CoordCopyTemplate(templateEntry); 39 final JMenuItem menu = MainMenu.addAfter(Main .main.menu.editMenu, t, false, previous);40 final JMenuItem menu = MainMenu.addAfter(MainApplication.getMenu().editMenu, t, false, previous); 40 41 menu.setToolTipText(tr("Copies the {0} template to the system clipboard instantiated with the coordinates of the first selected node", templateEntry.name)); 41 42 previous = t; -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/gui/GuiUtils.java
r32888 r33541 3 3 4 4 import org.openstreetmap.josm.Main; 5 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 5 6 import org.openstreetmap.josm.data.osm.OsmPrimitive; 6 7 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 7 import org.openstreetmap.josm.gui.DefaultNameFormatter;8 8 import org.openstreetmap.josm.gui.util.GuiHelper; 9 9 import org.openstreetmap.josm.tools.AlphanumComparator; -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/gui/WikidataItemSearchDialog.java
r32887 r33541 25 25 import org.openstreetmap.josm.data.osm.Tag; 26 26 import org.openstreetmap.josm.gui.ExtendedDialog; 27 import org.openstreetmap.josm.gui.MainApplication; 27 28 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox; 28 29 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem; … … 74 75 75 76 private void initTargetKeys() { 76 final DataSet editDataSet = Main .getLayerManager().getEditDataSet();77 final DataSet editDataSet = MainApplication.getLayerManager().getEditDataSet(); 77 78 if (editDataSet == null) { 78 79 return; -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/gui/WikidataTagCellRenderer.java
r32888 r33541 21 21 import org.openstreetmap.josm.Main; 22 22 import org.openstreetmap.josm.gui.util.GuiHelper; 23 import org.openstreetmap.josm.tools.Logging; 23 24 import org.openstreetmap.josm.tools.Utils; 24 25 import org.wikipedia.WikipediaApp; … … 70 71 label = labelCache.get(id).get(); 71 72 } catch (InterruptedException | ExecutionException e) { 72 Main.warn("Could not fetch Wikidata label for " + id);73 Main.warn(e);73 Logging.warn("Could not fetch Wikidata label for " + id); 74 Logging.warn(e); 74 75 return null; 75 76 } -
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/gui/WikipediaToggleDialog.java
r33075 r33541 32 32 import org.openstreetmap.josm.data.osm.event.DatasetEventManager; 33 33 import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode; 34 import org.openstreetmap.josm.data.osm.search.SearchMode; 34 35 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 35 36 import org.openstreetmap.josm.data.preferences.StringProperty; 37 import org.openstreetmap.josm.gui.MainApplication; 38 import org.openstreetmap.josm.gui.MapView; 36 39 import org.openstreetmap.josm.gui.SideButton; 37 40 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; … … 40 43 import org.openstreetmap.josm.tools.ImageProvider; 41 44 import org.openstreetmap.josm.tools.LanguageInfo; 45 import org.openstreetmap.josm.tools.Logging; 42 46 import org.openstreetmap.josm.tools.OpenBrowser; 43 47 import org.wikipedia.WikipediaApp; … … 71 75 @Override 72 76 public void mouseClicked(MouseEvent e) { 73 if (e.getClickCount() == 2 && getSelectedValue() != null && Main .getLayerManager().getEditDataSet() != null) {77 if (e.getClickCount() == 2 && getSelectedValue() != null && MainApplication.getLayerManager().getEditDataSet() != null) { 74 78 final WikipediaEntry entry = getSelectedValue(); 75 79 if (entry.coordinate != null) { 76 80 BoundingXYVisitor bbox = new BoundingXYVisitor(); 77 81 bbox.visit(entry.coordinate); 78 Main .map.mapView.zoomTo(bbox);82 MainApplication.getMap().mapView.zoomTo(bbox); 79 83 } 80 84 final String search = entry.getSearchText().replaceAll("\\(.*\\)", ""); 81 SearchAction.search(search, Search Action.SearchMode.replace);85 SearchAction.search(search, SearchMode.replace); 82 86 } 83 87 } … … 146 150 try { 147 151 // determine bbox 148 final LatLon min = Main.map.mapView.getLatLon(0, Main.map.mapView.getHeight()); 149 final LatLon max = Main.map.mapView.getLatLon(Main.map.mapView.getWidth(), 0); 152 MapView mapView = MainApplication.getMap().mapView; 153 final LatLon min = mapView.getLatLon(0, mapView.getHeight()); 154 final LatLon max = mapView.getLatLon(mapView.getWidth(), 0); 150 155 // add entries to list model 151 156 titleContext = tr("coordinates"); … … 258 263 if (list.getSelectedValue() != null) { 259 264 final String url = list.getSelectedValue().getBrowserUrl(); 260 Main.info("Wikipedia: opening " + url);265 Logging.info("Wikipedia: opening " + url); 261 266 OpenBrowser.displayUrl(url); 262 267 } … … 313 318 return; 314 319 } 315 final Collection<OsmPrimitive> selected = Main .getLayerManager().getEditDataSet().getSelected();320 final Collection<OsmPrimitive> selected = MainApplication.getLayerManager().getEditDataSet().getSelected(); 316 321 if (!GuiUtils.confirmOverwrite(tag.getKey(), tag.getValue(), selected)) { 317 322 return; … … 320 325 selected, 321 326 tag.getKey(), tag.getValue()); 322 Main .main.undoRedo.add(cmd);323 Main .worker.submit(new FetchWikidataAction.Fetcher(selected));327 MainApplication.undoRedo.add(cmd); 328 MainApplication.worker.submit(new FetchWikidataAction.Fetcher(selected)); 324 329 } 325 330 } … … 345 350 return; 346 351 } 347 Main .map.mapView.zoomTo(latLon);352 MainApplication.getMap().mapView.zoomTo(latLon); 348 353 } 349 354 } … … 352 357 final String language = getLanguageOfFirstItem(); 353 358 articles.clear(); 354 if (Main.main != null && Main .getLayerManager().getEditDataSet() != null) {355 Main.getLayerManager().getEditDataSet().allPrimitives().stream()359 if (Main.main != null && MainApplication.getLayerManager().getEditDataSet() != null) { 360 MainApplication.getLayerManager().getEditDataSet().allPrimitives().stream() 356 361 .flatMap(p -> WikipediaApp.forLanguage(language).getWikipediaArticles(p)) 357 362 .forEach(articles::add); … … 364 369 public void showNotify() { 365 370 DatasetEventManager.getInstance().addDatasetListener(dataChangedAdapter, FireMode.IN_EDT_CONSOLIDATED); 366 Main .getLayerManager().addActiveLayerChangeListener(this);371 MainApplication.getLayerManager().addActiveLayerChangeListener(this); 367 372 updateWikipediaArticles(); 368 373 } … … 371 376 public void hideNotify() { 372 377 DatasetEventManager.getInstance().removeDatasetListener(dataChangedAdapter); 373 Main .getLayerManager().removeActiveLayerChangeListener(this);378 MainApplication.getLayerManager().removeActiveLayerChangeListener(this); 374 379 articles.clear(); 375 380 }
Note:
See TracChangeset
for help on using the changeset viewer.