- Timestamp:
- 2020-02-10T22:58:02+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r15716 r15834 32 32 import java.util.Collections; 33 33 import java.util.Comparator; 34 import java.util.HashMap;35 34 import java.util.List; 36 35 import java.util.Map; 37 36 import java.util.Objects; 37 import java.util.Optional; 38 38 import java.util.TreeMap; 39 import java.util.stream.Collectors; 39 40 import java.util.stream.IntStream; 40 41 … … 547 548 commands.add(new ChangePropertyCommand(sel, key, null)); 548 549 if (value.equals(tr("<different>"))) { 549 Map<String, List<OsmPrimitive>> map = new HashMap<>(); 550 for (OsmPrimitive osm: sel) { 551 String val = osm.get(key); 552 if (val != null) { 553 if (map.containsKey(val)) { 554 map.get(val).add(osm); 555 } else { 556 List<OsmPrimitive> v = new ArrayList<>(); 557 v.add(osm); 558 map.put(val, v); 559 } 560 } 561 } 562 for (Map.Entry<String, List<OsmPrimitive>> e: map.entrySet()) { 563 commands.add(new ChangePropertyCommand(e.getValue(), newkey, e.getKey())); 564 } 550 String newKey = newkey; 551 sel.stream() 552 .filter(osm -> osm.hasKey(key)) 553 .collect(Collectors.groupingBy(osm -> osm.get(key))) 554 .forEach((newValue, osmPrimitives) -> commands.add(new ChangePropertyCommand(osmPrimitives, newKey, newValue))); 565 555 } else { 566 556 commands.add(new ChangePropertyCommand(sel, newkey, value)); … … 667 657 ComboBoxModel<AutoCompletionItem> currentModel = values.getModel(); 668 658 final int size = correctItems.size(); 669 boolean valuesOK = size == currentModel.getSize(); 670 for (int i = 0; valuesOK && i < size; i++) { 671 valuesOK = Objects.equals(currentModel.getElementAt(i), correctItems.get(i)); 672 } 659 boolean valuesOK = size == currentModel.getSize() 660 && IntStream.range(0, size).allMatch(i -> Objects.equals(currentModel.getElementAt(i), correctItems.get(i))); 673 661 if (!valuesOK) { 674 662 values.setPossibleAcItems(correctItems); … … 682 670 editor.addFocusListener(focus); 683 671 return focus; 672 } 673 674 private Optional<ImageIcon> findIcon(Tag tag) { 675 // Find and display icon 676 ImageIcon icon = MapPaintStyles.getNodeIcon(tag, false); // Filters deprecated icon 677 if (icon != null) { 678 return Optional.of(icon); 679 } 680 // If no icon found in map style look at presets 681 return TaggingPresets.getMatchingPresets(null, tag.getKeys(), false).stream() 682 .map(TaggingPreset::getIcon) 683 .filter(Objects::nonNull) 684 .findFirst(); 684 685 } 685 686 … … 947 948 action.setEnabled(false); 948 949 } 949 // Find and display icon 950 ImageIcon icon = MapPaintStyles.getNodeIcon(t, false); // Filters deprecated icon 951 if (icon == null) { 952 // If no icon found in map style look at presets 953 Map<String, String> map = new HashMap<>(); 954 map.put(t.getKey(), t.getValue()); 955 for (TaggingPreset tp : TaggingPresets.getMatchingPresets(null, map, false)) { 956 icon = tp.getIcon(); 957 if (icon != null) { 958 break; 959 } 960 } 961 // If still nothing display an empty icon 962 if (icon == null) { 963 icon = new ImageIcon(new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB)); 964 } 965 } 950 ImageIcon icon = findIcon(t) 951 // If still nothing display an empty icon 952 953 .orElseGet(() -> new ImageIcon(new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB))); 966 954 GridBagConstraints gbc = new GridBagConstraints(); 967 955 gbc.ipadx = 5;
Note:
See TracChangeset
for help on using the changeset viewer.