Changeset 33694 in osm for applications/editors
- Timestamp:
- 2017-10-03T22:34:26+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/reltoolbox
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reltoolbox/build.xml
r33530 r33694 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="12 663"/>6 <property name="plugin.main.version" value="12840"/> 7 7 8 8 <property name="plugin.author" value="Ilya Zverev"/> -
applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextDialog.java
r33530 r33694 608 608 if (property != null && property.length() > 0 && e.getSource() instanceof JCheckBoxMenuItem) { 609 609 boolean value = ((JCheckBoxMenuItem) e.getSource()).isSelected(); 610 Main.pref.put (property, value);610 Main.pref.putBoolean(property, value); 611 611 show(getInvoker(), getX(), getY()); 612 612 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateMultipolygonAction.java
r33530 r33694 124 124 // for now, just copying standard action 125 125 MultipolygonBuilder mpc = new MultipolygonBuilder(); 126 String error = mpc.makeFromWays( getLayerManager().getEditDataSet().getSelectedWays());126 String error = mpc.makeFromWays(ds.getSelectedWays()); 127 127 if (error != null) { 128 128 JOptionPane.showMessageDialog(Main.parent, error); … … 159 159 } 160 160 } 161 list.add(new AddCommand( rel));161 list.add(new AddCommand(ds, rel)); 162 162 MainApplication.undoRedo.add(new SequenceCommand(tr("Create multipolygon"), list)); 163 163 … … 166 166 } 167 167 168 getLayerManager().getEditDataSet().setSelected(rel);168 ds.setSelected(rel); 169 169 } 170 170 … … 335 335 } 336 336 337 for (String linearTag : Main.pref.get Collection(PREF_MULTIPOLY + "lineartags", DEFAULT_LINEAR_TAGS)) {337 for (String linearTag : Main.pref.getList(PREF_MULTIPOLY + "lineartags", DEFAULT_LINEAR_TAGS)) { 338 338 values.remove(linearTag); 339 339 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/CreateRelationAction.java
r33530 r33694 22 22 import org.openstreetmap.josm.actions.JosmAction; 23 23 import org.openstreetmap.josm.command.AddCommand; 24 import org.openstreetmap.josm.data.osm.DataSet; 24 25 import org.openstreetmap.josm.data.osm.OsmPrimitive; 25 26 import org.openstreetmap.josm.data.osm.Relation; … … 64 65 rel.put("type", type); 65 66 } 66 for (OsmPrimitive selected : getLayerManager().getEditDataSet().getSelected()) { 67 DataSet ds = getLayerManager().getEditDataSet(); 68 for (OsmPrimitive selected : ds.getSelected()) { 67 69 rel.addMember(new RelationMember("", selected)); 68 70 } 69 71 70 MainApplication.undoRedo.add(new AddCommand( rel));72 MainApplication.undoRedo.add(new AddCommand(ds, rel)); 71 73 72 74 if (chRel != null) { -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DeleteChosenRelationAction.java
r33530 r33694 33 33 Relation r = rel.get(); 34 34 rel.clear(); 35 Command c = DeleteCommand.delete( MainApplication.getLayerManager().getEditLayer(),Collections.singleton(r), true, true);35 Command c = DeleteCommand.delete(Collections.singleton(r), true, true); 36 36 if (c != null) { 37 37 MainApplication.undoRedo.add(c); -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/DuplicateChosenRelationAction.java
r33530 r33694 9 9 10 10 import org.openstreetmap.josm.command.AddCommand; 11 import org.openstreetmap.josm.data.osm.DataSet; 11 12 import org.openstreetmap.josm.data.osm.Relation; 12 13 import org.openstreetmap.josm.gui.MainApplication; … … 17 18 18 19 public class DuplicateChosenRelationAction extends AbstractAction implements ChosenRelationListener { 19 private ChosenRelation rel;20 private final ChosenRelation rel; 20 21 21 22 public DuplicateChosenRelationAction(ChosenRelation rel) { … … 30 31 @Override 31 32 public void actionPerformed(ActionEvent e) { 32 Relation r = rel.get(); 33 Relation copy = new Relation(r, true); 34 MainApplication.undoRedo.add(new AddCommand(copy)); 35 rel.set(copy); 36 if (MainApplication.getLayerManager().getEditDataSet() != null) { 37 MainApplication.getLayerManager().getEditDataSet().setSelected(copy); 33 DataSet ds = MainApplication.getLayerManager().getEditDataSet(); 34 if (ds != null) { 35 Relation r = rel.get(); 36 Relation copy = new Relation(r, true); 37 MainApplication.undoRedo.add(new AddCommand(ds, copy)); 38 rel.set(copy); 39 ds.setSelected(copy); 38 40 } 39 41 } -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/ReconstructPolygonAction.java
r33530 r33694 24 24 import org.openstreetmap.josm.command.SequenceCommand; 25 25 import org.openstreetmap.josm.data.coor.EastNorth; 26 import org.openstreetmap.josm.data.osm.DataSet; 26 27 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 27 28 import org.openstreetmap.josm.data.osm.MultipolygonBuilder; … … 85 86 List<OsmPrimitive> newSelection = new ArrayList<>(); 86 87 List<Command> commands = new ArrayList<>(); 87 Command relationDeleteCommand = DeleteCommand.delete( 88 MainApplication.getLayerManager().getEditLayer(), Collections.singleton(r), true, true); 88 Command relationDeleteCommand = DeleteCommand.delete(Collections.singleton(r), true, true); 89 89 if (relationDeleteCommand == null) 90 90 return; 91 91 92 DataSet ds = MainApplication.getLayerManager().getEditDataSet(); 92 93 for (JoinedPolygon p : mpc.outerWays) { 93 94 … … 123 124 } 124 125 if (relationReused) { 125 commands.add(new AddCommand( n));126 commands.add(new AddCommand(ds, n)); 126 127 } else { 127 128 relationReused = true; … … 189 190 result.setKeys(tags); 190 191 newSelection.add(candidateWay == null ? result : candidateWay); 191 commands.add(candidateWay == null ? new AddCommand( result) : new ChangeCommand(candidateWay, result));192 commands.add(candidateWay == null ? new AddCommand(ds, result) : new ChangeCommand(candidateWay, result)); 192 193 } 193 194 … … 199 200 MainApplication.undoRedo.add(new SequenceCommand(tr("Reconstruct polygons from relation {0}", 200 201 r.getDisplayName(DefaultNameFormatter.getInstance())), commands)); 201 MainApplication.getLayerManager().getEditDataSet().setSelected(newSelection);202 ds.setSelected(newSelection); 202 203 } 203 204 -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SplittingMultipolygons.java
r33530 r33694 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.DataSet; 22 23 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 23 24 import org.openstreetmap.josm.data.osm.Node; … … 218 219 } 219 220 221 DataSet ds = MainApplication.getLayerManager().getEditDataSet(); 220 222 for (int i = 1; i < chunks.size(); i++) { 221 223 List<Node> achunk = chunks.get(i); … … 229 231 newWay.setNodes(achunk); 230 232 if (commands != null) { 231 commands.add(new AddCommand( newWay));233 commands.add(new AddCommand(ds, newWay)); 232 234 } 233 235 } … … 273 275 newRelation.put("type", "multipolygon"); 274 276 newRelation.addMember(new RelationMember("outer", segment)); 275 Collection<String> linearTags = Main.pref.get Collection(PREF_MULTIPOLY + "lineartags", CreateMultipolygonAction.DEFAULT_LINEAR_TAGS);277 Collection<String> linearTags = Main.pref.getList(PREF_MULTIPOLY + "lineartags", CreateMultipolygonAction.DEFAULT_LINEAR_TAGS); 276 278 Way segmentCopy = new Way(segment); 277 279 boolean changed = false; … … 307 309 } 308 310 newRelation.addMember(new RelationMember("outer", addingWay.getUniqueId() == target.getUniqueId() ? target : addingWay)); 309 commands.add(new AddCommand( newRelation));311 commands.add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newRelation)); 310 312 resultingCommands.add(new SequenceCommand(tr("Complete multipolygon for way {0}", 311 313 DefaultNameFormatter.getInstance().format(segment)), commands)); -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/TheRing.java
r33530 r33694 17 17 import org.openstreetmap.josm.command.Command; 18 18 import org.openstreetmap.josm.command.DeleteCommand; 19 import org.openstreetmap.josm.data.osm.DataSet; 19 20 import org.openstreetmap.josm.data.osm.Node; 20 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 22 23 import org.openstreetmap.josm.data.osm.RelationMember; 23 24 import org.openstreetmap.josm.data.osm.Way; 25 import org.openstreetmap.josm.gui.MainApplication; 24 26 import org.openstreetmap.josm.tools.Geometry; 25 27 import org.openstreetmap.josm.tools.Geometry.PolygonIntersection; … … 329 331 Way sourceCopy = new Way(source); 330 332 if (createMultipolygon) { 331 Collection<String> linearTags = Main.pref.get Collection(PREF_MULTIPOLY + "lineartags", CreateMultipolygonAction.DEFAULT_LINEAR_TAGS);333 Collection<String> linearTags = Main.pref.getList(PREF_MULTIPOLY + "lineartags", CreateMultipolygonAction.DEFAULT_LINEAR_TAGS); 332 334 relation = new Relation(); 333 335 relation.put("type", "multipolygon"); … … 369 371 } 370 372 373 DataSet ds = MainApplication.getLayerManager().getEditDataSet(); 371 374 List<Command> commands = new ArrayList<>(); 372 375 boolean foundOwnWay = false; … … 375 378 Way w = seg.constructWay(seg.isReference() ? null : sourceCopy); 376 379 if (needAdding) { 377 commands.add(new AddCommand( w));380 commands.add(new AddCommand(ds, w)); 378 381 } 379 382 if (w.equals(source)) { … … 398 401 commands.addAll(relationCommands); 399 402 if (createMultipolygon) { 400 commands.add(new AddCommand( relation));403 commands.add(new AddCommand(ds, relation)); 401 404 } 402 405 return commands; -
applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/MultipolygonFixer.java
r33311 r33694 17 17 import org.openstreetmap.josm.data.osm.RelationMember; 18 18 import org.openstreetmap.josm.data.osm.Way; 19 import org.openstreetmap.josm.gui.MainApplication; 19 20 20 21 /** … … 46 47 public Command fixRelation(Relation rel) { 47 48 Relation rr = fixMultipolygonRoles(rel); 48 return rr != null ? new ChangeCommand( rel, rr) : null;49 return rr != null ? new ChangeCommand(MainApplication.getLayerManager().getEditDataSet(), rel, rr) : null; 49 50 } 50 51 … … 82 83 if (m.isWay()) { 83 84 String role = null; 84 if (outerWays.contains( (Way)m.getMember())) {85 if (outerWays.contains(m.getMember())) { 85 86 role = "outer"; 86 } else if (innerWays.contains( (Way)m.getMember())) {87 } else if (innerWays.contains(m.getMember())) { 87 88 role = "inner"; 88 89 }
Note:
See TracChangeset
for help on using the changeset viewer.