@Override public void complete(String message) { if (completeSilently()) { fireEvent(new ProgressStatusEventComplete(id, message)); } }
@Override public synchronized void setTotalStepCount(int totalStepCount) { if (completed || this.totalStepCount == totalStepCount) { return; } this.totalStepCount = totalStepCount; if (totalStepCount >= 0 && this.currentStepCount > totalStepCount) { this.currentStepCount = totalStepCount; } fireEvent(new ProgressStatusEventSet(id, totalStepCount, null)); }
public synchronized ProgressStatus createChild(String name, int allocatedSteps, int totalStepCount) { if (allocatedSteps < 0) { allocatedSteps = 0; } allocateStapsForChildProcess(allocatedSteps); ProgressStatusBase result = doCreateChild(name, totalStepCount); children.add(new ChildProgressStatus(allocatedSteps, result)); fireEvent(new ProgressStatusEventCreateChild(id, name, result.getId(), allocatedSteps, totalStepCount)); return result; }
/** Ignores allocated steps. It's mirroring implementation. */ @Override public synchronized ProgressStatus createChild(String name, int allocatedSteps, int totalStepCount) { ProgressStatusBase result = doCreateChild(name, totalStepCount); children.add(new ChildProgressStatus(allocatedSteps, result)); fireEvent(new ProgressStatusEventCreateChild(id, name, result.getId(), 0, totalStepCount)); return result; }
@Override public synchronized ProgressStatusMirroringImpl createMirroringChild(int allocatedSteps) { allocateStapsForChildProcess(allocatedSteps); String childId = (id == null ? "" : id) + "." + (children.size() + 1); ProgressStatusMirroringImpl result = new ProgressStatusMirroringImpl(null, this, childId); children.add(new ChildProgressStatus(allocatedSteps, result)); fireEvent(new ProgressStatusEventCreateChild(id, null, result.getId(), allocatedSteps, -1)); return result; }
protected synchronized float computeCompleteSteps() { if (isComplete()) { return totalStepCount; } float realStepCount = currentStepCount; for (ChildProgressStatus child : children) { float childPortion = child.progressStatus.computeCompletePortion(); if (childPortion < 0) { return -1; } realStepCount += ((float) child.getAllocatedSteps()) * childPortion; } return realStepCount; }
/** Applies event on existing structures. If not appliable do nothing. */ public synchronized void mirror(ProgressStatusEvent event) { if (event == null) { return; } ProgressStatus effected = map.get(event.getSourceId()); ProgressStatus result = event.apply(effected); if (event instanceof ProgressStatusEventCreateChild) { map.put(((ProgressStatusEventCreateChild) event).getChildId(), result); } }
@Override public int getRemainingStepCount() { int childAlocSteps = 0; for (ChildProgressStatus childProgressStatus : children) { childAlocSteps += childProgressStatus.getAllocatedSteps(); } return totalStepCount - currentStepCount - childAlocSteps; }
/** Fires {@link ProgressStatusEvent} to parent. */ protected void fireEvent(ProgressStatusEvent event) { if (parent != null) { parent.fireEvent(event); } }
@Override public ProgressStatus getProgressStatus() { if (progressStatus == null) { progressStatus = new ProgressStatusImpl(); } return progressStatus; }
@Override public ProgressStatus createChild(int allocatedSteps) { return createChild(null, allocatedSteps); }
@Override public void progress(String message) { progress(0, message, false); }
public synchronized ProgressStatus createChild(String name, int allocatedSteps, int totalStepCount) { if (allocatedSteps < 0) { allocatedSteps = 0; } allocateStapsForChildProcess(allocatedSteps); ProgressStatusBase result = doCreateChild(name, totalStepCount); children.add(new ChildProgressStatus(allocatedSteps, result)); fireEvent(new ProgressStatusEventCreateChild(id, name, result.getId(), allocatedSteps, totalStepCount)); return result; }
/** Ignores allocated steps. It's mirroring implementation. */ @Override public synchronized ProgressStatus createChild(String name, int allocatedSteps, int totalStepCount) { ProgressStatusBase result = doCreateChild(name, totalStepCount); children.add(new ChildProgressStatus(allocatedSteps, result)); fireEvent(new ProgressStatusEventCreateChild(id, name, result.getId(), 0, totalStepCount)); return result; }
protected synchronized float computeCompleteSteps() { if (isComplete()) { return totalStepCount; } float realStepCount = currentStepCount; for (ChildProgressStatus child : children) { float childPortion = child.progressStatus.computeCompletePortion(); if (childPortion < 0) { return -1; } realStepCount += ((float) child.getAllocatedSteps()) * childPortion; } return realStepCount; }
@Override public void complete(String message) { if (completeSilently()) { fireEvent(new ProgressStatusEventComplete(id, message)); } }
@Override public synchronized void setTotalStepCount(int totalStepCount) { if (completed || this.totalStepCount == totalStepCount) { return; } this.totalStepCount = totalStepCount; if (totalStepCount >= 0 && this.currentStepCount > totalStepCount) { this.currentStepCount = totalStepCount; } fireEvent(new ProgressStatusEventSet(id, totalStepCount, null)); }
/** Fires {@link ProgressStatusEvent} to parent. */ protected void fireEvent(ProgressStatusEvent event) { if (parent != null) { parent.fireEvent(event); } }