- Timestamp:
- 2020-06-07T09:47:48+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java
r16526 r16544 14 14 import java.util.Collection; 15 15 import java.util.Collections; 16 import java.util.Comparator; 16 17 import java.util.List; 17 18 import java.util.Objects; … … 20 21 import java.util.concurrent.CopyOnWriteArraySet; 21 22 import java.util.stream.Collectors; 23 import java.util.stream.IntStream; 22 24 23 25 import javax.swing.ImageIcon; … … 114 116 } 115 117 118 if (index == -1) { 119 // Take the longest element for the preferred width (#19321) 120 // We do not want the editor to have the maximum height of all entries. Return a dummy with bogus height. 121 IntStream.range(0, list.getModel().getSize()) 122 .mapToObj(i -> getListCellRendererComponent(list, list.getModel().getElementAt(i), i, isSelected, cellHasFocus)) 123 .map(Component::getPreferredSize) 124 .max(Comparator.comparingInt(dim -> dim.width)) 125 .ifPresent(dim -> lbl.setPreferredSize(new Dimension(dim.width, 10))); 126 return lbl; 127 } 128 116 129 // Only return cached size, item is not shown 117 130 if (!list.isShowing() && item.preferredWidth != -1 && item.preferredHeight != -1) { 118 if (index == -1) { 119 lbl.setPreferredSize(new Dimension(item.preferredWidth, 10)); 120 } else { 121 lbl.setPreferredSize(new Dimension(item.preferredWidth, item.preferredHeight)); 122 } 131 lbl.setPreferredSize(new Dimension(item.preferredWidth, item.preferredHeight)); 123 132 return lbl; 124 133 } … … 144 153 item.preferredHeight = (short) lbl.getPreferredSize().height; 145 154 146 // We do not want the editor to have the maximum height of all147 // entries. Return a dummy with bogus height.148 if (index == -1) {149 lbl.setPreferredSize(new Dimension(lbl.getPreferredSize().width, 10));150 }151 155 return lbl; 152 156 }
Note:
See TracChangeset
for help on using the changeset viewer.