/** File: ProcessData.java */ import java.awt.Cursor; /** * Class ProcessData is used to create data processing Thread to run the converter. *
* List of Methods*
* =================== * ProcessData() - Constructor * run() - Process data specified by the GUI state * *
* This code is available at the HTMLtools project on SourceForge at * http://htmltools.sourceforge.net/ * under the "Common Public License Version 1.0" * * http://www.opensource.org/licenses/cpl1.0.php.
** It was derived and refactored from the open source * MAExplorer (http://maexplorer.sourceforge.net/), and * Open2Dprot (http://Open2Dprot.sourceforge.net/) Table modules. *
* $Date: 2009/07/13 11:45:56 $ $Revision: 1.28 $
*
* Copyright 2008, 2009 by Peter Lemkin
* E-Mail: lemkin@users.sourceforge.net
* http://lemkingroup.com/
*
*/
public class ProcessData extends Thread
{ /* ProcessData */
public final static long
serialVersionUID= 0;
/** Note all GUI global variables are in CvtGUI.java instance. */
private CvtGUI
gui= null;
/** Thread version of the converter */
public HTMLtools
cvtT= null;
/** Command line string created to use when running the converter
* used by ProcessData.
*/
public volatile String
sGuiArgV= null;
/** String array created from sGuiArgV to use when running the converter */
private String
guiArgV[]= null;
/** Ready to do new computation flag. Set false while processing. */
private volatile boolean
readyFlag= false;
/**
* ProcessData() - Constructor
* @param gui is an instance of the CvtGUI class
* @param sGuiArgV is the command arg line as a string
* @param guiArgV - is arg list for the converter
*/
public ProcessData(CvtGUI gui, String sGuiArgV, String guiArgV[])
{ /* ProcessData */
this.setName("ProcessData"); /* Set the Thread name */
this.cvtT= new HTMLtools();
this.gui= gui;
this.sGuiArgV= sGuiArgV;
this.guiArgV= guiArgV;
if(guiArgV==null)
{ /* No job to run */
gui.setEnableAssignButtonsAndMenus();
UtilCM.logMsg("\nCan't Process data since no command '"+
sGuiArgV+"'.\n");
readyFlag= false;
}
else
readyFlag= true;
} /* ProcessData */
/**
* run() - Process data specified by the GUI state
*/
public void run()
{ /* run */
if(!readyFlag)
return; /* No job to run */
/* [2] Run the converter if enabled in this infinite loop.
* Test for termination and for thread interruption.
* Call converter with data specified by GUI state.
* Do the heavy lifting.
*/
gui.doneFlag= false;
gui.processFlag= true;
gui.processedOKflag= false;
/* [3] Process to perform the conversion */
gui.printGuiFSMlf("pd.run()-START-CONVERSION",gui.printFSMflag);
gui.processedOKflag= cvtT.cmdLineProcess(guiArgV);
UtilCM.logMsg("\n##################################################\n"+
"##################################################\n");
/* [4] Set process completion status */
String genHTMLpathList[]= gui.cvt.getGenHTMLpathList();
if(gui.processedOKflag)
{ /* Succeeded */
gui.setEnableViewingButtonsAndMenus();
UtilCM.logMsg("\nProcessing succeeded.\n");
if(genHTMLpathList!=null)
{ /* There are files to view */
UtilCM.logMsg("The following files are available for viewing:\n");
UtilCM.logMsg(gui.getListGeneratedHTMLfileNames());
UtilCM.logMsg("\nSelect a generated HTML file from the view "+
"HTML file list to popup a Web browser.\n");
}
else
gui.setEnableAssignButtonsAndMenus();
} /* Succeeded */
else
{ /* Failed or interrupted */
UtilCM.logMsg("\nProcessing failed - no files to view. "+
"Please try another script file\n");
gui.setEnableAssignButtonsAndMenus();
}
gui.doneFlag= true;
gui.printGuiFSMlf("pd.run()-FINISHED-CONVERSION",gui.printFSMflag);
/* [4] Kills pd thread when return from run() */
return;
} /* run */
} /* end of class ProcessData */