Changeset 5353 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2012-07-19T23:04:38+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/util/MultipleNameVisitor.java
r3671 r5353 2 2 package org.openstreetmap.josm.data.validation.util; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr;5 4 import static org.openstreetmap.josm.tools.I18n.trn; 6 5 … … 20 19 public class MultipleNameVisitor extends NameVisitor 21 20 { 21 public static final int MULTIPLE_NAME_MAX_LENGTH = 80; 22 22 23 /** The class name of the combined primitives */ 23 String multipleClassname;24 private String multipleClassname; 24 25 /* name to be displayed */ 25 String displayName;26 private String displayName; 26 27 /** Size of the collection */ 27 int size;28 private int size; 28 29 29 30 /** … … 32 33 */ 33 34 public void visit(Collection<? extends OsmPrimitive> data) { 34 String multipleName = null;35 String multipleName = ""; 35 36 String multiplePluralClassname = null; 36 String firstName = null;37 boolean initializedname = false;38 37 size = data.size(); 39 38 … … 44 43 name = osm.get("ref"); 45 44 } 46 if (!initializedname) { 47 multipleName = name; initializedname = true; 48 } else if (multipleName != null && (name == null || !name.equals(multipleName))) { 49 multipleName = null; 45 if (name != null && !name.isEmpty() && multipleName.length() <= MULTIPLE_NAME_MAX_LENGTH) { 46 if (!multipleName.isEmpty()) { 47 multipleName += ", "; 48 } 49 multipleName += name; 50 50 } 51 51 52 if (firstName == null && name != null) {53 firstName = name;54 }55 52 osm.visit(this); 56 53 if (multipleClassname == null) { … … 65 62 if (size == 1) { 66 63 displayName = name; 67 } else if (multipleName != null) {68 displayName = size + " " + trn(multipleClassname, multiplePluralClassname, size) + ": " + multipleName;69 } else if (firstName != null) {70 displayName = size + " " + trn(multipleClassname, multiplePluralClassname, size) + ": " + tr("{0}, ...", firstName);71 64 } else { 72 65 displayName = size + " " + trn(multipleClassname, multiplePluralClassname, size); 66 if (!multipleName.isEmpty()) { 67 if (multipleName.length() <= MULTIPLE_NAME_MAX_LENGTH) { 68 displayName += ": " + multipleName; 69 } else { 70 displayName += ": " + multipleName.substring(0, MULTIPLE_NAME_MAX_LENGTH) + "..."; 71 } 72 } 73 73 } 74 74 } … … 97 97 return ImageProvider.get("data", multipleClassname); 98 98 } 99 100 @Override 101 public String toString() { 102 return getText(); 103 } 99 104 }
Note:
See TracChangeset
for help on using the changeset viewer.