Changeset 2074 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2009-09-07T00:01:31+02:00 (15 years ago)
Author:
Gubaer
Message:

fixed #3422: Upload dialog allows modification of the created_by=* tag when adding to an existing changeset

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/UploadAction.java

    r2065 r2074  
    1919import java.util.List;
    2020import java.util.Map;
     21import java.util.Properties;
    2122import java.util.logging.Logger;
    2223import java.util.regex.Matcher;
     
    246247        );
    247248        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 happen
    254             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));
    255256        }
    256257    }
     
    286287        );
    287288        switch(ret) {
    288         case JOptionPane.CLOSED_OPTION: return;
    289         case 1: return;
    290         case 0: synchronizeDataSet(); break;
    291         default:
    292             // should not happen
    293             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));
    294295        }
    295296    }
     
    936937                southTabbedPane.setTitleAt(1, tr("Tags of new changeset"));
    937938                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());
    938942                tagEditorPanel.getModel().initFromPrimitive(cs);
    939943            } else {
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r2070 r2074  
    278278    }
    279279
    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>
    282283     *
    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
    290285     * @param progressMonitor the progress monitor
    291286     * @throws OsmTransferException signifying a non-200 return code, or connection errors
    292287     */
    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 {
    297289        try {
    298290            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())));
    320294        } finally {
    321295            progressMonitor.finishTask();
     
    324298
    325299    /**
    326      * Update a changeset on the server.
    327      *
    328      * @param changeset the changeset to update
     300     * Updates the current changeset with the keys in  <code>changesetUpdate</code>.
     301     *
     302     * @param changesetUpdate the changeset to update
    329303     * @param progressMonitor the progress monitor
    330304     *
    331305     * @throws OsmTransferException if something goes wrong.
    332306     */
    333     public void updateChangeset(Changeset changeset, ProgressMonitor progressMonitor) throws OsmTransferException {
     307    public void updateChangeset(Changeset changesetUpdate, ProgressMonitor progressMonitor) throws OsmTransferException {
    334308        try {
    335309            progressMonitor.beginTask(tr("Updating changeset..."));
    336310            initialize(progressMonitor);
    337311            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()));
    340314                    return;
    341315                }
    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()));
    344318                sendRequest(
    345319                        "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),
    348322                        progressMonitor
    349323                );
    350                 this.changeset = changeset;
    351324            } else
    352325                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  
    9292            progressMonitor.setTicksCount(primitives.size());
    9393            if (changesetProcessingType.isUseNew()) {
    94                 api.createChangeset(changeset, changesetProcessingType,progressMonitor.createSubTaskMonitor(0, false));
     94                api.createChangeset(changeset,progressMonitor.createSubTaskMonitor(0, false));
    9595            } else {
    9696                api.updateChangeset(changeset,progressMonitor.createSubTaskMonitor(0, false));
     
    102102                String msg = "";
    103103                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;
    107107                }
    108108                progressMonitor.subTask(
     
    151151        try {
    152152            if (changesetProcessingType.isUseNew()) {
    153                 api.createChangeset(changeset, changesetProcessingType,progressMonitor.createSubTaskMonitor(0, false));
     153                api.createChangeset(changeset,progressMonitor.createSubTaskMonitor(0, false));
    154154            } else {
    155155                api.updateChangeset(changeset,progressMonitor.createSubTaskMonitor(0, false));
Note: See TracChangeset for help on using the changeset viewer.