Ignore:
Timestamp:
15.06.2009 20:22:46 (3 years ago)
Author:
Gubaer
Message:

fixed: bug in OsmApi.getOsmApi()
cleanup: exception handling in interfacing with OSM API
new: new action for updating individual elements with the their current state on the server (including new menu item in the file menu)
new: improved user feedback in case of conflicts
new: handles 410 Gone conflicts when uploading a changeset
new: undoable command for "purging" a primitive from the current dataset (necessary if the primitive is already deleted on the server and the user wants to remove it from its local dataset)
new: undoable command for "undeleting" an already deleted primitive on the server (kind of "cloning")
new: after a full upload, checks whether there are primitives in the local dataset which might be deleted on the server.
new: data structures for history data
new: history download support in io package

File:
1 edited

Legend:

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

    r1647 r1670  
    2222import org.openstreetmap.josm.io.OsmServerLocationReader; 
    2323import org.openstreetmap.josm.io.OsmServerReader; 
     24import org.openstreetmap.josm.io.OsmTransferException; 
    2425import org.xml.sax.SAXException; 
    2526 
     
    3233    private static Bounds currentBounds; 
    3334    private Future<Task> task = null; 
     35    private DataSet downloadedData; 
    3436 
    35     private static class Task extends PleaseWaitRunnable { 
     37    private class Task extends PleaseWaitRunnable { 
    3638        private OsmServerReader reader; 
    3739        private DataSet dataSet; 
     
    4951        } 
    5052 
    51         @Override public void realRun() throws IOException, SAXException { 
     53        @Override public void realRun() throws IOException, SAXException, OsmTransferException { 
    5254            Main.pleaseWaitDlg.setCustomText(msg); 
    5355            dataSet = reader.parseOsm(); 
     
    5961            if (dataSet.allPrimitives().isEmpty()) { 
    6062                // If silent is set to true, we don't want to see information messages 
    61                 if(!silent) 
     63                if(!silent) { 
    6264                    errorMessage = tr("No data imported."); 
     65                } 
    6366                // need to synthesize a download bounds lest the visual indication of downloaded 
    6467                // area doesn't work 
    6568                dataSet.dataSources.add(new DataSource(currentBounds, "OpenStreetMap server")); 
    6669            } 
    67  
     70            rememberDownloadedData(dataSet); 
    6871            OsmDataLayer layer = new OsmDataLayer(dataSet, tr("Data Layer {0}", num), null); 
    69             if (newLayer) 
     72            if (newLayer) { 
    7073                Main.main.addLayer(layer); 
    71             else 
     74            } else { 
    7275                Main.main.editLayer().mergeFrom(layer); 
     76            } 
    7377 
    7478            Main.pleaseWaitDlg.setCustomText(""); 
     
    7680 
    7781        @Override protected void cancel() { 
    78             if (reader != null) 
     82            if (reader != null) { 
    7983                reader.cancel(); 
     84            } 
    8085            Main.pleaseWaitDlg.cancel.setEnabled(false); 
    8186        } 
    8287    } 
    8388    private JCheckBox checkBox = new JCheckBox(tr("OpenStreetMap data"), true); 
     89 
     90    private void rememberDownloadedData(DataSet ds) { 
     91        this.downloadedData = ds; 
     92    } 
     93 
     94    public DataSet getDownloadedData() { 
     95        return downloadedData; 
     96    } 
    8497 
    8598    public void download(DownloadAction action, double minlat, double minlon, 
     
    96109 
    97110        boolean newLayer = action != null 
    98                                 && (action.dialog == null || action.dialog.newLayer.isSelected()); 
     111        && (action.dialog == null || action.dialog.newLayer.isSelected()); 
    99112 
    100113        Task t = new Task(newLayer, 
     
    124137                false, 
    125138                getDataLayersCount(), 
    126                 ""); 
     139        ""); 
    127140        task = Main.worker.submit(t, t); 
    128141    } 
     
    145158        int num = 0; 
    146159        for(Layer l : Main.map.mapView.getAllLayers()) 
    147             if(l instanceof OsmDataLayer) 
     160            if(l instanceof OsmDataLayer) { 
    148161                num++; 
     162            } 
    149163        return num; 
    150164    } 
    151165 
    152    /* 
    153     * (non-Javadoc) 
    154     * @see org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask#getErrorMessage() 
    155     */ 
     166    /* 
     167     * (non-Javadoc) 
     168     * @see org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask#getErrorMessage() 
     169     */ 
    156170    public String getErrorMessage() { 
    157171        if(task == null) 
     
    161175            Task t = task.get(); 
    162176            return t.errorMessage == null 
    163                 ? "" 
    164                 : t.errorMessage; 
     177            ? "" 
     178                    : t.errorMessage; 
    165179        } catch (Exception e) { 
    166180            return ""; 
Note: See TracChangeset for help on using the changeset viewer.