org.knime.core.node
Class DefaultNodeProgressMonitor

java.lang.Object
  extended by org.knime.core.node.DefaultNodeProgressMonitor
All Implemented Interfaces:
NodeProgressMonitor

public class DefaultNodeProgressMonitor
extends Object
implements NodeProgressMonitor

The default node progress monitor which keep a progress value between 0 and 1, and a progress message. Both can be null if not available or set wrong (progress value out of range). Furthermore, it holds a flag which indicates that the task during execution was interrupted.

This progress monitor uses a static timer task looking every 250 milliseconds if progress information has changed. The ProgressEvent is fired if either the value or message has changed only.

Author:
Thomas Gabriel, University of Konstanz

Nested Class Summary
(package private) static class DefaultNodeProgressMonitor.SilentSubNodeProgressMonitor
          Silent progress monitor which does only forward changed of the progress value rather than progress message.
(package private) static class DefaultNodeProgressMonitor.SubNodeProgressMonitor
          Progress monitor that is used by "sub-progresses", it doesn't have the range [0, 1] but only [0, b] where b is user-defined.
 
Constructor Summary
DefaultNodeProgressMonitor()
          Creates a new progress monitor with an empty set of listeners.
DefaultNodeProgressMonitor(NodeProgressListener l)
          Creates a new node progress monitor, with the cancel requested false, and no progress.
 
Method Summary
 void addProgressListener(NodeProgressListener l)
          Adds a new listener to the list of instances which are interested in receiving progress events.
 void checkCanceled()
          Checks if the execution was canceled.
 String getMessage()
          The current progress message displayed.
 Double getProgress()
          The current progress value or null if no progress available.
(package private)  boolean isCanceled()
           
 void removeAllProgressListener()
          Removes all registered progress listeners.
 void removeProgressListener(NodeProgressListener l)
          Removes the given listener from the list and will therefore no longer receive progress events.
 void reset()
          Resets this monitor.
 void setExecuteCanceled()
          Sets the cancel requested flag.
 void setMessage(String message)
          Displays the message as given by the argument.
 void setProgress(double progress)
          Sets a new progress value.
 void setProgress(double progress, String message)
          Updates the progress value and message if different from the current one.
 void setProgress(String message)
          Sets a new message according to the argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultNodeProgressMonitor

public DefaultNodeProgressMonitor()
Creates a new progress monitor with an empty set of listeners.

See Also:
DefaultNodeProgressMonitor(NodeProgressListener)

DefaultNodeProgressMonitor

public DefaultNodeProgressMonitor(NodeProgressListener l)
Creates a new node progress monitor, with the cancel requested false, and no progress.

Parameters:
l - Initial node progress listener.
Method Detail

reset

public void reset()
Resets this monitor. I. e. no message and no progress is set. The cancel flag is cleared. The list of progress listeners is not affected.
NOTE: No notification is send to listeners! Reset progress, message and cancel flag.

Specified by:
reset in interface NodeProgressMonitor

isCanceled

boolean isCanceled()
Returns:
true if the execution of the NodeModel has been canceled.

checkCanceled

public void checkCanceled()
                   throws CanceledExecutionException
Checks if the execution was canceled. If yes, it throws an CanceledExecutionExeption.

Specified by:
checkCanceled in interface NodeProgressMonitor
Throws:
CanceledExecutionException - If the execution has been canceled.
See Also:
isCanceled()

setExecuteCanceled

public void setExecuteCanceled()
Sets the cancel requested flag.

Specified by:
setExecuteCanceled in interface NodeProgressMonitor

setProgress

public void setProgress(double progress,
                        String message)
Updates the progress value and message if different from the current one.

Specified by:
setProgress in interface NodeProgressMonitor
Parameters:
progress - The (new) progress value.
message - The text message shown in the progress monitor.
See Also:
setProgress(double)

setProgress

public void setProgress(double progress)
Sets a new progress value. If the value is not in range, it will be set to null.

Specified by:
setProgress in interface NodeProgressMonitor
Parameters:
progress - The value between 0 and 1.

setMessage

public void setMessage(String message)
Displays the message as given by the argument.

Specified by:
setMessage in interface NodeProgressMonitor
Parameters:
message - A convenience message shown in the progress monitor.
See Also:
NodeProgressMonitor.setProgress(String)

setProgress

public void setProgress(String message)
Sets a new message according to the argument.

Specified by:
setProgress in interface NodeProgressMonitor
Parameters:
message - The text message shown in the progress monitor.

getProgress

public Double getProgress()
Description copied from interface: NodeProgressMonitor
The current progress value or null if no progress available.

Specified by:
getProgress in interface NodeProgressMonitor
Returns:
The current progress value, or null if not yet set.

getMessage

public String getMessage()
Description copied from interface: NodeProgressMonitor
The current progress message displayed.

Specified by:
getMessage in interface NodeProgressMonitor
Returns:
The current progress message.

addProgressListener

public void addProgressListener(NodeProgressListener l)
Adds a new listener to the list of instances which are interested in receiving progress events.

Specified by:
addProgressListener in interface NodeProgressMonitor
Parameters:
l - The progress listener to add.

removeProgressListener

public void removeProgressListener(NodeProgressListener l)
Removes the given listener from the list and will therefore no longer receive progress events.

Specified by:
removeProgressListener in interface NodeProgressMonitor
Parameters:
l - The progress listener to remove.

removeAllProgressListener

public void removeAllProgressListener()
Removes all registered progress listeners.

Specified by:
removeAllProgressListener in interface NodeProgressMonitor


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.