[jsword-svn] r1218 - in trunk: bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop common/src/main/java/org/crosswire/common/progress common/src/test/java/org/crosswire/common/progress common-swing/src/main/java/org/crosswire/common/progress/swing jsword/src/main/java/org/crosswire/jsword/book jsword/src/main/java/org/crosswire/jsword/book/basic jsword/src/main/java/org/crosswire/jsword/book/install/sword jsword/src/main/java/org/crosswire/jsword/book/sword jsword/src/main/java/org/crosswire/jsword/index/lucene jsword-limbo/src/main/java/org/crosswire/bibledesktop/desktop jsword-limbo/src/main/java/org/crosswire/jsword/book/basic jsword-limbo/src/main/java/org/crosswire/jsword/book/install/sword jsword-limbo/src/main/java/org/crosswire/jsword/book/search/ser
dmsmith at www.crosswire.org
dmsmith at www.crosswire.org
Tue Dec 19 13:31:41 MST 2006
Author: dmsmith
Date: 2006-12-19 13:31:39 -0700 (Tue, 19 Dec 2006)
New Revision: 1218
Modified:
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Splash.java
trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsProgressBar.java
trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsViewPane.java
trunk/common/src/main/java/org/crosswire/common/progress/Job.java
trunk/common/src/main/java/org/crosswire/common/progress/JobManager.java
trunk/common/src/main/java/org/crosswire/common/progress/WorkEvent.java
trunk/common/src/test/java/org/crosswire/common/progress/JobTest.java
trunk/common/src/test/java/org/crosswire/common/progress/WorkEventTest.java
trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/desktop/CompareResultsPane.java
trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/desktop/DebugPane.java
trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/desktop/GeneratorPane.java
trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/AbstractLocalURLBook.java
trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/Verifier.java
trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/install/sword/FtpSwordInstaller.java
trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/search/ser/SerIndex.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/Books.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/Msg.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/Msg.properties
trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword/AbstractSwordInstaller.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword/HttpSwordInstaller.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/GZIPBackend.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookPath.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordUtil.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKeyIndex.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeNode.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java
trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java
Log:
Changed Job to implement Progress.
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Desktop.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -67,8 +67,8 @@
import org.crosswire.common.config.ChoiceFactory;
import org.crosswire.common.config.Config;
import org.crosswire.common.history.History;
-import org.crosswire.common.progress.Job;
import org.crosswire.common.progress.JobManager;
+import org.crosswire.common.progress.Progress;
import org.crosswire.common.swing.CatchingThreadGroup;
import org.crosswire.common.swing.ExceptionPane;
import org.crosswire.common.swing.FixedSplitPane;
@@ -181,18 +181,18 @@
// Splash screen
URL predicturl = project.getWritablePropertiesURL(SPLASH_PROPS);
- Job startJob = JobManager.createJob(Msg.STARTUP_TITLE.toString(), predicturl, true);
+ Progress startJob = JobManager.createJob(Msg.STARTUP_TITLE.toString(), predicturl, true);
//startJob.setProgress(Msg.STARTUP_CONFIG.toString());
// Create the Desktop Actions
actions = new DesktopActions(this);
- startJob.setProgress(Msg.STARTUP_GENERATE.toString());
+ startJob.setSectionName(Msg.STARTUP_GENERATE.toString());
createComponents();
// Configuration
- startJob.setProgress(Msg.STARTUP_GENERAL_CONFIG.toString());
+ startJob.setSectionName(Msg.STARTUP_GENERAL_CONFIG.toString());
// GUI setup
debug();
init();
Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Splash.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Splash.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/Splash.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -41,8 +41,8 @@
import javax.swing.JWindow;
import javax.swing.SwingConstants;
-import org.crosswire.common.progress.Job;
import org.crosswire.common.progress.JobManager;
+import org.crosswire.common.progress.Progress;
import org.crosswire.common.progress.WorkEvent;
import org.crosswire.common.progress.WorkListener;
import org.crosswire.common.progress.swing.JobsProgressBar;
@@ -192,8 +192,8 @@
*/
public void workProgressed(WorkEvent ev)
{
- Job job = ev.getJob();
- if (job.getPercent() == 0 || job.isFinished())
+ Progress job = ev.getJob();
+ if (job.getWork() == 0 || job.isFinished())
{
Splash.this.pack();
}
Modified: trunk/common/src/main/java/org/crosswire/common/progress/Job.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/progress/Job.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/common/src/main/java/org/crosswire/common/progress/Job.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -45,36 +45,50 @@
* The copyright to this program is held by it's authors.
* @author Joe Walker [joe at eireneh dot com]
*/
-public final class Job
+public final class Job implements Progress
{
/**
* Create a new Job. This will automatically fire a workProgressed event to
- * all WorkListeners, with the percent property of this job set to 0.
+ * all WorkListeners, with the work property of this job set to 0.
* @param description Short description of this job
- * @param predicturl Optional URL to save/load prediction times from
- * @param work Optional thread to use in request to stop work
+ * @param predictURL Optional URL to save/load prediction times from
+ * @param workerThread Optional thread to use in request to stop workerThread
*/
- protected Job(String description, URL predicturl, Thread work, boolean fakeupdates)
+ protected Job(String description, URL predicturl, Thread worker, int totalWork)
{
- this.statedesc = description;
- this.jobdesc = description;
- this.predicturl = predicturl;
- this.work = work;
- this.reportedpc = 0;
- this.finished = false;
- this.interruptable = work != null;
+ this.predictURL = predicturl;
+ this.workerThread = worker;
this.listeners = new ArrayList();
this.start = -1;
- this.predictedlen = -1;
+ this.predictedLength = -1;
+ beginJob(description, totalWork);
+ }
- if (fakeupdates)
+ /* (non-Javadoc)
+ * @see org.crosswire.common.progress.Progress#beginJob(java.lang.String, int)
+ */
+ public void beginJob(String name, int workToDo)
+ {
+ if (this.finished)
{
+ return;
+ }
+
+ this.totalWork = workToDo;
+ this.sectionName = name;
+ this.jobName = name;
+ this.work = 0;
+ this.finished = false;
+ this.cancelable = workerThread != null;
+
+ if (totalWork == UNKNOWN)
+ {
updater = new Timer();
updater.schedule(new PredictTask(), 0, 100);
}
// Set-up the timings files. It's not a disaster if it doesn't load
- if (predicturl != null)
+ if (predictURL != null)
{
loadPredictions();
}
@@ -83,68 +97,100 @@
current = new HashMap();
start = System.currentTimeMillis();
- JobManager.fireWorkProgressed(this, false);
+ JobManager.fireWorkProgressed(this);
}
- /**
- * We have moved onto another section so update the section title and if
- * available used previous runs to predict timings.
+ /* (non-Javadoc)
+ * @see org.crosswire.common.progress.Progress#getTotalWork()
*/
- public void setProgress(String statedesc)
+ public int getTotalWork()
{
+ return totalWork;
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.common.progress.Progress#setSectionName(java.lang.String)
+ */
+ public void setSectionName(String statedesc)
+ {
+ if (this.finished)
+ {
+ return;
+ }
+
synchronized (this)
{
- this.statedesc = statedesc;
- if (predictedlen != 0)
+ this.sectionName = statedesc;
+
+ if (updater != null)
{
- this.reportedpc = 100 * getAgeFromMap(predicted, statedesc) / predictedlen;
- this.guessedpc = reportedpc;
+ if (predictedLength != 0)
+ {
+ setWork(100 * getAgeFromMap(predicted, statedesc) / predictedLength);
+ }
+ else
+ {
+ setWork(0);
+ }
}
- else
- {
- this.reportedpc = 0;
- this.guessedpc = 0;
- }
-
predictSection(statedesc);
-
+
current.put(statedesc, new Integer((int) (System.currentTimeMillis() - start)));
}
- JobManager.fireWorkProgressed(this, true);
+ if (updater != null)
+ {
+ JobManager.fireWorkProgressed(this);
+ }
}
- /**
- * We have moved onto another section so update the percentage complete
- * and the section title.
+ /* (non-Javadoc)
+ * @see org.crosswire.common.progress.Progress#setWork(int)
*/
- public void setProgress(int percent, String statedesc)
+ public void setWork(int work)
{
+ if (this.finished)
+ {
+ return;
+ }
+
synchronized (this)
{
- this.statedesc = statedesc;
- this.reportedpc = percent;
- this.guessedpc = percent;
+ if (this.work == work)
+ {
+ return;
+ }
- predictSection(statedesc);
+ this.work = work;
- current.put(statedesc, new Integer((int) (System.currentTimeMillis() - start)));
+ predictSection(sectionName);
+
+ current.put(sectionName, new Integer((int) (System.currentTimeMillis() - start)));
}
- JobManager.fireWorkProgressed(this, false);
+ JobManager.fireWorkProgressed(this);
}
/**
- * Called to indicate that we are finished with the dialog
+ * We have moved onto another section so update the percentage complete
+ * and the section title.
*/
+ public void setProgress(int work, String statedesc)
+ {
+ setSectionName(statedesc);
+ setWork(work);
+ }
+
+ /* (non-Javadoc)
+ * @see org.crosswire.common.progress.Progress#done()
+ */
public void done()
{
synchronized (this)
{
finished = true;
- statedesc = Msg.DONE.toString();
- reportedpc = 100;
- guessedpc = 100;
+ sectionName = Msg.DONE.toString();
+ work = 100;
if (updater != null)
{
@@ -152,101 +198,93 @@
updater = null;
}
- current.put(statedesc, new Integer((int) (System.currentTimeMillis() - start)));
+ current.put(sectionName, new Integer((int) (System.currentTimeMillis() - start)));
}
- JobManager.fireWorkProgressed(this, false);
+ JobManager.fireWorkProgressed(this);
- if (predicturl != null)
+ if (predictURL != null)
{
savePredictions();
}
}
- /**
- * Typically called from in a catch block, this ensures that we don't save
- * the timing file because we have a messed up run.
+ /* (non-Javadoc)
+ * @see org.crosswire.common.progress.Progress#getSectionName()
*/
- public void ignoreTimings()
+ public synchronized String getSectionName()
{
- predicturl = null;
+ return sectionName;
}
- /**
- * Accessor for the job description
+ /* (non-Javadoc)
+ * @see org.crosswire.common.progress.Progress#cancel()
*/
- public synchronized String getStateDescription()
+ public void cancel()
{
- return statedesc;
- }
-
- /**
- * Interrupt the job (if possible)
- */
- public void interrupt()
- {
- if (work != null && !finished)
+ if (!finished)
{
ignoreTimings();
done();
- work.interrupt();
+ if (workerThread != null)
+ {
+ workerThread.interrupt();
+ }
}
}
- /**
- * Might the job be interruptable?
+ /* (non-Javadoc)
+ * @see org.crosswire.common.progress.Progress#isCancelable()
*/
- public boolean isInterruptable()
+ public boolean isCancelable()
{
- return interruptable;
+ return cancelable;
}
- /**
- * @param newInterruptable The interruptable to set.
+ /* (non-Javadoc)
+ * @see org.crosswire.common.progress.Progress#setCancelable(boolean)
*/
- public void setInterruptable(boolean newInterruptable)
+ public void setCancelable(boolean newInterruptable)
{
- if (work == null || finished)
+ if (workerThread == null || finished)
{
return;
}
- interruptable = newInterruptable;
+ cancelable = newInterruptable;
fireStateChanged();
}
- /**
- * Shortcut to check if percent == 100
+ /* (non-Javadoc)
+ * @see org.crosswire.common.progress.Progress#isFinished()
*/
public boolean isFinished()
{
return finished;
}
- /**
- * Get estimated the percent progress, extrapolating between sections
- * @return The estimated progress
+ /* (non-Javadoc)
+ * @see org.crosswire.common.progress.Progress#getWork()
*/
- public synchronized int getPercent()
+ public synchronized int getWork()
{
- return guessedpc;
+ return work;
}
- /**
- * Get the last reported total percent progress
- * @return The last reported progress
+ /* (non-Javadoc)
+ * @see org.crosswire.common.progress.Progress#getJobName()
*/
- public synchronized int getReportedPercent()
+ public String getJobName()
{
- return reportedpc;
+ return jobName;
}
/**
- * Get a short descriptive phrase
- * @return The description
+ * Typically called from in a catch block, this ensures that we don't save
+ * the timing file because we have a messed up run.
*/
- public String getJobDescription()
+ private void ignoreTimings()
{
- return jobdesc;
+ predictURL = null;
}
/**
@@ -329,38 +367,36 @@
{
long now = System.currentTimeMillis();
- if (now < sectionstart)
+ if (now < sectionStart)
{
- log.warn("now before started: now=" + new Date(now) + " started=" + new Date(sectionstart)); //$NON-NLS-1$ //$NON-NLS-2$
- guessedpc = reportedpc;
+ log.warn("now before started: now=" + new Date(now) + " started=" + new Date(sectionStart)); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
- if (now == sectionstart)
+ if (now == sectionStart)
{
- guessedpc = reportedpc;
return;
}
- if (now > sectionend)
+ if (now > sectionEnd)
{
// the prediction went wrong and we are ahead of ourselves
- guessedpc = percentend;
+ work = percentEnd;
return;
}
// how long is this section
- int sectlen = (int) (sectionend - sectionstart);
+ int sectlen = (int) (sectionEnd - sectionStart);
// what percent of the way through it are we?
- int sectpc = (int) (100 * (now - sectionstart) / sectlen);
+ int sectpc = (int) (100 * (now - sectionStart) / sectlen);
// so what do we need to add to the current percentage
- int boost = sectpc * (percentend - reportedpc) / 100;
+ int boost = sectpc * (percentEnd - work) / 100;
// so we guess at progress at:
- int total = reportedpc + boost;
+ int total = work + boost;
// but check this is not more than 100
total = total <= 100 ? total : 100;
- guessedpc = total;
+ work = total;
}
/**
@@ -368,18 +404,18 @@
*/
private synchronized void predictSection(String message)
{
- sectionstart = System.currentTimeMillis();
+ sectionStart = System.currentTimeMillis();
// if we have nothing to go on assume 10 sections of 10 sec each.
- if (predicted == null || predictedlen == 0)
+ if (predicted == null || predictedLength == 0)
{
- sectionend = 10000;
- percentend = 10;
+ sectionEnd = 10000;
+ percentEnd = 10;
return;
}
// from the predictions get this section starts and ends and the final finish
- int predsectstart = getAgeFromMap(predicted, statedesc);
+ int predsectstart = getAgeFromMap(predicted, sectionName);
int predsectend = Integer.MAX_VALUE;
// find better values for predsectend and predallend
@@ -397,16 +433,16 @@
}
int predsecttime = predsectend - predsectstart;
- sectionend = sectionstart + predsecttime;
+ sectionEnd = sectionStart + predsecttime;
// And what is the end percentage?
- int pcstart = 100 * predsectstart / predictedlen;
- int pcend = 100 * predsectend / predictedlen;
+ int pcstart = 100 * predsectstart / predictedLength;
+ int pcend = 100 * predsectend / predictedLength;
int pcdiff = pcend - pcstart;
- percentend = reportedpc + pcdiff;
+ percentEnd = work + pcdiff;
- log.debug("Predicting " + predsecttime + "ms (" + reportedpc + '-' + percentend + "%) for section " + message); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ log.debug("Predicting " + predsecttime + "ms (" + work + '-' + percentEnd + "%) for section " + message); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
/**
@@ -416,7 +452,7 @@
{
try
{
- InputStream in = predicturl.openStream();
+ InputStream in = predictURL.openStream();
if (in != null)
{
predicted = new HashMap();
@@ -436,9 +472,9 @@
// if this time is later than the latest
int age = time.intValue();
- if (age > predictedlen)
+ if (age > predictedLength)
{
- predictedlen = age;
+ predictedLength = age;
}
}
catch (NumberFormatException ex)
@@ -486,7 +522,7 @@
// And save. It's not a disaster if this goes wrong
try
{
- OutputStream out = NetUtil.getOutputStream(predicturl);
+ OutputStream out = NetUtil.getOutputStream(predictURL);
predictions.store(out, "Predicted Startup Times"); //$NON-NLS-1$
}
catch (IOException ex)
@@ -496,9 +532,14 @@
}
/**
+ * Total amount of work to do.
+ */
+ private int totalWork;
+
+ /**
* Does this job allow interruptions?
*/
- private boolean interruptable;
+ private boolean cancelable;
/**
* Have we just finished?
@@ -508,42 +549,37 @@
/**
* The officially reported progress
*/
- private int reportedpc;
+ private int work;
/**
- * The guessed progress
- */
- private int guessedpc;
-
- /**
* When do we expect this section to end
*/
- private long sectionend;
+ private long sectionEnd;
/**
* When did this section start?
*/
- private long sectionstart;
+ private long sectionStart;
/**
* The percentage at the end of this section
*/
- private int percentend;
+ private int percentEnd;
/**
* A short descriptive phrase
*/
- private String jobdesc;
+ private String jobName;
/**
* Optional thread to monitor progress
*/
- private Thread work;
+ private Thread workerThread;
/**
* Description of what we are doing
*/
- private String statedesc;
+ private String sectionName;
/**
* When did this job start?
@@ -563,12 +599,12 @@
/**
* How long to we predict this job is going to last?
*/
- private int predictedlen;
+ private int predictedLength;
/**
* The URL to which we load and save timings
*/
- private URL predicturl;
+ private URL predictURL;
/**
* The timer that lets us post fake progress events
@@ -576,7 +612,7 @@
private Timer updater;
/**
- * People that want to know about "interruptable" changes
+ * People that want to know about "cancelable" changes
*/
private List listeners;
@@ -592,7 +628,7 @@
public void run()
{
guessProgress();
- JobManager.fireWorkProgressed(Job.this, true);
+ JobManager.fireWorkProgressed(Job.this);
}
/**
Modified: trunk/common/src/main/java/org/crosswire/common/progress/JobManager.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/progress/JobManager.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/common/src/main/java/org/crosswire/common/progress/JobManager.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -41,7 +41,7 @@
* public void run()
* {
* URL predicturl = Project.instance().getWritablePropertiesURL("save-name");
- * Job job = JobManager.createJob("Job Title", predicturl, this, true);
+ * Progress job = JobManager.createJob("Job Title", predicturl, this, true);
*
* try
* {
@@ -82,12 +82,12 @@
/**
* Create a new Job
*/
- public static Job createJob(String description, URL predicturl, Thread work, boolean fakeupdates)
+ public static Progress createJob(String description, URL predicturl, Thread work, boolean fakeupdates)
{
- Job job = new Job(description, predicturl, work, fakeupdates);
+ Progress job = new Job(description, predicturl, work, fakeupdates ? Progress.UNKNOWN : 100);
jobs.add(job);
- log.debug("job starting: " + job.getJobDescription()); //$NON-NLS-1$
+ log.debug("job starting: " + job.getJobName()); //$NON-NLS-1$
return job;
}
@@ -95,7 +95,7 @@
/**
* Create a new Job
*/
- public static Job createJob(String description, Thread work, boolean fakeupdates)
+ public static Progress createJob(String description, Thread work, boolean fakeupdates)
{
return createJob(description, null, work, fakeupdates);
}
@@ -103,7 +103,7 @@
/**
* Create a new Job
*/
- public static Job createJob(String description, URL predicturl, boolean fakeupdates)
+ public static Progress createJob(String description, URL predicturl, boolean fakeupdates)
{
return createJob(description, predicturl, null, fakeupdates);
}
@@ -111,7 +111,7 @@
/**
* Create a new Job
*/
- public static Job createJob(String description, boolean fakeupdates)
+ public static Progress createJob(String description, boolean fakeupdates)
{
return createJob(description, null, null, fakeupdates);
}
@@ -158,9 +158,9 @@
/**
* Inform the listeners that a title has changed.
*/
- protected static void fireWorkProgressed(Job job, boolean predicted)
+ protected static void fireWorkProgressed(Progress job)
{
- final WorkEvent ev = new WorkEvent(job, predicted);
+ final WorkEvent ev = new WorkEvent(job);
// we need to keep the synchronized section very small to avoid deadlock
// certainly keep the event dispatch clear of the synchronized block or
@@ -190,7 +190,7 @@
{
if (job.isFinished())
{
- log.debug("job finished: " + job.getJobDescription()); //$NON-NLS-1$
+ log.debug("job finished: " + job.getJobName()); //$NON-NLS-1$
jobs.remove(job);
}
}
Modified: trunk/common/src/main/java/org/crosswire/common/progress/WorkEvent.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/progress/WorkEvent.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/common/src/main/java/org/crosswire/common/progress/WorkEvent.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -36,42 +36,20 @@
/**
* Initialize a WorkEvent
*/
- public WorkEvent(Job source, boolean predicted)
+ public WorkEvent(Progress source)
{
super(source);
- this.predicted = predicted;
}
/**
- * Initialize a WorkEvent
- */
- public WorkEvent(Job source)
- {
- super(source);
- }
-
- /**
* Accessor for the Job
*/
- public Job getJob()
+ public Progress getJob()
{
- return (Job) getSource();
+ return (Progress) getSource();
}
/**
- * Is this a predicted or actual progress report?
- */
- public boolean isPredicted()
- {
- return predicted;
- }
-
- /**
- * Is this a predicted or actual progress report?
- */
- private boolean predicted;
-
- /**
* Serialization ID
*/
private static final long serialVersionUID = 3976736990807011378L;
Modified: trunk/common/src/test/java/org/crosswire/common/progress/JobTest.java
===================================================================
--- trunk/common/src/test/java/org/crosswire/common/progress/JobTest.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/common/src/test/java/org/crosswire/common/progress/JobTest.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -51,60 +51,52 @@
public void testJob() throws IOException
{
- Job job;
+ Progress job;
File tempfile = File.createTempFile("jobtest", "tmp"); //$NON-NLS-1$ //$NON-NLS-2$
URL url = new URL(NetUtil.PROTOCOL_FILE, null, tempfile.getAbsolutePath());
job = JobManager.createJob(WIBBLE, false);
- assertEquals(job.getJobDescription(), WIBBLE);
+ assertEquals(job.getJobName(), WIBBLE);
assertEquals(job.isFinished(), false);
- assertEquals(job.isInterruptable(), false);
- assertEquals(job.getStateDescription(), WIBBLE);
- assertEquals(job.getPercent(), 0);
- assertEquals(job.getReportedPercent(), 0);
+ assertEquals(job.isCancelable(), false);
+ assertEquals(job.getSectionName(), WIBBLE);
+ assertEquals(job.getWork(), 0);
job.done();
assertEquals(job.isFinished(), true);
- assertEquals(job.getPercent(), 100);
- assertEquals(job.getReportedPercent(), 100);
- assertEquals(job.isInterruptable(), false);
+ assertEquals(job.getWork(), 100);
+ assertEquals(job.isCancelable(), false);
job = JobManager.createJob(WIBBLE, Thread.currentThread(), false);
- assertEquals(job.getJobDescription(), WIBBLE);
+ assertEquals(job.getJobName(), WIBBLE);
assertEquals(job.isFinished(), false);
- assertEquals(job.isInterruptable(), true);
- assertEquals(job.getStateDescription(), WIBBLE);
- assertEquals(job.getPercent(), 0);
- assertEquals(job.getReportedPercent(), 0);
+ assertEquals(job.isCancelable(), true);
+ assertEquals(job.getSectionName(), WIBBLE);
+ assertEquals(job.getWork(), 0);
job.done();
assertEquals(job.isFinished(), true);
- assertEquals(job.getPercent(), 100);
- assertEquals(job.getReportedPercent(), 100);
-// assertEquals(job.isInterruptable(), false);
+ assertEquals(job.getWork(), 100);
+// assertEquals(job.isCancelable(), false);
job = JobManager.createJob(WIBBLE, url, false);
- assertEquals(job.getJobDescription(), WIBBLE);
+ assertEquals(job.getJobName(), WIBBLE);
assertEquals(job.isFinished(), false);
- assertEquals(job.isInterruptable(), false);
- assertEquals(job.getStateDescription(), WIBBLE);
- assertEquals(job.getPercent(), 0);
- assertEquals(job.getReportedPercent(), 0);
+ assertEquals(job.isCancelable(), false);
+ assertEquals(job.getSectionName(), WIBBLE);
+ assertEquals(job.getWork(), 0);
job.done();
assertEquals(job.isFinished(), true);
- assertEquals(job.getPercent(), 100);
- assertEquals(job.getReportedPercent(), 100);
-// assertEquals(job.isInterruptable(), false);
+ assertEquals(job.getWork(), 100);
+// assertEquals(job.isCancelable(), false);
job = JobManager.createJob(WIBBLE, url, Thread.currentThread(), false);
- assertEquals(job.getJobDescription(), WIBBLE);
+ assertEquals(job.getJobName(), WIBBLE);
assertEquals(job.isFinished(), false);
- assertEquals(job.isInterruptable(), true);
- assertEquals(job.getStateDescription(), WIBBLE);
- assertEquals(job.getPercent(), 0);
- assertEquals(job.getReportedPercent(), 0);
+ assertEquals(job.isCancelable(), true);
+ assertEquals(job.getSectionName(), WIBBLE);
+ assertEquals(job.getWork(), 0);
job.done();
assertEquals(job.isFinished(), true);
- assertEquals(job.getPercent(), 100);
- assertEquals(job.getReportedPercent(), 100);
-// assertEquals(job.isInterruptable(), false);
+ assertEquals(job.getWork(), 100);
+// assertEquals(job.isCancelable(), false);
}
}
Modified: trunk/common/src/test/java/org/crosswire/common/progress/WorkEventTest.java
===================================================================
--- trunk/common/src/test/java/org/crosswire/common/progress/WorkEventTest.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/common/src/test/java/org/crosswire/common/progress/WorkEventTest.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -43,11 +43,10 @@
public void testGetJob()
{
- Job job = JobManager.createJob("wibble", false); //$NON-NLS-1$
- WorkEvent ev = new WorkEvent(job, false);
+ Progress job = JobManager.createJob("wibble", false); //$NON-NLS-1$
+ WorkEvent ev = new WorkEvent(job);
assertEquals(ev.getJob(), job);
assertEquals(ev.getSource(), job);
- assertEquals(ev.isPredicted(), false);
}
}
Modified: trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsProgressBar.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsProgressBar.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsProgressBar.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -44,6 +44,7 @@
import org.crosswire.common.progress.Job;
import org.crosswire.common.progress.JobManager;
+import org.crosswire.common.progress.Progress;
import org.crosswire.common.progress.WorkEvent;
import org.crosswire.common.progress.WorkListener;
import org.crosswire.common.swing.GuiUtil;
@@ -76,7 +77,7 @@
Set current = JobManager.getJobs();
for (Iterator it = current.iterator(); it.hasNext(); )
{
- Job job = (Job) it.next();
+ Progress job = (Job) it.next();
addJob(job);
}
@@ -92,7 +93,7 @@
{
public void run()
{
- Job job = ev.getJob();
+ Progress job = ev.getJob();
if (!jobs.containsKey(job))
{
@@ -114,7 +115,7 @@
*/
public void workStateChanged(WorkEvent ev)
{
- Job job = (Job) ev.getSource();
+ Progress job = (Job) ev.getSource();
JobData jobdata = (JobData) jobs.get(job);
jobdata.workStateChanged(ev);
}
@@ -122,16 +123,16 @@
/**
* Create a new set of components for the new Job
*/
- /*private*/ final synchronized void addJob(Job job)
+ /*private*/ final synchronized void addJob(Progress job)
{
- job.addWorkListener(this);
+ ((Job) job).addWorkListener(this);
int i = findEmptyPosition();
- log.debug("adding job to panel at " + i + ": " + job.getJobDescription()); //$NON-NLS-1$ //$NON-NLS-2$
+ log.debug("adding job to panel at " + i + ": " + job.getJobName()); //$NON-NLS-1$ //$NON-NLS-2$
JProgressBar progress = new JProgressBar();
progress.setStringPainted(true);
- progress.setToolTipText(job.getJobDescription());
+ progress.setToolTipText(job.getJobName());
progress.setBorder(null);
progress.setBackground(getBackground());
progress.setForeground(getForeground());
@@ -161,27 +162,27 @@
/**
* Update the job details because it has just progressed
*/
- protected synchronized void updateJob(Job job)
+ protected synchronized void updateJob(Progress job)
{
JobData jobdata = (JobData) jobs.get(job);
- int percent = job.getPercent();
- jobdata.getProgress().setString(job.getStateDescription() + ": (" + percent + "%)"); //$NON-NLS-1$ //$NON-NLS-2$
+ int percent = job.getWork();
+ jobdata.getProgress().setString(job.getSectionName() + ": (" + percent + "%)"); //$NON-NLS-1$ //$NON-NLS-2$
jobdata.getProgress().setValue(percent);
}
/**
* Remove the set of components from the panel
*/
- protected synchronized void removeJob(Job job)
+ protected synchronized void removeJob(Progress job)
{
- job.removeWorkListener(this);
+ ((Job) job).removeWorkListener(this);
JobData jobdata = (JobData) jobs.get(job);
positions.set(jobdata.getIndex(), null);
jobs.remove(job);
- log.debug("removing job from panel: " + jobdata.getJob().getJobDescription()); //$NON-NLS-1$
+ log.debug("removing job from panel: " + jobdata.getJob().getJobName()); //$NON-NLS-1$
this.remove(jobdata.getComponent());
GuiUtil.refresh(this);
@@ -245,7 +246,7 @@
/**
* Simple ctor
*/
- JobData(Job job, int index, JProgressBar progress)
+ JobData(Progress job, int index, JProgressBar progress)
{
this.job = job;
this.index = index;
@@ -266,7 +267,7 @@
/**
* Accessor for the Job
*/
- Job getJob()
+ Progress getJob()
{
return job;
}
@@ -314,7 +315,7 @@
{
if (cancelButton != null)
{
- cancelButton.setEnabled(job.isInterruptable());
+ cancelButton.setEnabled(job.isCancelable());
}
}
@@ -350,7 +351,7 @@
{
public void actionPerformed(ActionEvent ev)
{
- getJob().interrupt();
+ getJob().cancel();
}
});
return cancelButton;
@@ -364,7 +365,7 @@
*/
private Component decorateProgressBar()
{
- if (!job.isInterruptable())
+ if (!job.isCancelable())
{
return progress;
}
@@ -381,7 +382,7 @@
return panel;
}
- private Job job;
+ private Progress job;
private int index;
private JProgressBar progress;
private Component comp;
Modified: trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsViewPane.java
===================================================================
--- trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsViewPane.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/common-swing/src/main/java/org/crosswire/common/progress/swing/JobsViewPane.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -43,8 +43,8 @@
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingUtilities;
-import org.crosswire.common.progress.Job;
import org.crosswire.common.progress.JobManager;
+import org.crosswire.common.progress.Progress;
import org.crosswire.common.progress.WorkEvent;
import org.crosswire.common.progress.WorkListener;
import org.crosswire.common.swing.GuiUtil;
@@ -71,7 +71,7 @@
Set current = JobManager.getJobs();
for (Iterator it = current.iterator(); it.hasNext(); )
{
- Job job = (Job) it.next();
+ Progress job = (Progress) it.next();
addJob(job);
}
}
@@ -122,18 +122,18 @@
/**
* Create a new set of components for the new Job
*/
- /*private*/ final void addJob(final Job job)
+ /*private*/ final void addJob(final Progress job)
{
int i = findEmptyPosition();
- log.debug("adding job to panel at " + i + ": " + job.getJobDescription()); //$NON-NLS-1$ //$NON-NLS-2$
+ log.debug("adding job to panel at " + i + ": " + job.getJobName()); //$NON-NLS-1$ //$NON-NLS-2$
JProgressBar progress = new JProgressBar();
progress.setStringPainted(true);
progress.setString("0%"); //$NON-NLS-1$
- progress.setToolTipText(job.getJobDescription());
+ progress.setToolTipText(job.getJobName());
progress.setValue(0);
- JLabel label = new JLabel(job.getJobDescription() + ":"); //$NON-NLS-1$
+ JLabel label = new JLabel(job.getJobName() + ":"); //$NON-NLS-1$
// It is clumsy to use an ActionFactory for these buttons,
// since there is one cancel button per job.
@@ -143,7 +143,7 @@
// 2) not have a mnemonic
// 3) not have an accelerator
JButton cancel = new JButton(Msg.CANCEL.toString());
- if (!job.isInterruptable())
+ if (!job.isCancelable())
{
cancel.setEnabled(false);
}
@@ -169,24 +169,24 @@
/**
* Update the job details because it have just progressed
*/
- protected void updateJob(Job job)
+ protected void updateJob(Progress job)
{
JobData jobdata = (JobData) jobs.get(job);
- int percent = job.getPercent();
+ int percent = job.getWork();
jobdata.getProgress().setString(percent + "%"); //$NON-NLS-1$
- jobdata.getProgress().setToolTipText(job.getStateDescription());
+ jobdata.getProgress().setToolTipText(job.getSectionName());
jobdata.getProgress().setValue(percent);
}
/**
* Remove the set of components from the panel
*/
- protected void removeJob(Job job)
+ protected void removeJob(Progress job)
{
JobData jobdata = (JobData) jobs.get(job);
- log.debug("removing job from panel at " + jobdata.getIndex() + ": " + job.getJobDescription()); //$NON-NLS-1$ //$NON-NLS-2$
+ log.debug("removing job from panel at " + jobdata.getIndex() + ": " + job.getJobName()); //$NON-NLS-1$ //$NON-NLS-2$
positions.set(jobdata.getIndex(), null);
jobs.remove(job);
@@ -292,7 +292,7 @@
*/
public void run()
{
- Job job = event.getJob();
+ Progress job = event.getJob();
if (!pane.jobs.containsKey(job))
{
@@ -331,7 +331,7 @@
/**
* @param theJob
*/
- public CancelListener(Job theJob)
+ public CancelListener(Progress theJob)
{
job = theJob;
}
@@ -341,10 +341,10 @@
*/
public void actionPerformed(ActionEvent ev)
{
- job.interrupt();
+ job.cancel();
}
- private Job job;
+ private Progress job;
}
/**
* A simple struct to group information about a Job
@@ -354,7 +354,7 @@
/**
* Simple ctor
*/
- public JobData(Job job, int index, JLabel label, JProgressBar progress, JButton cancel)
+ public JobData(Progress job, int index, JLabel label, JProgressBar progress, JButton cancel)
{
this.job = job;
this.index = index;
@@ -378,7 +378,7 @@
/**
* Accessor for the job
*/
- Job getJob()
+ Progress getJob()
{
return job;
}
@@ -415,7 +415,7 @@
return index;
}
- private Job job;
+ private Progress job;
private JLabel label;
private JProgressBar progress;
private JButton cancel;
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/Books.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/Books.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/Books.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -391,8 +391,7 @@
{
// URL predicturl =
// Project.instance().getWritablePropertiesURL("books"); //$NON-NLS-1$
- // Job job = JobManager.createJob(Msg.JOB_TITLE.toString(), predicturl,
- // null, true);
+ // Progress job = JobManager.createJob(Msg.JOB_TITLE.toString(), predicturl, null, true);
// This will classload them all and they will register themselves.
Class[] types = ClassUtil.getImplementors(BookDriver.class);
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/Msg.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/Msg.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/Msg.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -35,12 +35,6 @@
static final Msg DRIVER_READONLY = new Msg("AbstractBookDriver.DriverReadonly"); //$NON-NLS-1$
static final Msg INDEX_FAIL = new Msg("AbstractBookDriver.IndexFail"); //$NON-NLS-1$
static final Msg FILTER_FAIL = new Msg("AbstractPassageBook.FilterFail"); //$NON-NLS-1$
- static final Msg VERIFY_START = new Msg("Verifier.Start"); //$NON-NLS-1$
- static final Msg VERIFY_VERSES = new Msg("Verifier.Verses"); //$NON-NLS-1$
- static final Msg VERIFY_VERSE = new Msg("Verifier.Verse"); //$NON-NLS-1$
- static final Msg VERIFY_PASSAGES = new Msg("Verifier.Passages"); //$NON-NLS-1$
- static final Msg VERIFY_WORDS = new Msg("Verifier.Words"); //$NON-NLS-1$
- static final Msg WORD = new Msg("Verifier.Word"); //$NON-NLS-1$
/**
* Passthrough ctor
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/Msg.properties
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/Msg.properties 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/basic/Msg.properties 2006-12-19 20:31:39 UTC (rev 1218)
@@ -8,9 +8,3 @@
AbstractBookDriver.DriverReadonly=This Book is read-only.
AbstractBookDriver.IndexFail=Failed to initialize the search index
AbstractPassageBook.FilterFail=Filtering input data failed.
-Verifier.Start=Copying Bible data to new driver
-Verifier.Verses=Checking Verses
-Verifier.Verse=Verse:
-Verifier.Passages=Checking Passages
-Verifier.Words=Checking Words
-Verifier.Word=Word:
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword/AbstractSwordInstaller.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword/AbstractSwordInstaller.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword/AbstractSwordInstaller.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -33,8 +33,8 @@
import java.util.Map;
import java.util.zip.GZIPInputStream;
-import org.crosswire.common.progress.Job;
import org.crosswire.common.progress.JobManager;
+import org.crosswire.common.progress.Progress;
import org.crosswire.common.util.IOUtil;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
@@ -74,7 +74,7 @@
* @param file The file to download
* @throws InstallException
*/
- protected abstract void download(Job job, String dir, String file, URL dest) throws InstallException;
+ protected abstract void download(Progress job, String dir, String file, URL dest) throws InstallException;
/* (non-Javadoc)
* @see org.crosswire.jsword.book.install.Installer#getURL()
@@ -181,25 +181,25 @@
public void run()
{
URL predicturl = Project.instance().getWritablePropertiesURL("sword-install"); //$NON-NLS-1$
- Job job = JobManager.createJob(Msg.INSTALLING.toString(sbmd.getName()), predicturl, this, true);
+ Progress job = JobManager.createJob(Msg.INSTALLING.toString(sbmd.getName()), predicturl, this, true);
yield();
try
{
- job.setProgress(Msg.JOB_INIT.toString());
+ job.setSectionName(Msg.JOB_INIT.toString());
URL temp = NetUtil.getTemporaryURL("swd", ZIP_SUFFIX); //$NON-NLS-1$
download(job, directory + '/' + PACKAGE_DIR, sbmd.getInitials() + ZIP_SUFFIX, temp);
// Once the unzipping is started, we need to continue
- job.setInterruptable(false);
+ job.setCancelable(false);
if (!job.isFinished())
{
File dldir = SwordBookPath.getSwordDownloadDir();
IOUtil.unpackZip(NetUtil.getAsFile(temp), dldir);
- job.setProgress(Msg.JOB_CONFIG.toString());
+ job.setSectionName(Msg.JOB_CONFIG.toString());
sbmd.setLibrary(NetUtil.getURL(dldir));
SwordBookDriver.registerNewBook(sbmd);
}
@@ -208,17 +208,17 @@
catch (IOException e)
{
Reporter.informUser(this, e);
- job.ignoreTimings();
+ job.cancel();
}
catch (InstallException e)
{
Reporter.informUser(this, e);
- job.ignoreTimings();
+ job.cancel();
}
catch (BookException e)
{
Reporter.informUser(this, e);
- job.ignoreTimings();
+ job.cancel();
}
finally
{
@@ -237,7 +237,7 @@
*/
public void reloadBookList() throws InstallException
{
- Job job = JobManager.createJob(Msg.JOB_DOWNLOADING.toString(), Thread.currentThread(), false);
+ Progress job = JobManager.createJob(Msg.JOB_DOWNLOADING.toString(), Thread.currentThread(), false);
try
{
@@ -247,7 +247,7 @@
}
catch (InstallException ex)
{
- job.ignoreTimings();
+ job.cancel();
throw ex;
}
finally
@@ -261,7 +261,7 @@
*/
public void downloadSearchIndex(Book book, URL localDest) throws InstallException
{
- Job job = JobManager.createJob(Msg.JOB_DOWNLOADING.toString(), Thread.currentThread(), false);
+ Progress job = JobManager.createJob(Msg.JOB_DOWNLOADING.toString(), Thread.currentThread(), false);
try
{
@@ -269,7 +269,7 @@
}
catch (InstallException ex)
{
- job.ignoreTimings();
+ job.cancel();
throw ex;
}
finally
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword/HttpSwordInstaller.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword/HttpSwordInstaller.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword/HttpSwordInstaller.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -24,7 +24,7 @@
import java.net.MalformedURLException;
import java.net.URL;
-import org.crosswire.common.progress.Job;
+import org.crosswire.common.progress.Progress;
import org.crosswire.common.util.LucidException;
import org.crosswire.common.util.NetUtil;
import org.crosswire.common.util.WebResource;
@@ -77,7 +77,7 @@
* @see org.crosswire.jsword.book.install.sword.AbstractSwordInstaller#download(java.lang.String, java.lang.String, java.net.URL)
*/
/* @Override */
- protected void download(Job job, String dir, String file, URL dest) throws InstallException
+ protected void download(Progress job, String dir, String file, URL dest) throws InstallException
{
try
{
@@ -100,11 +100,11 @@
* @param dest
* @throws LucidException
*/
- private void copy(Job job, URL url, URL dest) throws LucidException
+ private void copy(Progress job, URL url, URL dest) throws LucidException
{
if (job != null)
{
- job.setProgress(Msg.JOB_DOWNLOADING.toString());
+ job.setSectionName(Msg.JOB_DOWNLOADING.toString());
}
WebResource wr = new WebResource(url, proxyHost, proxyPort);
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/GZIPBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/GZIPBackend.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/GZIPBackend.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -234,7 +234,7 @@
try
{
int testament = SwordConstants.getTestament(verse);
- int index = SwordConstants.getIndex(verse);
+ long index = SwordConstants.getIndex(verse);
// If Bible does not contain the desired testament, return nothing.
if (compRaf[testament] == null)
@@ -254,7 +254,7 @@
}
// The data is little endian - extract the blockNum, verseStart and verseSize
- int blockNum = SwordUtil.decodeLittleEndian32(temp, 0);
+ long blockNum = SwordUtil.decodeLittleEndian32(temp, 0);
int verseStart = SwordUtil.decodeLittleEndian32(temp, 4);
int verseSize = SwordUtil.decodeLittleEndian16(temp, 8);
@@ -373,7 +373,7 @@
/**
*
*/
- private int lastBlockNum = -1;
+ private long lastBlockNum = -1;
/**
*
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/RawBackend.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -150,7 +150,7 @@
try
{
int testament = SwordConstants.getTestament(verse);
- int index = SwordConstants.getIndex(verse);
+ long index = SwordConstants.getIndex(verse);
// If this is a single testament Bible, return nothing.
if (idxRaf[testament] == null)
@@ -166,7 +166,7 @@
}
// The data is little endian - extract the start and size
- int start = SwordUtil.decodeLittleEndian32(read, 0);
+ long start = SwordUtil.decodeLittleEndian32(read, 0);
int size = SwordUtil.decodeLittleEndian16(read, 4);
if (size < 0)
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookPath.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookPath.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordBookPath.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -478,7 +478,7 @@
/**
* The directory URL
*/
- private static File overrideDownloadDir = null;
+ private static File overrideDownloadDir;
/**
* The log stream
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordUtil.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/SwordUtil.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -111,7 +111,6 @@
/**
* Read a RandomAccessFile until a particular byte is seen
* @param raf The file to read
- * @param offset The start of the record to read
* @param stopByte The point at which to stop reading
* @return the read data
*/
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKeyIndex.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKeyIndex.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeKeyIndex.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -154,7 +154,7 @@
buffer = SwordUtil.readUntilRAF(datRaf, (byte) 0);
int size = buffer.length;
- if (buffer[size-1] == 0)
+ if (buffer[size - 1] == 0)
{
size--;
}
@@ -169,7 +169,7 @@
node.setUserData(SwordUtil.readNextRAF(datRaf, userDataSize));
}
- return node;
+ return node;
}
/* (non-Javadoc)
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeNode.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeNode.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/TreeNode.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -93,7 +93,7 @@
*/
public byte[] getUserData()
{
- return userData;
+ return (byte[]) userData.clone();
}
/**
@@ -101,7 +101,7 @@
*/
public void setUserData(byte[] theUserData)
{
- userData = theUserData;
+ userData = (byte[]) theUserData.clone();
}
/**
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/sword/ZLDBackend.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -92,7 +92,7 @@
private RandomAccessFile zdtRaf;
private boolean active;
private Key keys;
- private int lastBlockNum = -1;
+ private long lastBlockNum = -1;
private static final byte[] EMPTY_BYTES = new byte[0];
private byte[] lastUncompressed = EMPTY_BYTES;
@@ -221,7 +221,7 @@
return keys;
}
- for (int entry = 0; entry < entries; entry++)
+ for (long entry = 0; entry < entries; entry++)
{
try
{
@@ -316,7 +316,7 @@
return getRawText(ikey);
}
- int blockNum = SwordUtil.decodeLittleEndian32(temp, 0);
+ long blockNum = SwordUtil.decodeLittleEndian32(temp, 0);
int entry = SwordUtil.decodeLittleEndian32(temp, 4);
// Can we get the data from the cache
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneIndex.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -43,8 +43,8 @@
import org.crosswire.common.activate.Activatable;
import org.crosswire.common.activate.Activator;
import org.crosswire.common.activate.Lock;
-import org.crosswire.common.progress.Job;
import org.crosswire.common.progress.JobManager;
+import org.crosswire.common.progress.Progress;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
import org.crosswire.common.util.Reporter;
@@ -112,7 +112,7 @@
throw new BookException(Msg.LUCENE_INIT, ex);
}
- Job job = JobManager.createJob(Msg.INDEX_START.toString(), Thread.currentThread(), false);
+ Progress job = JobManager.createJob(Msg.INDEX_START.toString(), Thread.currentThread(), false);
IndexStatus finalStatus = IndexStatus.UNDONE;
try
@@ -129,12 +129,13 @@
List errors = new ArrayList();
generateSearchIndexImpl(job, errors, writer, book.getGlobalKeyList());
- job.setProgress(95, Msg.OPTIMIZING.toString());
+ job.setSectionName(Msg.OPTIMIZING.toString());
+ job.setWork(95);
writer.optimize();
writer.close();
- job.setInterruptable(false);
+ job.setCancelable(false);
if (!job.isFinished())
{
tempPath.renameTo(finalPath);
@@ -160,7 +161,7 @@
}
catch (IOException ex)
{
- job.ignoreTimings();
+ job.cancel();
throw new BookException(Msg.LUCENE_INIT, ex);
}
finally
@@ -320,7 +321,7 @@
/**
* Dig down into a Key indexing as we go.
*/
- private void generateSearchIndexImpl(Job job, List errors, IndexWriter writer, Key key) throws BookException, IOException
+ private void generateSearchIndexImpl(Progress job, List errors, IndexWriter writer, Key key) throws BookException, IOException
{
int bookNum = 0;
int oldBookNum = -1;
@@ -382,7 +383,8 @@
name = subkey.getName();
}
- job.setProgress(percent, Msg.INDEXING.toString(name));
+ job.setSectionName(Msg.INDEXING.toString(name));
+ job.setWork(percent);
// This could take a long time ...
Thread.yield();
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/desktop/CompareResultsPane.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/desktop/CompareResultsPane.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/desktop/CompareResultsPane.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -43,8 +43,8 @@
import javax.swing.border.TitledBorder;
import javax.swing.text.Document;
-import org.crosswire.common.progress.Job;
import org.crosswire.common.progress.JobManager;
+import org.crosswire.common.progress.Progress;
import org.crosswire.common.progress.WorkEvent;
import org.crosswire.common.progress.WorkListener;
import org.crosswire.common.swing.DocumentWriter;
@@ -334,9 +334,9 @@
{
public void run()
{
- Job job = ev.getJob();
- int percent = job.getPercent();
- barProgress.setString(job.getStateDescription() + ": (" + percent + "%)"); //$NON-NLS-1$ //$NON-NLS-2$
+ Progress job = ev.getJob();
+ int percent = job.getWork();
+ barProgress.setString(job.getSectionName() + ": (" + percent + "%)"); //$NON-NLS-1$ //$NON-NLS-2$
barProgress.setValue(percent);
}
});
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/desktop/DebugPane.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/desktop/DebugPane.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/desktop/DebugPane.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -44,8 +44,8 @@
import javax.swing.JTextPane;
import org.crosswire.bibledesktop.book.BibleViewPane;
-import org.crosswire.common.progress.Job;
import org.crosswire.common.progress.JobManager;
+import org.crosswire.common.progress.Progress;
import org.crosswire.common.util.Logger;
import org.crosswire.jsword.util.Project;
@@ -190,9 +190,9 @@
/* @Override */
public synchronized void run()
{
- Job job = JobManager.createJob(predictbase, predicturl, Thread.currentThread(), fake);
+ Progress job = JobManager.createJob(predictbase, predicturl, Thread.currentThread(), fake);
- job.setProgress(0, Msg.DEBUG_STEPS.toString(new Object[] { new Integer(0), new Integer(steps) }));
+ job.setSectionName(Msg.DEBUG_STEPS.toString(new Object[] { new Integer(0), new Integer(steps) }));
log.debug("starting test job:"); //$NON-NLS-1$
for (int i = 1; i <= steps && !Thread.interrupted(); i++)
@@ -206,7 +206,8 @@
log.warn("Exception while waiting", ex); //$NON-NLS-1$
}
- job.setProgress((i * 100) / steps, Msg.DEBUG_STEPS.toString(new Object[] { new Integer(i), new Integer(steps) }));
+ job.setWork((i * 100) / steps);
+ job.setSectionName(Msg.DEBUG_STEPS.toString(new Object[] { new Integer(i), new Integer(steps) }));
}
job.done();
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/desktop/GeneratorPane.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/desktop/GeneratorPane.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/bibledesktop/desktop/GeneratorPane.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -48,7 +48,7 @@
import org.crosswire.bibledesktop.book.BookListCellRenderer;
import org.crosswire.bibledesktop.book.BooksComboBoxModel;
import org.crosswire.bibledesktop.book.DriversComboBoxModel;
-import org.crosswire.common.progress.Job;
+import org.crosswire.common.progress.Progress;
import org.crosswire.common.progress.WorkEvent;
import org.crosswire.common.progress.WorkListener;
import org.crosswire.common.swing.EirPanel;
@@ -392,9 +392,9 @@
{
public void run()
{
- Job job = ev.getJob();
- int percent = job.getPercent();
- barProg.setString(job.getStateDescription() + ": (" + percent + "%)"); //$NON-NLS-1$ //$NON-NLS-2$
+ Progress job = ev.getJob();
+ int percent = job.getWork();
+ barProg.setString(job.getSectionName() + ": (" + percent + "%)"); //$NON-NLS-1$ //$NON-NLS-2$
barProg.setValue(percent);
}
});
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/AbstractLocalURLBook.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/AbstractLocalURLBook.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/AbstractLocalURLBook.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -66,7 +66,7 @@
Passage temp = PassageFactory.createPassage(PassageFactory.SPEED);
- Job job = JobManager.createJob("Copying Bible data to new driver", Thread.currentThread(), false);
+ Progress job = JobManager.createJob("Copying Bible data to new driver", Thread.currentThread(), false);
int percent = -1;
// For every verse in the Bible
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/Verifier.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/Verifier.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/basic/Verifier.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -25,8 +25,8 @@
import java.util.ArrayList;
import java.util.Iterator;
-import org.crosswire.common.progress.Job;
import org.crosswire.common.progress.JobManager;
+import org.crosswire.common.progress.Progress;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.BookException;
@@ -100,7 +100,7 @@
*/
public void checkText(Key key, PrintWriter out)
{
- Job job = JobManager.createJob(Msg.VERIFY_START.toString(), Thread.currentThread(), false);
+ Progress job = JobManager.createJob(VerifierMsg.VERIFY_START.toString(), Thread.currentThread(), false);
if (key == null)
{
@@ -108,6 +108,7 @@
}
// For every verse in the Bible
+ job.setSectionName(VerifierMsg.VERIFY_VERSES.toString());
int percent = 0;
for (Iterator it = key.iterator(); it.hasNext(); )
{
@@ -128,7 +129,7 @@
// Check - this needs some work
if (!text1.equals(text2))
{
- out.println(Msg.VERIFY_VERSE.toString() + subkey);
+ out.println(VerifierMsg.VERIFY_VERSE.toString() + subkey);
out.println(book1.getName() + ": " + text1); //$NON-NLS-1$
out.println(book2.getName() + ": " + text2); //$NON-NLS-1$
out.println();
@@ -136,7 +137,7 @@
}
catch (Exception ex)
{
- out.println(Msg.VERIFY_VERSE.toString() + subkey);
+ out.println(VerifierMsg.VERIFY_VERSE.toString() + subkey);
ex.printStackTrace(out);
out.println();
}
@@ -148,7 +149,7 @@
percent = 100 * verse.getOrdinal() / BibleInfo.versesInBible();
}
- job.setProgress(percent, Msg.VERIFY_VERSES.toString());
+ job.setWork(percent);
// This could take a long time ...
Thread.yield();
@@ -165,7 +166,7 @@
*/
public void checkPassage(PrintWriter out) throws BookException
{
- Job job = JobManager.createJob(Msg.VERIFY_PASSAGES.toString(), Thread.currentThread(), false);
+ Progress job = JobManager.createJob(VerifierMsg.VERIFY_PASSAGES.toString(), Thread.currentThread(), false);
int count = 0;
int percent = -1;
@@ -182,7 +183,7 @@
if (percent != newpercent)
{
percent = newpercent;
- job.setProgress(percent, Msg.VERIFY_WORDS.toString());
+ job.setWork(percent);
}
// This could take a long time ...
@@ -207,7 +208,7 @@
// Check
if (!ref1.equals(ref2))
{
- out.println(Msg.WORD.toString() + word);
+ out.println(VerifierMsg.VERIFY_WORD.toString() + word);
out.println(book1.getName() + ": " + ref1); //$NON-NLS-1$
out.println(book2.getName() + ": " + ref2); //$NON-NLS-1$
out.println();
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/install/sword/FtpSwordInstaller.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/install/sword/FtpSwordInstaller.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/install/sword/FtpSwordInstaller.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -29,7 +29,7 @@
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
-import org.crosswire.common.progress.Job;
+import org.crosswire.common.progress.Progress;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
import org.crosswire.jsword.book.Book;
@@ -100,7 +100,7 @@
* @see org.crosswire.jsword.book.install.sword.AbstractSwordInstaller#download(java.lang.String, java.lang.String, java.net.URL)
*/
/* @Override */
- protected void download(Job job, String dir, String file, URL dest) throws InstallException
+ protected void download(Progress job, String dir, String file, URL dest) throws InstallException
{
FTPClient ftp = new FTPClient();
Modified: trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/search/ser/SerIndex.java
===================================================================
--- trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/search/ser/SerIndex.java 2006-12-19 02:23:09 UTC (rev 1217)
+++ trunk/jsword-limbo/src/main/java/org/crosswire/jsword/book/search/ser/SerIndex.java 2006-12-19 20:31:39 UTC (rev 1218)
@@ -37,8 +37,8 @@
import org.crosswire.common.activate.Activatable;
import org.crosswire.common.activate.Activator;
import org.crosswire.common.activate.Lock;
-import org.crosswire.common.progress.Job;
import org.crosswire.common.progress.JobManager;
+import org.crosswire.common.progress.Progress;
import org.crosswire.common.util.FileUtil;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
@@ -88,7 +88,7 @@
this.book = book;
this.url = storage;
- Job job = JobManager.createJob(Msg.INDEX_START.toString(), Thread.currentThread(), false);
+ Progress job = JobManager.createJob(Msg.INDEX_START.toString(), Thread.currentThread(), false);
try
{
@@ -99,7 +99,7 @@
}
catch (Exception ex)
{
- job.ignoreTimings();
+ job.cancel();
throw new BookException(Msg.SER_INIT, ex);
}
finally
@@ -189,7 +189,7 @@
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.AbstractIndex#generateSearchIndex(org.crosswire.common.progress.Job)
*/
- public void generateSearchIndex(Job job) throws BookException
+ public void generateSearchIndex(Progress job) throws BookException
{
// create a word/passage hashmap
Map matchmap = new HashMap();
@@ -219,7 +219,8 @@
// Fire a progress event?
int percent = PERCENT_READ + (PERCENT_WRITE * count++ / words) / BibleInfo.versesInBible();
- job.setProgress(percent, Msg.WRITING_WORDS.toString(word));
+ job.setSectionName(Msg.WRITING_WORDS.toString(word));
+ job.setWork(percent);
// This could take a long time ...
Thread.yield();
@@ -232,7 +233,8 @@
// Store the indexes on disk
try
{
- job.setProgress(PERCENT_READ + PERCENT_WRITE, Msg.SAVING.toString());
+ job.setSectionName(Msg.SAVING.toString());
+ job.setWork(PERCENT_READ + PERCENT_WRITE);
// Save the ascii Passage index
URL indexurl = NetUtil.lengthenURL(url, FILE_INDEX);
@@ -255,7 +257,7 @@
/**
* Dig down into a Key indexing as we go.
*/
- private void generateSearchIndexImpl(Job job, Key key, Map matchmap) throws BookException
+ private void generateSearchIndexImpl(Progress job, Key key, Map matchmap) throws BookException
{
// loop through all the verses
@@ -294,7 +296,8 @@
percent = PERCENT_READ * verse.getOrdinal() / BibleInfo.versesInBible();
}
- job.setProgress(percent, Msg.FINDING_WORDS.toString(sublist.getName()));
+ job.setSectionName(Msg.FINDING_WORDS.toString(sublist.getName()));
+ job.setWork(percent);
// This could take a long time ...
Thread.yield();
More information about the jsword-svn
mailing list