import java.awt.*; import javax.swing.*; public class ExeCrpc implements Runnable { private JTextField status; private JTextArea resultText; private JScrollPane sp; private String command; private boolean debug; private Thread rjThread, sfThread, rfThread, meThread; public ExeCrpc(JTextField status, JTextArea resultText, JScrollPane sp, String command, boolean debug) { this.status = status; this.resultText = resultText; this.sp = sp; this.command = command; this.debug = debug; if(debug) System.out.println("ExeAdcirc constructor completed"); } public void run(){ /* first upload a file */ /* no upload file status.setText("uploading input..."); String sourceFN = "planet.jpg"; String destFN = "/tmp/planet.jpg"; SendFile sf = new SendFile(sourceFN,destFN,status,true); sfThread = new Thread(sf); sfThread.start(); MonitorExecution me = new MonitorExecution(sfThread,status,debug); meThread = new Thread(me); meThread.start(); try { meThread.join(); } catch (Exception e) {System.out.println("upload "+e);} */ /* then run the job */ status.setText("running..."); runJob rj = new runJob(command, resultText, sp, debug); rjThread = new Thread(rj); rjThread.start(); MonitorExecution me = new MonitorExecution(rjThread,status,debug); meThread = new Thread(me); meThread.start(); try { meThread.join(); } catch (Exception e) {System.out.println("run "+e);} /* finally download results */ /* no download file status.setText("downloading results..."); try { short blksize = new Short("16384").shortValue(); Connection.remote.setBlockSize(blksize); } catch (Exception e) {System.out.println(e);} String s="/projects/cps/jgrid/webflow/jswdk-1.0/webpages/adcirc/fort.63"; String d="fort.63"; ReceiveFile rf = new ReceiveFile(d,s,status,true); rfThread = new Thread(rf); rfThread.start(); me = new MonitorExecution(rfThread,status,debug); meThread = new Thread(me); meThread.start(); */ } public synchronized void waitFor(long howLong){ try { wait(howLong); } catch (Exception e) { System.out.println(e);} } }