Ignore:
Timestamp:
2017-06-02T17:14:00+12:00 (7 years ago)
Author:
ak19
Message:
  1. GLI's DownloadJobs don't allow pausing and resuming (the button used to work, but didn't ever pause/resume in the background, at least it's been stopping the wget download activity after wget related changes from some years back). Changing the Pause/Resume button in the DownloadProgressBar to the Stop/Stopped button. 2. Added another useful link on InterruptedException to SafeProgress and its documentation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/download/DownloadJob.java

    r31692 r31720  
    7575
    7676    private final String download_url;
    77    
     77    private boolean wasClosed = false;
     78
    7879    //    private String current_url;
    7980    //    private String destination;
     
    212213        if (getState() == RUNNING) {
    213214        //setState(STOPPED);
    214         stopDownload(); // cancels any running SafeProcess     
     215        stopDownload(); // cancels any running SafeProcess
    215216        } else {
    216217        //previous_state = getState();
     
    220221    }
    221222    else if (event.getSource() == progress.close_button) {
     223        setClosed();
    222224        SafeProcess.log("@@@ Progress bar close button pressed");
    223225        if(getState() == RUNNING) {
    224226        previous_state = getState();
    225227        //setState(STOPPED); // do we need to do anything else to stop this? YES, we do:
    226         stopDownload(); // cancels any running SafeProcess     
    227         } 
     228        stopDownload(); // cancels any running SafeProcess
     229        }
    228230        mummy.deleteDownloadJob(this);
    229231    }
     
    798800        // if the cancel button was clicked when it had already naturally terminated
    799801
     802        // If the user had pressed the Close button to terminate the running job, then
    800803        // we're now ready to remove the display of the until now running job
    801804        // from the download progress bar interface
    802         mummy.deleteCurrentDownloadJob(this);
     805        // But don't bother removing the progress bar if the user had only pressed the Stop button
     806        if(wasClosed()) {
     807        mummy.deleteCurrentDownloadJob(this);
     808        }
    803809    } /*else {
    804810        // If we've got to here and the state isn't STOPPED then the
     
    962968    return state;
    963969    }
     970   
     971    /** @return true if the close button of the DownloadProgressBar was pressed,
     972     * false otherwise such as if the Stop button had been pressed.
     973    */
     974    private synchronized boolean wasClosed() {
     975    return this.wasClosed;
     976    }
    964977
    965978    /** Returns the current state of the stop flag for this job.
     
    978991    previous_state = this.state;
    979992    this.state = state;
     993    }
     994
     995    private synchronized void setClosed() {
     996    this.wasClosed = true;
    980997    }
    981998
Note: See TracChangeset for help on using the changeset viewer.