Index: /trunk/src/org/openstreetmap/josm/actions/UploadAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/UploadAction.java	(revision 2045)
+++ /trunk/src/org/openstreetmap/josm/actions/UploadAction.java	(revision 2046)
@@ -9,10 +9,13 @@
 import java.awt.GridBagLayout;
 import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.awt.event.KeyEvent;
 import java.io.IOException;
 import java.net.HttpURLConnection;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 import java.util.logging.Logger;
 import java.util.regex.Matcher;
@@ -54,4 +57,6 @@
 import org.openstreetmap.josm.tools.WindowGeometry;
 import org.xml.sax.SAXException;
+
+import com.sun.corba.se.spi.orbutil.fsm.Action;
 
 
@@ -596,9 +601,5 @@
         private JTabbedPane southTabbedPane;
         private ButtonGroup bgChangesetHandlingOptions;
-        private JRadioButton rbUseNewAndClose;
-        private JRadioButton rbUseNewAndLeaveOpen;
-        private JRadioButton rbUseExistingAndClose;
-        private JRadioButton rbUseExistingAndLeaveOpen;
-        private ChangesetProcessingType changesetProcessingType;
+        private Map<ChangesetProcessingType, JRadioButton> rbChangesetHandlingOptions;
 
         protected JPanel buildListsPanel() {
@@ -613,29 +614,28 @@
             pnl.setLayout(new BoxLayout(pnl, BoxLayout.Y_AXIS));
             bgChangesetHandlingOptions = new ButtonGroup();
-
-            rbUseNewAndClose = new JRadioButton(tr("Use a new changeset and close it"));
-            rbUseNewAndClose.setToolTipText(tr("Select to upload the data using a new changeset and to close the changeset after the upload"));
-
-            rbUseNewAndLeaveOpen = new JRadioButton(tr("Use a new changeset and leave it open"));
-            rbUseNewAndLeaveOpen.setToolTipText(tr("Select to upload the data using a new changeset and to leave the changeset open after the upload"));
-
-            rbUseExistingAndClose = new JRadioButton();
-            rbUseExistingAndLeaveOpen = new JRadioButton();
+            rbChangesetHandlingOptions = new HashMap<ChangesetProcessingType, JRadioButton>();
+            ChangesetProcessingTypeChangedAction a = new ChangesetProcessingTypeChangedAction();
+            for(ChangesetProcessingType type: ChangesetProcessingType.values()) {
+                rbChangesetHandlingOptions.put(type, new JRadioButton());
+                rbChangesetHandlingOptions.get(type).addActionListener(a);
+            }
+            JRadioButton rb = rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_NEW_AND_CLOSE);
+            rb.setText(tr("Use a new changeset and close it"));
+            rb.setToolTipText(tr("Select to upload the data using a new changeset and to close the changeset after the upload"));
+
+            rb = rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_NEW_AND_LEAVE_OPEN);
+            rb.setText(tr("Use a new changeset and leave it open"));
+            rb.setToolTipText(tr("Select to upload the data using a new changeset and to leave the changeset open after the upload"));
 
             pnl.add(new JLabel(tr("Upload to a new or to an existing changeset?")));
-            pnl.add(rbUseNewAndClose);
-            pnl.add(rbUseNewAndLeaveOpen);
-            pnl.add(rbUseExistingAndClose);
-            pnl.add(rbUseExistingAndLeaveOpen);
-
-            rbUseNewAndClose.setVisible(false);
-            rbUseNewAndLeaveOpen.setVisible(false);
-            rbUseExistingAndClose.setVisible(false);
-            rbUseExistingAndLeaveOpen.setVisible(false);
-
-            bgChangesetHandlingOptions.add(rbUseNewAndClose);
-            bgChangesetHandlingOptions.add(rbUseNewAndLeaveOpen);
-            bgChangesetHandlingOptions.add(rbUseExistingAndClose);
-            bgChangesetHandlingOptions.add(rbUseExistingAndLeaveOpen);
+            pnl.add(rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_NEW_AND_CLOSE));
+            pnl.add(rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_NEW_AND_LEAVE_OPEN));
+            pnl.add(rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_EXISTING_AND_CLOSE));
+            pnl.add(rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_EXISTING_AND_LEAVE_OPEN));
+
+            for(ChangesetProcessingType type: ChangesetProcessingType.values()) {
+                rbChangesetHandlingOptions.get(type).setVisible(false);
+                bgChangesetHandlingOptions.add(rbChangesetHandlingOptions.get(type));
+            }
             return pnl;
         }
@@ -682,5 +682,5 @@
             southTabbedPane.add(tagEditorPanel);
             southTabbedPane.setTitleAt(0, tr("Settings"));
-            southTabbedPane.setTitleAt(1, tr("Changeset Tags"));
+            southTabbedPane.setTitleAt(1, tr("Tags of new changeset"));
             JPanel pnl = new JPanel();
             pnl.setLayout(new BorderLayout());
@@ -765,52 +765,9 @@
             Main.pref.putCollection(HISTORY_KEY, cmt.getHistory());
             Main.pref.put("osm-server.atomic-upload", cbUseAtomicUpload.isSelected());
-
-            if (rbUseNewAndClose.isSelected()) {
-                changesetProcessingType = ChangesetProcessingType.USE_NEW_AND_CLOSE;
-            } else if (rbUseNewAndLeaveOpen.isSelected()) {
-                changesetProcessingType = ChangesetProcessingType.USE_NEW_AND_LEAVE_OPEN;
-            } else if (rbUseExistingAndClose.isSelected()) {
-                changesetProcessingType = ChangesetProcessingType.USE_EXISTING_AND_CLOSE;
-            } else if (rbUseExistingAndLeaveOpen.isSelected()) {
-                changesetProcessingType = ChangesetProcessingType.USE_EXISTING_AND_LEAVE_OPEN;
-            }
         }
 
         public void startUserInput() {
-            rbUseNewAndClose.setVisible(true);
-            rbUseNewAndLeaveOpen.setVisible(true);
-            if (OsmApi.getOsmApi().getCurrentChangeset() != null) {
-                Changeset cs = OsmApi.getOsmApi().getCurrentChangeset();
-                rbUseExistingAndClose.setVisible(true);
-                rbUseExistingAndLeaveOpen.setVisible(true);
-
-                rbUseExistingAndClose.setText(tr("Use the existing changeset {0} and close it after upload",cs.getId()));
-                rbUseExistingAndClose.setToolTipText(tr("Select to upload to the existing changeset {0} and to close the changeset after this upload",cs.getId()));
-
-                rbUseExistingAndLeaveOpen.setText(tr("Use the existing changeset {0} and leave it open",cs.getId()));
-                rbUseExistingAndLeaveOpen.setToolTipText(tr("Select to upload to the existing changeset {0} and to leave the changeset open for further uploads",cs.getId()));
-
-                if (changesetProcessingType == null) {
-                    rbUseNewAndClose.setSelected(true);
-                } else {
-                    switch(changesetProcessingType) {
-                        case USE_NEW_AND_CLOSE: rbUseNewAndClose.setSelected(true); break;
-                        case USE_NEW_AND_LEAVE_OPEN: rbUseNewAndLeaveOpen.setSelected(true); break;
-                        case USE_EXISTING_AND_CLOSE: rbUseExistingAndClose.setSelected(true); break;
-                        case USE_EXISTING_AND_LEAVE_OPEN: rbUseExistingAndLeaveOpen.setSelected(true); break;
-                    }
-                }
-            } else {
-                if (changesetProcessingType == null) {
-                    changesetProcessingType = ChangesetProcessingType.USE_NEW_AND_CLOSE;
-                }
-                rbUseExistingAndClose.setVisible(false);
-                rbUseExistingAndLeaveOpen.setVisible(false);
-                switch(changesetProcessingType) {
-                    case USE_NEW_AND_CLOSE: rbUseNewAndClose.setSelected(true); break;
-                    case USE_NEW_AND_LEAVE_OPEN: rbUseNewAndLeaveOpen.setSelected(true); break;
-                    default: rbUseNewAndClose.setSelected(true); break;
-                }
-            }
+            tagEditorPanel.initAutoCompletion(Main.main.getEditLayer());
+            initChangesetProcessingType();
             cmt.getEditor().selectAll();
             cmt.requestFocus();
@@ -818,6 +775,14 @@
 
         public ChangesetProcessingType getChangesetProcessingType() {
-            if (changesetProcessingType == null) return ChangesetProcessingType.USE_NEW_AND_CLOSE;
-            return changesetProcessingType;
+            ChangesetProcessingType changesetProcessingType = null;
+            for (ChangesetProcessingType type: ChangesetProcessingType.values()) {
+                if (rbChangesetHandlingOptions.get(type).isSelected()) {
+                    changesetProcessingType = type;
+                    break;
+                }
+            }
+            return changesetProcessingType == null ?
+                    ChangesetProcessingType.USE_NEW_AND_CLOSE :
+                        changesetProcessingType;
         }
 
@@ -828,4 +793,58 @@
             return changeset;
         }
+
+        protected void initChangesetProcessingType() {
+            for (ChangesetProcessingType type: ChangesetProcessingType.values()) {
+                // show options for new changeset, disable others
+                //
+                rbChangesetHandlingOptions.get(type).setVisible(type.isUseNew());
+            }
+            if (OsmApi.getOsmApi().getCurrentChangeset() != null) {
+                Changeset cs = OsmApi.getOsmApi().getCurrentChangeset();
+                for (ChangesetProcessingType type: ChangesetProcessingType.values()) {
+                    // show options for using existing changeset
+                    //
+                    if (!type.isUseNew()) {
+                        rbChangesetHandlingOptions.get(type).setVisible(true);
+                    }
+                }
+                JRadioButton rb = rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_EXISTING_AND_CLOSE);
+                rb.setText(tr("Use the existing changeset {0} and close it after upload",cs.getId()));
+                rb.setToolTipText(tr("Select to upload to the existing changeset {0} and to close the changeset after this upload",cs.getId()));
+
+                rb = rbChangesetHandlingOptions.get(ChangesetProcessingType.USE_EXISTING_AND_LEAVE_OPEN);
+                rb.setText(tr("Use the existing changeset {0} and leave it open",cs.getId()));
+                rb.setToolTipText(tr("Select to upload to the existing changeset {0} and to leave the changeset open for further uploads",cs.getId()));
+
+                rbChangesetHandlingOptions.get(getChangesetProcessingType()).setSelected(true);
+
+            } else {
+                ChangesetProcessingType type = getChangesetProcessingType();
+                if (!type.isUseNew()) {
+                    type = ChangesetProcessingType.USE_NEW_AND_CLOSE;
+                }
+                rbChangesetHandlingOptions.get(type).setSelected(true);
+            }
+        }
+
+        class ChangesetProcessingTypeChangedAction implements ActionListener {
+            public void actionPerformed(ActionEvent e) {
+                ChangesetProcessingType type = getChangesetProcessingType();
+                if (type.isUseNew()) {
+                    tagEditorPanel.setEnabled(true);
+                    southTabbedPane.setTitleAt(1, tr("Tags of new changeset"));
+                    cmt.setEnabled(true);
+                } else {
+                    tagEditorPanel.setEnabled(false);
+                    cmt.setEnabled(false);
+                    Changeset cs = OsmApi.getOsmApi().getCurrentChangeset();
+                    if (cs != null) {
+                        tagEditorPanel.getModel().initFromPrimitive(cs);
+                        southTabbedPane.setTitleAt(1, tr("Tags of changeset {0} (read-only)", cs.getId()));
+                        cmt.setText(cs.get("comment" == null ? "" : cs.get("comment")));
+                    }
+                }
+            }
+        }
     }
 }
Index: /trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorPanel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorPanel.java	(revision 2045)
+++ /trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorPanel.java	(revision 2046)
@@ -5,7 +5,10 @@
 
 import java.awt.BorderLayout;
+import java.awt.Component;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
 
 import javax.swing.AbstractAction;
@@ -17,11 +20,34 @@
 import javax.swing.event.ListSelectionListener;
 
+import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionCache;
+import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionList;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.tools.ImageProvider;
 
+/**
+ * TagEditorPanel is a {@see JPanel} which can be embedded as UI component in
+ * UIs. It provides a spreadsheet like tabular control for editing tag names
+ * and tag values. Two action buttons are placed on the left, one for additing
+ * a new tag and one for deleting the currently selected tags.
+ *
+ * 
+ */
 public class TagEditorPanel extends JPanel {
+    /** the tag editor model */
     private TagEditorModel model;
+    /** the tag table */
     private TagTable tagTable;
 
+    private AutoCompletionCache acCache;
+    private AutoCompletionList acList;
+
+
+    /**
+     * builds the panel with the table for editing tags
+     * 
+     * @return the panel
+     */
     protected JPanel buildTagTableEditorPanel() {
+
         JPanel pnl = new JPanel();
         model = new TagEditorModel();
@@ -33,4 +59,9 @@
     }
 
+    /**
+     * builds the panel with the button row
+     * 
+     * @return the panel
+     */
     protected JPanel buildButtonsPanel() {
         JPanel pnl = new JPanel();
@@ -41,4 +72,5 @@
         AddAction addAction = new AddAction();
         pnl.add(new JButton(addAction));
+        tagTable.addPropertyChangeListener(addAction);
 
         // delete action
@@ -46,8 +78,12 @@
         DeleteAction deleteAction = new DeleteAction();
         tagTable.getSelectionModel().addListSelectionListener(deleteAction);
+        tagTable.addPropertyChangeListener(deleteAction);
         pnl.add(new JButton(deleteAction));
         return pnl;
     }
 
+    /**
+     * builds the GUI
+     */
     protected void build() {
         setLayout(new GridBagLayout());
@@ -74,23 +110,51 @@
         add(tablePanel,gc);
     }
+
+    /**
+     * constructor
+     */
     public TagEditorPanel() {
         build();
     }
 
+    /**
+     * Replies the tag editor model used by this panel.
+     * 
+     * @return the tag editor model used by this panel
+     */
     public TagEditorModel getModel() {
         return model;
     }
 
-    class AddAction extends AbstractAction  {
+    /**
+     * The action for adding a tag
+     *
+     */
+    class AddAction extends AbstractAction implements PropertyChangeListener {
         public AddAction() {
             putValue(SMALL_ICON, ImageProvider.get("dialogs", "add"));
             putValue(SHORT_DESCRIPTION, tr("Add a new tag"));
-        }
+            updateEnabledState();
+        }
+
         public void actionPerformed(ActionEvent e) {
             model.appendNewTag();
         }
-    }
-
-    class DeleteAction extends AbstractAction implements ListSelectionListener {
+
+        protected void updateEnabledState() {
+            setEnabled(tagTable.isEnabled());
+        }
+
+        public void propertyChange(PropertyChangeEvent evt) {
+            updateEnabledState();
+        }
+    }
+
+    /**
+     * The action for deleting the currently selected tags
+     * 
+     *
+     */
+    class DeleteAction extends AbstractAction implements ListSelectionListener, PropertyChangeListener {
         public DeleteAction() {
             putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete"));
@@ -137,5 +201,5 @@
                     // should not happen
                     //
-                    throw new IllegalStateException("unexpected selected clolumn: getSelectedColumn() is "
+                    throw new IllegalStateException("unexpected selected column: getSelectedColumn() is "
                             + tagTable.getSelectedColumn());
             } else if (tagTable.getSelectedColumnCount() == 2) {
@@ -148,9 +212,35 @@
 
         public void updateEnabledState() {
-            setEnabled(tagTable.getSelectedRowCount() > 0 || tagTable.getSelectedColumnCount() >0);
+            setEnabled(tagTable.isEnabled() &&
+                    (tagTable.getSelectedRowCount() > 0 || tagTable.getSelectedColumnCount() >0));
         }
         public void valueChanged(ListSelectionEvent e) {
             updateEnabledState();
         }
+
+        public void propertyChange(PropertyChangeEvent evt) {
+            updateEnabledState();
+        }
+    }
+
+    public void initAutoCompletion(OsmDataLayer layer) {
+        // initialize the autocompletion infrastructure
+        //
+        acCache = AutoCompletionCache.getCacheForLayer(layer);
+        acCache.initFromJOSMDataset();
+        acList = new AutoCompletionList();
+
+        TagCellEditor editor = ((TagCellEditor) tagTable.getColumnModel().getColumn(0).getCellEditor());
+        editor.setAutoCompletionCache(acCache);
+        editor.setAutoCompletionList(acList);
+        editor = ((TagCellEditor) tagTable.getColumnModel().getColumn(1).getCellEditor());
+        editor.setAutoCompletionCache(acCache);
+        editor.setAutoCompletionList(acList);
+    }
+
+    @Override
+    public void setEnabled(boolean enabled) {
+        tagTable.setEnabled(enabled);
+        super.setEnabled(enabled);
     }
 }
