Index: /trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java	(revision 1755)
+++ /trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java	(revision 1756)
@@ -4,6 +4,8 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.awt.EventQueue;
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
+import java.io.IOException;
 import java.util.Collection;
 import java.util.HashSet;
@@ -13,9 +15,12 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.command.PurgePrimitivesCommand;
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.gui.PleaseWaitRunnable;
 import org.openstreetmap.josm.io.MultiFetchServerObjectReader;
+import org.openstreetmap.josm.io.OsmApi;
+import org.openstreetmap.josm.io.OsmTransferException;
 import org.openstreetmap.josm.tools.Shortcut;
+import org.xml.sax.SAXException;
 
 /**
@@ -25,6 +30,4 @@
  */
 public class UpdateSelectionAction extends JosmAction {
-
-    static public int DEFAULT_MAX_SIZE_UPDATE_SELECTION = 50;
 
     /**
@@ -43,5 +46,5 @@
             return;
         }
-        Main.main.createOrGetEditLayer().mergeFrom(ds);
+        Main.map.mapView.getEditLayer().mergeFrom(ds);
     }
 
@@ -63,6 +66,8 @@
 
     /**
-     * 
-     * @param id
+     * handles an exception case: primitive with id <code>id</code> is not in the current
+     * data set
+     * 
+     * @param id the primitive id
      */
     protected void handleMissingPrimitive(long id) {
@@ -76,23 +81,97 @@
 
     /**
-     * 
-     * 
-     * 
-     */
-    public void updatePrimitives(Collection<OsmPrimitive> selection) {
-        MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader();
-        reader.append(selection);
-        DataSet ds = null;
-        try {
-            ds = reader.parseOsm();
-        } catch(Exception e) {
-            handleUpdateException(e);
-            return;
+     * Updates the data for for the {@see OsmPrimitive}s in <code>selection</code>
+     * with the data currently kept on the server.
+     * 
+     * @param selection a collection of {@see OsmPrimitive}s to update
+     * 
+     */
+    public void updatePrimitives(final Collection<OsmPrimitive> selection) {
+
+        /**
+         * The asynchronous task for updating the data using multi fetch.
+         *
+         */
+        class UpdatePrimitiveTask extends PleaseWaitRunnable {
+            private DataSet ds;
+            private boolean cancelled;
+            Exception lastException;
+
+            protected void setIndeterminateEnabled(final boolean enabled) {
+                EventQueue.invokeLater(
+                        new Runnable() {
+                            public void run() {
+                                Main.pleaseWaitDlg.setIndeterminate(enabled);
+                            }
+                        }
+                );
+            }
+
+            public UpdatePrimitiveTask() {
+                super("Update primitives", false /* don't ignore exception*/);
+                cancelled = false;
+            }
+
+            protected void showLastException() {
+                String msg = lastException.getMessage();
+                if (msg == null) {
+                    msg = lastException.toString();
+                }
+                JOptionPane.showMessageDialog(
+                        Main.map,
+                        msg,
+                        tr("Error"),
+                        JOptionPane.ERROR_MESSAGE
+                );
+            }
+
+            @Override
+            protected void cancel() {
+                cancelled = true;
+                OsmApi.getOsmApi().cancel();
+            }
+
+            @Override
+            protected void finish() {
+                if (cancelled)
+                    return;
+                if (lastException != null) {
+                    showLastException();
+                    return;
+                }
+                if (ds != null) {
+                    Main.map.mapView.getEditLayer().mergeFrom(ds);
+                }
+            }
+
+            @Override
+            protected void realRun() throws SAXException, IOException, OsmTransferException {
+                setIndeterminateEnabled(true);
+                try {
+                    MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader();
+                    reader.append(selection);
+                    ds = reader.parseOsm();
+                } catch(Exception e) {
+                    if (cancelled)
+                        return;
+                    lastException = e;
+                } finally {
+                    setIndeterminateEnabled(false);
+                }
+            }
         }
-        Main.main.createOrGetEditLayer().mergeFrom(ds);
-    }
-
+
+        Main.worker.submit(new UpdatePrimitiveTask());
+    }
+
+    /**
+     * Updates the data for for the {@see OsmPrimitive}s with id <code>id</code>
+     * with the data currently kept on the server.
+     * 
+     * @param id  the id of a primitive in the {@see DataSet} of the current edit layser
+     * 
+     */
     public void updatePrimitive(long id) {
-        OsmPrimitive primitive = Main.main.createOrGetEditLayer().data.getPrimitiveById(id);
+        OsmPrimitive primitive = Main.map.mapView.getEditLayer().data.getPrimitiveById(id);
         Set<OsmPrimitive> s = new HashSet<OsmPrimitive>();
         s.add(primitive);
@@ -100,4 +179,7 @@
     }
 
+    /**
+     * constructor
+     */
     public UpdateSelectionAction() {
         super(tr("Update Selection"),
@@ -111,5 +193,7 @@
     }
 
-
+    /**
+     * action handler
+     */
     public void actionPerformed(ActionEvent e) {
         Collection<OsmPrimitive> selection = Main.ds.getSelected();
Index: /trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskList.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskList.java	(revision 1755)
+++ /trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskList.java	(revision 1756)
@@ -5,5 +5,4 @@
 
 import java.awt.EventQueue;
-import java.awt.event.ActionEvent;
 import java.awt.geom.Area;
 import java.awt.geom.Rectangle2D;
@@ -98,8 +97,8 @@
         }
 
-        Set<Long> myPrimitiveIds = Main.main.createOrGetEditLayer().data.getPrimitiveIds();
+        Set<Long> myPrimitiveIds = Main.map.mapView.getEditLayer().data.getCompletePrimitiveIds();
         Set<Long> downloadedIds = getDownloadedIds();
         myPrimitiveIds.removeAll(downloadedIds);
-        myPrimitiveIds.remove(new Long(0));
+        myPrimitiveIds.remove(new Long(0)); // ignore new primitives
         if (! myPrimitiveIds.isEmpty()) {
             handlePotentiallyDeletedPrimitives(myPrimitiveIds);
@@ -107,7 +106,13 @@
     }
 
-    protected void checkPotentiallyDeletedPrimitives(Set<Long> potentiallyDeleted) {
-        DataSet ds =  Main.main.createOrGetEditLayer().data;
-        ArrayList<OsmPrimitive> toSelect = new ArrayList<OsmPrimitive>();
+    /**
+     * Updates the local state of a set of primitives (given by a set of primitive
+     * ids) with the state currently held on the server.
+     * 
+     * @param potentiallyDeleted a set of ids to check update from the server
+     */
+    protected void updatePotentiallyDeletedPrimitives(Set<Long> potentiallyDeleted) {
+        DataSet ds =  Main.map.mapView.getEditLayer().data;
+        final ArrayList<OsmPrimitive> toSelect = new ArrayList<OsmPrimitive>();
         for (Long id : potentiallyDeleted) {
             OsmPrimitive primitive = ds.getPrimitiveById(id);
@@ -116,9 +121,8 @@
             }
         }
-        ds.setSelected(toSelect);
         EventQueue.invokeLater(
                 new Runnable() {
                     public void run() {
-                        new UpdateSelectionAction().actionPerformed(new ActionEvent(this, 0, ""));
+                        new UpdateSelectionAction().updatePrimitives(toSelect);
                     }
                 }
@@ -126,4 +130,12 @@
     }
 
+    /**
+     * Processes a set of primitives (given by a set of their ids) which might be
+     * deleted on the server. First prompts the user whether he wants to check
+     * the current state on the server. If yes, retrieves the current state on the server
+     * and checks whether the primitives are indeed deleted on the server.
+     * 
+     * @param potentiallyDeleted a set of primitives (given by their ids)
+     */
     protected void handlePotentiallyDeletedPrimitives(Set<Long> potentiallyDeleted) {
         String [] options = {
@@ -158,8 +170,17 @@
         case JOptionPane.CLOSED_OPTION: return;
         case JOptionPane.NO_OPTION: return;
-        case JOptionPane.YES_OPTION: checkPotentiallyDeletedPrimitives(potentiallyDeleted); break;
-        }
-    }
-
+        case JOptionPane.YES_OPTION: updatePotentiallyDeletedPrimitives(potentiallyDeleted); break;
+        }
+    }
+
+    /**
+     * replies true, if the primitive with id <code>id</code> was downloaded into the
+     * dataset <code>ds</code>
+     * 
+     * @param id the id
+     * @param ds the dataset
+     * @return true, if the primitive with id <code>id</code> was downloaded into the
+     * dataset <code>ds</code>; false otherwise
+     */
     protected boolean wasDownloaded(long id, DataSet ds) {
         OsmPrimitive primitive = ds.getPrimitiveById(id);
@@ -167,4 +188,13 @@
     }
 
+    /**
+     * replies true, if the primitive with id <code>id</code> was downloaded into the
+     * dataset of one of the download tasks
+     * 
+     * @param id the id
+     * @return true, if the primitive with id <code>id</code> was downloaded into the
+     * dataset of one of the download tasks
+     * 
+     */
     public boolean wasDownloaded(long id) {
         for (DownloadTask task : osmTasks) {
@@ -177,4 +207,9 @@
     }
 
+    /**
+     * Replies the set of primitive ids which have been downloaded by this task list
+     * 
+     * @return the set of primitive ids which have been downloaded by this task list
+     */
     public Set<Long> getDownloadedIds() {
         HashSet<Long> ret = new HashSet<Long>();
Index: /trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 1755)
+++ /trunk/src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 1756)
@@ -313,4 +313,30 @@
     }
 
+    /**
+     * Replies the set of ids of all complete primitivies (i.e. those with
+     * ! primitive.incomplete)
+     * 
+     * @return the set of ids of all complete primitivies
+     */
+    public Set<Long> getCompletePrimitiveIds() {
+        HashSet<Long> ret = new HashSet<Long>();
+        for (OsmPrimitive primitive : nodes) {
+            if (!primitive.incomplete) {
+                ret.add(primitive.id);
+            }
+        }
+        for (OsmPrimitive primitive : ways) {
+            if (! primitive.incomplete) {
+                ret.add(primitive.id);
+            }
+        }
+        for (OsmPrimitive primitive : relations) {
+            if (! primitive.incomplete) {
+                ret.add(primitive.id);
+            }
+        }
+        return ret;
+    }
+
     protected void deleteWay(Way way) {
         way.nodes.clear();
