ptolemy.gui
Class StreamExec

java.lang.Object
  |
  +--ptolemy.gui.StreamExec

public class StreamExec
extends java.lang.Object

Execute commands in a subprocess. This class does not use swing, for a graphical interface, see the derived class JTextAreaExec.

Loosely based on Example1.java from http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html

See also http://developer.java.sun.com/developer/qow/archive/135/index.jsp and http://jw.itworld.com/javaworld/jw-12-2000/jw-1229-traps.html

Since:
Ptolemy II 2.0
Version:
$Id: StreamExec.html,v 1.1 2004/02/17 15:36:59 mnwaltz Exp $
Author:
Christopher Hylands
See Also:
JTextAreaExec

Constructor Summary
StreamExec()
          Create a StreamExec
 
Method Summary
protected  void _setProgressBarMaximum(int size)
          Set the maximum of the progress bar.
 void cancel()
          Cancel any running commands.
 void clear()
          Clear the text area, status bar and progress bar.
 java.lang.Process getProcess()
          Return the value of the Process.
static void main(java.lang.String[] args)
          Main method used for testing.
 void setCommands(java.util.List commands)
          Set the list of commands.
 void start()
          Start running the commands.
 void stderr(java.lang.String text)
          Append the text message to stderr.
 void stdout(java.lang.String text)
          Append the text message to the output.
 void updateStatusBar(java.lang.String text)
          Set the text of the status bar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamExec

public StreamExec()
Create a StreamExec

Method Detail

cancel

public void cancel()
Cancel any running commands.


clear

public void clear()
Clear the text area, status bar and progress bar.


getProcess

public java.lang.Process getProcess()
Return the value of the Process. Typically the return value of this method is used to have the caller wait for the process to exit.


main

public static void main(java.lang.String[] args)
Main method used for testing. To run a simple test, use:
        java -classpath $PTII ptolemy.gui.StreamExec
  


setCommands

public void setCommands(java.util.List commands)
Set the list of commands.


start

public void start()
Start running the commands.


stderr

public void stderr(java.lang.String text)
Append the text message to stderr. A derived class could append to a StringBuffer. @link{JTextAreaExec} appends to a JTextArea. The output automatically gets a trailing newline appended.


stdout

public void stdout(java.lang.String text)
Append the text message to the output. A derived class could append to a StringBuffer. @link{JTextAreaExec} appends to a JTextArea. The output automatically gets a trailing newline appended.


updateStatusBar

public void updateStatusBar(java.lang.String text)
Set the text of the status bar. In this base class, do nothing, derived classes may update a status bar.


_setProgressBarMaximum

protected void _setProgressBarMaximum(int size)
Set the maximum of the progress bar. In this base class, do nothing, derived classes may update the size of the progress bar.

Parameters:
size - The maximum size of the progress bar.