Index: /trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java	(revision 4339)
+++ /trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java	(revision 4340)
@@ -118,8 +118,11 @@
 
     public static abstract class Item {
+
         protected void initAutoCompletionField(AutoCompletingTextField field, String key) {
             OsmDataLayer layer = Main.main.getEditLayer();
-            if (layer == null) return;
-            AutoCompletionList list  = new AutoCompletionList();
+            if (layer == null) {
+                return;
+            }
+            AutoCompletionList list = new AutoCompletionList();
             Main.main.getEditLayer().data.getAutoCompletionManager().populateWithTagValues(list, key);
             field.setAutoCompletionList(list);
@@ -127,6 +130,10 @@
 
         abstract boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel);
+
         abstract void addCommands(List<Tag> changedTags);
-        boolean requestFocusInWindow() {return false;}
+
+        boolean requestFocusInWindow() {
+            return false;
+        }
     }
 
@@ -140,5 +147,5 @@
 
         public boolean unused() {
-            return values.size() == 0;
+            return values.isEmpty();
         }
         public String getFirst() {
@@ -290,22 +297,30 @@
         }
 
-        @Override public void addCommands(List<Tag> changedTags) {
+        @Override
+        public void addCommands(List<Tag> changedTags) {
 
             // return if unchanged
-            String v = (value instanceof JComboBox) ?
-                    ((JComboBox)value).getEditor().getItem().toString() :
-                        ((JTextField)value).getText();
-
-                    if (!"false".equals(use_last_as_default)) {
-                        lastValue.put(key, v);
-                    }
-                    if (v.equals(originalValue) || (originalValue == null && v.length() == 0)) return;
-
-                    if (delete_if_empty && v.length() == 0) {
-                        v = null;
-                    }
-                    changedTags.add(new Tag(key, v));
-        }
-        @Override boolean requestFocusInWindow() {return value.requestFocusInWindow();}
+            String v = (value instanceof JComboBox)
+                    ? ((JComboBox) value).getEditor().getItem().toString()
+                    : ((JTextField) value).getText();
+            v = v.trim();
+
+            if (!"false".equals(use_last_as_default)) {
+                lastValue.put(key, v);
+            }
+            if (v.equals(originalValue) || (originalValue == null && v.length() == 0)) {
+                return;
+            }
+
+            if (delete_if_empty && v.length() == 0) {
+                v = null;
+            }
+            changedTags.add(new Tag(key, v));
+        }
+
+        @Override
+        boolean requestFocusInWindow() {
+            return value.requestFocusInWindow();
+        }
     }
 
@@ -395,275 +410,5 @@
     }
 
-    public static class Combo extends Item {
-
-        public String key;
-        public String text;
-        public String text_context;
-        public String locale_text;
-        public String values;
-        public String values_context;
-        public String display_values;
-        public String locale_display_values;
-        public String short_descriptions;
-        public String locale_short_descriptions;
-        public String default_;
-        public boolean delete_if_empty = false;
-        public boolean editable = true;
-        public String use_last_as_default = "false";
-        public boolean required = false;
-
-        private List<String> short_description_list;
-        private JComboBox combo;
-        private Map<String, PresetListEntry> lhm;
-        private Usage usage;
-        private PresetListEntry originalValue;
-
-        @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
-
-            // find out if our key is already used in the selection.
-            usage = determineTextUsage(sel, key);
-            String def = default_;
-
-            String[] value_array = splitEscaped(',', values);
-            String[] display_array;
-            String[] short_descriptions_array = null;
-
-            if(locale_display_values != null) {
-                display_array = splitEscaped(',', locale_display_values);
-            } else if (display_values != null) {
-                display_array = splitEscaped(',', display_values);
-            } else {
-                display_array = value_array;
-            }
-
-            if (locale_short_descriptions != null) {
-                short_descriptions_array = splitEscaped(',', locale_short_descriptions);
-            } else if (short_descriptions != null) {
-                short_descriptions_array = splitEscaped(',', short_descriptions);
-            } else if (short_description_list != null) {
-                short_descriptions_array = short_description_list.toArray(new String[0]);
-            }
-
-            if (!"false".equals(use_last_as_default) && def == null && lastValue.containsKey(key)) {
-                def = lastValue.get(key);
-            }
-
-            if (display_array.length != value_array.length) {
-                System.err.println(tr("Broken tagging preset \"{0}-{1}\" - number of items in ''display_values'' must be the same as in ''values''", key, text));
-                display_array = value_array;
-            }
-
-            if (short_descriptions_array != null && short_descriptions_array.length != value_array.length) {
-                System.err.println(tr("Broken tagging preset \"{0}-{1}\" - number of items in ''short_descriptions'' must be the same as in ''values''", key, text));
-                short_descriptions_array = null;
-            }
-
-            lhm = new LinkedHashMap<String, PresetListEntry>();
-            if (!usage.hasUniqueValue() && !usage.unused()) {
-                lhm.put(DIFFERENT, new PresetListEntry(DIFFERENT));
-            }
-            for (int i=0; i<value_array.length; i++) {
-                PresetListEntry e = new PresetListEntry(value_array[i]);
-                e.display_value = (locale_display_values == null)
-                ? (values_context == null ? tr(fixPresetString(display_array[i]))
-                        : trc(values_context, fixPresetString(display_array[i]))) : display_array[i];
-                if (short_descriptions_array != null) {
-                    e.short_description = locale_short_descriptions == null ? tr(fixPresetString(short_descriptions_array[i]))
-                            : fixPresetString(short_descriptions_array[i]);
-                }
-                lhm.put(value_array[i], e);
-            }
-            if(!usage.unused()){
-                for (String s : usage.values) {
-                    if (!lhm.containsKey(s)) {
-                        lhm.put(s, new PresetListEntry(s));
-                    }
-                }
-            }
-            if (def != null && !lhm.containsKey(def)) {
-                lhm.put(def, new PresetListEntry(def));
-            }
-            lhm.put("", new PresetListEntry(""));
-
-            combo = new JComboBox(lhm.values().toArray());
-            combo.setRenderer(new PresetComboListCellRenderer());
-            combo.setEditable(editable);
-            combo.setMaximumRowCount(13);
-            AutoCompletingTextField tf = new AutoCompletingTextField();
-            initAutoCompletionField(tf, key);
-            tf.getAutoCompletionList().add(Arrays.asList(display_array), AutoCompletionItemPritority.IS_IN_STANDARD);
-            combo.setEditor(tf);
-
-            if (usage.hasUniqueValue()) {
-                // all items have the same value (and there were no unset items)
-                originalValue=lhm.get(usage.getFirst());
-                combo.setSelectedItem(originalValue);
-            }
-            else if (def != null && usage.unused()) {
-                // default is set and all items were unset
-                if (!usage.hadKeys() || PROP_FILL_DEFAULT.get() || "force".equals(use_last_as_default)) {
-                    // selected osm primitives are untagged or filling default feature is enabled
-                    combo.setSelectedItem(def);
-                } else {
-                    // selected osm primitives are tagged and filling default feature is disabled
-                    combo.setSelectedItem("");
-                }
-                originalValue=lhm.get(DIFFERENT);
-            }
-            else if (usage.unused()) {
-                // all items were unset (and so is default)
-                originalValue=lhm.get("");
-                combo.setSelectedItem(originalValue);
-            }
-            else {
-                originalValue=lhm.get(DIFFERENT);
-                combo.setSelectedItem(originalValue);
-            }
-
-            if(locale_text == null) {
-                if(text_context != null) {
-                    locale_text = trc(text_context, fixPresetString(text));
-                } else {
-                    locale_text = tr(fixPresetString(text));
-                }
-            }
-            p.add(new JLabel(locale_text+":"), GBC.std().insets(0,0,10,0));
-            p.add(combo, GBC.eol().fill(GBC.HORIZONTAL));
-            return true;
-        }
-
-
-        private static class PresetComboListCellRenderer implements ListCellRenderer {
-
-            HtmlPanel lbl;
-            JComponent dummy = new JComponent() {};
-
-            public PresetComboListCellRenderer() {
-                lbl = new HtmlPanel();
-            }
-
-            public Component getListCellRendererComponent(
-                    JList list,
-                    Object value,
-                    int index,
-                    boolean isSelected,
-                    boolean cellHasFocus)
-            {
-                if (isSelected) {
-                    lbl.setBackground(list.getSelectionBackground());
-                    lbl.setForeground(list.getSelectionForeground());
-                } else {
-                    lbl.setBackground(list.getBackground());
-                    lbl.setForeground(list.getForeground());
-                }
-
-                PresetListEntry item = (PresetListEntry) value;
-                String s = item.getListDisplay();
-                lbl.setText(s);
-                // We do not want the editor to have the maximum height of all
-                // entries. Return a dummy with bogus height.
-                if (index == -1) {
-                    dummy.setPreferredSize(new Dimension(lbl.getPreferredSize().width, 10));
-                    return dummy;
-                }
-                return lbl;
-            }
-        }
-
-        @Override public void addCommands(List<Tag> changedTags) {
-            Object obj = combo.getSelectedItem();
-            String display = (obj == null) ? null : obj.toString();
-            String value = null;
-            if(display == null && combo.isEditable()) {
-                display = combo.getEditor().getItem().toString();
-            }
-
-            if (display != null)
-            {
-                for (String key : lhm.keySet()) {
-                    String k = lhm.get(key).toString();
-                    if (k != null && k.equals(display)) {
-                        value=key;
-                    }
-                }
-                if(value == null) {
-                    value = display;
-                }
-            } else {
-                value = "";
-            }
-
-            // no change if same as before
-            if (originalValue == null) {
-                if (value.length() == 0)
-                    return;
-            } else if (value.equals(originalValue.toString()))
-                return;
-
-            if (delete_if_empty && value.length() == 0) {
-                value = null;
-            }
-            if (!"false".equals(use_last_as_default)) {
-                lastValue.put(key, value);
-            }
-            changedTags.add(new Tag(key, value));
-        }
-
-        public void setShort_description(String s) {
-            if (short_description_list == null) {
-                short_description_list = new ArrayList<String>();
-            }
-            short_description_list.add(tr(s));
-        }
-
-        @Override boolean requestFocusInWindow() {return combo.requestFocusInWindow();}
-    }
-
-    /**
-     * Class that allows list values to be assigned and retrived as a comma-delimited
-     * string.
-     */
-    public static class ConcatenatingJList extends JList {
-        private String delimiter;
-        public ConcatenatingJList(String del, Object[] o) {
-            super(o);
-            delimiter = del;
-        }
-        public void setSelectedItem(Object o) {
-            if (o == null) {
-                clearSelection();
-            } else {
-                String s = o.toString();
-                HashSet<String> parts = new HashSet<String>(Arrays.asList(s.split(delimiter)));
-                ListModel lm = getModel();
-                int[] intParts = new int[lm.getSize()];
-                int j = 0;
-                for (int i = 0; i < lm.getSize(); i++) {
-                    if (parts.contains((((PresetListEntry)lm.getElementAt(i)).value))) {
-                        intParts[j++]=i;
-                    }
-                }
-                setSelectedIndices(Arrays.copyOf(intParts, j));
-                // check if we have acutally managed to represent the full
-                // value with our presets. if not, cop out; we will not offer
-                // a selection list that threatens to ruin the value.
-                setEnabled(s.equals(getSelectedItem()));
-            }
-        }
-        public String getSelectedItem() {
-            ListModel lm = getModel();
-            int[] si = getSelectedIndices();
-            StringBuilder builder = new StringBuilder();
-            for (int i=0; i<si.length; i++) {
-                if (i>0) {
-                    builder.append(delimiter);
-                }
-                builder.append(((PresetListEntry)lm.getElementAt(si[i])).value);
-            }
-            return builder.toString();
-        }
-    }
-
-    public static class MultiSelect extends Item {
+    public static abstract class ComboMultiSelect extends Item {
 
         public String key;
@@ -682,13 +427,16 @@
         public String use_last_as_default = "false";
         public boolean required = false;
-        public long rows = -1;
-
-        private List<String> short_description_list;
-        private ConcatenatingJList list;
-        private Map<String, PresetListEntry> lhm;
-        private Usage usage;
-        private String originalValue;
-
-        @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
+
+        protected List<String> short_description_list;
+        protected JComponent component;
+        protected Map<String, PresetListEntry> lhm;
+        protected Usage usage;
+        protected Object originalValue;
+
+        protected abstract Object getSelectedItem();
+        protected abstract void addToPanelAnchor(JPanel p, String def, String[] display_array);
+
+        @Override
+        public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
 
             // find out if our key is already used in the selection.
@@ -697,5 +445,5 @@
 
             char delChar = ';';
-            if (delimiter.length() > 0) {
+            if (!delimiter.isEmpty()) {
                 delChar = delimiter.charAt(0);
             }
@@ -739,39 +487,18 @@
                 lhm.put(DIFFERENT, new PresetListEntry(DIFFERENT));
             }
-            for (int i=0; i<value_array.length; i++) {
+            for (int i = 0; i < value_array.length; i++) {
                 PresetListEntry e = new PresetListEntry(value_array[i]);
                 e.display_value = (locale_display_values == null)
-                ? (values_context == null ? tr(fixPresetString(display_array[i]))
+                        ? (values_context == null ? tr(fixPresetString(display_array[i]))
                         : trc(values_context, fixPresetString(display_array[i]))) : display_array[i];
                 if (short_descriptions_array != null) {
                     e.short_description = locale_short_descriptions == null ? tr(fixPresetString(short_descriptions_array[i]))
-                            : short_descriptions_array[i];
+                            : fixPresetString(short_descriptions_array[i]);
                 }
                 lhm.put(value_array[i], e);
             }
 
-            list = new ConcatenatingJList(delimiter, lhm.values().toArray());
-            PresetListCellRenderer renderer = new PresetListCellRenderer();
-            list.setCellRenderer(renderer);
-
-            if (usage.hasUniqueValue() && !usage.unused()) {
-                originalValue=usage.getFirst();
-                list.setSelectedItem(originalValue);
-            }
-            else if (def != null && !usage.hadKeys() || PROP_FILL_DEFAULT.get() || "force".equals(use_last_as_default)) {
-                originalValue=DIFFERENT;
-                list.setSelectedItem(def);
-            }
-            else if (usage.unused()) {
-                originalValue=null;
-                list.setSelectedItem(originalValue);
-            }
-            else {
-                originalValue=DIFFERENT;
-                list.setSelectedItem(originalValue);
-            }
-
             if (locale_text == null) {
-                if(text_context != null) {
+                if (text_context != null) {
                     locale_text = trc(text_context, fixPresetString(text));
                 } else {
@@ -779,10 +506,258 @@
                 }
             }
-            p.add(new JLabel(locale_text+":"), GBC.std().insets(0,0,10,0));
+            p.add(new JLabel(locale_text + ":"), GBC.std().insets(0, 0, 10, 0));
+
+            addToPanelAnchor(p, def, display_array);
+
+            return true;
+
+        }
+
+        protected String getDisplayIfNull(String display) {
+            return display;
+        }
+
+        @Override
+        public void addCommands(List<Tag> changedTags) {
+            Object obj = getSelectedItem();
+            String display = (obj == null) ? null : obj.toString();
+            String value = null;
+            if (display == null) {
+                display = getDisplayIfNull(display);
+            }
+
+            if (display != null) {
+                for (String key : lhm.keySet()) {
+                    String k = lhm.get(key).toString();
+                    if (k != null && k.equals(display)) {
+                        value = key;
+                    }
+                }
+                if (value == null) {
+                    value = display;
+                }
+            } else {
+                value = "";
+            }
+            value = value.trim();
+
+            // no change if same as before
+            if (originalValue == null) {
+                if (value.length() == 0) {
+                    return;
+                }
+            } else if (value.equals(originalValue.toString())) {
+                return;
+            }
+
+            if (delete_if_empty && value.length() == 0) {
+                value = null;
+            }
+            if (!"false".equals(use_last_as_default)) {
+                lastValue.put(key, value);
+            }
+            changedTags.add(new Tag(key, value));
+        }
+
+        public void setShort_description(String s) {
+            if (short_description_list == null) {
+                short_description_list = new ArrayList<String>();
+            }
+            short_description_list.add(tr(s));
+        }
+
+        @Override
+        boolean requestFocusInWindow() {
+            return component.requestFocusInWindow();
+        }
+
+        protected ListCellRenderer getListCellRenderer() {
+            return new ListCellRenderer() {
+
+                HtmlPanel lbl = new HtmlPanel();
+                JComponent dummy = new JComponent() {
+                };
+
+                public Component getListCellRendererComponent(
+                        JList list,
+                        Object value,
+                        int index,
+                        boolean isSelected,
+                        boolean cellHasFocus) {
+                    if (isSelected) {
+                        lbl.setBackground(list.getSelectionBackground());
+                        lbl.setForeground(list.getSelectionForeground());
+                    } else {
+                        lbl.setBackground(list.getBackground());
+                        lbl.setForeground(list.getForeground());
+                    }
+
+                    PresetListEntry item = (PresetListEntry) value;
+                    String s = item.getListDisplay();
+                    lbl.setText(s);
+                    lbl.setEnabled(list.isEnabled());
+                    // We do not want the editor to have the maximum height of all
+                    // entries. Return a dummy with bogus height.
+                    if (index == -1) {
+                        dummy.setPreferredSize(new Dimension(lbl.getPreferredSize().width, 10));
+                        return dummy;
+                    }
+                    return lbl;
+                }
+            };
+        }
+    }
+
+    public static class Combo extends ComboMultiSelect {
+
+        public boolean editable = true;
+        protected JComboBox combo;
+
+        public Combo() {
+            delimiter = ",";
+        }
+
+        @Override
+        protected void addToPanelAnchor(JPanel p, String def, String[] display_array) {
+            if (!usage.unused()) {
+                for (String s : usage.values) {
+                    if (!lhm.containsKey(s)) {
+                        lhm.put(s, new PresetListEntry(s));
+                    }
+                }
+            }
+            if (def != null && !lhm.containsKey(def)) {
+                lhm.put(def, new PresetListEntry(def));
+            }
+            lhm.put("", new PresetListEntry(""));
+
+            combo = new JComboBox(lhm.values().toArray());
+            component = combo;
+            combo.setRenderer(getListCellRenderer());
+            combo.setEditable(editable);
+            combo.setMaximumRowCount(13);
+            AutoCompletingTextField tf = new AutoCompletingTextField();
+            initAutoCompletionField(tf, key);
+            tf.getAutoCompletionList().add(Arrays.asList(display_array), AutoCompletionItemPritority.IS_IN_STANDARD);
+            combo.setEditor(tf);
+
+            if (usage.hasUniqueValue()) {
+                // all items have the same value (and there were no unset items)
+                originalValue = lhm.get(usage.getFirst());
+                combo.setSelectedItem(originalValue);
+            } else if (def != null && usage.unused()) {
+                // default is set and all items were unset
+                if (!usage.hadKeys() || PROP_FILL_DEFAULT.get() || "force".equals(use_last_as_default)) {
+                    // selected osm primitives are untagged or filling default feature is enabled
+                    combo.setSelectedItem(def);
+                } else {
+                    // selected osm primitives are tagged and filling default feature is disabled
+                    combo.setSelectedItem("");
+                }
+                originalValue = lhm.get(DIFFERENT);
+            } else if (usage.unused()) {
+                // all items were unset (and so is default)
+                originalValue = lhm.get("");
+                combo.setSelectedItem(originalValue);
+            } else {
+                originalValue = lhm.get(DIFFERENT);
+                combo.setSelectedItem(originalValue);
+            }
+            p.add(combo, GBC.eol().fill(GBC.HORIZONTAL));
+
+        }
+
+        @Override
+        protected Object getSelectedItem() {
+            return combo.getSelectedItem();
+
+        }
+
+        @Override
+        protected String getDisplayIfNull(String display) {
+            if (combo.isEditable()) {
+                return combo.getEditor().getItem().toString();
+            } else {
+                return display;
+            }
+
+        }
+    }
+
+    /**
+     * Class that allows list values to be assigned and retrieved as a comma-delimited
+     * string.
+     */
+    public static class ConcatenatingJList extends JList {
+        private String delimiter;
+        public ConcatenatingJList(String del, Object[] o) {
+            super(o);
+            delimiter = del;
+        }
+        public void setSelectedItem(Object o) {
+            if (o == null) {
+                clearSelection();
+            } else {
+                String s = o.toString();
+                HashSet<String> parts = new HashSet<String>(Arrays.asList(s.split(delimiter)));
+                ListModel lm = getModel();
+                int[] intParts = new int[lm.getSize()];
+                int j = 0;
+                for (int i = 0; i < lm.getSize(); i++) {
+                    if (parts.contains((((PresetListEntry)lm.getElementAt(i)).value))) {
+                        intParts[j++]=i;
+                    }
+                }
+                setSelectedIndices(Arrays.copyOf(intParts, j));
+                // check if we have acutally managed to represent the full
+                // value with our presets. if not, cop out; we will not offer
+                // a selection list that threatens to ruin the value.
+                setEnabled(s.equals(getSelectedItem()));
+            }
+        }
+        public String getSelectedItem() {
+            ListModel lm = getModel();
+            int[] si = getSelectedIndices();
+            StringBuilder builder = new StringBuilder();
+            for (int i=0; i<si.length; i++) {
+                if (i>0) {
+                    builder.append(delimiter);
+                }
+                builder.append(((PresetListEntry)lm.getElementAt(si[i])).value);
+            }
+            return builder.toString();
+        }
+    }
+
+    public static class MultiSelect extends ComboMultiSelect {
+
+        public long rows = -1;
+        protected ConcatenatingJList list;
+
+        @Override
+        protected void addToPanelAnchor(JPanel p, String def, String[] display_array) {
+            list = new ConcatenatingJList(delimiter, lhm.values().toArray());
+            component = list;
+            ListCellRenderer renderer = getListCellRenderer();
+            list.setCellRenderer(renderer);
+
+            if (usage.hasUniqueValue() && !usage.unused()) {
+                originalValue = usage.getFirst();
+                list.setSelectedItem(originalValue);
+            } else if (def != null && !usage.hadKeys() || PROP_FILL_DEFAULT.get() || "force".equals(use_last_as_default)) {
+                originalValue = DIFFERENT;
+                list.setSelectedItem(def);
+            } else if (usage.unused()) {
+                originalValue = null;
+                list.setSelectedItem(originalValue);
+            } else {
+                originalValue = DIFFERENT;
+                list.setSelectedItem(originalValue);
+            }
+
             JScrollPane sp = new JScrollPane(list);
             // if a number of rows has been specified in the preset,
             // modify preferred height of scroll pane to match that row count.
-            if (rows != -1)
-            {
+            if (rows != -1) {
                 double height = renderer.getListCellRendererComponent(list,
                         new PresetListEntry("x"), 0, false, false).getPreferredSize().getHeight() * rows;
@@ -790,89 +765,12 @@
             }
             p.add(sp, GBC.eol().fill(GBC.HORIZONTAL));
-            return true;
-        }
-
-        private static class PresetListCellRenderer implements ListCellRenderer {
-
-            HtmlPanel lbl;
-            JComponent dummy = new JComponent() {};
-
-            public PresetListCellRenderer() {
-                lbl = new HtmlPanel();
-            }
-
-            public Component getListCellRendererComponent(
-                    JList list,
-                    Object value,
-                    int index,
-                    boolean isSelected,
-                    boolean cellHasFocus)
-            {
-                if (isSelected) {
-                    lbl.setBackground(list.getSelectionBackground());
-                    lbl.setForeground(list.getSelectionForeground());
-                } else {
-                    lbl.setBackground(list.getBackground());
-                    lbl.setForeground(list.getForeground());
-                }
-
-                PresetListEntry item = (PresetListEntry) value;
-                String s = item.getListDisplay();
-                lbl.setText(s);
-                lbl.setEnabled(list.isEnabled());
-                // We do not want the editor to have the maximum height of all
-                // entries. Return a dummy with bogus height.
-                if (index == -1) {
-                    dummy.setPreferredSize(new Dimension(lbl.getPreferredSize().width, 10));
-                    return dummy;
-                }
-                return lbl;
-            }
-        }
-
-        @Override public void addCommands(List<Tag> changedTags) {
-            Object obj = list.getSelectedItem();
-            String display = (obj == null) ? null : obj.toString();
-            String value = null;
-
-            if (display != null)
-            {
-                for (String key : lhm.keySet()) {
-                    String k = lhm.get(key).toString();
-                    if (k != null && k.equals(display)) {
-                        value=key;
-                    }
-                }
-                if (value == null) {
-                    value = display;
-                }
-            } else {
-                value = "";
-            }
-
-            // no change if same as before
-            if (originalValue == null) {
-                if (value.length() == 0)
-                    return;
-            } else if (value.equals(originalValue.toString()))
-                return;
-
-            if (delete_if_empty && value.length() == 0) {
-                value = null;
-            }
-            if (!"false".equals(use_last_as_default)) {
-                lastValue.put(key, value);
-            }
-            changedTags.add(new Tag(key, value));
-        }
-
-        public void setShort_description(String s) {
-            if (short_description_list == null) {
-                short_description_list = new ArrayList<String>();
-            }
-            short_description_list.add(tr(s));
-        }
-
-        @Override boolean requestFocusInWindow() {return list.requestFocusInWindow();}
+
+
+        }
+
+        @Override
+        protected Object getSelectedItem() {
+            return list.getSelectedItem();
+        }
     }
 
@@ -909,11 +807,13 @@
 
     public static class Label extends Item {
+
         public String text;
         public String text_context;
         public String locale_text;
 
-        @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
-            if(locale_text == null) {
-                if(text_context != null) {
+        @Override
+        public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
+            if (locale_text == null) {
+                if (text_context != null) {
                     locale_text = trc(text_context, fixPresetString(text));
                 } else {
@@ -924,8 +824,12 @@
             return false;
         }
-        @Override public void addCommands(List<Tag> changedTags) {}
+
+        @Override
+        public void addCommands(List<Tag> changedTags) {
+        }
     }
 
     public static class Link extends Item {
+
         public String href;
         public String text;
@@ -934,9 +838,10 @@
         public String locale_href;
 
-        @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
-            if(locale_text == null) {
-                if(text == null) {
+        @Override
+        public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
+            if (locale_text == null) {
+                if (text == null) {
                     locale_text = tr("More information about this feature");
-                } else if(text_context != null) {
+                } else if (text_context != null) {
                     locale_text = trc(text_context, fixPresetString(text));
                 } else {
@@ -953,5 +858,8 @@
             return false;
         }
-        @Override public void addCommands(List<Tag> changedTags) {}
+
+        @Override
+        public void addCommands(List<Tag> changedTags) {
+        }
     }
 
@@ -1025,13 +933,15 @@
 
     public static class Roles extends Item {
+
         public List<Role> roles = new LinkedList<Role>();
-        @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
+
+        @Override
+        public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
             p.add(new JLabel(" "), GBC.eol()); // space
-            if(roles.size() > 0)
-            {
+            if (roles.size() > 0) {
                 JPanel proles = new JPanel(new GridBagLayout());
-                proles.add(new JLabel(tr("Available roles")), GBC.std().insets(0,0,10,0));
-                proles.add(new JLabel(tr("role")), GBC.std().insets(0,0,10,0));
-                proles.add(new JLabel(tr("count")), GBC.std().insets(0,0,10,0));
+                proles.add(new JLabel(tr("Available roles")), GBC.std().insets(0, 0, 10, 0));
+                proles.add(new JLabel(tr("role")), GBC.std().insets(0, 0, 10, 0));
+                proles.add(new JLabel(tr("count")), GBC.std().insets(0, 0, 10, 0));
                 proles.add(new JLabel(tr("elements")), GBC.eol());
                 for (Role i : roles) {
@@ -1042,10 +952,15 @@
             return false;
         }
-        @Override public void addCommands(List<Tag> changedTags) {}
+
+        @Override
+        public void addCommands(List<Tag> changedTags) {
+        }
     }
 
     public static class Optional extends Item {
+
         // TODO: Draw a box around optional stuff
-        @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
+        @Override
+        public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
             p.add(new JLabel(" "), GBC.eol()); // space
             p.add(new JLabel(tr("Optional Attributes:")), GBC.eol());
@@ -1053,22 +968,36 @@
             return false;
         }
-        @Override public void addCommands(List<Tag> changedTags) {}
+
+        @Override
+        public void addCommands(List<Tag> changedTags) {
+        }
     }
 
     public static class Space extends Item {
-        @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
+
+        @Override
+        public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
             p.add(new JLabel(" "), GBC.eol()); // space
             return false;
         }
-        @Override public void addCommands(List<Tag> changedTags) {}
+
+        @Override
+        public void addCommands(List<Tag> changedTags) {
+        }
     }
 
     public static class Key extends Item {
+
         public String key;
         public String value;
 
-        @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { return false; }
-        @Override public void addCommands(List<Tag> changedTags) {
-            changedTags.add(new Tag(key, value != null && !value.equals("") ? value : null));
+        @Override
+        public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
+            return false;
+        }
+
+        @Override
+        public void addCommands(List<Tag> changedTags) {
+            changedTags.add(new Tag(key, value));
         }
     }
