Changeset 4414 in josm
- Timestamp:
- 2011-09-11T20:22:26+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r4191 r4414 10 10 11 11 import javax.swing.JOptionPane; 12 import javax.swing.SwingUtilities; 12 13 13 14 import org.openstreetmap.josm.Main; … … 147 148 * @param apiData the primitives to be added, updated, or deleted 148 149 */ 149 public void uploadData(OsmDataLayer layer, APIDataSet apiData) { 150 public void uploadData(final OsmDataLayer layer, APIDataSet apiData) { 150 151 if (apiData.isEmpty()) { 151 152 JOptionPane.showMessageDialog( … … 161 162 162 163 final UploadDialog dialog = UploadDialog.getUploadDialog(); 164 // If we simply set the changeset comment here, it would be 165 // overridden by subsequent events in EDT that are caused by 166 // dialog creation. The current solution is to queue this operation 167 // after these events. 168 // TODO: find better way to initialize the comment field 169 SwingUtilities.invokeLater(new Runnable() { 170 public void run() { 171 dialog.setDefaultChangesetTags(layer.data.getChangeSetTags()); 172 } 173 }); 163 174 dialog.setUploadedPrimitives(apiData); 164 175 dialog.setVisible(true); -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r4327 r4414 81 81 * Note that it is not necessary to call beginUpdate/endUpdate for every dataset modification - dataset will get locked 82 82 * automatically. 83 * 83 * 84 84 * Note that locks cannot be upgraded - if one threads use read lock and and then write lock, dead lock will occur - see #5814 for 85 85 * sample ticket … … 205 205 public void setVersion(String version) { 206 206 this.version = version; 207 } 208 209 /* 210 * Holding bin for changeset tag information, to be applied when or if this is ever uploaded. 211 */ 212 private Map<String, String> changeSetTags = new HashMap<String, String>(); 213 214 public Map<String, String> getChangeSetTags() { 215 return changeSetTags; 216 } 217 218 public void addChangeSetTag(String k, String v) { 219 this.changeSetTags.put(k,v); 207 220 } 208 221 … … 438 451 * nodes should be highlighted. WaySegments are used to avoid having 439 452 * to create a VirtualNode class that wouldn't have much purpose otherwise. 440 * 453 * 441 454 * @return unmodifiable collection of WaySegments 442 455 */ … … 448 461 * returns an unmodifiable collection of WaySegments that should be 449 462 * highlighted. 450 * 463 * 451 464 * @return unmodifiable collection of WaySegments 452 465 */ … … 1056 1069 /** 1057 1070 * Invalidates the internal cache of projected east/north coordinates. 1058 * 1071 * 1059 1072 * This method can be invoked after the globally configured projection method 1060 1073 * changed. In contrast to {@link DataSet#reproject()} it only invalidates the … … 1143 1156 /** 1144 1157 * <p>Replies the list of data source bounds.</p> 1145 * 1158 * 1146 1159 * <p>Dataset maintains a list of data sources which have been merged into the 1147 1160 * data set. Each of these sources can optionally declare a bounding box of the 1148 1161 * data it supplied to the dataset.</p> 1149 * 1162 * 1150 1163 * <p>This method replies the list of defined (non {@code null}) bounding boxes.</p> 1151 * 1164 * 1152 1165 * @return the list of data source bounds. An empty list, if no non-null data source 1153 1166 * bounds are defined. -
trunk/src/org/openstreetmap/josm/gui/io/ChangesetCommentModel.java
r3720 r4414 9 9 * 10 10 */ 11 public class ChangesetCommentModel extends Observable{ 11 public class ChangesetCommentModel extends Observable { 12 12 private String comment = ""; 13 13 … … 18 18 * @param comment the new upload comment. Empty string assumed if null. 19 19 */ 20 public void setComment(String comment){ 20 public void setComment(String comment) { 21 21 String oldValue = this.comment; 22 22 this.comment = comment == null ? "" : comment; -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r4310 r4414 301 301 public void setDefaultChangesetTags(Map<String, String> tags) { 302 302 pnlTagSettings.setDefaultTags(tags); 303 for (String key: tags.keySet()) { 304 if (key.equals("comment")) { 305 changesetCommentModel.setComment(tags.get(key)); 306 } 307 } 303 308 } 304 309 -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r4413 r4414 24 24 import org.openstreetmap.josm.data.Bounds; 25 25 import org.openstreetmap.josm.data.coor.LatLon; 26 import org.openstreetmap.josm.data.osm.Changeset; 26 27 import org.openstreetmap.josm.data.osm.DataSet; 27 28 import org.openstreetmap.josm.data.osm.DataSource; … … 36 37 import org.openstreetmap.josm.data.osm.RelationMember; 37 38 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; 39 import org.openstreetmap.josm.data.osm.Tagged; 38 40 import org.openstreetmap.josm.data.osm.User; 39 41 import org.openstreetmap.josm.data.osm.Way; … … 86 88 private Map<Long, Collection<RelationMemberData>> relations = new HashMap<Long, Collection<RelationMemberData>>(); 87 89 90 private Changeset uploadChangeset; 91 88 92 /** 89 93 * constructor (for private use only) … … 141 145 throwException(tr("Unsupported version: {0}", v)); 142 146 } 147 ds.setVersion(v); 143 148 String generator = parser.getAttributeValue(null, "generator"); 144 ds.setVersion(v); 149 Long uploadChangesetId = null; 150 if (parser.getAttributeValue(null, "upload-changeset") != null) { 151 uploadChangesetId = getLong("upload-changeset"); 152 } 145 153 while (true) { 146 154 int event = parser.next(); … … 154 162 } else if (parser.getLocalName().equals("relation")) { 155 163 parseRelation(); 164 } else if (parser.getLocalName().equals("changeset")) { 165 parseChangeset(uploadChangesetId); 156 166 } else { 157 167 parseUnkown(); … … 320 330 } 321 331 322 private void parseTag(OsmPrimitive osm) throws XMLStreamException { 332 private void parseChangeset(Long uploadChangesetId) throws XMLStreamException { 333 long id = getLong("id"); 334 335 if (id == uploadChangesetId) { 336 uploadChangeset = new Changeset((int) getLong("id")); 337 while (true) { 338 int event = parser.next(); 339 if (event == XMLStreamConstants.START_ELEMENT) { 340 if (parser.getLocalName().equals("tag")) { 341 parseTag(uploadChangeset); 342 } else { 343 parseUnkown(); 344 } 345 } else if (event == XMLStreamConstants.END_ELEMENT) { 346 return; 347 } 348 } 349 } else { 350 jumpToEnd(false); 351 } 352 } 353 354 private void parseTag(Tagged t) throws XMLStreamException { 323 355 String key = parser.getAttributeValue(null, "k"); 324 356 String value = parser.getAttributeValue(null, "v"); … … 326 358 throwException(tr("Missing key or value attribute in tag.")); 327 359 } 328 osm.put(key.intern(), value.intern());360 t.put(key.intern(), value.intern()); 329 361 jumpToEnd(); 330 }331 332 /**333 * When cursor is at the start of an element, moves it to the end tag of that element.334 * Nested content is skipped.335 *336 * This is basically the same code as parseUnkown(), except for the warnings, which337 * are displayed for inner elements and not at top level.338 */339 private void jumpToEnd() throws XMLStreamException {340 while (true) {341 int event = parser.next();342 if (event == XMLStreamConstants.START_ELEMENT) {343 parseUnkown();344 } else if (event == XMLStreamConstants.END_ELEMENT) {345 return;346 }347 }348 }349 350 private void parseUnkown() throws XMLStreamException {351 parseUnkown(true);352 362 } 353 363 … … 364 374 } 365 375 } 376 } 377 378 private void parseUnkown() throws XMLStreamException { 379 parseUnkown(true); 380 } 381 382 /** 383 * When cursor is at the start of an element, moves it to the end tag of that element. 384 * Nested content is skipped. 385 * 386 * This is basically the same code as parseUnkown(), except for the warnings, which 387 * are displayed for inner elements and not at top level. 388 */ 389 private void jumpToEnd(boolean printWarning) throws XMLStreamException { 390 while (true) { 391 int event = parser.next(); 392 if (event == XMLStreamConstants.START_ELEMENT) { 393 parseUnkown(printWarning); 394 } else if (event == XMLStreamConstants.END_ELEMENT) { 395 return; 396 } 397 } 398 } 399 400 private void jumpToEnd() throws XMLStreamException { 401 jumpToEnd(true); 366 402 } 367 403 … … 665 701 } 666 702 703 private void processChangesetAfterParsing() { 704 if (uploadChangeset != null) { 705 for (Map.Entry<String, String> e : uploadChangeset.getKeys().entrySet()) { 706 ds.addChangeSetTag(e.getKey(), e.getValue()); 707 } 708 } 709 } 710 667 711 /** 668 712 * Parse the given input source and return the dataset. … … 697 741 reader.processWaysAfterParsing(); 698 742 reader.processRelationsAfterParsing(); 743 reader.processChangesetAfterParsing(); 699 744 } finally { 700 745 reader.ds.endUpdate();
Note:
See TracChangeset
for help on using the changeset viewer.