Changeset 8691 in osm for applications/editors/josm/plugins/validator/src
- Timestamp:
- 2008-07-03T18:02:52+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/util/MultipleNameVisitor.java
r2453 r8691 1 1 package org.openstreetmap.josm.plugins.validator.util; 2 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 3 4 import static org.openstreetmap.josm.tools.I18n.trn; 4 5 … … 21 22 /** The class name of the combined primitives */ 22 23 String multipleClassname; 24 /* name to be displayed */ 25 String displayName; 23 26 /** Size of the collection */ 24 27 int size; … … 30 33 public void visit(Collection<? extends OsmPrimitive> data) 31 34 { 35 String multipleName = null; 36 String firstName = null; 37 boolean initializedname = false; 32 38 size = data.size(); 39 33 40 multipleClassname = null; 34 41 for (OsmPrimitive osm : data) 35 42 { 43 String name = osm.get("name"); 44 if(name == null) name = osm.get("ref"); 45 if(!initializedname) 46 { 47 multipleName = name; initializedname = true; 48 } 49 else if(multipleName != null && (name == null || !name.equals(multipleName))) 50 { 51 multipleName = null; 52 } 53 54 if(firstName == null && name != null) 55 firstName = name; 36 56 osm.visit(this); 37 57 if (multipleClassname == null) … … 40 60 multipleClassname = "object"; 41 61 } 62 63 if( size == 1 ) 64 displayName = name; 65 else if(multipleName != null) 66 displayName = size + " " + trn(multipleClassname, multipleClassname + "s", size) + ": " + multipleName; 67 else if(firstName != null) 68 displayName = size + " " + trn(multipleClassname, multipleClassname + "s", size) + ": " + tr("{0}, ...", firstName); 69 else 70 displayName = size + " " + trn(multipleClassname, multipleClassname + "s", size); 42 71 } 43 72 … … 45 74 public JLabel toLabel() 46 75 { 47 if( size == 1 ) 48 return super.toLabel(); 49 else 50 return new JLabel( size + " " + trn(multipleClassname, multipleClassname + "s", size), ImageProvider.get("data", multipleClassname), JLabel.HORIZONTAL); 76 return new JLabel(getText(), getIcon(), JLabel.HORIZONTAL); 51 77 } 52 78 … … 57 83 public String getText() 58 84 { 59 if( size == 1 ) 60 return name; 61 else 62 return size + " " + trn(multipleClassname, multipleClassname + "s", size); 85 return displayName; 63 86 } 64 87
Note:
See TracChangeset
for help on using the changeset viewer.