[jsword-svn] common/java/core/org/crosswire/common/progress s
jswordcvs at crosswire.org
jswordcvs at crosswire.org
Mon Mar 7 19:31:42 MST 2005
Update of /cvs/jsword/common/java/core/org/crosswire/common/progress
In directory www.crosswire.org:/tmp/cvs-serv23334/java/core/org/crosswire/common/progress
Modified Files:
Job.java
Log Message:
Improved the Job class allowing for cooperative interruption.
Fixed the download cancel. Improved the cancel of indexing.
It works but you have to restart to try to index again.
Index: Job.java
===================================================================
RCS file: /cvs/jsword/common/java/core/org/crosswire/common/progress/Job.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Job.java 6 Mar 2005 20:21:59 -0000 1.7
--- Job.java 8 Mar 2005 02:31:40 -0000 1.8
***************
*** 2,5 ****
--- 2,7 ----
import java.awt.event.ActionEvent;
+ import java.beans.PropertyChangeListener;
+ import java.beans.PropertyChangeSupport;
import java.io.IOException;
import java.io.InputStream;
***************
*** 59,63 ****
this.reportedpc = 0;
this.finished = false;
!
if (fakeupdates)
{
--- 61,69 ----
this.reportedpc = 0;
this.finished = false;
! this.interruptable = work != null;
! this.listeners = new PropertyChangeSupport(this);
! this.start = -1;
! this.predictedlen = -1;
!
if (fakeupdates)
{
***************
*** 180,183 ****
--- 186,191 ----
if (work != null && !finished)
{
+ ignoreTimings();
+ done();
work.interrupt();
}
***************
*** 187,196 ****
* Might the job be interruptable?
*/
! public boolean canInterrupt()
{
! return work != null && !finished;
}
/**
* Shortcut to check if percent == 100
*/
--- 195,219 ----
* Might the job be interruptable?
*/
! public boolean isInterruptable()
{
! return interruptable;
}
/**
+ * @param newInterruptable The interruptable to set.
+ */
+ public void setInterruptable(boolean newInterruptable)
+ {
+ if (work == null || finished)
+ {
+ return;
+ }
+ Boolean oldValue = Boolean.valueOf(interruptable);
+ Boolean newValue = Boolean.valueOf(newInterruptable);
+ interruptable = newInterruptable;
+ listeners.firePropertyChange("interruptable", oldValue, newValue); //$NON-NLS-1$
+ }
+
+ /**
* Shortcut to check if percent == 100
*/
***************
*** 416,419 ****
--- 439,467 ----
/**
+ * Interface for people to be notified of changes to the
+ * current Font.
+ * @param li The new listener class
+ */
+ public void addPropertyChangeListener(PropertyChangeListener li)
+ {
+ listeners.addPropertyChangeListener(li);
+ }
+
+ /**
+ * Interface for people to be notified of changes to the
+ * current Font.
+ * @param li The listener class to be deleted
+ */
+ public void removePropertyChangeListener(PropertyChangeListener li)
+ {
+ listeners.removePropertyChangeListener(li);
+ }
+
+ /**
+ * Does this job allow interruptions?
+ */
+ private boolean interruptable;
+
+ /**
* Have we just finished?
*/
***************
*** 463,467 ****
* When did this job start?
*/
! private long start = -1;
/**
--- 511,515 ----
* When did this job start?
*/
! private long start;
/**
***************
*** 478,482 ****
* How long to we predict this job is going to last?
*/
! private int predictedlen = -1;
/**
--- 526,530 ----
* How long to we predict this job is going to last?
*/
! private int predictedlen;
/**
***************
*** 491,494 ****
--- 539,547 ----
/**
+ * People that want to know about "interruptable" changes
+ */
+ protected PropertyChangeSupport listeners;
+
+ /**
* So we can fake progress for Jobs that don't tell us how they are doing
*/
More information about the jsword-svn
mailing list