Index: /trunk/src/org/openstreetmap/josm/actions/UploadAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/UploadAction.java	(revision 2479)
+++ /trunk/src/org/openstreetmap/josm/actions/UploadAction.java	(revision 2480)
@@ -38,9 +38,9 @@
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.gui.progress.ProgressMonitor;
+import org.openstreetmap.josm.io.ChangesetClosedException;
 import org.openstreetmap.josm.io.OsmApi;
 import org.openstreetmap.josm.io.OsmApiException;
 import org.openstreetmap.josm.io.OsmApiInitializationException;
 import org.openstreetmap.josm.io.OsmApiPrimitiveGoneException;
-import org.openstreetmap.josm.io.OsmChangesetCloseException;
 import org.openstreetmap.josm.io.OsmServerWriter;
 import org.openstreetmap.josm.io.OsmTransferException;
@@ -480,8 +480,4 @@
         }
 
-        if (e instanceof OsmChangesetCloseException) {
-            ExceptionDialogUtil.explainOsmChangesetCloseException((OsmChangesetCloseException)e);
-            return;
-        }
         if (e instanceof OsmApiPrimitiveGoneException) {
             handleGone((OsmApiPrimitiveGoneException)e);
@@ -674,5 +670,9 @@
             }
             layer.onPostUploadToServer();
-            UploadDialog.getUploadDialog().setOrUpdateChangeset(changeset);
+            if (lastException != null && lastException instanceof ChangesetClosedException) {
+                UploadDialog.getUploadDialog().removeChangeset(changeset);
+            } else {
+                UploadDialog.getUploadDialog().setOrUpdateChangeset(changeset);
+            }
         }
 
Index: /trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java	(revision 2479)
+++ /trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java	(revision 2480)
@@ -14,7 +14,7 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.io.ChangesetClosedException;
 import org.openstreetmap.josm.io.OsmApiException;
 import org.openstreetmap.josm.io.OsmApiInitializationException;
-import org.openstreetmap.josm.io.OsmChangesetCloseException;
 import org.openstreetmap.josm.io.OsmTransferException;
 import org.openstreetmap.josm.tools.BugReportExceptionHandler;
@@ -49,15 +49,15 @@
 
     /**
-     * handles an exception caught during OSM API initialization
+     * handles a ChangesetClosedException
      *
      * @param e the exception
      */
-    public static void explainOsmChangesetCloseException(OsmChangesetCloseException e) {
-        HelpAwareOptionPane.showOptionDialog(
-                Main.parent,
-                ExceptionUtil.explainOsmChangesetCloseException(e),
+    public static void explainChangesetClosedException(ChangesetClosedException e) {
+        HelpAwareOptionPane.showOptionDialog(
+                Main.parent,
+                ExceptionUtil.explainChangesetClosedException(e),
                 tr("Error"),
                 JOptionPane.ERROR_MESSAGE,
-                ht("/ErrorMessages#OsmChangesetCloseException")
+                ht("/ErrorMessages#ChangesetClosedException")
         );
     }
@@ -294,6 +294,7 @@
             return;
         }
-        if (e instanceof OsmChangesetCloseException) {
-            explainOsmChangesetCloseException((OsmChangesetCloseException) e);
+
+        if (e instanceof ChangesetClosedException) {
+            explainChangesetClosedException((ChangesetClosedException)e);
             return;
         }
Index: /trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java	(revision 2479)
+++ /trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java	(revision 2480)
@@ -334,4 +334,15 @@
     public void setOrUpdateChangeset(Changeset cs) {
         pnlChangesetSelection.setOrUpdateChangeset(cs);
+    }
+
+    /**
+     * Removes <code>cs</code> from the list of open changesets in the upload
+     * dialog
+     * 
+     * @param cs the changeset. Ignored if null.
+     */
+    public void removeChangeset(Changeset cs) {
+        if (cs == null) return;
+        pnlChangesetSelection.removeChangeset(cs);
     }
 
@@ -842,7 +853,9 @@
         public void setOrUpdateChangeset(Changeset cs) {
             if (cs == null) {
-                tagEditorPanel.getModel().clear();
-                tagEditorPanel.getModel().add("created_by", getDefaultCreatedBy());
+                cs = new Changeset();
+                cs.put("created_by", getDefaultCreatedBy());
+                tagEditorPanel.getModel().initFromPrimitive(cs);
                 tagEditorPanel.getModel().appendNewTag();
+                prepareDialogForNextUpload(cs);
             } else if (cs.getId() == 0) {
                 if (cs.get("created_by") == null) {
@@ -851,4 +864,5 @@
                 tagEditorPanel.getModel().initFromPrimitive(cs);
                 tagEditorPanel.getModel().appendNewTag();
+                prepareDialogForNextUpload(cs);
             } else if (cs.getId() > 0 && cs.isOpen()){
                 if (cs.get("created_by") == null) {
@@ -859,15 +873,33 @@
                 cs = model.getChangesetById(cs.getId());
                 cbOpenChangesets.setSelectedItem(cs);
+                prepareDialogForNextUpload(cs);
             } else if (cs.getId() > 0 && !cs.isOpen()){
+                removeChangeset(cs);
+            }
+        }
+
+        /**
+         * Remove a changeset from the list of open changeset
+         * 
+         * @param cs the changeset to be removed. Ignored if null.
+         */
+        public void removeChangeset(Changeset cs) {
+            if (cs ==  null) return;
+            Changeset selected = (Changeset)model.getSelectedItem();
+            model.removeChangeset(cs);
+            if (model.getSize() == 0 || selected == cs) {
+                // no more changesets or removed changeset is the currently selected
+                // changeset? Switch to using a new changeset.
+                //
+                rbUseNew.setSelected(true);
+                model.setSelectedItem(null);
+                southTabbedPane.setTitleAt(1, tr("Tags of new changeset"));
+
+                cs = new Changeset();
                 if (cs.get("created_by") == null) {
                     cs.put("created_by", getDefaultCreatedBy());
+                    cs.put("comment", getUploadComment());
                 }
                 tagEditorPanel.getModel().initFromPrimitive(cs);
-                model.removeChangeset(cs);
-                if (model.getSize() == 0) {
-                    rbUseNew.setSelected(true);
-                    model.setSelectedItem(null);
-                    southTabbedPane.setTitleAt(1, tr("Tags of new changeset"));
-                }
             }
             prepareDialogForNextUpload(cs);
Index: /trunk/src/org/openstreetmap/josm/io/ChangesetClosedException.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/ChangesetClosedException.java	(revision 2480)
+++ /trunk/src/org/openstreetmap/josm/io/ChangesetClosedException.java	(revision 2480)
@@ -0,0 +1,53 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.io;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class ChangesetClosedException extends OsmTransferException {
+
+    /** the changeset id */
+    private long changesetId;
+    /** the date on which the changeset was closed */
+    private Date closedOn;
+
+    protected void parseErrorHeader(String errorHeader) {
+        String pattern = "The changeset (\\d+) was closed at (.*)";
+        Pattern p = Pattern.compile(pattern);
+        Matcher m = p.matcher(errorHeader);
+        if (m.matches()) {
+            changesetId = Long.parseLong(m.group(1));
+            // Example: Tue Oct 15 10:00:00 UTC 2009. Always parsed with english locale regardless
+            // of the current locale in JOSM
+            DateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy",Locale.ENGLISH);
+            try {
+                closedOn = formatter.parse(m.group(2));
+            } catch(ParseException ex) {
+                System.err.println(tr("Failed to parse date ''{0}'' replied by server.", m.group(2)));
+                ex.printStackTrace();
+            }
+        } else {
+            System.err.println(tr("Unexpected format of error header for conflict in changeset update. Got ''{0}''", errorHeader));
+        }
+    }
+
+    public ChangesetClosedException(String errorHeader) {
+        super(errorHeader);
+        parseErrorHeader(errorHeader);
+    }
+
+    public long getChangesetId() {
+        return changesetId;
+    }
+
+    public Date getClosedOn() {
+        return closedOn;
+    }
+}
Index: /trunk/src/org/openstreetmap/josm/io/OsmApi.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/OsmApi.java	(revision 2479)
+++ /trunk/src/org/openstreetmap/josm/io/OsmApi.java	(revision 2480)
@@ -338,5 +338,5 @@
      * @throws OsmTransferException if something goes wrong.
      * @throws IllegalArgumentException if changeset is null
-     * @throws IllegalArgumentException if changeset.getId() == 0
+     * @throws IllegalArgumentException if changeset.getId() <= 0
      * 
      */
@@ -359,4 +359,8 @@
                     monitor
             );
+        } catch(OsmApiException e) {
+            if (e.getResponseCode() == HttpURLConnection.HTTP_CONFLICT)
+                throw new ChangesetClosedException(e.getErrorHeader());
+            throw e;
         } finally {
             monitor.finishTask();
Index: unk/src/org/openstreetmap/josm/io/OsmChangesetCloseException.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/OsmChangesetCloseException.java	(revision 2479)
+++ 	(revision )
@@ -1,36 +1,0 @@
-// License: GPL. For details, see LICENSE file.
-package org.openstreetmap.josm.io;
-
-import org.openstreetmap.josm.data.osm.Changeset;
-
-public class OsmChangesetCloseException extends OsmTransferException {
-    private Changeset changeset;
-
-    public OsmChangesetCloseException() {
-        super();
-        // TODO Auto-generated constructor stub
-    }
-
-    public OsmChangesetCloseException(String message, Throwable cause) {
-        super(message, cause);
-        // TODO Auto-generated constructor stub
-    }
-
-    public OsmChangesetCloseException(String message) {
-        super(message);
-        // TODO Auto-generated constructor stub
-    }
-
-    public OsmChangesetCloseException(Throwable cause) {
-        super(cause);
-        // TODO Auto-generated constructor stub
-    }
-
-    public Changeset getChangeset() {
-        return changeset;
-    }
-
-    public void setChangeset(Changeset changeset) {
-        this.changeset = changeset;
-    }
-}
Index: /trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java	(revision 2479)
+++ /trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java	(revision 2480)
@@ -14,12 +14,13 @@
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.Locale;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.io.ChangesetClosedException;
 import org.openstreetmap.josm.io.OsmApi;
 import org.openstreetmap.josm.io.OsmApiException;
 import org.openstreetmap.josm.io.OsmApiInitializationException;
-import org.openstreetmap.josm.io.OsmChangesetCloseException;
 import org.openstreetmap.josm.io.OsmTransferException;
 
@@ -39,19 +40,4 @@
                 + "Check the server URL in your preferences and your internet connection.</html>", Main.pref.get(
                         "osm-server.url", "http://api.openstreetmap.org/api"));
-        return msg;
-    }
-
-    /**
-     * handles an exception caught during OSM API initialization
-     *
-     * @param e the exception
-     */
-    public static String explainOsmChangesetCloseException(OsmChangesetCloseException e) {
-        e.printStackTrace();
-        String changsetId = e.getChangeset() == null ? tr("unknown") : Long.toString(e.getChangeset().getId());
-        String msg = tr(
-                "<html>Failed to close changeset ''{0}'' on the OSM server ''{1}''.<br>"
-                + "The changeset will automatically be closed by the server after a timeout.</html>", changsetId,
-                Main.pref.get("osm-server.url", "http://api.openstreetmap.org/api"));
         return msg;
     }
@@ -115,6 +101,7 @@
             if (m.matches()) {
                 long changesetId = Long.parseLong(m.group(1));
-                // Example: Tue Oct 15 10:00:00 UTC 2009
-                DateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
+                // Example: Tue Oct 15 10:00:00 UTC 2009. Always parsed with english locale, regardless
+                // of the current locale in JOSM
+                DateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
                 Date closeDate = null;
                 try {
@@ -153,4 +140,23 @@
 
     /**
+     * Explains an exception thrown during upload because the changeset which data is
+     * uploaded to is already closed.
+     * 
+     * @param e the exception
+     */
+    public static String explainChangesetClosedException(ChangesetClosedException e) {
+        String msg;
+        SimpleDateFormat dateFormat = new SimpleDateFormat();
+        msg = tr(
+                "<html>Failed to upload to changeset <strong>{0}</strong><br>"
+                +"because it has already been closed on {1}.</html>",
+                e.getChangesetId(),
+                dateFormat.format(e.getClosedOn())
+        );
+        e.printStackTrace();
+        return msg;
+    }
+
+    /**
      * Explains an exception with a generic message dialog
      * 
@@ -338,6 +344,7 @@
         if (e instanceof OsmApiInitializationException)
             return explainOsmApiInitializationException((OsmApiInitializationException) e);
-        if (e instanceof OsmChangesetCloseException)
-            return explainOsmChangesetCloseException((OsmChangesetCloseException) e);
+
+        if (e instanceof ChangesetClosedException)
+            return explainChangesetClosedException((ChangesetClosedException)e);
 
         if (e instanceof OsmApiException) {
