com.microsoft.tfs.util.tasks
Class FileProcessingProgressMonitorAdapter

java.lang.Object
  extended by com.microsoft.tfs.util.tasks.FileProcessingProgressMonitorAdapter
All Implemented Interfaces:
TaskMonitor

public class FileProcessingProgressMonitorAdapter
extends java.lang.Object
implements TaskMonitor


Constructor Summary
FileProcessingProgressMonitorAdapter(TaskMonitor parentMonitor, long totalLength)
           
FileProcessingProgressMonitorAdapter(TaskMonitor parentMonitor, long alreadyProcessed, long totalLength)
           
FileProcessingProgressMonitorAdapter(TaskMonitor parentMonitor, long alreadyProcessed, long totalLength, java.lang.String messageFormat)
           
FileProcessingProgressMonitorAdapter(TaskMonitor parentMonitor, long totalLength, java.lang.String messageFormat)
           
 
Method Summary
 void begin(java.lang.String taskName, int totalWork)
           Called to indicate the start of the task that this TaskMonitor instance is monitoring.
 void beginWithUnknownTotalWork(java.lang.String taskName)
           Called to indicate the start of the task that this TaskMonitor instance is monitoring.
 void done()
           Called to indicate the end of the task that this TaskMonitor instance is monitoring.
 boolean isCanceled()
           Called to test whether cancelation has been requested for the task that this TaskMonitor instance is monitoring.
 TaskMonitor newSubTaskMonitor(int amount)
           Called to obtain a new TaskMonitor instance to be used in a sub-task of the task being monitored by this TaskMonitor instance.
 void setCanceled()
           Sets the cancel state to true for the task this TaskMonitor is monitoring.
 void setCurrentWorkDescription(java.lang.String description)
           Called to set a more detailed description of the current work being done than the task name alone gives.
 void setTaskName(java.lang.String taskName)
          Called to set the task name of the task being monitored by this TaskMonitor.
 void worked(int processed)
          Called by the task that this TaskMonitor is monitoring to report progress.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileProcessingProgressMonitorAdapter

public FileProcessingProgressMonitorAdapter(TaskMonitor parentMonitor,
                                            long totalLength)

FileProcessingProgressMonitorAdapter

public FileProcessingProgressMonitorAdapter(TaskMonitor parentMonitor,
                                            long totalLength,
                                            java.lang.String messageFormat)

FileProcessingProgressMonitorAdapter

public FileProcessingProgressMonitorAdapter(TaskMonitor parentMonitor,
                                            long alreadyProcessed,
                                            long totalLength)

FileProcessingProgressMonitorAdapter

public FileProcessingProgressMonitorAdapter(TaskMonitor parentMonitor,
                                            long alreadyProcessed,
                                            long totalLength,
                                            java.lang.String messageFormat)
Method Detail

worked

public void worked(int processed)
Description copied from interface: TaskMonitor
Called by the task that this TaskMonitor is monitoring to report progress. This method is typically called multiple times during the task. Each time the number of work units that have been completed since the last call to this method are passed. In other words, the number of work units reported to this method must be non-cumulative.

Specified by:
worked in interface TaskMonitor
Parameters:
processed - a non-negative, non-cumulative amount of work units

isCanceled

public boolean isCanceled()
Description copied from interface: TaskMonitor

Called to test whether cancelation has been requested for the task that this TaskMonitor instance is monitoring.

To be cancelation-aware, the task should poll this method at regular intervals. If true is returned, the task should return early as quickly as possible.

Specified by:
isCanceled in interface TaskMonitor
Returns:
true if cancelation has been requested for this task

begin

public void begin(java.lang.String taskName,
                  int totalWork)
Description copied from interface: TaskMonitor

Called to indicate the start of the task that this TaskMonitor instance is monitoring. This method is called when the total number of work units for the task are known.

Either this method or the TaskMonitor.beginWithUnknownTotalWork(String) method must be called only once per TaskMonitor instance, and one or the other must be called before other methods on the instance are called.

Specified by:
begin in interface TaskMonitor
Parameters:
taskName - the name of the task that is beginning, or null if there is no task name
totalWork - the total amount of work units that this task will take (must be non-negative)

beginWithUnknownTotalWork

public void beginWithUnknownTotalWork(java.lang.String taskName)
Description copied from interface: TaskMonitor

Called to indicate the start of the task that this TaskMonitor instance is monitoring. This method is called when the total number of work units for the task is not known.

Either this method or the TaskMonitor.begin(String, int) method must be called only once per TaskMonitor instance, and one or the other must be called before other methods on the instance are called.

Specified by:
beginWithUnknownTotalWork in interface TaskMonitor
Parameters:
taskName - the name of the task that is beginning, or null if there is no task name

done

public void done()
Description copied from interface: TaskMonitor

Called to indicate the end of the task that this TaskMonitor instance is monitoring. This method must be called, even if the task aborts with an error or is canceled.

It is safe to call this method multiple times.

Specified by:
done in interface TaskMonitor

setCanceled

public void setCanceled()
Description copied from interface: TaskMonitor

Sets the cancel state to true for the task this TaskMonitor is monitoring.

Specified by:
setCanceled in interface TaskMonitor

setTaskName

public void setTaskName(java.lang.String taskName)
Description copied from interface: TaskMonitor
Called to set the task name of the task being monitored by this TaskMonitor. Normally there is no reason to call this method, since the task name is set by either the TaskMonitor.begin(String, int) or TaskMonitor.beginWithUnknownTotalWork(String) methods and generally remains constant throughout the lifetime of the task.

Specified by:
setTaskName in interface TaskMonitor
Parameters:
taskName - the task name as described above, or null to clear the task name

setCurrentWorkDescription

public void setCurrentWorkDescription(java.lang.String description)
Description copied from interface: TaskMonitor

Called to set a more detailed description of the current work being done than the task name alone gives. The current work description is an additional description above and beyond the task name that is specified in the TaskMonitor.begin(String, int), TaskMonitor.beginWithUnknownTotalWork(String), and/or TaskMonitor.setTaskName(String) methods.

Many UI implementations of TaskMonitor will render the task name as a header and the current work description as a sub-header. Other UI implementations may choose to ignore the current work description or to let it override the task name.

Specified by:
setCurrentWorkDescription in interface TaskMonitor
Parameters:
description - the current work description as described above, or null to clear the current work description

newSubTaskMonitor

public TaskMonitor newSubTaskMonitor(int amount)
Description copied from interface: TaskMonitor

Called to obtain a new TaskMonitor instance to be used in a sub-task of the task being monitored by this TaskMonitor instance.

Note that every call to this method results in a new TaskMonitor instance, and all of the TaskMonitor rules apply to each instance. Specifically, one of the begin methods should be called on the new instance, and the TaskMonitor.done() method must be called on the new instance.

Each sub-TaskMonitor uses up sub number of work units of its parent TaskMonitor. This number is specified as the amount argument to this method. The sub-TaskMonitor will have its own number of total work units (specified by the TaskMonitor.begin(String, int) method) and internally sub-task progress will be scaled into main-task progress.

Specified by:
newSubTaskMonitor in interface TaskMonitor
Parameters:
amount - the amount of work units of the main task that the sub-task will use up (must be non-negative)
Returns:
a new TaskMonitor instance to be used for a sub-task as described above (never null)


© 2015 Microsoft. All rights reserved.