Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java	(revision 9501)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java	(revision 9502)
@@ -87,5 +87,6 @@
  * @since 5633
  */
-class TagEditHelper {
+public class TagEditHelper {
+
     private final JTable tagTable;
     private final DefaultTableModel tagData;
@@ -93,5 +94,5 @@
 
     // Selection that we are editing by using both dialogs
-    private Collection<OsmPrimitive> sel;
+    protected Collection<OsmPrimitive> sel;
 
     private String changedKey;
@@ -108,6 +109,16 @@
     private String lastAddValue;
 
+    /** Default number of recent tags */
     public static final int DEFAULT_LRU_TAGS_NUMBER = 5;
+    /** Maximum number of recent tags */
     public static final int MAX_LRU_TAGS_NUMBER = 30;
+
+    /** Use English language for tag by default */
+    public static final BooleanProperty PROPERTY_FIX_TAG_LOCALE = new BooleanProperty("properties.fix-tag-combobox-locale", false);
+    /** Whether recent tags must be remembered */
+    public static final BooleanProperty PROPERTY_REMEMBER_TAGS = new BooleanProperty("properties.remember-recently-added-tags", true);
+    /** Number of recent tags */
+    public static final IntegerProperty PROPERTY_RECENT_TAGS_NUMBER = new IntegerProperty("properties.recently-added-tags",
+            DEFAULT_LRU_TAGS_NUMBER);
 
     // LRU cache for recently added tags (http://java-planet.blogspot.com/2005/08/how-to-set-up-simple-lru-cache-using.html)
@@ -119,5 +130,5 @@
     };
 
-    TagEditHelper(JTable tagTable, DefaultTableModel propertyData, Map<String, Map<String, Integer>> valueCount) {
+    public TagEditHelper(JTable tagTable, DefaultTableModel propertyData, Map<String, Map<String, Integer>> valueCount) {
         this.tagTable = tagTable;
         this.tagData = propertyData;
@@ -141,7 +152,8 @@
         changedKey = null;
         sel = Main.main.getInProgressSelection();
-        if (sel == null || sel.isEmpty()) return;
-
-        final AddTagsDialog addDialog = new AddTagsDialog();
+        if (sel == null || sel.isEmpty())
+            return;
+
+        final AddTagsDialog addDialog = getAddTagsDialog();
 
         addDialog.showDialog();
@@ -152,4 +164,8 @@
         else
             addDialog.undoAllTagsAdding();
+    }
+
+    protected AddTagsDialog getAddTagsDialog() {
+        return new AddTagsDialog();
     }
 
@@ -163,13 +179,27 @@
         changedKey = null;
         sel = Main.main.getInProgressSelection();
-        if (sel == null || sel.isEmpty()) return;
+        if (sel == null || sel.isEmpty())
+            return;
 
         String key = getDataKey(row);
         objKey = key;
 
-        final EditTagDialog editDialog = new EditTagDialog(key, getDataValues(row), focusOnKey);
+        final IEditTagDialog editDialog = getEditTagDialog(row, focusOnKey, key);
         editDialog.showDialog();
-        if (editDialog.getValue() != 1) return;
+        if (editDialog.getValue() != 1)
+            return;
         editDialog.performTagEdit();
+    }
+
+    protected interface IEditTagDialog {
+        ExtendedDialog showDialog();
+
+        int getValue();
+
+        void performTagEdit();
+    }
+
+    protected IEditTagDialog getEditTagDialog(int row, boolean focusOnKey, String key) {
+        return new EditTagDialog(key, getDataValues(row), focusOnKey);
     }
 
@@ -251,5 +281,5 @@
     }
 
-    public final class EditTagDialog extends AbstractTagsDialog {
+    protected class EditTagDialog extends AbstractTagsDialog implements IEditTagDialog {
         private final String key;
         private final transient Map<String, Integer> m;
@@ -278,7 +308,7 @@
                     String str = value.getValue();
                     if (valueCount.containsKey(objKey)) {
-                        Map<String, Integer> m = valueCount.get(objKey);
-                        if (m.containsKey(str)) {
-                            str = tr("{0} ({1})", str, m.get(str));
+                        Map<String, Integer> map = valueCount.get(objKey);
+                        if (map.containsKey(str)) {
+                            str = tr("{0} ({1})", str, map.get(str));
                             c.setFont(c.getFont().deriveFont(Font.ITALIC + Font.BOLD));
                         }
@@ -290,5 +320,5 @@
         };
 
-        private EditTagDialog(String key, Map<String, Integer> map, final boolean initialFocusOnKey) {
+        protected EditTagDialog(String key, Map<String, Integer> map, final boolean initialFocusOnKey) {
             super(Main.parent, trn("Change value?", "Change values?", map.size()), new String[] {tr("OK"), tr("Cancel")});
             setButtonIcons(new String[] {"ok", "cancel"});
@@ -366,5 +396,6 @@
          * Confirmations may be needed.
          */
-        private void performTagEdit() {
+        @Override
+        public void performTagEdit() {
             String value = Tag.removeWhiteSpaces(values.getEditor().getItem().toString());
             value = Normalizer.normalize(value, java.text.Normalizer.Form.NFC);
@@ -425,10 +456,5 @@
     }
 
-    public static final BooleanProperty PROPERTY_FIX_TAG_LOCALE = new BooleanProperty("properties.fix-tag-combobox-locale", false);
-    public static final BooleanProperty PROPERTY_REMEMBER_TAGS = new BooleanProperty("properties.remember-recently-added-tags", true);
-    public static final IntegerProperty PROPERTY_RECENT_TAGS_NUMBER = new IntegerProperty("properties.recently-added-tags",
-            DEFAULT_LRU_TAGS_NUMBER);
-
-    abstract class AbstractTagsDialog extends ExtendedDialog {
+    protected abstract class AbstractTagsDialog extends ExtendedDialog {
         protected AutoCompletingComboBox keys;
         protected AutoCompletingComboBox values;
@@ -546,11 +572,12 @@
     }
 
-    class AddTagsDialog extends AbstractTagsDialog {
+    protected class AddTagsDialog extends AbstractTagsDialog {
         private final List<JosmAction> recentTagsActions = new ArrayList<>();
+        protected final transient FocusAdapter focus;
 
         // Counter of added commands for possible undo
         private int commandCount;
 
-        AddTagsDialog() {
+        protected AddTagsDialog() {
             super(Main.parent, tr("Add value?"), new String[] {tr("OK"), tr("Cancel")});
             setButtonIcons(new String[] {"ok", "cancel"});
@@ -604,12 +631,7 @@
             }
 
-            FocusAdapter focus = addFocusAdapter(autocomplete, defaultACItemComparator);
+            focus = addFocusAdapter(autocomplete, defaultACItemComparator);
             // fire focus event in advance or otherwise the popup list will be too small at first
             focus.focusGained(null);
-
-            int recentTagsToShow = PROPERTY_RECENT_TAGS_NUMBER.get();
-            if (recentTagsToShow > MAX_LRU_TAGS_NUMBER) {
-                recentTagsToShow = MAX_LRU_TAGS_NUMBER;
-            }
 
             // Add tag on Shift-Enter
@@ -624,5 +646,5 @@
                 });
 
-            suggestRecentlyAddedTags(mainPanel, recentTagsToShow, focus);
+            suggestRecentlyAddedTags(mainPanel, focus);
 
             mainPanel.add(Box.createVerticalGlue(), GBC.eop().fill());
@@ -641,7 +663,8 @@
                 @Override
                 public void actionPerformed(ActionEvent e) {
-                    boolean sel = ((JCheckBoxMenuItem) e.getSource()).getState();
-                    PROPERTY_REMEMBER_TAGS.put(sel);
-                    if (sel) saveTagsIfNeeded();
+                    boolean state = ((JCheckBoxMenuItem) e.getSource()).getState();
+                    PROPERTY_REMEMBER_TAGS.put(state);
+                    if (state)
+                        saveTagsIfNeeded();
                 }
             });
@@ -674,5 +697,5 @@
         }
 
-        private void selectNumberOfTags() {
+        protected void selectNumberOfTags() {
             String s = JOptionPane.showInputDialog(this, tr("Please enter the number of recently added tags to display"));
             if (s == null) {
@@ -691,5 +714,6 @@
         }
 
-        private void suggestRecentlyAddedTags(JPanel mainPanel, int tagsToShow, final FocusAdapter focus) {
+        protected void suggestRecentlyAddedTags(JPanel mainPanel, final FocusAdapter focus) {
+            final int tagsToShow = Math.max(PROPERTY_RECENT_TAGS_NUMBER.get(), MAX_LRU_TAGS_NUMBER);
             if (!(tagsToShow > 0 && !recentTags.isEmpty()))
                 return;
@@ -816,6 +840,7 @@
             String key = Tag.removeWhiteSpaces(keys.getEditor().getItem().toString());
             String value = Tag.removeWhiteSpaces(values.getEditor().getItem().toString());
-            if (key.isEmpty() || value.isEmpty()) return;
-            for (OsmPrimitive osm: sel) {
+            if (key.isEmpty() || value.isEmpty())
+                return;
+            for (OsmPrimitive osm : sel) {
                 String val = osm.get(key);
                 if (val != null && !val.equals(value)) {
@@ -833,4 +858,8 @@
             Main.main.undoRedo.add(new ChangePropertyCommand(sel, key, value));
             changedKey = key;
+            clearEntries();
+        }
+
+        protected void clearEntries() {
             keys.getEditor().setItem("");
             values.getEditor().setItem("");
