Changeset 99 in josm for src/org/openstreetmap/josm/actions/mapmode/AddWayAction.java
- Timestamp:
- 2006-04-27T01:29:55+02:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/mapmode/AddWayAction.java
r98 r99 14 14 import org.openstreetmap.josm.command.AddCommand; 15 15 import org.openstreetmap.josm.command.ChangeCommand; 16 import org.openstreetmap.josm.command.Command;17 16 import org.openstreetmap.josm.command.DeleteCommand; 18 17 import org.openstreetmap.josm.data.SelectionChangedListener; … … 64 63 @Override public void enterMode() { 65 64 super.enterMode(); 66 Command c = null;67 65 way = makeWay(); 68 if (way != null) { 69 c = new AddCommand(way); 70 Main.ds.setSelected(way); 71 Main.main.editLayer().add(c); 72 } else 73 Main.ds.clearSelection(); 66 Main.ds.setSelected(way); 74 67 Main.map.mapView.addMouseListener(this); 75 68 } … … 147 140 } 148 141 142 Way wayToAdd = null; 143 boolean reordered = false; 149 144 if (numberOfSelectedWays > 0) { 150 145 String ways = "way" + (numberOfSelectedWays==1?" has":"s have"); … … 155 150 if (osm instanceof Way) 156 151 segmentSet.addAll(((Way)osm).segments); 152 } else if (numberOfSelectedWays == 1) { 153 answer = JOptionPane.showConfirmDialog(Main.parent, "Do you want to add all other selected segments to the one selected way?", "Add segments to way?", JOptionPane.YES_NO_OPTION); 154 if (answer == JOptionPane.YES_OPTION) { 155 for (OsmPrimitive osm : selection) { 156 if (osm instanceof Way) { 157 wayToAdd = (Way)osm; 158 answer = JOptionPane.showConfirmDialog(Main.parent, "Reorder all line segments?", "Reorder?", JOptionPane.YES_NO_CANCEL_OPTION); 159 if (answer == JOptionPane.CANCEL_OPTION) 160 return wayToAdd; 161 if (answer == JOptionPane.YES_OPTION) { 162 segmentSet.addAll(wayToAdd.segments); 163 reordered = true; 164 } else 165 segmentSet.removeAll(wayToAdd.segments); 166 break; 167 } 168 } 169 } 157 170 } 158 171 } … … 193 206 } 194 207 208 if (wayToAdd != null) { 209 Way w = new Way(wayToAdd); 210 if (reordered) 211 w.segments.clear(); 212 w.segments.addAll(sortedSegments); 213 Main.main.editLayer().add(new ChangeCommand(wayToAdd, w)); 214 return wayToAdd; 215 } 216 195 217 if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog(Main.parent, "Create a new way out of "+sortedSegments.size()+" segments?", "Create new way", JOptionPane.YES_NO_OPTION)) 196 218 return null; … … 198 220 Way w = new Way(); 199 221 w.segments.addAll(sortedSegments); 222 223 if (way != null) 224 Main.main.editLayer().add(new AddCommand(way)); 200 225 return w; 201 226 }
Note:
See TracChangeset
for help on using the changeset viewer.
