Changeset 18399 in osm for applications/editors/josm/plugins/addrinterpolation/src/org
- Timestamp:
- 2009-10-31T21:14:07+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/addrinterpolation/src/org/openstreetmap/josm/plugins/AddrInterpolation/AddrInterpolationDialog.java
r18398 r18399 24 24 import java.awt.event.WindowEvent; 25 25 import java.util.ArrayList; 26 import java.util.Collection; 27 import java.util.LinkedList; 26 28 import java.util.regex.Pattern; 27 29 … … 40 42 41 43 import org.openstreetmap.josm.Main; 44 import org.openstreetmap.josm.command.AddCommand; 45 import org.openstreetmap.josm.command.ChangeCommand; 46 import org.openstreetmap.josm.command.ChangePropertyCommand; 47 import org.openstreetmap.josm.command.Command; 48 import org.openstreetmap.josm.command.SequenceCommand; 42 49 import org.openstreetmap.josm.data.osm.DataSet; 43 50 import org.openstreetmap.josm.data.osm.Node; … … 92 99 private JComboBox addrInterpolationList = null; 93 100 101 // For tracking edit changes as group for undo 102 private Collection<Command> commandGroup = null; 103 private Relation editedRelation = null; 94 104 95 105 public AddrInterpolationDialog(String name) { … … 744 754 745 755 // Entries are valid ... save in map 756 757 commandGroup = new LinkedList<Command>(); 758 746 759 String streetName = selectedStreet.get("name"); 747 760 748 761 if (addrInterpolationWay != null) { 749 addrInterpolationWay.setModified(true);750 762 751 763 Node firstNode = addrInterpolationWay.getNode(0); 752 764 Node lastNode = addrInterpolationWay.getNode(addrInterpolationWay.getNodesCount()-1); 753 765 754 addrInterpolationWay.put("addr:interpolation", selectedMethod);755 firstNode.put("addr:housenumber", startValueString);756 lastNode.put("addr:housenumber", endValueString);766 commandGroup.add(new ChangePropertyCommand(addrInterpolationWay, "addr:interpolation", selectedMethod)); 767 commandGroup.add(new ChangePropertyCommand(firstNode, "addr:housenumber", startValueString)); 768 commandGroup.add(new ChangePropertyCommand(lastNode, "addr:housenumber", endValueString)); 757 769 if (streetNameButton.isSelected()) { 758 770 759 firstNode.put("addr:street", streetName);760 lastNode.put("addr:street", streetName);771 commandGroup.add(new ChangePropertyCommand(firstNode, "addr:street", streetName)); 772 commandGroup.add(new ChangePropertyCommand(lastNode, "addr:street", streetName)); 761 773 762 774 } … … 779 791 if (associatedStreetRelation == null) { 780 792 CreateRelation(streetName); 781 relationChanged = true; 782 } 783 793 // relationChanged = true; (not changed since it was created) 794 } 795 // Make any additional changes only to the copy 796 editedRelation = new Relation(associatedStreetRelation); 784 797 785 798 if (addrInterpolationWay != null) { … … 793 806 for (Node node : houseNumberNodes) { 794 807 795 node.setModified(true); // Trigger re-upload in case there is a change796 797 808 if (streetRelationButton.isSelected()) { 798 809 AddToRelation(associatedStreetRelation, node, "house"); … … 800 811 if ((city != null) || (streetNameButton.isSelected()) ) { 801 812 // Include street unconditionally if adding nodes only or city name specified 802 node.put("addr:street", streetName);813 commandGroup.add(new ChangePropertyCommand(node, "addr:street", streetName)); 803 814 } 804 815 // Set or remove remaining optional fields 805 node.put("addr:city", city);806 node.put("addr:state", state);807 node.put("addr:postcode", postCode);808 node.put("addr:country", country);809 node.put("addr:full", fullAddress);816 commandGroup.add(new ChangePropertyCommand(node, "addr:city", city)); 817 commandGroup.add(new ChangePropertyCommand(node, "addr:state", state)); 818 commandGroup.add(new ChangePropertyCommand(node, "addr:postcode", postCode)); 819 commandGroup.add(new ChangePropertyCommand(node, "addr:country", country)); 820 commandGroup.add(new ChangePropertyCommand(node, "addr:full", fullAddress)); 810 821 } 811 822 812 823 if (relationChanged) { 813 associatedStreetRelation.setModified(true); 814 815 // Redraw relation list dialog 816 Main.main.getEditLayer().fireDataChange(); 817 } 818 819 820 Main.map.mapView.repaint(); 824 commandGroup.add(new ChangeCommand(associatedStreetRelation, editedRelation)); 825 } 826 827 828 Main.main.undoRedo.add(new SequenceCommand(tr("Address Interpolation"), commandGroup)); 829 Main.map.repaint(); 821 830 822 831 return true; 823 832 } 824 833 825 // Create Associated Street relation, add street, and add to map834 // Create Associated Street relation, add street, and add to list of commands to perform 826 835 private void CreateRelation(String streetName) { 827 836 associatedStreetRelation = new Relation(); … … 830 839 RelationMember newStreetMember = new RelationMember("street", selectedStreet); 831 840 associatedStreetRelation.addMember(newStreetMember); 832 Main.main.getCurrentDataSet().addPrimitive(associatedStreetRelation);841 commandGroup.add(new AddCommand(associatedStreetRelation)); 833 842 } 834 843 … … 863 872 if (!isFound) { 864 873 RelationMember newMember = new RelationMember(role, testMember); 865 associatedStreetRelation.addMember(newMember); 874 editedRelation.addMember(newMember); 875 866 876 relationChanged = true; 867 877 }
Note:
See TracChangeset
for help on using the changeset viewer.