|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--edu.jhu.pha.ivoa.TaskManager
Current Version =============== ID: $Id: TaskManager.html,v 1.3 2003/08/18 18:05:02 carliles Exp $ Revision: $Revision: 1.3 $ Date/time: $Date: 2003/08/18 18:05:02 $This class encapsulates a
JFrame which displays
Task name, status, and message information, as well as giving
users a button with which to cancel selected Tasks.
As currently implemented, if the TaskManager's
JFrame is not visible when a Task is added,
it will be made visible. Here is a simple, yet complete application
showing how to use these classes.
import java.io.*;
import edu.jhu.pha.ivoa.*;
// prints lines from specified files to the screen, with each
// file being printed in a different Thread, so the output
// won't necessarily come out in any order that makes sense.
public class TaskManagerTest
{
public static void main(String[] args) throws Exception
{
TaskManager tm = new TaskManager();
for(int i = 0; i < args.length; ++i)
{
tm.addTask(new FileTask(args[i]));
}
}
public static class FileTask extends Task
{
public FileTask(String filename)
{
super("Printing " + filename);
_filename = filename;
}
public void execute()
{
try
{
int linesRead = 0;
BufferedReader in =
new BufferedReader(new FileReader(_filename));
for(String line = in.readLine(); line != null; line = in.readLine())
{
if(line != null)
{
System.out.println(line);
setMessage((++linesRead) + " lines read.");
}
}
System.out.flush();
}
catch(IOException e)
{
e.printStackTrace();
}
}
protected String _filename;
};
}
| Constructor Summary | |
TaskManager()
Initializes this TaskManager. |
|
| Method Summary | |
void |
addTask(edu.jhu.pha.ivoa.Task task)
Adds a Task to this TaskManager and starts it.
|
void |
cancelSelectedTasks(int[] rowNumbers)
Cancels the Tasks in the specified rows of the
JTable in this TaskManager's
JFrame. |
boolean |
isVisible()
|
static void |
main(java.lang.String[] args)
For testing purposes. |
void |
propertyChange(java.beans.PropertyChangeEvent e)
|
static java.lang.String |
revision()
|
void |
setVisible(boolean visible)
Sets the visibility of the JFrame representing this
TaskManager to the value of visible. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public TaskManager()
TaskManager. Initially the
JFrame representing this TaskManager is
not visible.
| Method Detail |
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exceptionpublic void setVisible(boolean visible)
JFrame representing this
TaskManager to the value of visible.
visible - boolean value representing whether to show the
JFrame for this TaskManager.public boolean isVisible()
public void addTask(edu.jhu.pha.ivoa.Task task)
Task to this TaskManager and starts it.
If this TaskManager's JFrame is not visible,
it will be made visible.
task - The Task to be added.public void cancelSelectedTasks(int[] rowNumbers)
Tasks in the specified rows of the
JTable in this TaskManager's
JFrame.
rowNumbers - The indices of the JTable rows containing
Tasks to be cancelled.public void propertyChange(java.beans.PropertyChangeEvent e)
propertyChange in interface java.beans.PropertyChangeListenerpublic static java.lang.String revision()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||