public abstract class ProgressMonitor extends Object
GitClient
provides methods to start proper git
commands and such a method accepts an instance if ProgressMonitor
as its argument.
Clients of the git API may extend this class and through its methods catch
error and warning messages produced by a git command, changes in the state
of a command (when the command is started and when it's finished) and they may
cancel a running command by implementing the isCanceled
method.Modifier and Type | Class and Description |
---|---|
static class |
ProgressMonitor.DefaultProgressMonitor
Basic implementation of the
ProgressMonitor abstract class. |
Modifier and Type | Field and Description |
---|---|
static int |
UNKNOWN_WORK_UNITS
A constant indicating an unknown number of work units of a task.
|
Constructor and Description |
---|
ProgressMonitor() |
Modifier and Type | Method and Description |
---|---|
void |
beginTask(String taskName,
int totalWorkUnits)
Implementors may override this to be notified when a task is started
during a command execution.
|
void |
endTask()
Called when the currently running task ends.
|
abstract void |
finished()
Called by a git command when it finishes its progress.
|
abstract boolean |
isCanceled()
Returns
true if the progress should be canceled. |
abstract void |
notifyError(String message)
Called when an error occurs during a git command's execution that however
does not prevent it from further actions.
|
void |
notifyMessage(String message)
Notifies about an informational message passed from the running command.
|
abstract void |
notifyWarning(String message)
Called when a non-fatal warning should be delivered to a git command's
caller.
|
abstract void |
preparationsFailed(String message)
Called when a git command fails to start.
|
abstract void |
started(String command)
Called when a git command is started.
|
void |
updateTaskState(int completed)
Override to get notified when the currently running task finishes one or
more of its scheduled steps.
|
public static final int UNKNOWN_WORK_UNITS
public abstract boolean isCanceled()
true
if the progress should be canceled.
Git commands periodically check the result of the method and end their
progress immediately when the method returns true
public abstract void started(String command)
command
- a string representing a commandline version of the started commandpublic abstract void finished()
public abstract void preparationsFailed(String message)
message
- error descriptionpublic abstract void notifyError(String message)
message
- description of the errorpublic abstract void notifyWarning(String message)
message
- description of the warningpublic void notifyMessage(String message)
message
- informational messagepublic void beginTask(String taskName, int totalWorkUnits)
ProgressMonitor.UNKNOWN_WORK_UNITS
as the value of
totalWorkUnits
indicates the task cannot anticipate the
number of steps it will take.
This may be useful for long commands such as clone or fetch to update progress bars etc.
taskName
- name of the tasktotalWorkUnits
- number of work units the task will takepublic void updateTaskState(int completed)
completed
- number of completed steps since the last call. The value
is not a sum of all finished steps but an incremental value.public void endTask()