ItEr37S06ValidacionEProbasFuncionaisItEr36S07: all resources per day is showed always. When disabled keeps track of the sum of all resources per day

This commit is contained in:
Óscar González Fernández 2009-12-06 19:43:33 +01:00
parent 79abecd496
commit 0d8ea666ed
2 changed files with 30 additions and 5 deletions

View file

@ -314,4 +314,10 @@ public abstract class AllocationRow {
hoursInput.setValue(hours);
}
public void addListenerForResourcesPerDayInputChange(
EventListener resourcesPerDayRowInputChange) {
resourcesPerDayInput.addEventListener(Events.ON_CHANGE,
resourcesPerDayRowInputChange);
}
}

View file

@ -125,6 +125,16 @@ class FormBinder {
}
};
private EventListener resourcesPerDayRowInputChange = new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
if (allResourcesPerDay.isDisabled()) {
sumResourcesPerDayFromRowsAndAssignToAllResourcesPerDay();
}
}
};
private EventListener allHoursInputChange = new EventListener() {
@Override
@ -139,7 +149,7 @@ class FormBinder {
@Override
public void onEvent(Event event) throws Exception {
if (allResourcesPerDay.isVisible()) {
if (!allResourcesPerDay.isDisabled()) {
distributeResourcesPerDayToRows();
}
}
@ -293,15 +303,15 @@ class FormBinder {
}
private void allResourcesPerDayVisibilityRule() {
this.allResourcesPerDay.setVisible(recommendedAllocation);
this.allResourcesPerDay.setDisabled(allocationRowsHandler
.getCalculatedValue() == CalculatedValue.RESOURCES_PER_DAY);
.getCalculatedValue() == CalculatedValue.RESOURCES_PER_DAY
|| !recommendedAllocation);
this.allResourcesPerDay
.setConstraint(constraintForAllResourcesPerDay());
}
private Constraint constraintForAllResourcesPerDay() {
if (!allResourcesPerDay.isVisible() || allResourcesPerDay.isDisabled()) {
if (allResourcesPerDay.isDisabled()) {
return null;
}
return AllocationRow.CONSTRAINT_FOR_RESOURCES_PER_DAY;
@ -313,10 +323,19 @@ class FormBinder {
rows = result;
applyDisabledRulesOnRows();
bindTotalHoursToHoursInputs();
bindAllResourcesPerDayToRows();
return result;
}
private void bindAllResourcesPerDayToRows() {
sumResourcesPerDayFromRowsAndAssignToAllResourcesPerDay();
for (AllocationRow each : rows) {
each
.addListenerForResourcesPerDayInputChange(resourcesPerDayRowInputChange);
}
}
private List<AllocationRow> addListeners(List<AllocationRow> list) {
for (AllocationRow each : list) {
each.addListenerForInputChange(onChangeEnableApply);
@ -542,7 +561,7 @@ class FormBinder {
}
private void sumResourcesPerDayFromRowsAndAssignToAllResourcesPerDay() {
if (allResourcesPerDay.isDisabled() && allResourcesPerDay.isVisible()) {
if (allResourcesPerDay.isDisabled()) {
allResourcesPerDay.setValue(sumResourcesPerDayFromInputs());
}
}