Changeset 33530 in osm for applications
- Timestamp:
- 2017-08-26T02:16:05+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/reltoolbox
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reltoolbox/build.xml
r32680 r33530 4 4 <property name="commit.message" value="RelToolbox: make natural sort for relation and find relation lists"/> 5 5 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 6 <property name="plugin.main.version" value="1 0580"/>6 <property name="plugin.main.version" value="12663"/> 7 7 8 8 <property name="plugin.author" value="Ilya Zverev"/> -
applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelation.java
r33311 r33530 13 13 import java.util.Set; 14 14 15 import org.openstreetmap.josm.Main;16 15 import org.openstreetmap.josm.data.Bounds; 17 16 import org.openstreetmap.josm.data.osm.Node; … … 28 27 import org.openstreetmap.josm.data.osm.event.TagsChangedEvent; 29 28 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent; 29 import org.openstreetmap.josm.gui.MainApplication; 30 30 import org.openstreetmap.josm.gui.MapView; 31 31 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; … … 49 49 chosenRelation = rel; 50 50 analyse(); 51 Main .map.mapView.repaint();51 MainApplication.getMap().mapView.repaint(); 52 52 fireRelationChanged(oldRel); 53 53 } … … 124 124 // todo: dim chosen relation when changing layer 125 125 // todo: check this WTF! 126 OsmDataLayer newLayer = Main .getLayerManager().getEditLayer();126 OsmDataLayer newLayer = MainApplication.getLayerManager().getEditLayer(); 127 127 clear(); 128 128 if (newLayer != null && e.getPreviousEditLayer() == null) { 129 Main .map.mapView.addTemporaryLayer(this);129 MainApplication.getMap().mapView.addTemporaryLayer(this); 130 130 } else if (newLayer == null) { 131 Main .map.mapView.removeTemporaryLayer(this);131 MainApplication.getMap().mapView.removeTemporaryLayer(this); 132 132 } 133 133 } … … 159 159 visitedRelations.add(rel); 160 160 for (OsmPrimitive element : rel.getMemberPrimitives()) { 161 if (null != element.getType()) switch(element.getType()) { 161 if (null != element.getType()) { 162 switch(element.getType()) { 162 163 case NODE: 163 164 Node node = (Node) element; … … 185 186 default: 186 187 break; 188 } 187 189 } 188 190 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/ExtraNameFormatHook.java
r32398 r33530 5 5 import org.openstreetmap.josm.data.osm.IRelation; 6 6 import org.openstreetmap.josm.data.osm.IWay; 7 import org.openstreetmap.josm. gui.NameFormatterHook;7 import org.openstreetmap.josm.data.osm.NameFormatterHook; 8 8 9 9 /** -
applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextDialog.java
r33311 r33530 64 64 import org.openstreetmap.josm.command.SequenceCommand; 65 65 import org.openstreetmap.josm.data.SelectionChangedListener; 66 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 66 67 import org.openstreetmap.josm.data.osm.OsmPrimitive; 67 68 import org.openstreetmap.josm.data.osm.Relation; … … 70 71 import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode; 71 72 import org.openstreetmap.josm.data.osm.event.SelectionEventManager; 72 import org.openstreetmap.josm.gui. DefaultNameFormatter;73 import org.openstreetmap.josm.gui.MainApplication; 73 74 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 74 75 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; … … 77 78 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox; 78 79 import org.openstreetmap.josm.tools.GBC; 80 import org.openstreetmap.josm.tools.Logging; 79 81 import org.openstreetmap.josm.tools.Shortcut; 80 82 … … 125 127 chosenRelation = new ChosenRelation(); 126 128 chosenRelation.addChosenRelationListener(this); 127 Main .getLayerManager().addActiveLayerChangeListener(chosenRelation);129 MainApplication.getLayerManager().addActiveLayerChangeListener(chosenRelation); 128 130 129 131 popupMenu = new ChosenRelationPopupMenu(chosenRelation); … … 252 254 Relation relation = (Relation) relationsData.getValueAt(row, 0); 253 255 if (e.getClickCount() > 1) { 254 Main .getLayerManager().getEditLayer().data.setSelected(relation);256 MainApplication.getLayerManager().getEditLayer().data.setSelected(relation); 255 257 } 256 258 } … … 337 339 public void hideNotify() { 338 340 SelectionEventManager.getInstance().removeSelectionListener(this); 339 Main .getLayerManager().removeActiveLayerChangeListener(this);341 MainApplication.getLayerManager().removeActiveLayerChangeListener(this); 340 342 DatasetEventManager.getInstance().removeDatasetListener(chosenRelation); 341 343 chosenRelation.clear(); … … 345 347 public void showNotify() { 346 348 SelectionEventManager.getInstance().addSelectionListener(this, FireMode.IN_EDT_CONSOLIDATED); 347 Main .getLayerManager().addActiveLayerChangeListener(this);349 MainApplication.getLayerManager().addActiveLayerChangeListener(this); 348 350 DatasetEventManager.getInstance().addDatasetListener(chosenRelation, FireMode.IN_EDT); 349 351 } … … 358 360 chosenRelationPanel.setVisible(newRelation != null); 359 361 } 360 if (Main .getLayerManager().getEditDataSet() != null) {361 selectionChanged(Main .getLayerManager().getEditDataSet().getSelected());362 if (MainApplication.getLayerManager().getEditDataSet() != null) { 363 selectionChanged(MainApplication.getLayerManager().getEditDataSet().getSelected()); 362 364 } 363 365 roleBoxModel.update(); … … 409 411 410 412 private void updateSelection() { 411 if (Main .getLayerManager().getEditDataSet() == null) {413 if (MainApplication.getLayerManager().getEditDataSet() == null) { 412 414 selectionChanged(Collections.<OsmPrimitive>emptyList()); 413 415 } else { 414 selectionChanged(Main .getLayerManager().getEditDataSet().getSelected());416 selectionChanged(MainApplication.getLayerManager().getEditDataSet().getSelected()); 415 417 } 416 418 } … … 455 457 } 456 458 } catch (Exception e) { 457 Main.error("[RelToolbox] Error reading possible roles file.");458 Main.error(e);459 Logging.error("[RelToolbox] Error reading possible roles file."); 460 Logging.error(e); 459 461 } 460 462 return result; … … 510 512 public void mouseClicked(MouseEvent e) { 511 513 if (e.isControlDown() || !(e.getComponent() instanceof JComboBox)) // do not use left click handler on combo box 512 if (SwingUtilities.isLeftMouseButton(e) && chosenRelation.get() != null && Main.getLayerManager().getEditLayer() != null) { 513 Main.getLayerManager().getEditLayer().data.setSelected(chosenRelation.get()); 514 if (SwingUtilities.isLeftMouseButton(e) && chosenRelation.get() != null 515 && MainApplication.getLayerManager().getEditLayer() != null) { 516 MainApplication.getLayerManager().getEditLayer().data.setSelected(chosenRelation.get()); 514 517 } 515 518 } … … 549 552 protected void applyRoleToSelection(String role) { 550 553 if (chosenRelation != null && chosenRelation.get() != null 551 && Main.getLayerManager().getEditDataSet() != null && !Main.getLayerManager().getEditDataSet().selectionEmpty()) { 552 Collection<OsmPrimitive> selected = Main.getLayerManager().getEditDataSet().getSelected(); 554 && MainApplication.getLayerManager().getEditDataSet() != null 555 && !MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 556 Collection<OsmPrimitive> selected = MainApplication.getLayerManager().getEditDataSet().getSelected(); 553 557 Relation r = chosenRelation.get(); 554 558 List<Command> commands = new ArrayList<>(); … … 563 567 if (!commands.isEmpty()) { 564 568 // Main.main.undoRedo.add(new ChangeCommand(chosenRelation.get(), r)); 565 Main .main.undoRedo.add(new SequenceCommand(tr("Change relation member roles to {0}", role), commands));569 MainApplication.undoRedo.add(new SequenceCommand(tr("Change relation member roles to {0}", role), commands)); 566 570 } 567 571 } … … 706 710 String role = null; 707 711 if (chosenRelation != null && chosenRelation.get() != null 708 && Main.getLayerManager().getEditDataSet() != null && !Main.getLayerManager().getEditDataSet().selectionEmpty()) { 709 Collection<OsmPrimitive> selected = Main.getLayerManager().getEditDataSet().getSelected(); 712 && MainApplication.getLayerManager().getEditDataSet() != null 713 && !MainApplication.getLayerManager().getEditDataSet().selectionEmpty()) { 714 Collection<OsmPrimitive> selected = MainApplication.getLayerManager().getEditDataSet().getSelected(); 710 715 for (RelationMember m : chosenRelation.get().getMembers()) { 711 716 if (selected.contains(m.getMember())) { -
applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextPlugin.java
r32395 r33530 2 2 package relcontext; 3 3 4 import org.openstreetmap.josm. gui.DefaultNameFormatter;4 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 5 5 import org.openstreetmap.josm.gui.MapFrame; 6 6 import org.openstreetmap.josm.plugins.Plugin; -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/AddRemoveMemberAction.java
r32398 r33530 9 9 import java.util.Collection; 10 10 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.actions.JosmAction; 13 12 import org.openstreetmap.josm.command.ChangeCommand; … … 20 19 import org.openstreetmap.josm.data.osm.RelationMember; 21 20 import org.openstreetmap.josm.data.osm.Way; 21 import org.openstreetmap.josm.gui.MainApplication; 22 22 import org.openstreetmap.josm.gui.util.GuiHelper; 23 23 import org.openstreetmap.josm.tools.ImageProvider; … … 82 82 83 83 if (!r.getMemberPrimitives().equals(rel.get().getMemberPrimitives())) { 84 Main .main.undoRedo.add(new ChangeCommand(rel.get(), r));84 MainApplication.undoRedo.add(new ChangeCommand(rel.get(), r)); 85 85 } 86 86 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateMultipolygonAction.java
r32398 r33530 41 41 import org.openstreetmap.josm.data.osm.RelationMember; 42 42 import org.openstreetmap.josm.data.osm.Way; 43 import org.openstreetmap.josm.gui.MainApplication; 43 44 import org.openstreetmap.josm.tools.GBC; 44 45 import org.openstreetmap.josm.tools.Shortcut; … … 104 105 rels = TheRing.makeManySimpleMultipolygons(ds.getSelectedWays(), commands); 105 106 if (!commands.isEmpty()) { 106 Main .main.undoRedo.add(new SequenceCommand(tr("Create multipolygons from rings"), commands));107 MainApplication.undoRedo.add(new SequenceCommand(tr("Create multipolygons from rings"), commands)); 107 108 } 108 109 } … … 147 148 List<Command> list = removeTagsFromInnerWays(rel); 148 149 if (!list.isEmpty() && isBoundary) { 149 Main .main.undoRedo.add(new SequenceCommand(tr("Move tags from ways to relation"), list));150 MainApplication.undoRedo.add(new SequenceCommand(tr("Move tags from ways to relation"), list)); 150 151 list = new ArrayList<>(); 151 152 } … … 159 160 } 160 161 list.add(new AddCommand(rel)); 161 Main .main.undoRedo.add(new SequenceCommand(tr("Create multipolygon"), list));162 MainApplication.undoRedo.add(new SequenceCommand(tr("Create multipolygon"), list)); 162 163 163 164 if (chRel != null) { -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateRelationAction.java
r32398 r33530 25 25 import org.openstreetmap.josm.data.osm.Relation; 26 26 import org.openstreetmap.josm.data.osm.RelationMember; 27 import org.openstreetmap.josm.gui.MainApplication; 27 28 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox; 28 29 import org.openstreetmap.josm.tools.GBC; … … 67 68 } 68 69 69 Main .main.undoRedo.add(new AddCommand(rel));70 MainApplication.undoRedo.add(new AddCommand(rel)); 70 71 71 72 if (chRel != null) { -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DeleteChosenRelationAction.java
r32398 r33530 9 9 import javax.swing.AbstractAction; 10 10 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.command.Command; 13 12 import org.openstreetmap.josm.command.DeleteCommand; 14 13 import org.openstreetmap.josm.data.osm.Relation; 14 import org.openstreetmap.josm.gui.MainApplication; 15 15 import org.openstreetmap.josm.tools.ImageProvider; 16 16 … … 33 33 Relation r = rel.get(); 34 34 rel.clear(); 35 Command c = DeleteCommand.delete(Main .getLayerManager().getEditLayer(), Collections.singleton(r), true, true);35 Command c = DeleteCommand.delete(MainApplication.getLayerManager().getEditLayer(), Collections.singleton(r), true, true); 36 36 if (c != null) { 37 Main .main.undoRedo.add(c);37 MainApplication.undoRedo.add(c); 38 38 } 39 39 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DownloadChosenRelationAction.java
r32398 r33530 11 11 import javax.swing.AbstractAction; 12 12 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 14 import org.openstreetmap.josm.data.osm.Relation; 16 15 import org.openstreetmap.josm.data.osm.RelationMember; 16 import org.openstreetmap.josm.gui.MainApplication; 17 17 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask; 18 18 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationTask; … … 67 67 protected void downloadMembers(Relation rel) { 68 68 if (!rel.isNew()) { 69 Main.worker.submit(new DownloadRelationTask(Collections.singletonList(rel), Main.getLayerManager().getEditLayer())); 69 MainApplication.worker.submit( 70 new DownloadRelationTask(Collections.singletonList(rel), MainApplication.getLayerManager().getEditLayer())); 70 71 } 71 72 } … … 76 77 ret.addAll(rel.getIncompleteMembers()); 77 78 if (ret.isEmpty()) return; 78 Main.worker.submit(new DownloadRelationMemberTask(Collections.singletonList(rel), ret, Main.getLayerManager().getEditLayer())); 79 MainApplication.worker.submit( 80 new DownloadRelationMemberTask(Collections.singletonList(rel), ret, MainApplication.getLayerManager().getEditLayer())); 79 81 } 80 82 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DownloadParentsAction.java
r32398 r33530 13 13 import javax.swing.AbstractAction; 14 14 15 import org.openstreetmap.josm.Main;16 15 import org.openstreetmap.josm.actions.downloadtasks.DownloadReferrersTask; 17 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 18 17 import org.openstreetmap.josm.data.osm.Relation; 18 import org.openstreetmap.josm.gui.MainApplication; 19 19 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask; 20 20 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationTask; … … 38 38 this.rel = rel; 39 39 rel.addChosenRelationListener(this); 40 setEnabled(rel.get() != null && Main .getLayerManager().getEditLayer() != null);40 setEnabled(rel.get() != null && MainApplication.getLayerManager().getEditLayer() != null); 41 41 } 42 42 … … 48 48 objects.add(relation); 49 49 objects.addAll(relation.getMemberPrimitives()); 50 Main.worker.submit(new DownloadReferrersTask(Main.getLayerManager().getEditLayer(), objects)); 50 MainApplication.worker.submit( 51 new DownloadReferrersTask(MainApplication.getLayerManager().getEditLayer(), objects)); 51 52 } 52 53 53 54 @Override 54 55 public void chosenRelationChanged(Relation oldRelation, Relation newRelation) { 55 setEnabled(newRelation != null && Main .getLayerManager().getEditLayer() != null);56 setEnabled(newRelation != null && MainApplication.getLayerManager().getEditLayer() != null); 56 57 } 57 58 58 59 protected void downloadMembers(Relation rel) { 59 60 if (!rel.isNew()) { 60 Main.worker.submit(new DownloadRelationTask(Collections.singletonList(rel), Main.getLayerManager().getEditLayer())); 61 MainApplication.worker.submit( 62 new DownloadRelationTask(Collections.singletonList(rel), MainApplication.getLayerManager().getEditLayer())); 61 63 } 62 64 } … … 67 69 ret.addAll(rel.getIncompleteMembers()); 68 70 if (ret.isEmpty()) return; 69 Main.worker.submit(new DownloadRelationMemberTask(Collections.singletonList(rel), ret, Main.getLayerManager().getEditLayer())); 71 MainApplication.worker.submit( 72 new DownloadRelationMemberTask(Collections.singletonList(rel), ret, MainApplication.getLayerManager().getEditLayer())); 70 73 } 71 74 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DuplicateChosenRelationAction.java
r32398 r33530 8 8 import javax.swing.AbstractAction; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.command.AddCommand; 12 11 import org.openstreetmap.josm.data.osm.Relation; 12 import org.openstreetmap.josm.gui.MainApplication; 13 13 import org.openstreetmap.josm.tools.ImageProvider; 14 14 … … 32 32 Relation r = rel.get(); 33 33 Relation copy = new Relation(r, true); 34 Main .main.undoRedo.add(new AddCommand(copy));34 MainApplication.undoRedo.add(new AddCommand(copy)); 35 35 rel.set(copy); 36 if (Main .getLayerManager().getEditDataSet() != null) {37 Main .getLayerManager().getEditDataSet().setSelected(copy);36 if (MainApplication.getLayerManager().getEditDataSet() != null) { 37 MainApplication.getLayerManager().getEditDataSet().setSelected(copy); 38 38 } 39 39 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/EditChosenRelationAction.java
r32398 r33530 8 8 import javax.swing.AbstractAction; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.osm.Relation; 11 import org.openstreetmap.josm.gui.MainApplication; 12 12 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 13 13 import org.openstreetmap.josm.tools.ImageProvider; … … 36 36 Relation relation = rel.get(); 37 37 if (relation == null) return; 38 RelationEditor.getEditor(Main .getLayerManager().getEditLayer(), relation, null).setVisible(true);38 RelationEditor.getEditor(MainApplication.getLayerManager().getEditLayer(), relation, null).setVisible(true); 39 39 } 40 40 -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/FindRelationAction.java
r33265 r33530 31 31 import org.openstreetmap.josm.Main; 32 32 import org.openstreetmap.josm.actions.JosmAction; 33 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 33 34 import org.openstreetmap.josm.data.osm.Relation; 34 import org.openstreetmap.josm.gui.DefaultNameFormatter;35 35 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 36 import org.openstreetmap.josm.tools.Logging; 36 37 import org.openstreetmap.josm.tools.Shortcut; 37 38 … … 159 160 } 160 161 161 if ( Main.isDebugEnabled()) {162 Main.debug("keywords.length = " + keywords.length);162 if (Logging.isDebugEnabled()) { 163 Logging.debug("keywords.length = " + keywords.length); 163 164 for (int i = 0; i < keywords.length; i++) { 164 Main.debug("keyword["+i+"] = " + keywords[i]);165 Logging.debug("keyword["+i+"] = " + keywords[i]); 165 166 } 166 167 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructPolygonAction.java
r33265 r33530 24 24 import org.openstreetmap.josm.command.SequenceCommand; 25 25 import org.openstreetmap.josm.data.coor.EastNorth; 26 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 26 27 import org.openstreetmap.josm.data.osm.MultipolygonBuilder; 27 28 import org.openstreetmap.josm.data.osm.MultipolygonBuilder.JoinedPolygon; … … 30 31 import org.openstreetmap.josm.data.osm.RelationMember; 31 32 import org.openstreetmap.josm.data.osm.Way; 32 import org.openstreetmap.josm.gui. DefaultNameFormatter;33 import org.openstreetmap.josm.gui.MainApplication; 33 34 import org.openstreetmap.josm.tools.ImageProvider; 34 35 … … 84 85 List<OsmPrimitive> newSelection = new ArrayList<>(); 85 86 List<Command> commands = new ArrayList<>(); 86 Command relationDeleteCommand = DeleteCommand.delete(Main.getLayerManager().getEditLayer(), Collections.singleton(r), true, true); 87 Command relationDeleteCommand = DeleteCommand.delete( 88 MainApplication.getLayerManager().getEditLayer(), Collections.singleton(r), true, true); 87 89 if (relationDeleteCommand == null) 88 90 return; … … 195 197 } 196 198 197 Main .main.undoRedo.add(new SequenceCommand(tr("Reconstruct polygons from relation {0}",199 MainApplication.undoRedo.add(new SequenceCommand(tr("Reconstruct polygons from relation {0}", 198 200 r.getDisplayName(DefaultNameFormatter.getInstance())), commands)); 199 Main .getLayerManager().getEditDataSet().setSelected(newSelection);201 MainApplication.getLayerManager().getEditDataSet().setSelected(newSelection); 200 202 } 201 203 -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructRouteAction.java
r32398 r33530 12 12 import javax.swing.AbstractAction; 13 13 14 import org.openstreetmap.josm.Main;15 14 import org.openstreetmap.josm.command.ChangeCommand; 16 15 import org.openstreetmap.josm.command.Command; … … 22 21 import org.openstreetmap.josm.data.osm.RelationMember; 23 22 import org.openstreetmap.josm.data.osm.Way; 23 import org.openstreetmap.josm.gui.MainApplication; 24 24 import org.openstreetmap.josm.gui.dialogs.relation.sort.RelationSorter; 25 25 import org.openstreetmap.josm.tools.Geometry; … … 190 190 } 191 191 Command command = new ChangeCommand(r, recRel); 192 Main .main.undoRedo.add(command);192 MainApplication.undoRedo.add(command); 193 193 } 194 194 -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/RelationHelpAction.java
r32398 r33530 15 15 import org.openstreetmap.josm.Main; 16 16 import org.openstreetmap.josm.data.osm.Relation; 17 import org.openstreetmap.josm.gui.MainApplication; 17 18 import org.openstreetmap.josm.tools.ImageProvider; 18 19 import org.openstreetmap.josm.tools.LanguageInfo; … … 61 62 uris.add(new URI(String.format("%sRelations", base))); 62 63 63 Main.worker.execute(new Runnable() { 64 @Override 65 public void run() { 66 try { 67 // find a page that actually exists in the wiki 68 HttpURLConnection conn; 69 for (URI u : uris) { 70 conn = (HttpURLConnection) u.toURL().openConnection(); 64 MainApplication.worker.execute(() -> { 65 try { 66 // find a page that actually exists in the wiki 67 HttpURLConnection conn; 68 for (URI u : uris) { 69 conn = (HttpURLConnection) u.toURL().openConnection(); 70 conn.setConnectTimeout(5000); 71 72 if (conn.getResponseCode() != 200) { 73 System.out.println("INFO: " + u + " does not exist"); 74 conn.disconnect(); 75 } else { 76 int osize = conn.getContentLength(); 77 conn.disconnect(); 78 79 conn = (HttpURLConnection) new URI(u.toString() 80 .replace("=", "%3D") /* do not URLencode whole string! */ 81 .replaceFirst("/wiki/", "/w/index.php?redirect=no&title=") 82 ).toURL().openConnection(); 71 83 conn.setConnectTimeout(5000); 72 84 73 if (conn.getResponseCode() != 200) { 74 System.out.println("INFO: " + u + " does not exist"); 85 /* redirect pages have different content length, but retrieving a "nonredirect" 86 * page using index.php and the direct-link method gives slightly different 87 * content lengths, so we have to be fuzzy.. (this is UGLY, recode if u know better) 88 */ 89 if (Math.abs(conn.getContentLength() - osize) > 200) { 90 System.out.println("INFO: " + u + " is a mediawiki redirect"); 75 91 conn.disconnect(); 76 92 } else { 77 int osize = conn.getContentLength();93 System.out.println("INFO: browsing to " + u); 78 94 conn.disconnect(); 79 95 80 conn = (HttpURLConnection) new URI(u.toString() 81 .replace("=", "%3D") /* do not URLencode whole string! */ 82 .replaceFirst("/wiki/", "/w/index.php?redirect=no&title=") 83 ).toURL().openConnection(); 84 conn.setConnectTimeout(5000); 85 86 /* redirect pages have different content length, but retrieving a "nonredirect" 87 * page using index.php and the direct-link method gives slightly different 88 * content lengths, so we have to be fuzzy.. (this is UGLY, recode if u know better) 89 */ 90 if (Math.abs(conn.getContentLength() - osize) > 200) { 91 System.out.println("INFO: " + u + " is a mediawiki redirect"); 92 conn.disconnect(); 93 } else { 94 System.out.println("INFO: browsing to " + u); 95 conn.disconnect(); 96 97 OpenBrowser.displayUrl(u.toString()); 98 break; 99 } 96 OpenBrowser.displayUrl(u.toString()); 97 break; 100 98 } 101 99 } 102 } catch (Exception e) {103 e.printStackTrace();104 100 } 101 } catch (Exception e1) { 102 e1.printStackTrace(); 105 103 } 106 104 }); -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectInRelationPanelAction.java
r32395 r33530 8 8 import javax.swing.AbstractAction; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.osm.Relation; 11 import org.openstreetmap.josm.gui.MainApplication; 12 12 import org.openstreetmap.josm.tools.ImageProvider; 13 13 … … 31 31 public void actionPerformed(ActionEvent e) { 32 32 if (rel.get() != null) { 33 Main .map.relationListDialog.selectRelation(rel.get());34 Main .map.relationListDialog.unfurlDialog();33 MainApplication.getMap().relationListDialog.selectRelation(rel.get()); 34 MainApplication.getMap().relationListDialog.unfurlDialog(); 35 35 } 36 36 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectMembersAction.java
r32398 r33530 8 8 import javax.swing.AbstractAction; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.osm.Relation; 11 import org.openstreetmap.josm.gui.MainApplication; 12 12 import org.openstreetmap.josm.tools.ImageProvider; 13 13 … … 28 28 @Override 29 29 public void actionPerformed(ActionEvent e) { 30 Main .getLayerManager().getEditLayer().data.setSelected(rel.get() == null ? null : rel.get().getMemberPrimitives());30 MainApplication.getLayerManager().getEditLayer().data.setSelected(rel.get() == null ? null : rel.get().getMemberPrimitives()); 31 31 } 32 32 -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SelectRelationAction.java
r32398 r33530 8 8 import javax.swing.AbstractAction; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.data.osm.Relation; 11 import org.openstreetmap.josm.gui.MainApplication; 12 12 import org.openstreetmap.josm.tools.ImageProvider; 13 13 … … 29 29 @Override 30 30 public void actionPerformed(ActionEvent e) { 31 Main .getLayerManager().getEditLayer().data.setSelected(rel.get() == null ? null : rel.get());31 MainApplication.getLayerManager().getEditLayer().data.setSelected(rel.get() == null ? null : rel.get()); 32 32 } 33 33 -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SortAndFixAction.java
r32398 r33530 11 11 import javax.swing.Action; 12 12 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.command.Command; 15 14 import org.openstreetmap.josm.data.osm.Relation; 16 15 import org.openstreetmap.josm.data.osm.RelationMember; 16 import org.openstreetmap.josm.gui.MainApplication; 17 17 import org.openstreetmap.josm.tools.ImageProvider; 18 18 … … 57 57 Command c = fixRelation(rel.get()); 58 58 if (c != null) { 59 Main .main.undoRedo.add(c);59 MainApplication.undoRedo.add(c); 60 60 } 61 61 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SplittingMultipolygons.java
r32398 r33530 20 20 import org.openstreetmap.josm.data.coor.EastNorth; 21 21 import org.openstreetmap.josm.data.coor.LatLon; 22 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 22 23 import org.openstreetmap.josm.data.osm.Node; 23 24 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 25 26 import org.openstreetmap.josm.data.osm.RelationMember; 26 27 import org.openstreetmap.josm.data.osm.Way; 27 import org.openstreetmap.josm.gui. DefaultNameFormatter;28 import org.openstreetmap.josm.gui.MainApplication; 28 29 import org.openstreetmap.josm.tools.Geometry; 29 30 import org.openstreetmap.josm.tools.Geometry.PolygonIntersection; … … 43 44 List<Way> rings = new ArrayList<>(); 44 45 List<Way> arcs = new ArrayList<>(); 45 Area a = Main .getLayerManager().getEditDataSet().getDataSourceArea();46 Area a = MainApplication.getLayerManager().getEditDataSet().getDataSourceArea(); 46 47 for (Way way : ways) { 47 48 if (way.isDeleted()) … … 104 105 Relation newRelation = SplittingMultipolygons.attachRingToNeighbours(ring, commands); 105 106 if (newRelation != null && !commands.isEmpty()) { 106 Main .main.undoRedo.add(commands.get(0));107 MainApplication.undoRedo.add(commands.get(0)); 107 108 result.add(newRelation); 108 109 } … … 113 114 Relation newRelation = SplittingMultipolygons.tryToCloseOneWay(arc, commands); 114 115 if (newRelation != null && !commands.isEmpty()) { 115 Main .main.undoRedo.add(commands.get(0));116 MainApplication.undoRedo.add(commands.get(0)); 116 117 result.add(newRelation); 117 118 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/TheRing.java
r32398 r33530 24 24 import org.openstreetmap.josm.tools.Geometry; 25 25 import org.openstreetmap.josm.tools.Geometry.PolygonIntersection; 26 import org.openstreetmap.josm.tools.Logging; 26 27 27 28 /** … … 431 432 432 433 private static void log(String s) { 433 Main.debug(s);434 Logging.debug(s); 434 435 } 435 436
Note:
See TracChangeset
for help on using the changeset viewer.