Task.ProgressMonitor
Interface UIHookIF


public interface UIHookIF

UIHookIF is an interface that allows the apps to interact with a UI component that's displaying status information. Two kinds of interaction are possible:

  1. reporting status information to the UI - read status
  2. reporting status information to the UI - write status
  3. user cancelling the operation, from the UI - cancel IO operation

EDT and Threading concerns

Make sure that the Swing implementation of this UIHookIF dispatches each of it's methods on the EDT! Otherwise, the main UI thread will be affected by UI updates.

Since:
Sep 30, 2007, 2:30:22 PM
Version:
1.0
Author:
Nazmul Idris

Method Summary
 void cancel()
          allows the UI to cancel IO operations. once called this bit is set, and all subsequent IO ops will be cancelled.
 void close()
          this is called when the underlying IO stream is closed, a signal that the IO operation has ended
 java.lang.String getProgressMessage()
          This method simply returns the message set by setProgressMessage(String).
 void interrupedIO()
          this is called when cancel() is called, or the underlying SwingWorker is cancelled. it results in the underlying IO operation to be interrupted, and an InterruptedIOException to be thrown
 boolean isCancelled()
          if the user has called cancel() then this returns true
 void resetCancelFlag()
          if cancel() has been called, then this method must be called to allow future IO ops to proceed.
 void setProgressMessage(java.lang.String msg)
          When the status is reported (SEND or RECIEVE), this message is passed along with those method calls to the UI itself.
 void updateRecieveStatus(int progress, int total)
          The RECIEVE status lets the UI know how much of the "recieve from service" operation has been completed.
 void updateSendStatus(int progress, int total)
          The SEND status lets the UI know how much of the "send to service" operation has been completed.
 

Method Detail

setProgressMessage

void setProgressMessage(java.lang.String msg)
When the status is reported (SEND or RECIEVE), this message is passed along with those method calls to the UI itself.

Parameters:
msg - this message is passed to the UI along with status updates on SEND/RECIEVE this may be null.

getProgressMessage

java.lang.String getProgressMessage()
This method simply returns the message set by setProgressMessage(String). When status updates are sent to the UI, it can choose to use this message to update the UI with.

Returns:
may be null

updateSendStatus

void updateSendStatus(int progress,
                      int total)
The SEND status lets the UI know how much of the "send to service" operation has been completed. This represents the POST request being sent to an HTTP servlet for example.

Parameters:
progress - current number of bytes read
total - bytes to be read, can be 0

updateRecieveStatus

void updateRecieveStatus(int progress,
                         int total)
The RECIEVE status lets the UI know how much of the "recieve from service" operation has been completed. This represents the POST response being recieved by the client from an HTTP servlet for example.

Parameters:
progress - current number of bytes read
total - bytes to be read, can be 0

cancel

void cancel()
allows the UI to cancel IO operations. once called this bit is set, and all subsequent IO ops will be cancelled. to undo this call resetCancelFlag().


isCancelled

boolean isCancelled()
if the user has called cancel() then this returns true


resetCancelFlag

void resetCancelFlag()
if cancel() has been called, then this method must be called to allow future IO ops to proceed.


close

void close()
this is called when the underlying IO stream is closed, a signal that the IO operation has ended


interrupedIO

void interrupedIO()
this is called when cancel() is called, or the underlying SwingWorker is cancelled. it results in the underlying IO operation to be interrupted, and an InterruptedIOException to be thrown



Copyright © 2011. All Rights Reserved.