Ticket #3381: changeset_source.patch
| File changeset_source.patch, 5.2 KB (added by , 17 years ago) |
|---|
-
src/org/openstreetmap/josm/actions/UploadAction.java
59 59 static private Logger logger = Logger.getLogger(UploadAction.class.getName()); 60 60 61 61 public static final String HISTORY_KEY = "upload.comment.history"; 62 62 public static final String SOURCE_KEY = "upload.source.history"; 63 63 64 /** Upload Hook */ 64 65 public interface UploadHook { 65 66 /** … … 482 483 p.add(cmt, GBC.eol().fill(GBC.HORIZONTAL)); 483 484 //final JTextField cmt = new JTextField(lastCommitComment); 484 485 486 p.add(new JLabel(tr("Source of your changes: (e.g. survey, aerial image, ...)")), GBC.eol().insets(0, 5, 10, 3)); 487 SuggestingJHistoryComboBox src = new SuggestingJHistoryComboBox(); 488 List<String> srcHistory = new LinkedList<String>(Main.pref.getCollection(SOURCE_KEY, new LinkedList<String>())); 489 src.setHistory(srcHistory); 490 p.add(src, GBC.eol().fill(GBC.HORIZONTAL)); 491 //final JTextField src = new JTextField(lastCommitComment); 492 485 493 // configuration options for atomic upload 486 494 p.add(buildChangesetControlPanel(), GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 487 495 … … 504 512 if (cmt.getText().trim().length() < 3) { 505 513 continue; 506 514 } 515 if (src.getText().trim().length() < 3) { 516 continue; 517 } 507 518 508 // store the history of comments 519 // store the history of comments and sources 509 520 cmt.addCurrentItemToHistory(); 510 521 Main.pref.putCollection(HISTORY_KEY, cmt.getHistory()); 522 src.addCurrentItemToHistory(); 523 Main.pref.putCollection(SOURCE_KEY, src.getHistory()); 511 524 Main.pref.put("osm-server.atomic-upload", cbUseAtomicUpload.isSelected()); 512 525 513 526 break; -
src/org/openstreetmap/josm/io/OsmApi.java
282 282 * @param comment the "commit comment" for the new changeset 283 283 * @throws OsmTransferException signifying a non-200 return code, or connection errors 284 284 */ 285 public void createChangeset(String comment, ProgressMonitor progressMonitor) throws OsmTransferException {285 public void createChangeset(String comment, String source, ProgressMonitor progressMonitor) throws OsmTransferException { 286 286 progressMonitor.beginTask((tr("Opening changeset..."))); 287 287 try { 288 288 changeset = new Changeset(); … … 290 290 Object ua = sysProp.get("http.agent"); 291 291 changeset.put("created_by", (ua == null) ? "JOSM" : ua.toString()); 292 292 changeset.put("comment", comment); 293 changeset.put("source", source); 293 294 createPrimitive(changeset); 294 295 } finally { 295 296 progressMonitor.finishTask(); -
src/org/openstreetmap/josm/io/OsmServerWriter.java
77 77 return cmt; 78 78 } 79 79 80 /** 81 * retrieves the most recent changeset comment from the preferences 82 * 83 * @return the most recent changeset comment 84 */ 85 protected String getChangesetSource() { 86 String cmt = ""; 87 List<String> history = new LinkedList<String>( 88 Main.pref.getCollection(UploadAction.SOURCE_KEY, new LinkedList<String>())); 89 if(history.size() > 0) { 90 cmt = history.get(0); 91 } 92 return cmt; 93 } 94 80 95 /** 81 96 * Uploads the changes individually. Invokes one API call per uploaded primitmive. 82 97 * … … 87 102 protected void uploadChangesIndividually(Collection<OsmPrimitive> primitives, ProgressMonitor progressMonitor) throws OsmTransferException { 88 103 try { 89 104 progressMonitor.setTicksCount(primitives.size()); 90 api.createChangeset(getChangesetComment(), progressMonitor.createSubTaskMonitor(0, false));105 api.createChangeset(getChangesetComment(), getChangesetSource(), progressMonitor.createSubTaskMonitor(0, false)); 91 106 uploadStartTime = System.currentTimeMillis(); 92 107 for (OsmPrimitive osm : primitives) { 93 108 int progress = progressMonitor.getTicks(); … … 143 158 // upload everything in one changeset 144 159 // 145 160 try { 146 api.createChangeset(getChangesetComment(), progressMonitor.createSubTaskMonitor(0, false));161 api.createChangeset(getChangesetComment(), getChangesetSource(), progressMonitor.createSubTaskMonitor(0, false)); 147 162 processed.addAll(api.uploadDiff(primitives, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false))); 148 163 } catch(OsmTransferException e) { 149 164 throw e;
