Changeset 31720
- Timestamp:
- 2017-06-02T17:14:00+12:00 (7 years ago)
- Location:
- main/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/classes/dictionary.properties
r31691 r31720 861 861 Mirroring.DownloadJob.Pause_Tooltip:Pause this download 862 862 Mirroring.DownloadJob.Stop:Stop 863 Mirroring.DownloadJob.Stop_Tooltip:Stop this download 863 Mirroring.DownloadJob.Stop_Tooltip:Stop this download job if it is currently running 864 Mirroring.DownloadJob.Stopped:Stopped 865 Mirroring.DownloadJob.Stopped_Tooltip:This download has been stopped 864 866 Mirroring.DownloadJob.Resume:Resume 865 867 Mirroring.DownloadJob.Resume_Tooltip:Resume this download -
main/trunk/gli/src/org/greenstone/gatherer/download/DownloadJob.java
r31692 r31720 75 75 76 76 private final String download_url; 77 77 private boolean wasClosed = false; 78 78 79 // private String current_url; 79 80 // private String destination; … … 212 213 if (getState() == RUNNING) { 213 214 //setState(STOPPED); 214 stopDownload(); // cancels any running SafeProcess 215 stopDownload(); // cancels any running SafeProcess 215 216 } else { 216 217 //previous_state = getState(); … … 220 221 } 221 222 else if (event.getSource() == progress.close_button) { 223 setClosed(); 222 224 SafeProcess.log("@@@ Progress bar close button pressed"); 223 225 if(getState() == RUNNING) { 224 226 previous_state = getState(); 225 227 //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 } 228 230 mummy.deleteDownloadJob(this); 229 231 } … … 798 800 // if the cancel button was clicked when it had already naturally terminated 799 801 802 // If the user had pressed the Close button to terminate the running job, then 800 803 // we're now ready to remove the display of the until now running job 801 804 // 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 } 803 809 } /*else { 804 810 // If we've got to here and the state isn't STOPPED then the … … 962 968 return state; 963 969 } 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 } 964 977 965 978 /** Returns the current state of the stop flag for this job. … … 978 991 previous_state = this.state; 979 992 this.state = state; 993 } 994 995 private synchronized void setClosed() { 996 this.wasClosed = true; 980 997 } 981 998 -
main/trunk/gli/src/org/greenstone/gatherer/download/DownloadProgressBar.java
r31692 r31720 132 132 // However, now we additionally ensure that the wget launched by the perl is stopped before 133 133 // process.destroy(), so at least it cleans up better. I'm therefore changing it to a "Stop" button. 134 stop_start_button = new GLIButton(Dictionary.get("Mirroring.DownloadJob.Pause"),Dictionary.get("Mirroring.DownloadJob.Pause_Tooltip")); 135 //stop_start_button = new GLIButton(Dictionary.get("Mirroring.DownloadJob.Stop"),Dictionary.get("Mirroring.DownloadJob.Stop_Tooltip")); 134 stop_start_button = new GLIButton(Dictionary.get("Mirroring.DownloadJob.Stop"),Dictionary.get("Mirroring.DownloadJob.Stop_Tooltip")); 136 135 stop_start_button.addActionListener(this); 137 136 stop_start_button.addActionListener(owner); … … 189 188 if (current_action == DownloadJob.RUNNING) { 190 189 current_action = DownloadJob.STOPPED; 191 stop_start_button.setText(Dictionary.get("Mirroring.DownloadJob. Resume"));192 stop_start_button.setToolTipText(Dictionary.get("Mirroring.DownloadJob. Resume_Tooltip"));190 stop_start_button.setText(Dictionary.get("Mirroring.DownloadJob.Stopped")); 191 stop_start_button.setToolTipText(Dictionary.get("Mirroring.DownloadJob.Stopped_Tooltip")); 193 192 194 193 progress.setString(Dictionary.get("Mirroring.DownloadJob.Download_Stopped")); 195 194 progress.setIndeterminate(false); 196 } else { 197 current_action = DownloadJob.RUNNING; 198 // we are stopped, so restart 199 stop_start_button.setText(Dictionary.get("Mirroring.DownloadJob.Pause")); 200 stop_start_button.setToolTipText(Dictionary.get("Mirroring.DownloadJob.Pause_Tooltip")); 201 progress.setString(Dictionary.get("Mirroring.DownloadJob.Download_Progress")); 202 progress.setIndeterminate(true); 195 stop_start_button.setEnabled(false); 203 196 } 204 197 } -
main/trunk/gli/src/org/greenstone/gatherer/util/Readme_Using_SafeProcess.txt
r31719 r31720 581 581 - http://stackoverflow.com/questions/4906799/why-invoke-thread-currentthread-interrupt-when-catch-any-interruptexception 582 582 - https://praveer09.github.io/technology/2015/12/06/understanding-thread-interruption-in-java/ 583 - http://michaelscharf.blogspot.co.nz/2006/09/dont-swallow-interruptedexception-call.html 583 584 584 585 -
main/trunk/gli/src/org/greenstone/gatherer/util/SafeProcess.java
r31718 r31720 618 618 // See also http://stackoverflow.com/questions/4906799/why-invoke-thread-currentthread-interrupt-when-catch-any-interruptexception 619 619 // and https://praveer09.github.io/technology/2015/12/06/understanding-thread-interruption-in-java/ 620 // http://michaelscharf.blogspot.co.nz/2006/09/dont-swallow-interruptedexception-call.html 620 621 Thread.currentThread().interrupt(); // re-interrupt the thread - which thread? Infinite loop? 621 622 -
main/trunk/greenstone3/src/java/org/greenstone/util/SafeProcess.java
r31718 r31720 619 619 // See also http://stackoverflow.com/questions/4906799/why-invoke-thread-currentthread-interrupt-when-catch-any-interruptexception 620 620 // and https://praveer09.github.io/technology/2015/12/06/understanding-thread-interruption-in-java/ 621 // http://michaelscharf.blogspot.co.nz/2006/09/dont-swallow-interruptedexception-call.html 621 622 Thread.currentThread().interrupt(); // re-interrupt the thread - which thread? Infinite loop? 622 623
Note:
See TracChangeset
for help on using the changeset viewer.