- Timestamp:
- 2016-01-15T22:25:06+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r9062 r9473 225 225 tr("Cannot merge nodes: Would have to delete way {0} which is still used by {1}", 226 226 DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(w), 227 DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(w.getReferrers() )),227 DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(w.getReferrers(), 20)), 228 228 tr("Warning"), 229 229 JOptionPane.WARNING_MESSAGE, -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r9371 r9473 505 505 + "<br/>" 506 506 + "Do you really want to delete?", 507 relations.size(), relations.size(), DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(relations ))507 relations.size(), relations.size(), DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(relations, 20)) 508 508 + "</html>")); 509 509 return ConditionalOptionPaneUtil.showConfirmationDialog( -
trunk/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java
r9203 r9473 644 644 * Formats the given collection of primitives as an HTML unordered list. 645 645 * @param primitives collection of primitives to format 646 * @param maxElements the maximum number of elements to display 646 647 * @return HTML unordered list 647 648 */ 648 public String formatAsHtmlUnorderedList(Collection<? extends OsmPrimitive> primitives ) {649 return Utils.joinAsHtmlUnorderedList(Utils.transform(primitives, new Function<OsmPrimitive, String>() {649 public String formatAsHtmlUnorderedList(Collection<? extends OsmPrimitive> primitives, int maxElements) { 650 final Collection<String> displayNames = Utils.transform(primitives, new Function<OsmPrimitive, String>() { 650 651 651 652 @Override … … 653 654 return x.getDisplayName(DefaultNameFormatter.this); 654 655 } 655 })); 656 } 657 658 /** 659 * Formats the given primitive(s) as an HTML unordered list. 660 * @param primitives primitive(s) to format 656 }); 657 return Utils.joinAsHtmlUnorderedList(Utils.limit(displayNames, maxElements, "...")); 658 } 659 660 /** 661 * Formats the given primitive as an HTML unordered list. 662 * @param primitive primitive to format 661 663 * @return HTML unordered list 662 664 */ 663 public String formatAsHtmlUnorderedList(OsmPrimitive ... primitives) {664 return formatAsHtmlUnorderedList( Arrays.asList(primitives));665 public String formatAsHtmlUnorderedList(OsmPrimitive primitive) { 666 return formatAsHtmlUnorderedList(Collections.singletonList(primitive), 1); 665 667 } 666 668 } -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java
r9211 r9473 551 551 + "Do you want to continue?", 552 552 parentRelations.size(), parentRelations.size(), primitives.size(), 553 DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(parentRelations ));553 DefaultNameFormatter.getInstance().formatAsHtmlUnorderedList(parentRelations, 20)); 554 554 555 555 if (!ConditionalOptionPaneUtil.showConfirmationDialog( -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r9419 r9473 1307 1307 return null; 1308 1308 } else { 1309 final List<String> lines = Arrays.asList(s.split("\\n")); 1310 if (lines.size() > maxLines) { 1311 return join("\n", lines.subList(0, maxLines - 1)) + "\n..."; 1309 return join("\n", limit(Arrays.asList(s.split("\\n")), maxLines, "...")); 1310 } 1311 } 1312 1313 /** 1314 * If the collection {@code elements} is larger than {@code maxElements} elements, 1315 * the collection is shortened and the {@code overflowIndicator} is appended. 1316 * @param elements collection to shorten 1317 * @param maxElements maximum number of elements to keep (including including the {@code overflowIndicator}) 1318 * @param overflowIndicator the element used to indicate that the collection has been shortened 1319 * @return the shortened collection 1320 */ 1321 public static <T> Collection<T> limit(Collection<T> elements, int maxElements, T overflowIndicator) { 1322 if (elements == null) { 1323 return null; 1324 } else { 1325 if (elements.size() > maxElements) { 1326 final Collection<T> r = new ArrayList<>(maxElements); 1327 final Iterator<T> it = elements.iterator(); 1328 while (r.size() < maxElements - 1) { 1329 r.add(it.next()); 1330 } 1331 r.add(overflowIndicator); 1332 return r; 1312 1333 } else { 1313 return s;1334 return elements; 1314 1335 } 1315 1336 }
Note:
See TracChangeset
for help on using the changeset viewer.