updatesEmitter.doUpdate(disableButton(false));
}
}
private IDesktopUpdate disableButton(final boolean disable) {
return new IDesktopUpdate() {
@Override
public void doUpdate() {
btnRunMonteCarlo.setDisabled(disable);
}
};
}
private int getIterations() {
int iterations = ibIterations.getValue() != null ? ibIterations
.getValue().intValue() : 0;
if (iterations == 0) {
throw new WrongValueException(ibIterations,
_("cannot be empty"));
}
if (iterations < 0 || iterations > MAX_NUMBER_ITERATIONS) {
throw new WrongValueException(ibIterations,
_("Number of iterations should be between 1 and {0}",
MAX_NUMBER_ITERATIONS));
}
return iterations;
}
private void validateRowsPercentages() {
Intbox intbox;
int page = 0;
int counter = 0;
Rows rows = gridCriticalPathTasks.getRows();
for (Object each : rows.getChildren()) {
Row row = (Row) each;
List<org.zkoss.zk.ui.Component> children = row
.getChildren();
Integer sum = 0;
intbox = (Intbox) children.get(3);
sum += intbox.getValue();
intbox = (Intbox) children.get(5);
sum += intbox.getValue();
intbox = (Intbox) children.get(7);
sum += intbox.getValue();
if (sum != 100) {
gridCriticalPathTasks.setActivePage(page);
throw new WrongValueException(row,
_("Percentages should sum 100"));
}
counter++;
if (counter % gridCriticalPathTasks.getPageSize() == 0) {
page++;
}
}
}
private IDesktopUpdatesEmitter<Integer> percentageCompletedNotifier(
final IDesktopUpdatesEmitter<IDesktopUpdate> updatesEmitter) {
return new IDesktopUpdatesEmitter<Integer>() {
@Override
public void doUpdate(final Integer percentage) {
updatesEmitter
.doUpdate(showCompletedPercentage(percentage));
}
private IDesktopUpdate showCompletedPercentage(
final Integer value) {
return new IDesktopUpdate() {
@Override
public void doUpdate() {
progressMonteCarloCalculation.setValue(value);
}
};
}
};
}
private IDesktopUpdate showCalculatedData(
final Map<LocalDate, BigDecimal> monteCarloData) {
return new IDesktopUpdate() {
@Override
public void doUpdate() {
showMonteCarloGraph(monteCarloData);
}