Index: trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java	(revision 5403)
+++ trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java	(revision 5404)
@@ -117,15 +117,15 @@
         public static PresetType forPrimitiveType(org.openstreetmap.josm.data.osm.OsmPrimitiveType type) {
             switch (type) {
-                case NODE:
-                    return NODE;
-                case WAY:
-                    return WAY;
-                case CLOSEDWAY:
-                    return CLOSEDWAY;
-                case RELATION:
-                case MULTIPOLYGON:
-                    return RELATION;
-                default:
-                    throw new IllegalArgumentException("Unexpected primitive type: " + type);
+            case NODE:
+                return NODE;
+            case WAY:
+                return WAY;
+            case CLOSEDWAY:
+                return CLOSEDWAY;
+            case RELATION:
+            case MULTIPOLYGON:
+                return RELATION;
+            default:
+                throw new IllegalArgumentException("Unexpected primitive type: " + type);
             }
         }
@@ -166,7 +166,6 @@
         public static MatchType ofString(String type) {
             for (MatchType i : EnumSet.allOf(MatchType.class)) {
-                if (i.getValue().equals(type)) {
+                if (i.getValue().equals(type))
                     return i;
-                }
             }
             throw new IllegalArgumentException(type + " is not allowed");
@@ -229,14 +228,14 @@
         Boolean matches(Map<String, String> tags) {
             switch (MatchType.ofString(match)) {
-                case NONE:
-                    return null;
-                case KEY:
-                    return tags.containsKey(key) ? true : null;
-                case KEY_REQUIRED:
-                    return tags.containsKey(key);
-                case KEY_VALUE:
-                    return tags.containsKey(key) && (getValues().contains(tags.get(key)));
-                default:
-                    throw new IllegalStateException();
+            case NONE:
+                return null;
+            case KEY:
+                return tags.containsKey(key) ? true : null;
+            case KEY_REQUIRED:
+                return tags.containsKey(key);
+            case KEY_VALUE:
+                return tags.containsKey(key) && (getValues().contains(tags.get(key)));
+            default:
+                throw new IllegalStateException();
             }
         }
@@ -306,4 +305,8 @@
         private final File zipIcons = TaggingPreset.zipIcons;
 
+        // Cached size (currently only for Combo) to speed up preset dialog initialization
+        private int prefferedWidth = -1;
+        private int prefferedHeight = -1;
+
         public String getListDisplay() {
             if (value.equals(DIFFERENT))
@@ -339,5 +342,5 @@
             return translated
                     ? Utils.firstNonNull(locale_display_value, tr(display_value), trc(value_context, value))
-                    : Utils.firstNonNull(display_value, value);
+                            : Utils.firstNonNull(display_value, value);
         }
 
@@ -345,5 +348,5 @@
             return translated
                     ? Utils.firstNonNull(locale_short_description, tr(short_description))
-                    : short_description;
+                            : short_description;
         }
 
@@ -444,7 +447,6 @@
         @Override
         public Collection<String> getValues() {
-            if (default_ == null || default_.isEmpty()) {
+            if (default_ == null || default_.isEmpty())
                 return Collections.emptyList();
-            }
             return Collections.singleton(default_);
         }
@@ -662,12 +664,12 @@
                 e.locale_display_value = locale_display_values != null
                         ? display_array[i]
-                        : trc(values_context, fixPresetString(display_array[i]));
-                if (short_descriptions_array != null) {
-                    e.locale_short_description = locale_short_descriptions != null
-                            ? short_descriptions_array[i]
-                            : tr(fixPresetString(short_descriptions_array[i]));
-                }
-                lhm.put(value_array[i], e);
-                display_array[i] = e.getDisplayValue(true);
+                                : trc(values_context, fixPresetString(display_array[i]));
+                        if (short_descriptions_array != null) {
+                            e.locale_short_description = locale_short_descriptions != null
+                                    ? short_descriptions_array[i]
+                                            : tr(fixPresetString(short_descriptions_array[i]));
+                        }
+                        lhm.put(value_array[i], e);
+                        display_array[i] = e.getDisplayValue(true);
             }
 
@@ -732,40 +734,59 @@
         }
 
-        protected ListCellRenderer getListCellRenderer() {
-            return new ListCellRenderer() {
-
-                JLabel lbl = new JLabel();
-                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());
+        private static ListCellRenderer RENDERER = new ListCellRenderer() {
+
+            JLabel lbl = new JLabel();
+
+            public Component getListCellRendererComponent(
+                    JList list,
+                    Object value,
+                    int index,
+                    boolean isSelected,
+                    boolean cellHasFocus) {
+                PresetListEntry item = (PresetListEntry) value;
+
+                // Only return cached size, item is not shown
+                if (!list.isShowing() && item.prefferedWidth != -1 && item.prefferedHeight != -1) {
+                    if (index == -1) {
+                        lbl.setPreferredSize(new Dimension(item.prefferedWidth, 10));
                     } else {
-                        lbl.setBackground(list.getBackground());
-                        lbl.setForeground(list.getForeground());
-                    }
-
-                    PresetListEntry item = (PresetListEntry) value;
-                    lbl.setOpaque(true);
-                    lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN));
-                    lbl.setText("<html>" + item.getListDisplay() + "</html>");
-                    lbl.setIcon(item.getIcon());
-                    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;
+                        lbl.setPreferredSize(new Dimension(item.prefferedWidth, item.prefferedHeight));
                     }
                     return lbl;
                 }
-            };
+
+                lbl.setPreferredSize(null);
+
+
+                if (isSelected) {
+                    lbl.setBackground(list.getSelectionBackground());
+                    lbl.setForeground(list.getSelectionForeground());
+                } else {
+                    lbl.setBackground(list.getBackground());
+                    lbl.setForeground(list.getForeground());
+                }
+
+                lbl.setOpaque(true);
+                lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN));
+                lbl.setText("<html>" + item.getListDisplay() + "</html>");
+                lbl.setIcon(item.getIcon());
+                lbl.setEnabled(list.isEnabled());
+
+                // Cache size
+                item.prefferedWidth = lbl.getPreferredSize().width;
+                item.prefferedHeight = lbl.getPreferredSize().height;
+
+                // We do not want the editor to have the maximum height of all
+                // entries. Return a dummy with bogus height.
+                if (index == -1) {
+                    lbl.setPreferredSize(new Dimension(lbl.getPreferredSize().width, 10));
+                }
+                return lbl;
+            }
+        };
+
+
+        protected ListCellRenderer getListCellRenderer() {
+            return RENDERER;
         }
 
@@ -949,7 +970,6 @@
      */
     private static String[] splitEscaped(char delimiter, String s) {
-        if (s == null) {
+        if (s == null)
             return new String[0];
-        }
         List<String> result = new ArrayList<String>();
         boolean backslash = false;
@@ -1265,7 +1285,6 @@
 
     static public EnumSet<PresetType> getType(String types) throws SAXException {
-        if (typeCache.containsKey(types)) {
+        if (typeCache.containsKey(types))
             return typeCache.get(types);
-        }
         EnumSet<PresetType> result = EnumSet.noneOf(PresetType.class);
         for (String type : Arrays.asList(types.split(","))) {
@@ -1366,7 +1385,6 @@
                         lastrole = (Roles) o;
                     } else if (o instanceof Role) {
-                        if (lastrole == null) {
+                        if (lastrole == null)
                             throw new SAXException(tr("Preset role element without parent"));
-                        }
                         lastrole.roles.add((Role) o);
                     } else if (o instanceof PresetListEntry) {
@@ -1695,15 +1713,14 @@
 
     public boolean matches(Collection<PresetType> t, Map<String, String> tags, boolean onlyShowable) {
-        if (onlyShowable && !isShowable()) {
+        if (onlyShowable && !isShowable())
             return false;
-        } else if (!typeMatches(t)) {
+        else if (!typeMatches(t))
             return false;
-        }
         boolean atLeastOnePositiveMatch = false;
         for (Item item : data) {
             Boolean m = item.matches(tags);
-            if (m != null && !m) {
+            if (m != null && !m)
                 return false;
-            } else if (m != null) {
+            else if (m != null) {
                 atLeastOnePositiveMatch = true;
             }
