Ticket #3381: changeset_source.patch

File changeset_source.patch, 5.2 KB (added by vsandre, 12 years ago)
  • src/org/openstreetmap/josm/actions/UploadAction.java

     
    5959    static private Logger logger = Logger.getLogger(UploadAction.class.getName());
    6060
    6161    public static final String HISTORY_KEY = "upload.comment.history";
    62 
     62    public static final String SOURCE_KEY = "upload.source.history";
     63       
    6364    /** Upload Hook */
    6465    public interface UploadHook {
    6566        /**
     
    482483            p.add(cmt, GBC.eol().fill(GBC.HORIZONTAL));
    483484            //final JTextField cmt = new JTextField(lastCommitComment);
    484485
     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                       
    485493            // configuration options for atomic upload
    486494            p.add(buildChangesetControlPanel(), GBC.eol().fill(GridBagConstraints.HORIZONTAL));
    487495
     
    504512                if (cmt.getText().trim().length() < 3) {
    505513                    continue;
    506514                }
     515                if (src.getText().trim().length() < 3) {
     516                    continue;
     517                }                               
    507518
    508                 // store the history of comments
     519                // store the history of comments and sources
    509520                cmt.addCurrentItemToHistory();
    510521                Main.pref.putCollection(HISTORY_KEY, cmt.getHistory());
     522                src.addCurrentItemToHistory();
     523                Main.pref.putCollection(SOURCE_KEY, src.getHistory());                         
    511524                Main.pref.put("osm-server.atomic-upload", cbUseAtomicUpload.isSelected());
    512525
    513526                break;
  • src/org/openstreetmap/josm/io/OsmApi.java

     
    282282     * @param comment the "commit comment" for the new changeset
    283283     * @throws OsmTransferException signifying a non-200 return code, or connection errors
    284284     */
    285     public void createChangeset(String comment, ProgressMonitor progressMonitor) throws OsmTransferException {
     285    public void createChangeset(String comment, String source, ProgressMonitor progressMonitor) throws OsmTransferException {
    286286        progressMonitor.beginTask((tr("Opening changeset...")));
    287287        try {
    288288            changeset = new Changeset();
     
    290290            Object ua = sysProp.get("http.agent");
    291291            changeset.put("created_by", (ua == null) ? "JOSM" : ua.toString());
    292292            changeset.put("comment", comment);
     293                        changeset.put("source", source);
    293294            createPrimitive(changeset);
    294295        } finally {
    295296            progressMonitor.finishTask();
  • src/org/openstreetmap/josm/io/OsmServerWriter.java

     
    7777        return cmt;
    7878    }
    7979
     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       
    8095    /**
    8196     * Uploads the changes individually. Invokes one API call per uploaded primitmive.
    8297     *
     
    87102    protected void uploadChangesIndividually(Collection<OsmPrimitive> primitives, ProgressMonitor progressMonitor) throws OsmTransferException {
    88103        try {
    89104            progressMonitor.setTicksCount(primitives.size());
    90             api.createChangeset(getChangesetComment(), progressMonitor.createSubTaskMonitor(0, false));
     105            api.createChangeset(getChangesetComment(), getChangesetSource(), progressMonitor.createSubTaskMonitor(0, false));
    91106            uploadStartTime = System.currentTimeMillis();
    92107            for (OsmPrimitive osm : primitives) {
    93108                int progress = progressMonitor.getTicks();
     
    143158        // upload everything in one changeset
    144159        //
    145160        try {
    146             api.createChangeset(getChangesetComment(), progressMonitor.createSubTaskMonitor(0, false));
     161            api.createChangeset(getChangesetComment(), getChangesetSource(), progressMonitor.createSubTaskMonitor(0, false));
    147162            processed.addAll(api.uploadDiff(primitives, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)));
    148163        } catch(OsmTransferException e) {
    149164            throw e;