Index: /trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java (revision 9570)
+++ /trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java (revision 9571)
@@ -250,11 +250,15 @@
return "" + Utils.escapeReservedCharactersHTML(DIFFERENT) + "";
- final StringBuilder res = new StringBuilder("");
- res.append(Utils.escapeReservedCharactersHTML(getDisplayValue(true)))
- .append("");
- if (getShortDescription(true) != null) {
+ String displayValue = Utils.escapeReservedCharactersHTML(getDisplayValue(true));
+ String shortDescription = getShortDescription(true);
+
+ if (displayValue.isEmpty() && (shortDescription == null || shortDescription.isEmpty()))
+ return " ";
+
+ final StringBuilder res = new StringBuilder("").append(displayValue).append("");
+ if (shortDescription != null) {
// wrap in table to restrict the text width
res.append("
")
- .append(getShortDescription(true))
+ .append(shortDescription)
.append("
");
}
@@ -295,7 +299,8 @@
@Override
public String toString() {
- if (value.equals(DIFFERENT))
+ if (DIFFERENT.equals(value))
return DIFFERENT;
- return getDisplayValue(true).replaceAll("<.*>", ""); // remove additional markup, e.g.
+ String displayValue = getDisplayValue(true);
+ return displayValue != null ? displayValue.replaceAll("<.*>", "") : null; // remove additional markup, e.g.
}
Index: /trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelectTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelectTest.java (revision 9571)
+++ /trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelectTest.java (revision 9571)
@@ -0,0 +1,31 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.tagging.presets.items;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.gui.tagging.presets.items.ComboMultiSelect.PresetListEntry;
+
+/**
+ * Unit tests of {@link ComboMultiSelect} class.
+ */
+public class ComboMultiSelectTest {
+
+ /**
+ * Setup test.
+ */
+ @BeforeClass
+ public static void setUp() {
+ JOSMFixture.createUnitTestFixture().init();
+ }
+
+ /**
+ * Non-regression test for ticket #12416.
+ */
+ @Test
+ public void testTicket12416() {
+ assertEquals(" ", new PresetListEntry("").getListDisplay());
+ }
+}