private void appendDecimalBoxMaxValue(final Listitem listItem,
boolean isQualityFormOrReadOnly) {
final AdvanceAssignment advanceAssignment = (AdvanceAssignment) listItem
.getValue();
final Decimalbox maxValue = new Decimalbox();
maxValue.setScale(2);
final DirectAdvanceAssignment directAdvanceAssignment;
if ((advanceAssignment instanceof IndirectAdvanceAssignment)
|| isQualityFormOrReadOnly
|| (advanceAssignment.getAdvanceType() != null && advanceAssignment
.getAdvanceType().getPercentage())
|| manageOrderElementAdvancesModel
.hasConsolidatedAdvances(advanceAssignment)) {
maxValue.setDisabled(true);
}
if (advanceAssignment instanceof IndirectAdvanceAssignment) {
directAdvanceAssignment = manageOrderElementAdvancesModel
.calculateFakeDirectAdvanceAssignment((IndirectAdvanceAssignment) advanceAssignment);
} else {
directAdvanceAssignment = (DirectAdvanceAssignment) advanceAssignment;
}
Util.bind(maxValue, new Util.Getter<BigDecimal>() {
@Override
public BigDecimal get() {
return directAdvanceAssignment.getMaxValue();
}
}, new Util.Setter<BigDecimal>() {
@Override
public void set(BigDecimal value) {
if (!manageOrderElementAdvancesModel
.hasConsolidatedAdvances(advanceAssignment)) {
directAdvanceAssignment.setMaxValue(value);
}
}
});
maxValue.addEventListener(Events.ON_CHANGE,
new EventListener() {
@Override
public void onEvent(Event event) {
if (manageOrderElementAdvancesModel
.hasConsolidatedAdvances(advanceAssignment)) {
throw new WrongValueException(
maxValue,
_("Progress Assignment cannot be deleted or changed. Progress Assignment contains Progress Consolidations values"));
} else {
setPercentage();
reloadAdvances();
}
}
});
Listcell listCell = new Listcell();
listCell.appendChild(maxValue);
listItem.appendChild(listCell);
maxValue.setConstraint(checkMaxValue());
}