Changeset 1872 in josm


Ignore:
Timestamp:
Jul 30, 2009 8:40:34 AM (4 years ago)
Author:
jttt
Message:

Fix #3130

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/UpdateDataAction.java

    r1865 r1872  
    1616import org.openstreetmap.josm.data.osm.DataSource; 
    1717import org.openstreetmap.josm.gui.OptionPaneUtil; 
     18import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; 
    1819import org.openstreetmap.josm.tools.Shortcut; 
    1920 
     
    3233    /** 
    3334     * Refreshes the enabled state 
    34      *  
     35     * 
    3536     */ 
    3637    @Override 
     
    8182        } 
    8283 
    83         new DownloadOsmTaskList().download(false, areas); 
     84        new DownloadOsmTaskList().download(false, areas, new PleaseWaitProgressMonitor()); 
    8485    } 
    8586} 
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskList.java

    r1847 r1872  
    2424import org.openstreetmap.josm.gui.layer.Layer; 
    2525import org.openstreetmap.josm.gui.layer.OsmDataLayer; 
    26 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 
    2726import org.openstreetmap.josm.gui.progress.ProgressMonitor; 
    2827 
     
    7675     * @param The Collection of Areas to download 
    7776     */ 
    78     public void download(boolean newLayer, Collection<Area> areas) { 
    79         List<Rectangle2D> rects = new LinkedList<Rectangle2D>(); 
    80         for(Area a : areas) { 
    81             rects.add(a.getBounds2D()); 
    82         } 
    83  
    84         download(newLayer, rects, NullProgressMonitor.INSTANCE); 
     77    public void download(boolean newLayer, Collection<Area> areas, ProgressMonitor progressMonitor) { 
     78        progressMonitor.beginTask(tr("Updating data")); 
     79        try { 
     80            List<Rectangle2D> rects = new LinkedList<Rectangle2D>(); 
     81            for(Area a : areas) { 
     82                rects.add(a.getBounds2D()); 
     83            } 
     84 
     85            download(newLayer, rects, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)); 
     86        } finally { 
     87            progressMonitor.finishTask(); 
     88        } 
    8589    } 
    8690 
  • trunk/src/org/openstreetmap/josm/gui/progress/AbstractProgressMonitor.java

    r1812 r1872  
    1919        String extraText; 
    2020        Boolean intermediate; 
     21 
     22        boolean finishRequested; 
    2123    } 
    2224 
     
    8688 
    8789            if (state == State.IN_SUBTASK) { 
    88                 // Make sure the subtask didn't start yet (once task start it must be finished) 
    89                 boolean broken = currentChild.state != State.INIT; 
    90                 for (Request request:requests) { 
    91                     broken = broken | request.originator.state != State.INIT; 
    92                 } 
    93                 if (broken) { 
    94                     throw new ProgressException("Cannot call finishTask when there are unfinished tasks"); 
    95                 } else { 
    96                     state = State.IN_TASK; 
    97                 } 
    98             } 
    99  
    100             checkState(State.IN_TASK); 
    101             state = State.FINISHED; 
    102             doFinishTask(); 
     90                requestedState.finishRequested = true; 
     91            } else { 
     92                checkState(State.IN_TASK); 
     93                state = State.FINISHED; 
     94                doFinishTask(); 
     95            } 
    10396        } 
    10497    } 
     
    282275 
    283276    private void applyThisRequest(Request request) { 
    284         if (request.customText != null) { 
    285             this.customText = request.customText; 
    286         } 
    287  
    288         if (request.title != null) { 
    289             this.taskTitle = request.title; 
    290         } 
    291  
    292         if (request.intermediate != null) { 
    293             this.intermediateTask = request.intermediate; 
    294         } 
    295  
    296         if (request.extraText != null) { 
    297             this.extraText = request.extraText; 
    298         } 
    299  
    300         resetState(); 
     277        if (request.finishRequested) { 
     278            finishTask(); 
     279        } else { 
     280            if (request.customText != null) { 
     281                this.customText = request.customText; 
     282            } 
     283 
     284            if (request.title != null) { 
     285                this.taskTitle = request.title; 
     286            } 
     287 
     288            if (request.intermediate != null) { 
     289                this.intermediateTask = request.intermediate; 
     290            } 
     291 
     292            if (request.extraText != null) { 
     293                this.extraText = request.extraText; 
     294            } 
     295 
     296            resetState(); 
     297        } 
    301298    } 
    302299 
Note: See TracChangeset for help on using the changeset viewer.