- Timestamp:
- 2012-08-13T02:37:03+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryNode.java
r5346 r5440 15 15 */ 16 16 public class HistoryNode extends HistoryOsmPrimitive { 17 17 18 /** the coordinates. May be null for deleted nodes */ 18 19 19 private LatLon coords; 20 20 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); 21 /** 22 * Constructs a new {@code HistoryNode}. 23 * 24 * @param id the id (> 0 required) 25 * @param version the version (> 0 required) 26 * @param visible whether the node is still visible 27 * @param user the user (! null required) 28 * @param changesetId the changeset id (> 0 required) 29 * @param timestamp the timestamp (! null required) 30 * @param coords the coordinates 31 * @throws IllegalArgumentException if preconditions are violated 32 */ 33 public HistoryNode(long id, long version, boolean visible, User user, long changesetId, Date timestamp, LatLon coords) throws IllegalArgumentException { 34 this(id, version, visible, user, changesetId, timestamp, coords, true); 35 } 36 37 /** 38 * Constructs a new {@code HistoryNode} with a configurable checking of historic parameters. 39 * This is needed to build virtual HistoryNodes for modified nodes, which do not have a timestamp and a changeset id. 40 * 41 * @param id the id (> 0 required) 42 * @param version the version (> 0 required) 43 * @param visible whether the node is still visible 44 * @param user the user (! null required) 45 * @param changesetId the changeset id (> 0 required if {@code checkHistoricParams} is true) 46 * @param timestamp the timestamp (! null required if {@code checkHistoricParams} is true) 47 * @param coords the coordinates 48 * @param checkHistoricParams if true, checks values of {@code changesetId} and {@code timestamp} 49 * @throws IllegalArgumentException if preconditions are violated 50 * @since 5440 51 */ 52 public HistoryNode(long id, long version, boolean visible, User user, long changesetId, Date timestamp, LatLon coords, boolean checkHistoricParams) throws IllegalArgumentException { 53 super(id, version, visible, user, changesetId, timestamp, checkHistoricParams); 23 54 setCoords(coords); 24 55 } 25 56 26 public HistoryNode(Node p) { 27 super(p); 28 setCoords(p.getCoor()); 57 /** 58 * Constructs a new {@code HistoryNode} from an existing {@link Node}. 59 * @param n the node 60 */ 61 public HistoryNode(Node n) { 62 super(n); 63 setCoords(n.getCoor()); 29 64 } 30 65 … … 34 69 } 35 70 71 /** 72 * Replies the coordinates. May be null. 73 * @return the coordinates. May be null. 74 */ 36 75 public LatLon getCoords() { 37 76 return coords; 38 77 } 39 78 79 /** 80 * Sets the coordinates. Can be null. 81 * @param coords the coordinates. Can be null. 82 */ 40 83 public void setCoords(LatLon coords) { 41 84 this.coords = coords; -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryOsmPrimitive.java
r5339 r5440 42 42 43 43 /** 44 * constructor45 * 46 * @param id the id (> 0 required)44 * Constructs a new {@code HistoryOsmPrimitive}. 45 * 46 * @param id the id (> 0 required) 47 47 * @param version the version (> 0 required) 48 48 * @param visible whether the primitive is still visible 49 * @param user the user (! null required) 50 * @param uid the user id (> 0 required) 51 * @param changesetId the changeset id (may be null if the changeset isn't known) 49 * @param user the user (! null required) 50 * @param changesetId the changeset id (> 0 required) 52 51 * @param timestamp the timestamp (! null required) 53 52 * 54 * @throws IllegalArgumentException thrownif preconditions are violated53 * @throws IllegalArgumentException if preconditions are violated 55 54 */ 56 55 public HistoryOsmPrimitive(long id, long version, boolean visible, User user, long changesetId, Date timestamp) throws IllegalArgumentException { 56 this(id, version, visible, user, changesetId, timestamp, true); 57 } 58 59 /** 60 * Constructs a new {@code HistoryOsmPrimitive} with a configurable checking of historic parameters. 61 * This is needed to build virtual HistoryOsmPrimitives for modified primitives, which do not have a timestamp and a changeset id. 62 * 63 * @param id the id (> 0 required) 64 * @param version the version (> 0 required) 65 * @param visible whether the primitive is still visible 66 * @param user the user (! null required) 67 * @param changesetId the changeset id (> 0 required if {@code checkHistoricParams} is true) 68 * @param timestamp the timestamp (! null required if {@code checkHistoricParams} is true) 69 * @param checkHistoricParams if true, checks values of {@code changesetId} and {@code timestamp} 70 * 71 * @throws IllegalArgumentException if preconditions are violated 72 * @since 5440 73 */ 74 public HistoryOsmPrimitive(long id, long version, boolean visible, User user, long changesetId, Date timestamp, boolean checkHistoricParams) throws IllegalArgumentException { 57 75 ensurePositiveLong(id, "id"); 58 76 ensurePositiveLong(version, "version"); 59 77 CheckParameterUtil.ensureParameterNotNull(user, "user"); 60 CheckParameterUtil.ensureParameterNotNull(timestamp, "timestamp"); 78 if (checkHistoricParams) { 79 ensurePositiveLong(changesetId, "changesetId"); 80 CheckParameterUtil.ensureParameterNotNull(timestamp, "timestamp"); 81 } 61 82 this.id = id; 62 83 this.version = version; 63 84 this.visible = visible; 64 85 this.user = user; 65 // FIXME: restrict to IDs > 0 as soon as OsmPrimitive holds the66 // changeset id too67 86 this.changesetId = changesetId; 68 87 this.timestamp = timestamp; 69 88 tags = new HashMap<String, String>(); 70 89 } 71 90 91 /** 92 * Constructs a new {@code HistoryOsmPrimitive} from an existing {@link OsmPrimitive}. 93 * @param p the primitive 94 */ 72 95 public HistoryOsmPrimitive(OsmPrimitive p) { 73 this(p.getId(), p.getVersion(), p.isVisible(), 74 p.getUser(), 75 p.getChangesetId(), p.getTimestamp()); 76 } 77 96 this(p.getId(), p.getVersion(), p.isVisible(), p.getUser(), p.getChangesetId(), p.getTimestamp()); 97 } 98 99 /** 100 * Replies a new {@link HistoryNode}, {@link HistoryWay} or {@link HistoryRelation} from an existing {@link OsmPrimitive}. 101 * @param p the primitive 102 * @return a new {@code HistoryNode}, {@code HistoryWay} or {@code HistoryRelation} from {@code p}. 103 */ 78 104 public static HistoryOsmPrimitive forOsmPrimitive(OsmPrimitive p) { 79 105 if (p instanceof Node) { … … 173 199 /** 174 200 * Replies the display name of a primitive formatted by <code>formatter</code> 201 * @param formatter The formatter used to generate a display name 175 202 * 176 203 * @return the display name -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryRelation.java
r5266 r5440 30 30 * @param visible whether the primitive is still visible 31 31 * @param user the user (! null required) 32 * @param uid the user id (> 0 required)33 32 * @param changesetId the changeset id (> 0 required) 34 33 * @param timestamp the timestamp (! null required) 35 34 * 36 * @throws IllegalArgumentException thrownif preconditions are violated35 * @throws IllegalArgumentException if preconditions are violated 37 36 */ 38 public HistoryRelation(long id, long version, boolean visible, User user, long changesetId, 39 Date timestamp) throws IllegalArgumentException { 37 public HistoryRelation(long id, long version, boolean visible, User user, long changesetId, Date timestamp) throws IllegalArgumentException { 40 38 super(id, version, visible, user, changesetId, timestamp); 41 39 } 40 42 41 /** 43 42 * constructor … … 47 46 * @param visible whether the primitive is still visible 48 47 * @param user the user (! null required) 49 * @param uid the user id (> 0 required) 48 * @param changesetId the changeset id (> 0 required if {@code checkHistoricParams} is true) 49 * @param timestamp the timestamp (! null required if {@code checkHistoricParams} is true) 50 * @param checkHistoricParams If true, checks values of {@code changesetId} and {@code timestamp} 51 * 52 * @throws IllegalArgumentException if preconditions are violated 53 * @since 5440 54 */ 55 public HistoryRelation(long id, long version, boolean visible, User user, long changesetId, Date timestamp, boolean checkHistoricParams) throws IllegalArgumentException { 56 super(id, version, visible, user, changesetId, timestamp, checkHistoricParams); 57 } 58 59 /** 60 * constructor 61 * 62 * @param id the id (>0 required) 63 * @param version the version (> 0 required) 64 * @param visible whether the primitive is still visible 65 * @param user the user (! null required) 50 66 * @param changesetId the changeset id (> 0 required) 51 67 * @param timestamp the timestamp (! null required) … … 62 78 } 63 79 64 public HistoryRelation(Relation p) { 65 super(p); 80 /** 81 * Constructs a new {@code HistoryRelation} from an existing {@link Relation}. 82 * @param r the relation 83 */ 84 public HistoryRelation(Relation r) { 85 super(r); 66 86 } 67 87 -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryWay.java
r5266 r5440 12 12 import org.openstreetmap.josm.data.osm.User; 13 13 import org.openstreetmap.josm.data.osm.Way; 14 import org.openstreetmap.josm.tools.CheckParameterUtil; 14 15 15 16 /** … … 22 23 private ArrayList<Long> nodeIds = new ArrayList<Long>(); 23 24 24 public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Date timestamp) { 25 /** 26 * Constructs a new {@code HistoryWay}. 27 * 28 * @param id the id (> 0 required) 29 * @param version the version (> 0 required) 30 * @param visible whether the node is still visible 31 * @param user the user (! null required) 32 * @param changesetId the changeset id (> 0 required if {@code checkHistoricParams} is true) 33 * @param timestamp the timestamp (! null required if {@code checkHistoricParams} is true) 34 * @throws IllegalArgumentException if preconditions are violated 35 */ 36 public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Date timestamp) throws IllegalArgumentException { 25 37 super(id, version, visible, user, changesetId, timestamp); 26 38 } 27 39 28 public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Date timestamp, ArrayList<Long> nodeIdList) { 40 /** 41 * Constructs a new {@code HistoryWay} with a configurable checking of historic parameters. 42 * This is needed to build virtual HistoryWays for modified ways, which do not have a timestamp and a changeset id. 43 * 44 * @param id the id (> 0 required) 45 * @param version the version (> 0 required) 46 * @param visible whether the node is still visible 47 * @param user the user (! null required) 48 * @param changesetId the changeset id (> 0 required if {@code checkHistoricParams} is true) 49 * @param timestamp the timestamp (! null required if {@code checkHistoricParams} is true) 50 * @param checkHistoricParams if true, checks values of {@code changesetId} and {@code timestamp} 51 * @throws IllegalArgumentException if preconditions are violated 52 * @since 5440 53 */ 54 public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Date timestamp, boolean checkHistoricParams) throws IllegalArgumentException { 55 super(id, version, visible, user, changesetId, timestamp, checkHistoricParams); 56 } 57 58 /** 59 * Constructs a new {@code HistoryWay} with a given list of node ids. 60 * 61 * @param id the id (> 0 required) 62 * @param version the version (> 0 required) 63 * @param visible whether the node is still visible 64 * @param user the user (! null required) 65 * @param changesetId the changeset id (> 0 required if {@code checkHistoricParams} is true) 66 * @param timestamp the timestamp (! null required if {@code checkHistoricParams} is true) 67 * @param nodeIdList the node ids (! null required) 68 * @throws IllegalArgumentException if preconditions are violated 69 */ 70 public HistoryWay(long id, long version, boolean visible, User user, long changesetId, Date timestamp, ArrayList<Long> nodeIdList) throws IllegalArgumentException { 29 71 this(id, version, visible, user, changesetId, timestamp); 72 CheckParameterUtil.ensureParameterNotNull(nodeIdList, "nodeIdList"); 30 73 this.nodeIds.addAll(nodeIdList); 31 74 } 32 75 33 public HistoryWay(Way p) { 34 super(p); 76 /** 77 * Constructs a new {@code HistoryWay} from an existing {@link Way}. 78 * @param w the way 79 */ 80 public HistoryWay(Way w) { 81 super(w); 35 82 } 36 83 -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowser.java
r5266 r5440 13 13 import javax.swing.JTable; 14 14 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 16 17 import org.openstreetmap.josm.data.osm.history.History; -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r5340 r5440 20 20 import org.openstreetmap.josm.data.osm.RelationMemberData; 21 21 import org.openstreetmap.josm.data.osm.User; 22 import org.openstreetmap.josm.data.osm.UserInfo; 22 23 import org.openstreetmap.josm.data.osm.Way; 23 24 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; … … 36 37 import org.openstreetmap.josm.data.osm.history.HistoryWay; 37 38 import org.openstreetmap.josm.data.osm.visitor.AbstractVisitor; 39 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 38 40 import org.openstreetmap.josm.gui.MapView; 39 41 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; … … 437 439 case 4: { 438 440 HistoryOsmPrimitive p = getPrimitive(row); 439 if (p != null )441 if (p != null && p.getTimestamp() != null) 440 442 return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(p.getTimestamp()); 441 443 return null; … … 877 879 878 880 public void visit(Node n) { 879 clone = new HistoryNode(n.getId(), n.getVersion(), n.isVisible(), n.getUser(), 0, n.getTimestamp(), n.getCoor());881 clone = new HistoryNode(n.getId(), n.getVersion(), n.isVisible(), getCurrentUser(), 0, null, n.getCoor(), false); 880 882 clone.setTags(n.getKeys()); 881 883 } 882 884 883 885 public void visit(Relation r) { 884 clone = new HistoryRelation(r.getId(), r.getVersion(), r.isVisible(), r.getUser(), 0, r.getTimestamp());886 clone = new HistoryRelation(r.getId(), r.getVersion(), r.isVisible(), getCurrentUser(), 0, null, false); 885 887 clone.setTags(r.getKeys()); 886 888 HistoryRelation hr = (HistoryRelation)clone; … … 891 893 892 894 public void visit(Way w) { 893 clone = new HistoryWay(w.getId(), w.getVersion(), w.isVisible(), w.getUser(), 0, w.getTimestamp());895 clone = new HistoryWay(w.getId(), w.getVersion(), w.isVisible(), getCurrentUser(), 0, null, false); 894 896 clone.setTags(w.getKeys()); 895 897 for (Node n: w.getNodes()) { … … 898 900 } 899 901 902 private User getCurrentUser() { 903 UserInfo info = JosmUserIdentityManager.getInstance().getUserInfo(); 904 return info == null ? User.getAnonymous() : User.createOsmUser(info.getId(), info.getDisplayName()); 905 } 906 900 907 public HistoryOsmPrimitive build(OsmPrimitive primitive) { 901 908 primitive.visit(this); -
trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java
r5319 r5440 20 20 import org.openstreetmap.josm.Main; 21 21 import org.openstreetmap.josm.actions.AbstractInfoAction; 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 23 import org.openstreetmap.josm.data.osm.User; 23 24 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; 24 25 import org.openstreetmap.josm.gui.JMultilineLabel; 26 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 25 27 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 26 import org.openstreetmap.josm.io.auth.CredentialsManager;27 28 import org.openstreetmap.josm.tools.CheckParameterUtil; 28 29 import org.openstreetmap.josm.tools.UrlLabel; … … 153 154 lblUser.setDescription(username); 154 155 } else { 155 String user = CredentialsManager.getInstance().getUsername();156 String user = JosmUserIdentityManager.getInstance().getUserName(); 156 157 if (user == null) { 157 158 lblUser.setDescription(tr("anonymous")); 159 lblUser.setUrl(null); 158 160 } else { 159 161 try { -
trunk/src/org/openstreetmap/josm/gui/history/VersionTableColumnModel.java
r5340 r5440 7 7 import javax.swing.table.DefaultTableColumnModel; 8 8 import javax.swing.table.TableColumn; 9 import javax.swing.table.TableColumnModel; 9 10 10 11 /** … … 58 59 } 59 60 61 /** 62 * Creates a new {@code VersionTableColumnModel}. 63 */ 60 64 public VersionTableColumnModel() { 61 65 createColumns(); -
trunk/src/org/openstreetmap/josm/tools/UrlLabel.java
r5050 r5440 49 49 if (url != null) { 50 50 setText("<html><a href=\""+url+"\">"+description+"</a></html>"); 51 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 52 setToolTipText(String.format("<html>%s<br/>%s</html>", url, tr("Right click = copy to clipboard"))); 51 53 } else { 52 54 setText("<html>" + description + "</html>"); 55 setCursor(null); 56 setToolTipText(null); 53 57 } 54 setToolTipText(String.format("<html>%s<br/>%s</html>",url, tr("Right click = copy to clipboard")));55 58 } 56 59
Note:
See TracChangeset
for help on using the changeset viewer.