- Timestamp:
- 2020-04-17T20:50:41+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java
r16322 r16323 16 16 import java.util.Map; 17 17 import java.util.Map.Entry; 18 import java.util.Objects; 18 19 import java.util.TreeMap; 20 import java.util.stream.Collectors; 19 21 20 22 import javax.swing.JPanel; … … 27 29 import org.openstreetmap.josm.data.osm.OsmData; 28 30 import org.openstreetmap.josm.data.osm.PrimitiveComparator; 31 import org.openstreetmap.josm.data.osm.User; 29 32 import org.openstreetmap.josm.gui.ExtendedDialog; 30 33 import org.openstreetmap.josm.gui.MainApplication; … … 187 190 Count only tagged nodes (so empty way nodes don't inflate counts). 188 191 */ 189 protected static String buildListOfEditorsText(Iterable<? extends IPrimitive> primitives) { 190 final Map<String, Integer> editCountByUser = new TreeMap<>(Collator.getInstance(Locale.getDefault())); 191 192 // Count who edited each selected object 193 for (IPrimitive o : primitives) { 194 if (o.getUser() != null) { 195 String username = o.getUser().getName(); 196 Integer oldCount = editCountByUser.get(username); 197 if (oldCount == null) { 198 editCountByUser.put(username, 1); 199 } else { 200 editCountByUser.put(username, oldCount + 1); 201 } 202 } 203 } 192 protected static String buildListOfEditorsText(Collection<? extends IPrimitive> primitives) { 193 final Map<String, Long> editCountByUser = primitives.stream() 194 .map(IPrimitive::getUser) 195 .filter(Objects::nonNull) 196 .collect(Collectors.groupingBy( 197 User::getName, 198 () -> new TreeMap<>(Collator.getInstance(Locale.getDefault())), 199 Collectors.counting())); 204 200 205 201 // Print the count in sorted order … … 208 204 editCountByUser.size(), editCountByUser.size())) 209 205 .append("\n\n"); 210 for (Map.Entry<String, Integer> entry : editCountByUser.entrySet()) { 211 final String username = entry.getKey(); 212 final Integer editCount = entry.getValue(); 213 s.append(String.format("%6d %s", editCount, username)).append('\n'); 214 } 206 editCountByUser.forEach((username, editCount) -> 207 s.append(String.format("%6d %s", editCount, username)).append('\n')); 215 208 return s.toString(); 216 209 }
Note:
See TracChangeset
for help on using the changeset viewer.