ItEr37S06ValidacionEProbasFuncionaisItEr36S07: Using zk constraint for resources per day in order to show feedback sooner

This commit is contained in:
Óscar González Fernández 2009-12-06 19:28:41 +01:00
parent 89b4f0936b
commit 79abecd496
2 changed files with 30 additions and 6 deletions

View file

@ -49,6 +49,10 @@ import org.zkoss.zul.SimpleConstraint;
*/
public abstract class AllocationRow {
public static final SimpleConstraint CONSTRAINT_FOR_RESOURCES_PER_DAY = new SimpleConstraint(
SimpleConstraint.NO_EMPTY
| SimpleConstraint.NO_ZERO | SimpleConstraint.NO_NEGATIVE);
public static void assignHours(List<AllocationRow> rows, int[] hours) {
int i = 0;
for (AllocationRow each : rows) {
@ -275,15 +279,26 @@ public abstract class AllocationRow {
hoursInput
.setDisabled(calculatedValue != CalculatedValue.RESOURCES_PER_DAY
|| recommendedAllocation);
if (!hoursInput.isDisabled()) {
hoursInput.setConstraint(new SimpleConstraint(
SimpleConstraint.NO_EMPTY | SimpleConstraint.NO_NEGATIVE));
} else {
hoursInput.setConstraint((Constraint) null);
}
hoursInput.setConstraint(constraintForHoursInput());
resourcesPerDayInput
.setDisabled(calculatedValue == CalculatedValue.RESOURCES_PER_DAY
|| recommendedAllocation);
resourcesPerDayInput.setConstraint(constraintForResourcesPerDayInput());
}
private Constraint constraintForHoursInput() {
if (hoursInput.isDisabled()) {
return null;
}
return new SimpleConstraint(SimpleConstraint.NO_EMPTY
| SimpleConstraint.NO_NEGATIVE);
}
private Constraint constraintForResourcesPerDayInput() {
if (resourcesPerDayInput.isDisabled()) {
return null;
}
return CONSTRAINT_FOR_RESOURCES_PER_DAY;
}
public void loadDataFromLast() {

View file

@ -296,6 +296,15 @@ class FormBinder {
this.allResourcesPerDay.setVisible(recommendedAllocation);
this.allResourcesPerDay.setDisabled(allocationRowsHandler
.getCalculatedValue() == CalculatedValue.RESOURCES_PER_DAY);
this.allResourcesPerDay
.setConstraint(constraintForAllResourcesPerDay());
}
private Constraint constraintForAllResourcesPerDay() {
if (!allResourcesPerDay.isVisible() || allResourcesPerDay.isDisabled()) {
return null;
}
return AllocationRow.CONSTRAINT_FOR_RESOURCES_PER_DAY;
}
public List<AllocationRow> getCurrentRows() {