Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetTagsPanel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetTagsPanel.java	(revision 2973)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetTagsPanel.java	(revision 2974)
@@ -7,4 +7,5 @@
 
 import javax.swing.BorderFactory;
+import javax.swing.DefaultListSelectionModel;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
@@ -26,6 +27,9 @@
         setLayout(new BorderLayout());
         setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
+        DefaultListSelectionModel rowSelectionModel = new DefaultListSelectionModel();
+        DefaultListSelectionModel colSelectionModel = new DefaultListSelectionModel();
 
-        tblTags = new TagTable(model = new TagEditorModel());
+        model = new TagEditorModel(rowSelectionModel, colSelectionModel);
+        tblTags = new TagTable(model, rowSelectionModel, colSelectionModel);
         tblTags.setEnabled(false);
         add(new JScrollPane(tblTags), BorderLayout.CENTER);
Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java	(revision 2973)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java	(revision 2974)
@@ -26,4 +26,5 @@
 import java.util.Iterator;
 import java.util.List;
+import java.util.logging.Logger;
 
 import javax.swing.AbstractAction;
@@ -76,5 +77,5 @@
  */
 public class GenericRelationEditor extends RelationEditor  {
-    //static private final Logger logger = Logger.getLogger(GenericRelationEditor.class.getName());
+    static private final Logger logger = Logger.getLogger(GenericRelationEditor.class.getName());
 
     /** the tag table and its model */
Index: /trunk/src/org/openstreetmap/josm/gui/tagging/TagCellEditor.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/tagging/TagCellEditor.java	(revision 2973)
+++ /trunk/src/org/openstreetmap/josm/gui/tagging/TagCellEditor.java	(revision 2974)
@@ -10,7 +10,5 @@
 
 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionCache;
-import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPritority;
 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList;
-import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem;
 
 /**
@@ -26,6 +24,4 @@
     private AutoCompletingTextField editor = null;
     private TagModel currentTag = null;
-    private TagEditorModel tagEditorModel = null;
-    private int currentColumn = 0;
 
     /** the cache of auto completion items derived from the current JOSM data set */
@@ -99,5 +95,4 @@
         if (column == 0) {
             editor.setText(currentTag.getName());
-            currentColumn = 0;
             TagEditorModel model = (TagEditorModel)table.getModel();
             initAutoCompletionListForKeys(model, currentTag);
@@ -112,5 +107,4 @@
                 editor.setText("");
             }
-            currentColumn = 1;
             initAutoCompletionListForValues(currentTag.getName());
             return editor;
@@ -123,28 +117,4 @@
     public Object getCellEditorValue() {
         return editor.getText();
-    }
-
-    @Override
-    public void cancelCellEditing() {
-        super.cancelCellEditing();
-    }
-
-    @Override
-    public boolean stopCellEditing() {
-        if (tagEditorModel == null) {
-            logger.warning("no tag editor model set. Can't update edited values. Please set tag editor model first");
-            return super.stopCellEditing();
-        }
-
-        if (currentColumn == 0) {
-            tagEditorModel.updateTagName(currentTag, editor.getText());
-        } else if (currentColumn == 1){
-            if (currentTag.getValueCount() > 1 && ! editor.getText().equals("")) {
-                tagEditorModel.updateTagValue(currentTag, editor.getText());
-            } else if (currentTag.getValueCount() <= 1) {
-                tagEditorModel.updateTagValue(currentTag, editor.getText());
-            }
-        }
-        return super.stopCellEditing();
     }
 
@@ -180,12 +150,3 @@
         return editor;
     }
-
-    /**
-     * sets the tag editor model
-     *
-     * @param tagEditorModel  the tag editor model
-     */
-    public void setTagEditorModel(TagEditorModel tagEditorModel) {
-        this.tagEditorModel = tagEditorModel;
-    }
 }
Index: /trunk/src/org/openstreetmap/josm/gui/tagging/TagCellRenderer.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/tagging/TagCellRenderer.java	(revision 2973)
+++ /trunk/src/org/openstreetmap/josm/gui/tagging/TagCellRenderer.java	(revision 2974)
@@ -4,14 +4,11 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
-import java.awt.Color;
 import java.awt.Component;
 import java.awt.Font;
 import java.util.logging.Logger;
 
-import javax.swing.BorderFactory;
-import javax.swing.ImageIcon;
 import javax.swing.JLabel;
 import javax.swing.JTable;
-import javax.swing.border.Border;
+import javax.swing.UIManager;
 import javax.swing.border.EmptyBorder;
 import javax.swing.table.TableCellRenderer;
@@ -25,13 +22,5 @@
 public class TagCellRenderer extends JLabel implements TableCellRenderer  {
 
-    private static Logger logger = Logger.getLogger(TagCellRenderer.class.getName());
-
-    public static final Color BG_COLOR_SELECTED = new Color(143,170,255);
-    public static final Color BG_COLOR_HIGHLIGHTED = new Color(255,255,204);
-
-    public static final Border BORDER_EMPHASIZED = BorderFactory.createLineBorder(new Color(253,75,45));
-
-    /** the icon displayed for deleting a tag */
-    private ImageIcon deleteIcon = null;
+    private static final Logger logger = Logger.getLogger(TagCellRenderer.class.getName());
 
     private Font fontStandard = null;
@@ -39,5 +28,5 @@
 
     public TagCellRenderer() {
-        fontStandard = getFont();
+        fontStandard = UIManager.getFont("Table.font");
         fontItalic = fontStandard.deriveFont(Font.ITALIC);
         setOpaque(true);
@@ -67,5 +56,5 @@
             setText(tag.getValues().get(0));
         } else if (tag.getValueCount() >  1) {
-            setText(tr("<multiple>"));
+            setText(tr("multiple"));
             setFont(fontItalic);
         }
@@ -86,14 +75,11 @@
 
     /**
-     * renders the background color. The default color is white. It is
-     * set to {@see TableCellRenderer#BG_COLOR_HIGHLIGHTED} if this cell
-     * displays the tag which is suggested by the currently selected
-     * preset.
-     *
+     * renders the background color.
+     * 
      * @param tagModel the tag model
      * @param model the tag editor model
      */
     protected void renderBackgroundColor(TagModel tagModel, TagEditorModel model) {
-        setBackground(Color.WHITE); // standard color
+        setBackground(UIManager.getColor("Table.background")); // standard color
     }
 
@@ -117,5 +103,6 @@
         //
         if (isSelected){
-            setBackground(BG_COLOR_SELECTED);
+            setBackground(UIManager.getColor("Table.selectionBackground"));
+            setForeground(UIManager.getColor("Table.selectionForeground"));
         } else {
             renderBackgroundColor(getModel(table).get(rowIndex), getModel(table));
@@ -130,6 +117,4 @@
         if (hasFocus && isSelected) {
             if (table.getSelectedColumnCount() == 1 && table.getSelectedRowCount() == 1) {
-                boolean success = table.editCellAt(rowIndex, vColIndex);
-
                 if (table.getEditorComponent() != null) {
                     table.getEditorComponent().requestFocusInWindow();
Index: /trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java	(revision 2973)
+++ /trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java	(revision 2974)
@@ -15,4 +15,5 @@
 import java.util.logging.Logger;
 
+import javax.swing.DefaultListSelectionModel;
 import javax.swing.table.AbstractTableModel;
 
@@ -42,11 +43,15 @@
     private boolean dirty =  false;
     private PropertyChangeSupport propChangeSupport = null;
+    private DefaultListSelectionModel rowSelectionModel;
+    private DefaultListSelectionModel colSelectionModel;
 
     /**
      * constructor
      */
-    public TagEditorModel(){
+    public TagEditorModel(DefaultListSelectionModel rowSelectionModel, DefaultListSelectionModel colSelectionModel){
         tags = new ArrayList<TagModel>();
         propChangeSupport = new PropertyChangeSupport(this);
+        this.rowSelectionModel = rowSelectionModel;
+        this.colSelectionModel  = colSelectionModel;
     }
 
@@ -86,8 +91,27 @@
         switch(columnIndex) {
         case 0:
-        case 1: return tag;
+        case 1:
+            return tag;
 
         default:
             throw new IndexOutOfBoundsException("unexpected columnIndex: columnIndex=" + columnIndex);
+        }
+    }
+
+    @Override
+    public void setValueAt(Object value, int row, int col) {
+        TagModel tag = get(row);
+        if (tag == null) return;
+        switch(col) {
+        case 0:
+            updateTagName(tag, (String)value);
+            break;
+        case 1:
+            String v = (String)value;
+            if (tag.getValueCount() > 1 && ! v.equals("")) {
+                updateTagValue(tag, v);
+            } else if (tag.getValueCount() <= 1) {
+                updateTagValue(tag, v);
+            }
         }
     }
@@ -166,4 +190,5 @@
 
     public TagModel get(int idx) {
+        if (idx >= tags.size()) return null;
         TagModel tagModel = tags.get(idx);
         return tagModel;
@@ -453,5 +478,7 @@
             setDirty(true);
         }
-        fireTableDataChanged();
+        SelectionStateMemento memento = new SelectionStateMemento();
+        fireTableDataChanged();
+        memento.apply();
     }
 
@@ -469,5 +496,7 @@
             setDirty(true);
         }
-        fireTableDataChanged();
+        SelectionStateMemento memento = new SelectionStateMemento();
+        fireTableDataChanged();
+        memento.apply();
     }
 
@@ -480,3 +509,30 @@
         return dirty;
     }
+
+    class SelectionStateMemento {
+        private int rowMin;
+        private int rowMax;
+        private int colMin;
+        private int colMax;
+
+        public SelectionStateMemento() {
+            rowMin = rowSelectionModel.getMinSelectionIndex();
+            rowMax = rowSelectionModel.getMaxSelectionIndex();
+            colMin = colSelectionModel.getMinSelectionIndex();
+            colMax = colSelectionModel.getMaxSelectionIndex();
+        }
+
+        public void apply() {
+            rowSelectionModel.setValueIsAdjusting(true);
+            colSelectionModel.setValueIsAdjusting(true);
+            if (rowMin >= 0 && rowMax >=0) {
+                rowSelectionModel.setSelectionInterval(rowMin, rowMax);
+            }
+            if (colMin >=0 && colMax >= 0) {
+                colSelectionModel.setSelectionInterval(colMin, colMax);
+            }
+            rowSelectionModel.setValueIsAdjusting(false);
+            colSelectionModel.setValueIsAdjusting(false);
+        }
+    }
 }
Index: /trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorPanel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorPanel.java	(revision 2973)
+++ /trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorPanel.java	(revision 2974)
@@ -1,6 +1,4 @@
 // License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.gui.tagging;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
 
 import java.awt.BorderLayout;
@@ -8,30 +6,25 @@
 import java.awt.GridBagLayout;
 import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
+import java.util.logging.Logger;
 
-import javax.swing.AbstractAction;
 import javax.swing.BoxLayout;
+import javax.swing.DefaultListSelectionModel;
 import javax.swing.JButton;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
 
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionCache;
 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList;
-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
+ * and tag values. Two action buttons are placed on the left, one for adding
  * a new tag and one for deleting the currently selected tags.
- *
  *
  */
 public class TagEditorPanel extends JPanel {
+    static private final Logger logger = Logger.getLogger(TagEditorPanel.class.getName());
     /** the tag editor model */
     private TagEditorModel model;
@@ -50,6 +43,9 @@
 
         JPanel pnl = new JPanel();
-        model = new TagEditorModel();
-        tagTable = new TagTable(model);
+        DefaultListSelectionModel rowSelectionModel = new DefaultListSelectionModel();
+        DefaultListSelectionModel colSelectionModel = new DefaultListSelectionModel();
+
+        model = new TagEditorModel(rowSelectionModel, colSelectionModel);
+        tagTable = new TagTable(model, rowSelectionModel, colSelectionModel);
 
         pnl.setLayout(new BorderLayout());
@@ -69,17 +65,13 @@
         // add action
         //
-        AddAction addAction = new AddAction();
         JButton btn;
-        pnl.add(btn = new JButton(addAction));
+        pnl.add(btn = new JButton(tagTable.getAddAction()));
         btn.setMargin(new Insets(0,0,0,0));
-        tagTable.addPropertyChangeListener(addAction);
+        tagTable.addComponentNotStoppingCellEditing(btn);
 
         // delete action
-        //
-        DeleteAction deleteAction = new DeleteAction();
-        tagTable.getSelectionModel().addListSelectionListener(deleteAction);
-        tagTable.addPropertyChangeListener(deleteAction);
-        pnl.add(btn = new JButton(deleteAction));
+        pnl.add(btn = new JButton(tagTable.getDeleteAction()));
         btn.setMargin(new Insets(0,0,0,0));
+        tagTable.addComponentNotStoppingCellEditing(btn);
         return pnl;
     }
@@ -129,101 +121,4 @@
     }
 
-    /**
-     * 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();
-        }
-
-        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"));
-            putValue(SHORT_DESCRIPTION, tr("Delete the selection in the tag table"));
-            updateEnabledState();
-        }
-
-        public void actionPerformed(ActionEvent e) {
-            run();
-        }
-
-        /**
-         * delete a selection of tag names
-         */
-        protected void deleteTagNames() {
-            int[] rows = tagTable.getSelectedRows();
-            model.deleteTagNames(rows);
-        }
-
-        /**
-         * delete a selection of tag values
-         */
-        protected void deleteTagValues() {
-            int[] rows = tagTable.getSelectedRows();
-            model.deleteTagValues(rows);
-        }
-
-        /**
-         * delete a selection of tags
-         */
-        protected void deleteTags() {
-            model.deleteTags(tagTable.getSelectedRows());
-        }
-
-        public void run() {
-            if (!isEnabled())
-                return;
-            if (tagTable.getSelectedColumnCount() == 1) {
-                if (tagTable.getSelectedColumn() == 0) {
-                    deleteTagNames();
-                } else if (tagTable.getSelectedColumn() == 1) {
-                    deleteTagValues();
-                } else
-                    // should not happen
-                    //
-                    throw new IllegalStateException("unexpected selected column: getSelectedColumn() is "
-                            + tagTable.getSelectedColumn());
-            } else if (tagTable.getSelectedColumnCount() == 2) {
-                deleteTags();
-            }
-            if (model.getRowCount() == 0) {
-                model.ensureOneTag();
-            }
-        }
-
-        public void updateEnabledState() {
-            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
Index: /trunk/src/org/openstreetmap/josm/gui/tagging/TagTable.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/tagging/TagTable.java	(revision 2973)
+++ /trunk/src/org/openstreetmap/josm/gui/tagging/TagTable.java	(revision 2974)
@@ -4,20 +4,29 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.applet.Applet;
 import java.awt.AWTException;
+import java.awt.Component;
 import java.awt.Container;
 import java.awt.Dimension;
+import java.awt.KeyboardFocusManager;
 import java.awt.MouseInfo;
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.Robot;
+import java.awt.Window;
 import java.awt.event.ActionEvent;
 import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
 import java.awt.event.KeyListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.EventObject;
+import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.swing.AbstractAction;
-import javax.swing.Action;
+import javax.swing.CellEditor;
+import javax.swing.DefaultListSelectionModel;
 import javax.swing.JComponent;
 import javax.swing.JTable;
@@ -35,4 +44,5 @@
 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionCache;
 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList;
+import org.openstreetmap.josm.tools.ImageProvider;
 
 /**
@@ -40,12 +50,17 @@
  *
  */
-@SuppressWarnings("serial")
 public class TagTable extends JTable  {
 
-    private static Logger logger = Logger.getLogger(TagTable.class.getName());
+    private static final Logger logger = Logger.getLogger(TagTable.class.getName());
 
     /** the table cell editor used by this table */
     private TagCellEditor editor = null;
 
+    /** a list of components to which focus can be transferred withouth stopping
+     * cell editing this table.
+     */
+    private final CopyOnWriteArrayList<Component> doNotStopCellEditingWhenFocused = new CopyOnWriteArrayList<Component>();
+    private CellEditorRemover editorRemover;
+
     /**
      * The table has two columns. The first column is used for editing rendering and
@@ -54,6 +69,6 @@
      */
     static class TagTableColumnModel extends DefaultTableColumnModel {
-
-        public TagTableColumnModel() {
+        public TagTableColumnModel(DefaultListSelectionModel selectionModel) {
+            setSelectionModel(selectionModel);
             TableColumn col = null;
             TagCellRenderer renderer = new TagCellRenderer();
@@ -72,5 +87,4 @@
             col.setCellRenderer(renderer);
             addColumn(col);
-
         }
     }
@@ -85,6 +99,4 @@
      *   last cell in the table</li>
      * <ul>
-     *
-     * @author gubaer
      *
      */
@@ -167,4 +179,12 @@
     class DeleteAction extends RunnableAction implements ListSelectionListener {
 
+        public DeleteAction() {
+            putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete"));
+            putValue(SHORT_DESCRIPTION, tr("Delete the selection in the tag table"));
+            getSelectionModel().addListSelectionListener(this);
+            getColumnModel().getSelectionModel().addListSelectionListener(this);
+            updateEnabledState();
+        }
+
         /**
          * delete a selection of tag names
@@ -194,19 +214,10 @@
         }
 
-        /**
-         * constructor
-         */
-        public DeleteAction() {
-            putValue(Action.NAME, tr("Delete"));
-            getSelectionModel().addListSelectionListener(this);
-            getColumnModel().getSelectionModel().addListSelectionListener(this);
-        }
-
         @Override
         public void run() {
             if (!isEnabled())
                 return;
-            getCellEditor().stopCellEditing();
-            if (getSelectedColumnCount() == 1) {
+            switch(getSelectedColumnCount()) {
+            case 1:
                 if (getSelectedColumn() == 0) {
                     deleteTagNames();
@@ -216,8 +227,18 @@
                     // should not happen
                     //
-                    throw new IllegalStateException("unexpected selected clolumn: getSelectedColumn() is " + getSelectedColumn());
-            } else if (getSelectedColumnCount() == 2) {
+                    throw new IllegalStateException("unexpected selected column: getSelectedColumn() is " + getSelectedColumn());
+                break;
+            case 2:
                 deleteTags();
-            }
+                break;
+            }
+
+            if (isEditing()) {
+                CellEditor editor = getCellEditor();
+                if (editor != null) {
+                    editor.cancelCellEditing();
+                }
+            }
+
             TagEditorModel model = (TagEditorModel)getModel();
             if (model.getRowCount() == 0) {
@@ -231,4 +252,8 @@
          */
         public void valueChanged(ListSelectionEvent e) {
+            updateEnabledState();
+        }
+
+        protected void updateEnabledState() {
             if (isEditing() && getSelectedColumnCount() == 1 && getSelectedRowCount() == 1) {
                 setEnabled(false);
@@ -240,5 +265,4 @@
                 setEnabled(false);
             }
-
         }
     }
@@ -249,17 +273,30 @@
      *
      */
-    class AddAction extends RunnableAction {
-
+    class AddAction extends RunnableAction implements PropertyChangeListener{
         public AddAction() {
-            putValue(Action.NAME, tr("Add"));
+            putValue(SMALL_ICON, ImageProvider.get("dialogs", "add"));
+            putValue(SHORT_DESCRIPTION, tr("Add a new tag"));
+            TagTable.this.addPropertyChangeListener(this);
+            updateEnabledState();
         }
 
         @Override
         public void run() {
-            getCellEditor().stopCellEditing();
+            CellEditor editor = getCellEditor();
+            if (editor != null) {
+                getCellEditor().stopCellEditing();
+            }
             ((TagEditorModel)getModel()).appendNewTag();
             final int rowIdx = getModel().getRowCount()-1;
             requestFocusInCell(rowIdx, 0);
         }
+
+        protected void updateEnabledState() {
+            setEnabled(TagTable.this.isEnabled());
+        }
+
+        public void propertyChange(PropertyChangeEvent evt) {
+            updateEnabledState();
+        }
     }
 
@@ -287,7 +324,8 @@
     protected void init() {
         setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
-        setCellSelectionEnabled(true);
+        //setCellSelectionEnabled(true);
+        setRowSelectionAllowed(true);
+        setColumnSelectionAllowed(true);
         setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
-        putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
 
         // make ENTER behave like TAB
@@ -316,7 +354,14 @@
         //
         editor = new TagCellEditor();
-        editor.setTagEditorModel((TagEditorModel)getModel());
         getColumnModel().getColumn(0).setCellEditor(editor);
         getColumnModel().getColumn(1).setCellEditor(editor);
+
+        getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+
+            public void valueChanged(ListSelectionEvent e) {
+                ListSelectionModel rm = getSelectionModel();
+                ListSelectionModel cm = getColumnModel().getSelectionModel();
+            }
+        });
     }
 
@@ -327,6 +372,6 @@
      * @param columnModel
      */
-    public TagTable(TableModel model) {
-        super(model, new TagTableColumnModel());
+    public TagTable(TableModel model, DefaultListSelectionModel rowSelectionModel, DefaultListSelectionModel colSelectionModel) {
+        super(model, new TagTableColumnModel(colSelectionModel), rowSelectionModel);
         init();
     }
@@ -430,3 +475,103 @@
         }
     }
+
+    public void addComponentNotStoppingCellEditing(Component component) {
+        if (component == null) return;
+        doNotStopCellEditingWhenFocused.addIfAbsent(component);
+    }
+
+    public void removeComponentNotStoppingCellEditing(Component component) {
+        if (component == null) return;
+        doNotStopCellEditingWhenFocused.remove(component);
+    }
+
+    @Override
+    public boolean editCellAt(int row, int column, EventObject e){
+
+        // a snipped copied from the Java 1.5 implementation of JTable
+        //
+        if (cellEditor != null && !cellEditor.stopCellEditing())
+            return false;
+
+        if (row < 0 || row >= getRowCount() ||
+                column < 0 || column >= getColumnCount())
+            return false;
+
+        if (!isCellEditable(row, column))
+            return false;
+
+        // make sure our custom implementation of CellEditorRemover is created
+        if (editorRemover == null) {
+            KeyboardFocusManager fm =
+                KeyboardFocusManager.getCurrentKeyboardFocusManager();
+            editorRemover = new CellEditorRemover(fm);
+            fm.addPropertyChangeListener("permanentFocusOwner", editorRemover);
+        }
+
+        // delegate to the default implementation
+        return super.editCellAt(row, column,e);
+    }
+
+
+    @Override
+    public void removeEditor() {
+        // make sure we unregister our custom implementation of CellEditorRemover
+        KeyboardFocusManager.getCurrentKeyboardFocusManager().
+        removePropertyChangeListener("permanentFocusOwner", editorRemover);
+        editorRemover = null;
+        super.removeEditor();
+    }
+
+    @Override
+    public void removeNotify() {
+        // make sure we unregister our custom implementation of CellEditorRemover
+        KeyboardFocusManager.getCurrentKeyboardFocusManager().
+        removePropertyChangeListener("permanentFocusOwner", editorRemover);
+        editorRemover = null;
+        super.removeNotify();
+    }
+
+    /**
+     * This is a custom implementation of the CellEditorRemover used in JTable
+     * to handle the client property <tt>terminateEditOnFocusLost</tt>.
+     * 
+     * This implementation also checks whether focus is transferred to one of a list
+     * of dedicated components, see {@see TagTable#doNotStopCellEditingWhenFocused}.
+     * A typical example for such a component is a button in {@see TagEditorPanel}
+     * which isn't a child component of {@see TagTable} but which should respond to
+     * to focus transfer in a similar way to a child of TagTable.
+     *
+     */
+    class CellEditorRemover implements PropertyChangeListener {
+        KeyboardFocusManager focusManager;
+
+        public CellEditorRemover(KeyboardFocusManager fm) {
+            this.focusManager = fm;
+        }
+
+        public void propertyChange(PropertyChangeEvent ev) {
+            if (!isEditing())
+                return;
+
+            Component c = focusManager.getPermanentFocusOwner();
+            while (c != null) {
+                if (c == TagTable.this)
+                    // focus remains inside the table
+                    return;
+                if (doNotStopCellEditingWhenFocused.contains(c))
+                    // focus remains on one of the associated components
+                    return;
+                else if ((c instanceof Window) ||
+                        (c instanceof Applet && c.getParent() == null)) {
+                    if (c == SwingUtilities.getRoot(TagTable.this)) {
+                        if (!getCellEditor().stopCellEditing()) {
+                            getCellEditor().cancelCellEditing();
+                        }
+                    }
+                    break;
+                }
+                c = c.getParent();
+            }
+        }
+    }
 }
Index: /trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionCache.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionCache.java	(revision 2973)
+++ /trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionCache.java	(revision 2974)
@@ -147,10 +147,14 @@
                 if (item instanceof TaggingPreset.Check) {
                     TaggingPreset.Check ch = (TaggingPreset.Check) item;
-                    if (ch.key == null) continue;
+                    if (ch.key == null) {
+                        continue;
+                    }
                     presetTagCache.put(ch.key, OsmUtils.falseval);
                     presetTagCache.put(ch.key, OsmUtils.trueval);
                 } else if (item instanceof TaggingPreset.Combo) {
                     TaggingPreset.Combo co = (TaggingPreset.Combo) item;
-                    if (co.key == null || co.values == null) continue;
+                    if (co.key == null || co.values == null) {
+                        continue;
+                    }
                     for (String value : co.values.split(",")) {
                         presetTagCache.put(co.key, value);
@@ -158,9 +162,13 @@
                 } else if (item instanceof TaggingPreset.Key) {
                     TaggingPreset.Key ky = (TaggingPreset.Key) item;
-                    if (ky.key == null || ky.value == null) continue;
+                    if (ky.key == null || ky.value == null) {
+                        continue;
+                    }
                     presetTagCache.put(ky.key, ky.value);
                 } else if (item instanceof TaggingPreset.Text) {
                     TaggingPreset.Text tt = (TaggingPreset.Text) item;
-                    if (tt.key == null) continue;
+                    if (tt.key == null) {
+                        continue;
+                    }
                     presetTagCache.putVoid(tt.key);
                     if (tt.default_ != null && !tt.default_.equals("")) {
@@ -171,5 +179,5 @@
         }
     }
-    
+
     /**
      * replies the keys held by the cache
