Ignore:
Timestamp:
2009-10-04T12:07:16+02:00 (17 years ago)
Author:
Gubaer
Message:

fixed #3650: Double-click on items in history dialog should open history
fixed #3649: History dialog does not show moved nodes
fixed #3383: changeset tags in history dialog (partial fix, there's now a link to the server page for browsing changesets)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmHistoryReader.java

    r2242 r2243  
    1212import javax.xml.parsers.SAXParserFactory;
    1313
     14import org.openstreetmap.josm.data.coor.LatLon;
    1415import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1516import org.openstreetmap.josm.data.osm.history.HistoryDataSet;
     
    8081        }
    8182
    82         protected long getAttributeLong(Attributes attr, String name, long defaultValue) throws SAXException{
    83             String v = attr.getValue(name);
    84             if (v == null) {
    85                 return defaultValue;
    86             }
    87             Long l = 0l;
    88             try {
    89                 l = Long.parseLong(v);
    90             } catch(NumberFormatException e) {
    91                 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type long. Got ''{1}''.", name, v));
    92             }
    93             if (l < 0) {
    94                 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type long (>=0). Got ''{1}''.", name, v));
    95             }
    96             return l;
    97         }
    98 
    99         protected int getMandatoryAttributeInt(Attributes attr, String name) throws SAXException{
    100             String v = attr.getValue(name);
    101             if (v == null) {
    102                 throwException(tr("Missing mandatory attribute ''{0}''.", name));
    103             }
    104             Integer i = 0;
    105             try {
    106                 i = Integer.parseInt(v);
    107             } catch(NumberFormatException e) {
    108                 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type int. Got ''{1}''.", name, v));
    109             }
    110             if (i < 0) {
    111                 throwException(tr("Illegal value for mandatory attribute ''{0}'' of type int (>=0). Got ''{1}''.", name, v));
    112             }
    113             return i;
    114         }
    115 
    116         protected double getMandatoryAttributeDouble(Attributes attr, String name) throws SAXException{
    117             String v = attr.getValue(name);
    118             if (v == null) {
    119                 throwException(tr("Missing mandatory attribute ''{0}''.", name));
    120             }
    121             double d = 0.0;
     83        protected Double getMandatoryAttributeDouble(Attributes attr, String name) throws SAXException{
     84            String v = attr.getValue(name);
     85            if (v == null) {
     86                throwException(tr("Missing mandatory attribute ''{0}''.", name));
     87            }
     88            double d = 0;
    12289            try {
    12390                d = Double.parseDouble(v);
     
    12592                throwException(tr("Illegal value for mandatory attribute ''{0}'' of type double. Got ''{1}''.", name, v));
    12693            }
     94            if (d < 0) {
     95                throwException(tr("Illegal value for mandatory attribute ''{0}'' of type double (>=0). Got ''{1}''.", name, v));
     96            }
    12797            return d;
    12898        }
     
    133103                throwException(tr("Missing mandatory attribute ''{0}''.", name));
    134104            }
    135             return v;
    136         }
    137 
    138         protected String getAttributeString(Attributes attr, String name, String defaultValue) {
    139             String v = attr.getValue(name);
    140             if (v == null)
    141                 v = defaultValue;
    142105            return v;
    143106        }
     
    157120        protected  HistoryOsmPrimitive createPrimitive(Attributes atts, OsmPrimitiveType type) throws SAXException {
    158121            long id = getMandatoryAttributeLong(atts,"id");
    159             long version = getMandatoryAttributeLong(atts, "version");
    160             long changesetId = getMandatoryAttributeLong(atts, "changeset");
    161             boolean visible = getMandatoryAttributeBoolean(atts, "visible");
    162             long uid = getAttributeLong(atts, "uid", -1);
    163             String user = getAttributeString(atts, "user", tr("<anonymous>"));
     122            long version = getMandatoryAttributeLong(atts,"version");
     123            long changesetId = getMandatoryAttributeLong(atts,"changeset");
     124            boolean visible= getMandatoryAttributeBoolean(atts, "visible");
     125            long uid = getMandatoryAttributeLong(atts, "uid");
     126            String user = getMandatoryAttributeString(atts, "user");
    164127            String v = getMandatoryAttributeString(atts, "timestamp");
    165128            Date timestamp = DateUtils.fromString(v);
     
    169132                double lon = getMandatoryAttributeDouble(atts, "lon");
    170133                primitive = new HistoryNode(
    171                         id,version,visible,user,uid,changesetId,timestamp,lat,lon
     134                        id,version,visible,user,uid,changesetId,timestamp, new LatLon(lat,lon)
    172135                );
     136
    173137            } else if (type.equals(OsmPrimitiveType.WAY)) {
    174138                primitive = new HistoryWay(
Note: See TracChangeset for help on using the changeset viewer.