- Timestamp:
- 2011-11-20T20:47:15+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AbstractInfoAction.java
r3995 r4602 54 54 * replies the base URL for browsing information about a user 55 55 * 56 * @return the base URL, i.e. http://ww .openstreetmap.org/user56 * @return the base URL, i.e. http://www.openstreetmap.org/user 57 57 */ 58 58 static public String getBaseUserUrl() { -
trunk/src/org/openstreetmap/josm/data/osm/User.java
r4601 r4602 1 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.data.osm; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.io.BufferedReader; … … 35 37 private static HashSet<Long> relicensingUsers = null; 36 38 private static HashSet<Long> nonRelicensingUsers = null; 39 private final static User anonymous = createLocalUser(tr("<anonymous>")); 37 40 38 41 private static long getNextLocalUid() { … … 110 113 } 111 114 return ret; 115 } 116 117 public static User getAnonymous() { 118 return anonymous; 112 119 } 113 120 … … 185 192 public static final int STATUS_ANONYMOUS = 4; 186 193 187 /** 194 /** 188 195 * Finds out this user's relicensing status and saves it for quicker 189 196 * access. -
trunk/src/org/openstreetmap/josm/data/osm/history/History.java
r3083 r4602 156 156 new FilterPredicate() { 157 157 public boolean matches(HistoryOsmPrimitive primitive) { 158 return primitive.getU id() == uid;158 return primitive.getUser() != null && primitive.getUser().getId() == uid; 159 159 } 160 160 } -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryNode.java
r4339 r4602 7 7 import org.openstreetmap.josm.data.osm.Node; 8 8 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 9 import org.openstreetmap.josm.data.osm.User; 9 10 10 11 /** … … 18 19 private LatLon coords; 19 20 20 public HistoryNode(long id, long version, boolean visible, String user, long uid, long changesetId, Date timestamp, LatLon coords) {21 super(id, version, visible, user, uid,changesetId, timestamp);21 public HistoryNode(long id, long version, boolean visible, User user, long changesetId, Date timestamp, LatLon coords) { 22 super(id, version, visible, user, changesetId, timestamp); 22 23 setCoords(coords); 23 24 } -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryOsmPrimitive.java
r4339 r4602 17 17 import org.openstreetmap.josm.data.osm.Relation; 18 18 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; 19 import org.openstreetmap.josm.data.osm.User; 19 20 import org.openstreetmap.josm.data.osm.Way; 20 21 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 29 30 private long id; 30 31 private boolean visible; 31 private String user; 32 private long uid; 32 private User user; 33 33 private long changesetId; 34 34 private Date timestamp; … … 54 54 * @throws IllegalArgumentException thrown if preconditions are violated 55 55 */ 56 public HistoryOsmPrimitive(long id, long version, boolean visible, String user, long uid, long changesetId, Date timestamp) throws IllegalArgumentException {56 public HistoryOsmPrimitive(long id, long version, boolean visible, User user, long changesetId, Date timestamp) throws IllegalArgumentException { 57 57 ensurePositiveLong(id, "id"); 58 58 ensurePositiveLong(version, "version"); 59 if(uid != -1) {60 ensurePositiveLong(uid, "uid");61 }62 59 CheckParameterUtil.ensureParameterNotNull(user, "user"); 63 60 CheckParameterUtil.ensureParameterNotNull(timestamp, "timestamp"); … … 66 63 this.visible = visible; 67 64 this.user = user; 68 this.uid = uid;69 65 // FIXME: restrict to IDs > 0 as soon as OsmPrimitive holds the 70 66 // changeset id too … … 76 72 public HistoryOsmPrimitive(OsmPrimitive p) { 77 73 this(p.getId(), p.getVersion(), p.isVisible(), 78 p.getUser() == null ? null : p.getUser().getName(), 79 p.getUser() == null ? 0 : p.getUser().getId(), 74 p.getUser(), 80 75 p.getChangesetId(), p.getTimestamp()); 81 76 } … … 104 99 return visible; 105 100 } 106 public StringgetUser() {101 public User getUser() { 107 102 return user; 108 }109 public long getUid() {110 return uid;111 103 } 112 104 public long getChangesetId() { -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryRelation.java
r4339 r4602 10 10 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 11 11 import org.openstreetmap.josm.data.osm.Relation; 12 import org.openstreetmap.josm.data.osm.User; 12 13 import org.openstreetmap.josm.tools.CheckParameterUtil; 13 14 … … 34 35 * @throws IllegalArgumentException thrown if preconditions are violated 35 36 */ 36 public HistoryRelation(long id, long version, boolean visible, String user, long uid, long changesetId,37 public HistoryRelation(long id, long version, boolean visible, User user, long changesetId, 37 38 Date timestamp) throws IllegalArgumentException { 38 super(id, version, visible, user, uid,changesetId, timestamp);39 super(id, version, visible, user, changesetId, timestamp); 39 40 } 40 41 /** … … 52 53 * @throws IllegalArgumentException thrown if preconditions are violated 53 54 */ 54 public HistoryRelation(long id, long version, boolean visible, String user, long uid, long changesetId,55 public HistoryRelation(long id, long version, boolean visible, User user, long changesetId, 55 56 Date timestamp, ArrayList<RelationMember> members) { 56 this(id, version, visible, user, uid,changesetId, timestamp);57 this(id, version, visible, user, changesetId, timestamp); 57 58 if (members != null) { 58 59 this.members.addAll(members); -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryWay.java
r4339 r4602 10 10 11 11 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 12 import org.openstreetmap.josm.data.osm.User; 12 13 import org.openstreetmap.josm.data.osm.Way; 14 13 15 /** 14 16 * Represents an immutable OSM way in the context of a historical view on … … 20 22 private ArrayList<Long> nodeIds = new ArrayList<Long>(); 21 23 22 public HistoryWay(long id, long version, boolean visible, String user, long uid, long changesetId, Date timestamp) {23 super(id, version, visible, user, uid,changesetId, timestamp);24 public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Date timestamp) { 25 super(id, version, visible, user, changesetId, timestamp); 24 26 } 25 27 26 public HistoryWay(long id, long version, boolean visible, String user, long uid, long changesetId, Date timestamp, ArrayList<Long> nodeIdList) {27 this(id, version, visible, user, uid,changesetId, timestamp);28 public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Date timestamp, ArrayList<Long> nodeIdList) { 29 this(id, version, visible, user, changesetId, timestamp); 28 30 this.nodeIds.addAll(nodeIdList); 29 31 } -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r4601 r4602 41 41 import org.openstreetmap.josm.gui.layer.Layer; 42 42 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 43 import org.openstreetmap.josm.io.XmlWriter; 43 44 import org.openstreetmap.josm.tools.CheckParameterUtil; 44 45 import org.openstreetmap.josm.tools.Diff; … … 420 421 case 2: 421 422 return isCurrentPointInTime(row); 422 case 3: 423 long uId = getPrimitive(row).getUid(); 424 User user = User.getById(uId); 425 int status; 426 if (user == null) { 427 status = User.STATUS_UNKNOWN; 428 } else { 429 status = user.getRelicensingStatus(); 423 case 3: { 424 User user = getPrimitive(row).getUser(); 425 int status; 426 if (user == null) { 427 status = User.STATUS_UNKNOWN; 428 } else { 429 status = user.getRelicensingStatus(); 430 } 431 return UserListDialog.getRelicensingStatusIcon(status); 430 432 } 431 return UserListDialog.getRelicensingStatusIcon(status);432 433 case 4: { 433 434 HistoryOsmPrimitive p = getPrimitive(row); … … 438 439 case 5: { 439 440 HistoryOsmPrimitive p = getPrimitive(row); 440 if (p != null) 441 return "<html>"+p.getUser() + " <font color=gray>(" + p.getUid() + ")</font></html>"; 441 if (p != null) { 442 User user = p.getUser(); 443 if (user != null) 444 return "<html>" + XmlWriter.encode(user.getName()) + " <font color=gray>(" + user.getId() + ")</font></html>"; 445 } 442 446 return null; 443 447 } … … 868 872 private HistoryOsmPrimitive clone; 869 873 870 private String getUserName(OsmPrimitive primitive) {871 return primitive.getUser() == null?null:primitive.getUser().getName();872 }873 874 private long getUserId(OsmPrimitive primitive) {875 return primitive.getUser() == null?0:primitive.getUser().getId();876 }877 878 874 public void visit(Node n) { 879 clone = new HistoryNode(n.getId(), n.getVersion(), n.isVisible(), getUserName(n), getUserId(n), 0, n.getTimestamp(), n.getCoor());875 clone = new HistoryNode(n.getId(), n.getVersion(), n.isVisible(), n.getUser(), 0, n.getTimestamp(), n.getCoor()); 880 876 clone.setTags(n.getKeys()); 881 877 } 882 878 883 879 public void visit(Relation r) { 884 clone = new HistoryRelation(r.getId(), r.getVersion(), r.isVisible(), getUserName(r), getUserId(r), 0, r.getTimestamp());880 clone = new HistoryRelation(r.getId(), r.getVersion(), r.isVisible(), r.getUser(), 0, r.getTimestamp()); 885 881 clone.setTags(r.getKeys()); 886 882 HistoryRelation hr = (HistoryRelation)clone; … … 891 887 892 888 public void visit(Way w) { 893 clone = new HistoryWay(w.getId(), w.getVersion(), w.isVisible(), getUserName(w), getUserId(w), 0, w.getTimestamp());889 clone = new HistoryWay(w.getId(), w.getVersion(), w.isVisible(), w.getUser(), 0, w.getTimestamp()); 894 890 clone.setTags(w.getKeys()); 895 891 for (Node n: w.getNodes()) { -
trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java
r4299 r4602 19 19 import org.openstreetmap.josm.Main; 20 20 import org.openstreetmap.josm.actions.AbstractInfoAction; 21 import org.openstreetmap.josm.data.osm.User; 21 22 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; 22 23 import org.openstreetmap.josm.gui.JMultilineLabel; … … 135 136 136 137 try { 137 if (getPrimitive().getU id() != -1) {138 url = AbstractInfoAction.getBaseUserUrl() + "/" + URLEncoder.encode(getPrimitive().getUser() , "UTF-8").replaceAll("\\+", "%20");138 if (getPrimitive().getUser() != null && getPrimitive().getUser() != User.getAnonymous()) { 139 url = AbstractInfoAction.getBaseUserUrl() + "/" + URLEncoder.encode(getPrimitive().getUser().getName(), "UTF-8").replaceAll("\\+", "%20"); 139 140 lblUser.setUrl(url); 140 141 } else { … … 145 146 lblUser.setUrl(null); 146 147 } 147 String username = getPrimitive().getUser(); 148 String username = ""; 149 if (getPrimitive().getUser() != null) { 150 username = getPrimitive().getUser().getName(); 151 } 148 152 lblUser.setDescription(username); 149 153 } else { -
trunk/src/org/openstreetmap/josm/io/OsmChangesetContentParser.java
r3083 r4602 17 17 import org.openstreetmap.josm.data.osm.ChangesetDataSet; 18 18 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 19 import org.openstreetmap.josm.data.osm.User; 19 20 import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetModificationType; 20 21 import org.openstreetmap.josm.data.osm.history.HistoryNode; … … 85 86 } 86 87 87 protected long getAttributeLong(Attributes attr, String name, long defaultValue) throws SAXException{88 protected Long getAttributeLong(Attributes attr, String name) throws SAXException{ 88 89 String v = attr.getValue(name); 89 90 if (v == null) 90 return defaultValue;91 Long l = 0l;91 return null; 92 Long l = null; 92 93 try { 93 94 l = Long.parseLong(v); … … 123 124 } 124 125 125 protected String getAttributeString(Attributes attr, String name, String defaultValue) {126 String v = attr.getValue(name);127 if (v == null)128 return defaultValue;129 return v;130 }131 132 126 protected boolean getMandatoryAttributeBoolean(Attributes attr, String name) throws SAXException{ 133 127 String v = attr.getValue(name); … … 147 141 long changesetId = getMandatoryAttributeLong(atts,"changeset"); 148 142 boolean visible= getMandatoryAttributeBoolean(atts, "visible"); 149 long uid = getAttributeLong(atts, "uid",-1); 150 String user = getAttributeString(atts, "user", tr("<anonymous>")); 143 144 Long uid = getAttributeLong(atts, "uid"); 145 String userStr = atts.getValue("user"); 146 User user; 147 if (userStr != null) { 148 if (uid != null) { 149 user = User.createOsmUser(uid, userStr); 150 } else { 151 user = User.createLocalUser(userStr); 152 } 153 } else { 154 user = User.getAnonymous(); 155 } 156 151 157 String v = getMandatoryAttributeString(atts, "timestamp"); 152 158 Date timestamp = DateUtils.fromString(v); … … 156 162 double lon = getMandatoryAttributeDouble(atts, "lon"); 157 163 primitive = new HistoryNode( 158 id,version,visible,user, uid,changesetId,timestamp, new LatLon(lat,lon)164 id,version,visible,user,changesetId,timestamp, new LatLon(lat,lon) 159 165 ); 160 166 161 167 } else if (type.equals(OsmPrimitiveType.WAY)) { 162 168 primitive = new HistoryWay( 163 id,version,visible,user, uid,changesetId,timestamp169 id,version,visible,user,changesetId,timestamp 164 170 ); 165 171 }if (type.equals(OsmPrimitiveType.RELATION)) { 166 172 primitive = new HistoryRelation( 167 id,version,visible,user, uid,changesetId,timestamp173 id,version,visible,user,changesetId,timestamp 168 174 ); 169 175 } -
trunk/src/org/openstreetmap/josm/io/OsmHistoryReader.java
r3083 r4602 14 14 import org.openstreetmap.josm.data.coor.LatLon; 15 15 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 16 import org.openstreetmap.josm.data.osm.User; 16 17 import org.openstreetmap.josm.data.osm.history.HistoryDataSet; 17 18 import org.openstreetmap.josm.data.osm.history.HistoryNode; … … 81 82 } 82 83 83 protected long getAttributeLong(Attributes attr, String name, long defaultValue) throws SAXException{84 protected Long getAttributeLong(Attributes attr, String name) throws SAXException { 84 85 String v = attr.getValue(name); 85 86 if (v == null) 86 return defaultValue;87 Long l = 0l;87 return null; 88 Long l = null; 88 89 try { 89 90 l = Long.parseLong(v); … … 116 117 throwException(tr("Missing mandatory attribute ''{0}''.", name)); 117 118 } 118 return v;119 }120 121 protected String getAttributeString(Attributes attr, String name, String defaultValue) {122 String v = attr.getValue(name);123 if (v == null)124 return defaultValue;125 119 return v; 126 120 } … … 143 137 long changesetId = getMandatoryAttributeLong(atts,"changeset"); 144 138 boolean visible= getMandatoryAttributeBoolean(atts, "visible"); 145 long uid = getAttributeLong(atts, "uid",-1); 146 String user = getAttributeString(atts, "user", tr("<anonymous>")); 139 Long uid = getAttributeLong(atts, "uid"); 140 String userStr = atts.getValue("user"); 141 User user; 142 if (userStr != null) { 143 if (uid != null) { 144 user = User.createOsmUser(uid, userStr); 145 } else { 146 user = User.createLocalUser(userStr); 147 } 148 } else { 149 user = User.getAnonymous(); 150 } 147 151 String v = getMandatoryAttributeString(atts, "timestamp"); 148 152 Date timestamp = DateUtils.fromString(v); … … 152 156 double lon = getMandatoryAttributeDouble(atts, "lon"); 153 157 primitive = new HistoryNode( 154 id,version,visible,user, uid,changesetId,timestamp, new LatLon(lat,lon)158 id,version,visible,user,changesetId,timestamp, new LatLon(lat,lon) 155 159 ); 156 160 157 161 } else if (type.equals(OsmPrimitiveType.WAY)) { 158 162 primitive = new HistoryWay( 159 id,version,visible,user, uid,changesetId,timestamp163 id,version,visible,user,changesetId,timestamp 160 164 ); 161 165 }if (type.equals(OsmPrimitiveType.RELATION)) { 162 166 primitive = new HistoryRelation( 163 id,version,visible,user, uid,changesetId,timestamp167 id,version,visible,user,changesetId,timestamp 164 168 ); 165 169 }
Note:
See TracChangeset
for help on using the changeset viewer.