ItEr37S08CUCreacionUnidadesPlanificacionItEr36S11: Letting choose resources per day. Setting disable values accordingly

This commit is contained in:
Óscar González Fernández 2009-12-01 20:13:39 +01:00
parent 17be262f61
commit 5f5691fc84
3 changed files with 31 additions and 5 deletions

View file

@ -26,6 +26,7 @@ import java.util.Collection;
import java.util.List;
import org.apache.commons.lang.Validate;
import org.navalplanner.business.planner.entities.CalculatedValue;
import org.navalplanner.business.planner.entities.ResourceAllocation;
import org.navalplanner.business.planner.entities.ResourcesPerDay;
import org.navalplanner.business.planner.entities.Task;
@ -184,4 +185,10 @@ public abstract class AllocationRow {
return null;
}
public void applyDisabledRules(CalculatedValue calculatedValue) {
hoursInput
.setDisabled(calculatedValue != CalculatedValue.RESOURCES_PER_DAY);
resourcesPerDayInput
.setDisabled(calculatedValue == CalculatedValue.RESOURCES_PER_DAY);
}
}

View file

@ -131,10 +131,6 @@ class FormBinder {
}
public void setCalculatedValue(CalculatedValue calculatedValue) {
if (calculatedValue == CalculatedValue.RESOURCES_PER_DAY) {
throw new RuntimeException(CalculatedValue.RESOURCES_PER_DAY
+ " not implemented yet");
}
if (calculatedValue == resourceAllocationsBeingEdited
.getCalculatedValue()) {
return;
@ -148,6 +144,13 @@ class FormBinder {
private void applyDisabledRules() {
assignedHoursComponentDisabilityRule();
endDateDisabilityRule();
applyDisabledRulesOnRows();
}
private void applyDisabledRulesOnRows() {
for (AllocationRow each : rows) {
each.applyDisabledRules(getCalculatedValue());
}
}
public CalculatedValue getCalculatedValue() {
@ -204,8 +207,11 @@ class FormBinder {
}
public List<AllocationRow> getCurrentRows() {
return rows = addListeners(resourceAllocationsBeingEdited
List<AllocationRow> result = addListeners(resourceAllocationsBeingEdited
.getCurrentRows());
rows = result;
applyDisabledRulesOnRows();
return result;
}
private List<AllocationRow> addListeners(List<AllocationRow> list) {

View file

@ -343,6 +343,19 @@ public class ResourceAllocationController extends GenericForwardComposer {
ResourceAllocationController resourceAllocationController) {
return resourceAllocationController.taskEndDate;
}
},
RESOURCES_PER_DAY(CalculatedValue.RESOURCES_PER_DAY) {
@Override
public String getName() {
return _("Calculate Resources per Day");
}
@Override
public Component input(
ResourceAllocationController resourceAllocationController) {
return new Label("");
}
};
public static CalculationTypeRadio from(CalculatedValue calculatedValue) {