harmonic.mz.manager
Class ProgressManager

java.lang.Object
  |
  +--harmonic.mz.manager.ProgressManager

public class ProgressManager
extends java.lang.Object

This is the unit that proceedures talk to to report progress. As the progress state changes this class notifies ProgressListener.


Nested Class Summary
static class ProgressManager.WorkItem
           
 
Constructor Summary
ProgressManager()
           
 
Method Summary
 void addProgressListener(ProgressListener l)
          Adds a listener to the progress state
 void addThread(java.lang.Thread thread)
          If work is started in a new thread, call this to let the user know
 void beginWork(java.lang.String key)
          This pushes a message onto the progress feedback interface.
 void beginWork(java.lang.String key, java.lang.String msg)
          Call through to beginWork(key), then progress(msg)
 void endWork(java.lang.String key)
          This pops a message from the progress feedback interface.
 long getDuration(java.lang.Thread thread)
          Handy function that returns for the work item associated with the given thread, System.currentTimeMillis() - workItem.currentItem.startTime
 float getProgress(java.lang.Thread thread)
          Handy function that returns for the work item associated with the given thread, WorkItem.currentItem.progress
 java.util.Vector getThreads()
          Return all threads known to progresss manager
 ProgressManager.WorkItem getWorkItem(java.lang.Thread thread)
          Returns the WorkItem associated with the given thread
 java.lang.String getWorkText(java.lang.Thread thread)
          Handy function that generates a blank line deliminated string showing the work stack associated with the given thread
 void notifyListeners(ProgressEvent e)
          Notify registered listeners
 void progress(float p)
          Report progress the current (most recently pushed) work item, as a percentage.
 void progress(java.lang.String msg)
          Report progress in the current (most recently pushed) WorkItem.
 void removeProgressListener(ProgressListener l)
          Removes a listener from the progress state
 void removeThread(java.lang.Thread thread)
          If work is started in a new thread, call this to let the user know
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgressManager

public ProgressManager()
Method Detail

addProgressListener

public void addProgressListener(ProgressListener l)
Adds a listener to the progress state


removeProgressListener

public void removeProgressListener(ProgressListener l)
Removes a listener from the progress state


notifyListeners

public void notifyListeners(ProgressEvent e)
Notify registered listeners


getWorkItem

public ProgressManager.WorkItem getWorkItem(java.lang.Thread thread)
Returns the WorkItem associated with the given thread


getWorkText

public java.lang.String getWorkText(java.lang.Thread thread)
Handy function that generates a blank line deliminated string showing the work stack associated with the given thread


getProgress

public float getProgress(java.lang.Thread thread)
Handy function that returns for the work item associated with the given thread, WorkItem.currentItem.progress


getDuration

public long getDuration(java.lang.Thread thread)
Handy function that returns for the work item associated with the given thread, System.currentTimeMillis() - workItem.currentItem.startTime


addThread

public void addThread(java.lang.Thread thread)
If work is started in a new thread, call this to let the user know

Sends a ProgressEvent.THREAD_ADDED event


removeThread

public void removeThread(java.lang.Thread thread)
If work is started in a new thread, call this to let the user know

Sends a ProgressEvent.THREAD_REMOVED event


getThreads

public java.util.Vector getThreads()
Return all threads known to progresss manager


beginWork

public void beginWork(java.lang.String key,
                      java.lang.String msg)
Call through to beginWork(key), then progress(msg)


beginWork

public void beginWork(java.lang.String key)
This pushes a message onto the progress feedback interface. (This is done by adding a WorkItem to the WorkItem associated to the currently executing thread). Subsequent calls to progress(String) will replace the message at this level. Subsequent calls to progress(float) will replace the progress time at this level. A call to endWork() with the same key will remove the pushed item.

This progress tracking system mirrors they way computer programs get things done: We start with some general task, and then along the way sub-tasks are executed. Any significant task can call beginWork to push a new work item, and then call progress() along the way to let the user know whats going on. The task may call functions that themselves call beginWork.

This sends a ProgressEvent.THREAD_CHANGED, ProgressEvent.THREAD_CHANGED event


progress

public void progress(java.lang.String msg)
Report progress in the current (most recently pushed) WorkItem. It is not possible to report progress for a parent work item, so there is no need to give this function a key. Therefore it is important that callers of beginWork dont throw and uncaught exception and bail out before calling endWork with their key, since WorkItem's will then appear in the wrong place. There is a different progres stack/tree for every thread. This function finds out what thread called it and effects the work item in the right place.

This sends a ProgressEvent.THREAD_CHANGED event


progress

public void progress(float p)
Report progress the current (most recently pushed) work item, as a percentage. This function finds out what thread called it and effects the WorkItem in the right place.

This sends a ProgressEvent.THREAD_CHANGED event


endWork

public void endWork(java.lang.String key)
This pops a message from the progress feedback interface. The begin/end Work calles are keepd in a linked list, in a system intended to avoid problems if endWork is called with a key that differs from the most recent call to beginWork. If this happens, all beginWork calls after the one matched by the key are removed, or you might say the work tree is pruned at this point.

This sends a ProgressEvent.THREAD_CHANGED event