package org.sf.mustru.ui;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.sf.mustru.search.SearchQuestion;
/**
* The thread to start the question generator - reads the language models and
* initialize GATE code.
*/
public class RunQAStartup implements IRunnableWithProgress
{
private boolean jobRan = true;
private SearchQuestion sq = null;
public RunQAStartup() { super(); }
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
{
monitor.beginTask("Starting QA System...", 10);
QAStartup qaStart = new QAStartup(this);
qaStart.start();
boolean done = false;
while (!done)
{ done = true;
//*-- wait a second
try { Thread.sleep(1000); } catch (InterruptedException e) { }
if (qaStart.running) done = false;
if (monitor.isCanceled())
{ done = true; monitor.done(); setJobRan(false); }
monitor.worked(1);
} //*-- end of while
monitor.done();
}
public boolean isJobRan()
{ return jobRan; }
public void setJobRan(boolean jobRan)
{ this.jobRan = jobRan; }
public SearchQuestion getSq()
{ return sq; }
public void setSq(SearchQuestion sq)
{ this.sq = sq; }
}
//*-- inner class to create the query generator instance
class QAStartup extends Thread
{
public boolean running;
public RunQAStartup parent;
public QAStartup(RunQAStartup parent)
{ this.parent = parent; }
public void run()
{ running = true;
parent.setSq( new SearchQuestion());
running = false;
}
}