Ignore:
Timestamp:
10.03.2010 10:00:20 (2 years ago)
Author:
Gubaer
Message:

fixed #4651: Ability to download incomplete relation from selection
fixed #4098: Popup Menu entry "download relation members" in relation dialog should be "download incomplete relation members"
fixed two NPEs in RelationListDialog and SelectionListDialog
refactored SelectionListDialog to support better user feedback (enabled/disabled buttons and menu items)
Finally removed the sort() method on DataSet, marked as FIXME since a long time.

CAVEAT: DataSet.getSelected() now returns an unmodifiable list instead of a copy of the selection list. This may lead to UnsupportedOperationExceptions in the next few days. I tried to make sure the JOSM core uses getSelected() only for reading, but I didn't check the plugins.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/DownloadRelationMemberTask.java

    r3083 r3102  
    88import java.io.IOException; 
    99import java.util.Collection; 
     10import java.util.HashSet; 
     11import java.util.Set; 
    1012 
    1113import javax.swing.SwingUtilities; 
     
    3234    private boolean cancelled; 
    3335    private Exception lastException; 
    34     private Relation parent; 
     36    private final Set<Relation> parents = new HashSet<Relation>(); 
    3537    private Collection<OsmPrimitive> children; 
    3638    private OsmDataLayer curLayer; 
    3739    private MultiFetchServerObjectReader objectReader; 
    3840 
    39     public DownloadRelationMemberTask(Relation parent, Collection<OsmPrimitive> children, OsmDataLayer curLayer, MemberTableModel memberTableModel, Dialog dialog) { 
     41    public DownloadRelationMemberTask(Relation parent, Collection<OsmPrimitive> children, OsmDataLayer curLayer, Dialog dialog) { 
    4042        super(tr("Download relation members"), new PleaseWaitProgressMonitor(dialog), false /* don't ignore exception */); 
    41         this.parent = parent; 
     43        this.parents.add(parent); 
    4244        this.children = children; 
    4345        this.curLayer = curLayer; 
    4446    } 
    4547 
    46     public DownloadRelationMemberTask(Relation parent, Collection<OsmPrimitive> children, OsmDataLayer curLayer, MemberTableModel memberTableModel) { 
     48    public DownloadRelationMemberTask(Relation parent, Collection<OsmPrimitive> children, OsmDataLayer curLayer) { 
    4749        super(tr("Download relation members"), false /* don't ignore exception */); 
    48         this.parent = parent; 
     50        this.parents.add(parent); 
     51        this.children = children; 
     52        this.curLayer = curLayer; 
     53    } 
     54 
     55    /** 
     56     * Creates a download task for downloading the child primitives {@code children} for all parent 
     57     * relations in {@code parents}. 
     58     *  
     59     * @param parents the collection of parent relations 
     60     * @param children the collection of child primitives to download 
     61     * @param curLayer the current OSM layer 
     62     */ 
     63    public DownloadRelationMemberTask(Collection<Relation> parents, Collection<OsmPrimitive> children, OsmDataLayer curLayer) { 
     64        super(tr("Download relation members"), false /* don't ignore exception */); 
     65        this.parents.addAll(parents); 
    4966        this.children = children; 
    5067        this.curLayer = curLayer; 
     
    7188    } 
    7289 
     90    protected String buildDownloadFeedbackMessage() { 
     91        if (parents.size() == 1) { 
     92            Relation parent = parents.iterator().next(); 
     93            return trn("Downloading {0} incomplete child of relation ''{1}''", 
     94                    "Downloading {0} incomplete children of relation ''{1}''", 
     95                    children.size(), 
     96                    children.size(), 
     97                    parent.getDisplayName(DefaultNameFormatter.getInstance()) 
     98            ); 
     99        } else 
     100            return trn("Downloading {0} incomplete child of {1} parent relations", 
     101                    "Downloading {0} incomplete children of  {1} parent relations", 
     102                    children.size(), 
     103                    children.size(), 
     104                    parents.size() 
     105            ); 
     106    } 
     107 
    73108    @Override 
    74109    protected void realRun() throws SAXException, IOException, OsmTransferException { 
     
    80115            objectReader.append(children); 
    81116            progressMonitor.indeterminateSubTask( 
    82                     trn("Downloading {0} incomplete child of relation ''{1}''", 
    83                             "Downloading {0} incomplete children of relation ''{1}''", 
    84                             children.size(), 
    85                             children.size(), 
    86                             parent.getDisplayName(DefaultNameFormatter.getInstance()) 
    87                     ) 
     117                    buildDownloadFeedbackMessage() 
    88118            ); 
    89119            final DataSet dataSet = objectReader.parseOsm(progressMonitor 
Note: See TracChangeset for help on using the changeset viewer.