int totalWorked = -1;
public void beginTask(String name, int totalWorked) {
this.totalWorked = totalWorked;
sarosSession.sendActivity(recipients, new ProgressActivity(
localUser, progressID, 0, totalWorked, name,
ProgressAction.UPDATE));
}
public void done() {
sarosSession.sendActivity(recipients, new ProgressActivity(
localUser, progressID, 0, 0, null, ProgressAction.DONE));
}
public void internalWorked(double work) {
// do nothing
}
public boolean isCanceled() {
// It would be cool to support communicating cancellation
// to the originator
return false;
}
public void setCanceled(boolean value) {
throw new UnsupportedOperationException();
}
public void setTaskName(String name) {
sarosSession.sendActivity(recipients, new ProgressActivity(
localUser, progressID, worked, totalWorked, name,
ProgressAction.UPDATE));
}
public void subTask(String name) {
sarosSession.sendActivity(recipients, new ProgressActivity(
localUser, progressID, worked, totalWorked, name,
ProgressAction.UPDATE));
}
public void worked(int work) {
worked += work;
if (worked > totalWorked)
log.warn(
MessageFormat
.format(
"Worked ({0})is greater than totalWork ({1}). Forgot to call beginTask?",
worked, totalWorked), new StackTrace());
sarosSession.sendActivity(recipients, new ProgressActivity(
localUser, progressID, worked, totalWorked, null,
ProgressAction.UPDATE));
}
};
}