Ignore:
Timestamp:
03.12.2009 19:02:25 (2 years ago)
Author:
Gubaer
Message:

fixed #3400: relation editor: improvement to highlight an element
fixed #3873: Feature request: download selected elements in relation editor
New: Dbl-Click in member table to set the map selection to this member
New: Ctrl-Dbl-Clik in member table to add the member to the the map selection
New: Download selected incomplete members only

File:
1 edited

Legend:

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

    r2484 r2563  
    99import org.openstreetmap.josm.data.osm.DataSet; 
    1010import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 
     11import org.openstreetmap.josm.data.osm.PrimitiveId; 
     12import org.openstreetmap.josm.data.osm.SimplePrimitiveId; 
     13import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 
    1114import org.openstreetmap.josm.gui.progress.ProgressMonitor; 
    1215import org.xml.sax.SAXException; 
    1316 
     17/** 
     18 * OsmServerObjectReader reads an individual object from the OSM server. 
     19 *  
     20 * It can either download the object including or not including its immediate children. 
     21 * The former case is called a "full download". 
     22 *  
     23 */ 
    1424public class OsmServerObjectReader extends OsmServerReader { 
     25    /** the id of the object to download */ 
     26    private PrimitiveId id; 
     27    /** true if a full download is required, i.e. a download including the immediate children */ 
     28    private boolean full; 
    1529 
    16     long id; 
    17     OsmPrimitiveType type; 
    18     boolean full; 
    19  
    20     public OsmServerObjectReader(long id, OsmPrimitiveType type, boolean full) { 
    21         this.id = id; 
    22         this.type = type; 
     30    /** 
     31     * Creates a new server object reader for a given id and a primitive type. 
     32     *  
     33     * @param id the object id. > 0 required. 
     34     * @param type the type. Must not be null. 
     35     * @param full true, if a full download is requested (i.e. a download including 
     36     * immediate children); false, otherwise 
     37     * @throws IllegalArgumentException thrown if id <= 0 
     38     * @throws IllegalArgumentException thrown if type is null 
     39     */ 
     40    public OsmServerObjectReader(long id, OsmPrimitiveType type, boolean full) throws IllegalArgumentException { 
     41        if (id <= 0) 
     42            throw new IllegalArgumentException(tr("Expected value > 0 for parameter ''{0}'', got {1}", "id", id)); 
     43        if (type == null) 
     44            throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null", "type")); 
     45        this.id = new SimplePrimitiveId(id, type); 
    2346        this.full = full; 
    2447    } 
     48 
    2549    /** 
    26      * Method to download single objects from OSM server. ways, relations, nodes 
    27      * @return the data requested 
     50     * Creates a new server object reader for an object with the given <code>id</code> 
     51     *  
     52     * @param id the object id. Must not be null. Unique id > 0 required. 
     53     * @param full true, if a full download is requested (i.e. a download including 
     54     * immediate children); false, otherwise 
     55     * @throws IllegalArgumentException thrown if id is null 
     56     * @throws IllegalArgumentException thrown if id.getUniqueId() <= 0 
     57     */ 
     58    public OsmServerObjectReader(PrimitiveId id, boolean full) { 
     59        if (id == null) 
     60            throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null", "id")); 
     61        if (id.getUniqueId() <= 0) 
     62            throw new IllegalArgumentException(tr("Expected value > 0 for parameter ''{0}'', got {1}", "id.getUniqueId()", id.getUniqueId())); 
     63        this.id = id; 
     64        this.full = full; 
     65    } 
     66 
     67    /** 
     68     * Downloads and parses the data. 
     69     *  
     70     * @param progressMonitor the progress monitor. Set to {@see NullProgressMonitor#INSTANCE} if 
     71     * null 
     72     * @return the downloaded data 
    2873     * @throws SAXException 
    2974     * @throws IOException 
     
    3176    @Override 
    3277    public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException { 
     78        if (progressMonitor == null) { 
     79            progressMonitor = NullProgressMonitor.INSTANCE; 
     80        } 
    3381        progressMonitor.beginTask("", 1); 
    3482        InputStream in = null; 
     
    3684            progressMonitor.indeterminateSubTask(tr("Downloading OSM data...")); 
    3785            StringBuffer sb = new StringBuffer(); 
    38             sb.append(type.getAPIName()); 
     86            sb.append(id.getType().getAPIName()); 
    3987            sb.append("/"); 
    40             sb.append(id); 
    41             if (full && ! type.equals(OsmPrimitiveType.NODE)) { 
     88            sb.append(id.getUniqueId()); 
     89            if (full && ! id.getType().equals(OsmPrimitiveType.NODE)) { 
    4290                sb.append("/full"); 
    4391            } 
     
    59107                try { 
    60108                    in.close(); 
    61                 } catch(Exception e) {} 
     109                } catch(Exception e) {/* ignore this exception */} 
    62110            } 
    63111            activeConnection = null; 
    64112        } 
    65113    } 
    66  
    67114} 
Note: See TracChangeset for help on using the changeset viewer.