Changeset 2074 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-09-07T00:01:31+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r2065 r2074 19 19 import java.util.List; 20 20 import java.util.Map; 21 import java.util.Properties; 21 22 import java.util.logging.Logger; 22 23 import java.util.regex.Matcher; … … 246 247 ); 247 248 switch(ret) { 248 case JOptionPane.CLOSED_OPTION: return;249 case JOptionPane.CANCEL_OPTION: return;250 case 0: synchronizePrimitive(id); break;251 case 1: synchronizeDataSet(); break;252 default:253 // should not happen254 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret));249 case JOptionPane.CLOSED_OPTION: return; 250 case JOptionPane.CANCEL_OPTION: return; 251 case 0: synchronizePrimitive(id); break; 252 case 1: synchronizeDataSet(); break; 253 default: 254 // should not happen 255 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret)); 255 256 } 256 257 } … … 286 287 ); 287 288 switch(ret) { 288 case JOptionPane.CLOSED_OPTION: return;289 case 1: return;290 case 0: synchronizeDataSet(); break;291 default:292 // should not happen293 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret));289 case JOptionPane.CLOSED_OPTION: return; 290 case 1: return; 291 case 0: synchronizeDataSet(); break; 292 default: 293 // should not happen 294 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret)); 294 295 } 295 296 } … … 936 937 southTabbedPane.setTitleAt(1, tr("Tags of new changeset")); 937 938 Changeset cs = new Changeset(); 939 Properties sysProp = System.getProperties(); 940 Object ua = sysProp.get("http.agent"); 941 cs.put("created_by", (ua == null) ? "JOSM" : ua.toString()); 938 942 tagEditorPanel.getModel().initFromPrimitive(cs); 939 943 } else { -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r2070 r2074 278 278 } 279 279 280 /** 281 * Creates the changeset to be used for subsequent uploads. 280 281 /** 282 * Creates a new changeset based on the keys in <code>changeset</code> 282 283 * 283 * If changesetProcessingType is {@see ChangesetProcessingType#USE_NEW} creates a new changeset based 284 * on <code>changeset</code>. Otherwise uses the changeset given by {@see OsmApi#getCurrentChangeset()}. 285 * If this changeset is null or has an id of value 0, a new changeset is created too. 286 * 287 * @param changeset the changeset to be used for uploading if <code>changesetProcessingType</code> is 288 * {@see ChangesetProcessingType#USE_NEW} 289 * @param changesetProcessingType how to handel changesets; set to {@see ChangesetProcessingType#USE_NEW} if null 284 * @param changeset the changeset to be used for uploading 290 285 * @param progressMonitor the progress monitor 291 286 * @throws OsmTransferException signifying a non-200 return code, or connection errors 292 287 */ 293 public void createChangeset(Changeset changeset, ChangesetProcessingType changesetProcessingType, ProgressMonitor progressMonitor) throws OsmTransferException { 294 if (changesetProcessingType == null) { 295 changesetProcessingType = ChangesetProcessingType.USE_NEW_AND_CLOSE; 296 } 288 public void createChangeset(Changeset changeset, ProgressMonitor progressMonitor) throws OsmTransferException { 297 289 try { 298 290 progressMonitor.beginTask((tr("Creating changeset..."))); 299 if (changesetProcessingType.isUseNew()) { 300 Properties sysProp = System.getProperties(); 301 Object ua = sysProp.get("http.agent"); 302 changeset.put("created_by", (ua == null) ? "JOSM" : ua.toString()); 303 createPrimitive(changeset, progressMonitor); 304 this.changeset = changeset; 305 progressMonitor.setCustomText((tr("Successfully opened changeset {0}",changeset.getId()))); 306 } else { 307 if (this.changeset == null || this.changeset.getId() == 0) { 308 progressMonitor.setCustomText((tr("No currently open changeset. Opening a new changeset..."))); 309 System.out.println(tr("Warning: could not reuse an existing changeset as requested. Opening a new one.")); 310 Properties sysProp = System.getProperties(); 311 Object ua = sysProp.get("http.agent"); 312 changeset.put("created_by", (ua == null) ? "JOSM" : ua.toString()); 313 createPrimitive(changeset, progressMonitor); 314 this.changeset = changeset; 315 progressMonitor.setCustomText((tr("Successfully opened changeset {0}",this.changeset.getId()))); 316 } else { 317 progressMonitor.setCustomText((tr("Reusing existing changeset {0}", this.changeset.getId()))); 318 } 319 } 291 createPrimitive(changeset, progressMonitor); 292 this.changeset = changeset; 293 progressMonitor.setCustomText((tr("Successfully opened changeset {0}",this.changeset.getId()))); 320 294 } finally { 321 295 progressMonitor.finishTask(); … … 324 298 325 299 /** 326 * Update a changeset on the server.327 * 328 * @param changeset the changeset to update300 * Updates the current changeset with the keys in <code>changesetUpdate</code>. 301 * 302 * @param changesetUpdate the changeset to update 329 303 * @param progressMonitor the progress monitor 330 304 * 331 305 * @throws OsmTransferException if something goes wrong. 332 306 */ 333 public void updateChangeset(Changeset changeset , ProgressMonitor progressMonitor) throws OsmTransferException {307 public void updateChangeset(Changeset changesetUpdate, ProgressMonitor progressMonitor) throws OsmTransferException { 334 308 try { 335 309 progressMonitor.beginTask(tr("Updating changeset...")); 336 310 initialize(progressMonitor); 337 311 if (this.changeset != null && this.changeset.getId() > 0) { 338 if (this.changeset.hasEqualSemanticAttributes(changeset )) {339 progressMonitor.setCustomText(tr("Changeset {0} is unchanged. Skipping update.", changeset .getId()));312 if (this.changeset.hasEqualSemanticAttributes(changesetUpdate)) { 313 progressMonitor.setCustomText(tr("Changeset {0} is unchanged. Skipping update.", changesetUpdate.getId())); 340 314 return; 341 315 } 342 this.changeset.setKeys(changeset .getKeys());343 progressMonitor.setCustomText(tr("Updating changeset {0}...", changeset.getId()));316 this.changeset.setKeys(changesetUpdate.getKeys()); 317 progressMonitor.setCustomText(tr("Updating changeset {0}...", this.changeset.getId())); 344 318 sendRequest( 345 319 "PUT", 346 OsmPrimitiveType.from(changeset ).getAPIName() + "/" +changeset.getId(),347 toXml( changeset, true),320 OsmPrimitiveType.from(changesetUpdate).getAPIName() + "/" + this.changeset.getId(), 321 toXml(this.changeset, true), 348 322 progressMonitor 349 323 ); 350 this.changeset = changeset;351 324 } else 352 325 throw new OsmTransferException(tr("Failed to update changeset. Either there is no current changeset or the id of the current changeset is 0")); -
trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
r2061 r2074 92 92 progressMonitor.setTicksCount(primitives.size()); 93 93 if (changesetProcessingType.isUseNew()) { 94 api.createChangeset(changeset, changesetProcessingType,progressMonitor.createSubTaskMonitor(0, false));94 api.createChangeset(changeset,progressMonitor.createSubTaskMonitor(0, false)); 95 95 } else { 96 96 api.updateChangeset(changeset,progressMonitor.createSubTaskMonitor(0, false)); … … 102 102 String msg = ""; 103 103 switch(OsmPrimitiveType.from(osm)) { 104 case NODE: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading node ''{4}'' (id: {5})"); break;105 case WAY: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading way ''{4}'' (id: {5})"); break;106 case RELATION: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading relation ''{4}'' (id: {5})"); break;104 case NODE: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading node ''{4}'' (id: {5})"); break; 105 case WAY: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading way ''{4}'' (id: {5})"); break; 106 case RELATION: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading relation ''{4}'' (id: {5})"); break; 107 107 } 108 108 progressMonitor.subTask( … … 151 151 try { 152 152 if (changesetProcessingType.isUseNew()) { 153 api.createChangeset(changeset, changesetProcessingType,progressMonitor.createSubTaskMonitor(0, false));153 api.createChangeset(changeset,progressMonitor.createSubTaskMonitor(0, false)); 154 154 } else { 155 155 api.updateChangeset(changeset,progressMonitor.createSubTaskMonitor(0, false));
Note:
See TracChangeset
for help on using the changeset viewer.