Ignore:
Timestamp:
2009-09-02T21:17:52+02:00 (15 years ago)
Author:
Gubaer
Message:

new: improved dialog for uploading/saving modified layers on exit
new: improved dialog for uploading/saving modified layers if layers are deleted
new: new progress monitor which can delegate rendering to any Swing component
more setters/getters for properties in OSM data classes (fields are @deprecated); started to update references in the code base

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java

    r2004 r2025  
    9595                String msg = "";
    9696                switch(OsmPrimitiveType.from(osm)) {
    97                 case NODE: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading node ''{4}'' (id: {5})"); break;
    98                 case WAY: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading way ''{4}'' (id: {5})"); break;
    99                 case RELATION: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading relation ''{4}'' (id: {5})"); break;
     97                    case NODE: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading node ''{4}'' (id: {5})"); break;
     98                    case WAY: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading way ''{4}'' (id: {5})"); break;
     99                    case RELATION: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading relation ''{4}'' (id: {5})"); break;
    100100                }
    101101                progressMonitor.subTask(
     
    105105                                primitives.size(),
    106106                                time_left_str,
    107                                 osm.getName() == null ? osm.id : osm.getName(),
    108                                         osm.id));
     107                                osm.getName() == null ? osm.getId() : osm.getName(),
     108                                        osm.getId()));
    109109                makeApiRequest(osm,progressMonitor);
    110110                processed.add(osm);
     
    117117        } finally {
    118118            try {
    119                 api.stopChangeset(progressMonitor.createSubTaskMonitor(0, false));
     119                // starting the changeset may have failed, for instance because the user
     120                // cancelled the upload task. Only close the changeset if we currently have
     121                // an open changeset
     122
     123                if (api.getCurrentChangeset() != null && api.getCurrentChangeset().getId() > 0) {
     124                    api.stopChangeset(progressMonitor.createSubTaskMonitor(0, false));
     125                }
    120126            } catch(Exception e) {
    121127                Changeset changeset = api.getCurrentChangeset();
    122                 String changesetId = (changeset == null ? tr("unknown") : Long.toString(changeset.id));
     128                String changesetId = (changeset == null ? tr("unknown") : Long.toString(changeset.getId()));
    123129                logger.warning(tr("Failed to close changeset {0}, will be closed by server after timeout. Exception was: {1}",
    124130                        changesetId, e.toString()));
     
    149155            } catch (Exception ee) {
    150156                Changeset changeset = api.getCurrentChangeset();
    151                 String changesetId = (changeset == null ? tr("unknown") : Long.toString(changeset.id));
     157                String changesetId = (changeset == null ? tr("unknown") : Long.toString(changeset.getId()));
    152158                logger.warning(tr("Failed to close changeset {0}, will be closed by server after timeout. Exception was: {1}",
    153159                        changesetId, ee.toString()));
     
    166172
    167173        api.initialize();
    168 
    169         progressMonitor.beginTask("");
    170174
    171175        try {
     
    180184
    181185            if (useChangeset) {
     186                progressMonitor.beginTask(tr("Starting to upload in one request ..."));
    182187                uploadChangesAsDiffUpload(primitives, progressMonitor);
    183188            } else {
     189                progressMonitor.beginTask(tr("Starting to upload with one request per primitive ..."));
    184190                uploadChangesIndividually(primitives, progressMonitor);
    185191            }
     
    190196
    191197    void makeApiRequest(OsmPrimitive osm, ProgressMonitor progressMonitor) throws OsmTransferException {
    192         if (osm.deleted) {
     198        if (osm.isDeleted()) {
    193199            api.deletePrimitive(osm, progressMonitor);
    194         } else if (osm.id == 0) {
     200        } else if (osm.getId() == 0) {
    195201            api.createPrimitive(osm);
    196202        } else {
Note: See TracChangeset for help on using the changeset viewer.