|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object extended byptolemy.util.StreamExec
Execute commands in a subprocess. This class does not use swing,
for a graphical interface, see JTextAreaExec.
Sample usage:
List execCommands = new LinkedList();
execCommands.add("date");
execCommands.add("sleep 3");
execCommands.add("date");
execCommands.add("notACommand");
final StreamExec exec = new StreamExec();
exec.setCommands(execCommands);
exec.start();
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
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. |
int |
getLastSubprocessReturnCode()
Return the return code of the last subprocess that was executed. |
void |
setCommands(java.util.List commands)
Set the list of commands. |
void |
setWorkingDirectory(java.io.File workingDirectory)
Set the working directory of the subprocess. |
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 |
public StreamExec()
| Method Detail |
public void cancel()
cancel in interface ExecuteCommandspublic void clear()
clear in interface ExecuteCommandspublic int getLastSubprocessReturnCode()
getLastSubprocessReturnCode in interface ExecuteCommandspublic void setCommands(java.util.List commands)
setCommands in interface ExecuteCommandscommands - A list of Strings, where each element is a command.public void setWorkingDirectory(java.io.File workingDirectory)
setWorkingDirectory in interface ExecuteCommandsworkingDirectory - The working directory of the
subprocess. If this argument is null, then the subprocess is
executed in the working directory of the current process.public void start()
start in interface ExecuteCommandspublic void stderr(java.lang.String text)
stderr in interface ExecuteCommandstext - The text to append to standard error.public void stdout(java.lang.String text)
stdout in interface ExecuteCommandstext - The text to append to standard out.public void updateStatusBar(java.lang.String text)
updateStatusBar in interface ExecuteCommandstext - The text with which the status bar is updated.protected void _setProgressBarMaximum(int size)
size - The maximum size of the progress bar.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||