From e4442c8afa999942e8e0c811cce319a2f56c4509 Mon Sep 17 00:00:00 2001 From: Susana Montes Pedreira Date: Wed, 12 May 2010 12:10:08 +0200 Subject: [PATCH] ItEr58S04ValidacionEProbasFuncionaisItEr57S04: [Bug #435] Fixing Bug. and the strategy used for the allocation is now shown correctly. --- .../ResourceAllocationController.java | 53 +++++++++++++------ 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationController.java index d6cb0eb7d..411360837 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationController.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationController.java @@ -102,8 +102,6 @@ public class ResourceAllocationController extends GenericForwardComposer { private Intbox assignedHoursComponent; - private Datebox taskStartDatebox = new Datebox(); - private Grid calculationTypesGrid; private Radiogroup calculationTypeSelector; @@ -183,7 +181,8 @@ public class ResourceAllocationController extends GenericForwardComposer { @Override public Component cellFor(Integer column, CalculationTypeRadio data) { - return data.createComponent(getController()); + return data.createComponent(getController(), + getCalculationTypeRadio()); } }; } @@ -192,6 +191,13 @@ public class ResourceAllocationController extends GenericForwardComposer { return taskEndDate; } + private CalculationTypeRadio getCalculationTypeRadio() { + if (formBinder != null) { + return CalculationTypeRadio.from(formBinder.getCalculatedValue()); + } + return null; + } + public ResourceAllocationController getController() { return this; } @@ -230,9 +236,11 @@ public class ResourceAllocationController extends GenericForwardComposer { formBinder.setMessagesForUser(messagesForUser); formBinder.setWorkerSearchTab(workerSearchTab); formBinder.setCheckbox(recommendedAllocationCheckbox); + CalculationTypeRadio calculationTypeRadio = CalculationTypeRadio .from(formBinder.getCalculatedValue()); calculationTypeRadio.doTheSelectionOn(calculationTypeSelector); + tbResourceAllocation.setSelected(true); orderElementHoursGrid.setModel(new ListModelList( resourceAllocationModel.getHoursAggregatedByCriterions())); @@ -421,39 +429,52 @@ public class ResourceAllocationController extends GenericForwardComposer { ResourceAllocationController resourceAllocationController); public Component createComponent( - ResourceAllocationController resourceAllocationController) { + ResourceAllocationController resourceAllocationController, + CalculationTypeRadio calculationTypeRadio) { if (this.equals(END_DATE)) { - return createHbox(resourceAllocationController.taskEndDate); + return createHbox(resourceAllocationController.taskEndDate, + calculationTypeRadio); } else { - return createRadio(); + return createRadio(calculationTypeRadio); } } - public Radio createRadio() { + public Radio createRadio(CalculationTypeRadio calculationTypeRadio) { Radio result = new Radio(); result.setLabel(getName()); result.setValue(toString()); + result.setChecked(isSameCalculationTypeRadio(result, + calculationTypeRadio)); return result; } - public Hbox createHbox(Datebox datebox) { + public Hbox createHbox(Datebox datebox, + CalculationTypeRadio calculationTypeRadio) { Hbox hbox = new Hbox(); hbox.setSpacing("65px"); - Radio radio = createRadio(); + Radio radio = createRadio(calculationTypeRadio); hbox.appendChild(radio); hbox.appendChild(datebox); return hbox; } - public void doTheSelectionOn(Radiogroup radiogroup) { - for (int i = 0; i < radiogroup.getItemCount(); i++) { - Radio radio = radiogroup.getItemAtIndex(i); - if (name().equals(radio.getValue())) { - radiogroup.setSelectedIndex(i); - break; - } + public boolean isSameCalculationTypeRadio(Radio radio, + CalculationTypeRadio calculationTypeRadio) { + if (calculationTypeRadio != null) { + return name().equals(calculationTypeRadio.name()); } + return false; + } + + public void doTheSelectionOn(final Radiogroup radiogroup) { + for (int i = 0; i < radiogroup.getItemCount(); i++) { + Radio radio = radiogroup.getItemAtIndex(i); + if (name().equals(radio.getValue())) { + radiogroup.setSelectedIndex(i); + break; + } + } } private final CalculatedValue calculatedValue;