|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectTask.ProgressMonitor.UIHookAdapter
Task.ProgressMonitor.SwingUIHookAdapter
public class SwingUIHookAdapter
SwingUIHookAdapter is an EDT friendly adapter that uses the UIHookIF facility of the
networking layer to provide feedback to the UI, and get cancel-signal from the UI as well.
isCancelled(). Note that when
used in this manner, resetting the cancel flag only resets the flag controlled by this class and
NOT the isCancelled method on the SwingWorker/Future.
The following abstract methods that you have to implement to tie this into your UI:
In your GUI, if you want to interrupt the IO operation of the underlying HTTP client, then just
call cancel(). This will interrupt the underlying IO stream. Please note that the cancel
flag will cause any subsequent IO operations with this SwingUIHookAdapter to cancel as well.
If you do not want this to happen, then call resetCancelFlag(). AbstractTask automatically
does this for you, so you don't have to do any of this yourself.
This ProgressMonitor may be used by more than 1 objects. So be sure to clearAllStatusListeners() once you are done using this ProgressMonitor, so that there are no
ties to the UI once you are done using this monitor.
| Nested Class Summary | |
|---|---|
static class |
SwingUIHookAdapter.PropertyList
|
| Field Summary | |
|---|---|
protected java.beans.PropertyChangeSupport |
_boundProperties
property change listener support for status property |
| Fields inherited from class Task.ProgressMonitor.UIHookAdapter |
|---|
_uiHook |
| Constructor Summary | |
|---|---|
SwingUIHookAdapter()
simply creates an adapter class that you have to override with the implementations of the callback methods: updateRecieveStatusInUI(int,int) updateSendStatusInUI(int,int) (int, int)} closeInUI() |
|
SwingUIHookAdapter(java.util.concurrent.Future<?> future)
The Future object is used to determine if the cancel has occured. |
|
| Method Summary | |
|---|---|
void |
addRecieveStatusListener(java.beans.PropertyChangeListener l)
The property change event that's fired to the listener has the following parts: public void propertyChange(PropertyChangeEvent evt) { String type = evt.getPropertyName(); String progressStr = evt.getOldValue().toString(); int progress = Integer.parseInt(progressStr); String msg = evt.getNewValue().toString(); } |
void |
addSendStatusListener(java.beans.PropertyChangeListener l)
The property change event that's fired to the listener has the following parts: public void propertyChange(PropertyChangeEvent evt) { String type = evt.getPropertyName(); String progressStr = evt.getOldValue().toString(); int progress = Integer.parseInt(progressStr); String msg = evt.getNewValue().toString(); } |
void |
addUnderlyingIOStreamInterruptedOrClosed(java.beans.PropertyChangeListener l)
The property change event that's fired to the listener has the following parts: public void propertyChange(PropertyChangeEvent evt) { String type = evt.getPropertyName(); } |
void |
cancel()
Call this method to interrupt the underlying IO stream. |
void |
clearAllStatusListeners()
this runs in the EDT. why? |
void |
closeInUI()
this is called in EDT, in your code. this is called if the underlying IO stream was closed for some reason. |
void |
enableRecieveStatusNotification(boolean enabled)
you can put this UIHook in silent mode - will not update UI with status updates on RECV |
void |
enableSendStatusNotification(boolean enabled)
you can put this UIHook in silent mode - will not update UI with status updates on SEND |
java.lang.String |
getProgressMessage()
|
java.util.concurrent.Future<?> |
getSwingWorker()
Returns a reference to the underlying SwingWorker providing the execution context/thread, if one has been copyFrom |
void |
interruptedIOInUI()
this is called in EDT, in your code. this is called if the underlying IO stream was interrupted for some reason (user cancellation via UIHookIF, or SwingWorker (which belongs to a task)
cancellation for some reason). |
boolean |
isCancelled()
This is used to check if cancel() was called already. |
boolean |
isRecieveStatusNotificationEnabled()
see if silent mode is activated for RECV updates |
boolean |
isSendStatusNotificationEnabled()
see if silent mode is activated for SEND updates |
void |
resetCancelFlag()
If cancel() is called, then all subsequent IO operations will be cancelled, until this
method is called to reset the cancel condition. |
void |
restoreNotificationSet()
|
void |
saveNotificationSet()
this saves the current state of enableRecieveStatusNotification(boolean) and
enableSendStatusNotification(boolean) |
void |
setProgressMessage(java.lang.String msg)
|
void |
setSwingWorker(java.util.concurrent.Future<?> future)
sets a reference to the underlying SwingWorker providing the execution context/thread. this is used to evaluate cancellation. |
void |
updateRecieveStatusInUI(int progress,
int total)
this is called in EDT, in your code. provides a RECV status update (progress bytes of total bytes) |
void |
updateSendStatusInUI(int progress,
int total)
this is called in EDT, in your code. provides a SEND status update (progress bytes of total bytes) |
| Methods inherited from class Task.ProgressMonitor.UIHookAdapter |
|---|
getUIHook |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.beans.PropertyChangeSupport _boundProperties
| Constructor Detail |
|---|
public SwingUIHookAdapter()
public SwingUIHookAdapter(java.util.concurrent.Future<?> future)
throws java.lang.IllegalArgumentException
future - SwingWorker that is provided by the Task API
java.lang.IllegalArgumentException| Method Detail |
|---|
public void clearAllStatusListeners()
public void addSendStatusListener(java.beans.PropertyChangeListener l)
throws java.lang.IllegalArgumentException
public void propertyChange(PropertyChangeEvent evt) {
String type = evt.getPropertyName();
String progressStr = evt.getOldValue().toString();
int progress = Integer.parseInt(progressStr);
String msg = evt.getNewValue().toString();
}
java.lang.IllegalArgumentExceptionSwingUIHookAdapter.PropertyList.Send
public void addRecieveStatusListener(java.beans.PropertyChangeListener l)
throws java.lang.IllegalArgumentException
public void propertyChange(PropertyChangeEvent evt) {
String type = evt.getPropertyName();
String progressStr = evt.getOldValue().toString();
int progress = Integer.parseInt(progressStr);
String msg = evt.getNewValue().toString();
}
java.lang.IllegalArgumentExceptionSwingUIHookAdapter.PropertyList.Recieve
public void addUnderlyingIOStreamInterruptedOrClosed(java.beans.PropertyChangeListener l)
throws java.lang.IllegalArgumentException
public void propertyChange(PropertyChangeEvent evt) {
String type = evt.getPropertyName();
}
java.lang.IllegalArgumentExceptionSwingUIHookAdapter.PropertyList.UnderlyingIOStreamClosed,
SwingUIHookAdapter.PropertyList.UnderlyingIOStreamInterruped
public void updateSendStatusInUI(int progress,
int total)
public void updateRecieveStatusInUI(int progress,
int total)
public void closeInUI()
public void interruptedIOInUI()
UIHookIF, or SwingWorker (which belongs to a task)
cancellation for some reason).
public void enableSendStatusNotification(boolean enabled)
enabled - false activates silent mode. default is true (non silent mode)public void enableRecieveStatusNotification(boolean enabled)
enabled - false activates silent mode. default is true (non silent mode)public void saveNotificationSet()
enableRecieveStatusNotification(boolean) and
enableSendStatusNotification(boolean)
public void restoreNotificationSet()
public boolean isSendStatusNotificationEnabled()
public boolean isRecieveStatusNotificationEnabled()
public java.util.concurrent.Future<?> getSwingWorker()
public void setSwingWorker(java.util.concurrent.Future<?> future)
public void cancel()
resetCancelFlag().
public boolean isCancelled()
cancel() was called already.
public void resetCancelFlag()
cancel() is called, then all subsequent IO operations will be cancelled, until this
method is called to reset the cancel condition.
public void setProgressMessage(java.lang.String msg)
public java.lang.String getProgressMessage()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||