/* File: ProcessDataSearchSearch.java */ import java.awt.Cursor; /** * Class ProcessDataSearch is used to create data processing Thread to run the * search converter. *
 * List of Methods
* =================== * ProcessDataSearch() - 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/11/23 11:45:56 $ $Revision: 1.37 $ *
* Copyright 2008, 2009 by Peter Lemkin * E-Mail: lemkin@users.sourceforge.net * http://lemkingroup.com/ *
*/ public class ProcessDataSearch extends Thread { /* ProcessDataSearch */ public final static long serialVersionUID= 0; /** Note all GUI global variables are in SearchsGui.java instance. */ private SearchGUI sGui= null; /** Thread version of the converter */ private HTMLtools cvtT= null; /** Command line string created to use when running the converter * used by ProcessDataSearch. */ 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; /** * ProcessDataSearch() - 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 ProcessDataSearch(SearchGUI sGui, String sGuiArgV, String guiArgV[]) { /* ProcessDataSearch */ this.setName("ProcessDataSearch"); /* Set the Thread name */ this.cvtT= new HTMLtools(); this.sGui= sGui; this.sGuiArgV= sGuiArgV; this.guiArgV= guiArgV; if(guiArgV==null) { /* No job to run */ sGui.setEnableSearchParamsButtonsAndMenus(); UtilCM.logMsg("\nCan't Process data since no command '"+ sGuiArgV+"'.\n"); readyFlag= false; } else readyFlag= true; } /* ProcessDataSearch */ /** * 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. */ readyFlag= false; sGui.doneFlag= false; sGui.processFlag= true; sGui.processedOKflag= false; /* [3] Process to perform the conversion */ sGui.setCursor(Cursor.WAIT_CURSOR); sGui.processedOKflag= cvtT.cmdLineProcess(guiArgV); sGui.setCursor(Cursor.DEFAULT_CURSOR); UtilCM.logMsg("\n##################################################\n"+ "##################################################\n"); /* [4] Set process completion status */ String genHTMLpathList[]= sGui.cvt.getGenHTMLpathList(); if(sGui.processedOKflag && (genHTMLpathList!=null)) { /* Succeeded */ sGui.setEnableViewingButtonsAndMenus(); UtilCM.logMsg("\nProcessing succeeded.\n"); if(genHTMLpathList!=null) { /* There are files to view */ UtilCM.logMsg("The following Excel compatible file was generated: '"); UtilCM.logMsg(sGui.guiActiveTXTfile); UtilCM.logMsg("'\nThe following file is available for viewing: '"); UtilCM.logMsg(sGui.guiActiveHTMLfile); UtilCM.logMsg("'\nSelect a generated HTML file from the view "+ "HTML file list to popup a Web browser.\n"); } else sGui.setEnableSearchParamsState(); } else { /* Failed or interrupted */ UtilCM.logMsg("\nProcessing failed - no files to view. "+ "Please try another script file\n"); sGui.setEnableSearchParamsButtonsAndMenus(); } sGui.doneFlag= true; /* [4] Kills pd thread when return from run() */ return; } /* run */ } /* end of class ProcessDataSearch */