/** 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; }
/** Recursive search for child by id. */ protected ProgressStatusBase findById(String id) { if (id == null || id.isEmpty()) { return null; } if (id.equals(getId())) { return this; } for (ChildProgressStatus child : getChildProgressStatuses()) { ProgressStatusBase result = child.getProgressStatus().findById(id); if (result != null) { return result; } } return null; }
int newCurrentStepCount = 0; for (ChildProgressStatus child : children) { ProgressStatusBase mirr = child.getProgressStatus(); if (!unknown) { int tsc = mirr.getTotalStepCount();
int newCurrentStepCount = 0; for (ChildProgressStatus child : children) { ProgressStatusBase mirr = child.getProgressStatus(); if (!unknown) { int tsc = mirr.getTotalStepCount();
protected void allocateStapsForChildProcess(int allocatedSteps) { if (allocatedSteps < 0) { allocatedSteps = 0; } if (totalStepCount >= 0) { for (ChildProgressStatus child : children) { allocatedSteps += child.getAllocatedSteps(); } if ((allocatedSteps + currentStepCount) > totalStepCount) { currentStepCount = totalStepCount - allocatedSteps; if (currentStepCount < 0) { currentStepCount = 0; totalStepCount = allocatedSteps; } } } }
protected void allocateStapsForChildProcess(int allocatedSteps) { if (allocatedSteps < 0) { allocatedSteps = 0; } if (totalStepCount >= 0) { for (ChildProgressStatus child : children) { allocatedSteps += child.getAllocatedSteps(); } if ((allocatedSteps + currentStepCount) > totalStepCount) { currentStepCount = totalStepCount - allocatedSteps; if (currentStepCount < 0) { currentStepCount = 0; totalStepCount = allocatedSteps; } } } }
/** Complete this {@code ProgressStatus} and all sub-ProgressStatuses * but does not fire event to parent statuses. */ protected synchronized boolean completeSilently() { if (completed) { return false; } if (totalStepCount >= 0) { currentStepCount = totalStepCount; } completed = true; for (ChildProgressStatus child : children) { child.getProgressStatus().completeSilently(); } return true; }
/** Complete this {@code ProgressStatus} and all sub-ProgressStatuses * but does not fire event to parent statuses. */ protected synchronized boolean completeSilently() { if (completed) { return false; } if (totalStepCount >= 0) { currentStepCount = totalStepCount; } completed = true; for (ChildProgressStatus child : children) { child.getProgressStatus().completeSilently(); } return true; }
/** Recursive search for child by id. */ protected ProgressStatusBase findById(String id) { if (id == null || id.isEmpty()) { return null; } if (id.equals(getId())) { return this; } for (ChildProgressStatus child : getChildProgressStatuses()) { ProgressStatusBase result = child.getProgressStatus().findById(id); if (result != null) { return result; } } return null; }
private void mirror(ProgressStatusBase source, ProgressStatus stat) { stat.setTotalStepCount(source.getTotalStepCount()); stat.setCurrentStepCount(source.getCurrentStepCount()); if (source.isComplete()) { stat.complete(); } for (ProgressStatusBase.ChildProgressStatus chld : source.getChildProgressStatuses()) { ProgressStatus dst = map.get(chld.getProgressStatus().getId()); if (dst == null) { dst = stat.createChild(chld.getProgressStatus().getName(), chld.getAllocatedSteps()); map.put(chld.getProgressStatus().getId(), dst); } mirror(chld.getProgressStatus(), dst); } }
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; }
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; }
public synchronized Collection<ProgressStatusBase> getChildren() { Collection<ProgressStatusBase> result = new ArrayList<ProgressStatusBase>(children.size()); for (ChildProgressStatus chld : children) { result.add(chld.getProgressStatus()); } return result; }
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; }
@Override public int getRemainingStepCount() { int childAlocSteps = 0; for (ChildProgressStatus childProgressStatus : children) { childAlocSteps += childProgressStatus.getAllocatedSteps(); } return totalStepCount - currentStepCount - childAlocSteps; }
@Override public int getRemainingStepCount() { int childAlocSteps = 0; for (ChildProgressStatus childProgressStatus : children) { childAlocSteps += childProgressStatus.getAllocatedSteps(); } return totalStepCount - currentStepCount - childAlocSteps; }
@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; }
public synchronized Collection<ProgressStatusBase> getChildren() { Collection<ProgressStatusBase> result = new ArrayList<ProgressStatusBase>(children.size()); for (ChildProgressStatus chld : children) { result.add(chld.getProgressStatus()); } 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; }
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; }