From e9bd396f33d780624699b85922059f638d3ba50d Mon Sep 17 00:00:00 2001 From: Manuel Rego Casasnovas Date: Fri, 17 Jul 2009 09:09:41 +0200 Subject: [PATCH] ItEr17S13CUConfiguracionDeOrganizacionsDeTraballoConUnidadesTraballoItEr15S11: Fixed the problem with the header of the HoursGroup list when editing an OrderElement. --- .../web/orders/OrderElementController.java | 49 +++++++++++++------ 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/orders/OrderElementController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/orders/OrderElementController.java index 9a7c13b01..15089b6c8 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/orders/OrderElementController.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/orders/OrderElementController.java @@ -385,7 +385,7 @@ public class OrderElementController extends GenericForwardComposer { item.setValue(hoursGroup); - Listhead header = ((Listbox) item.getParent()).getListheadApi(); + generateListhead(((Listbox) item.getParent()).getListheadApi()); Listcell cellWorkingHours = new Listcell(); cellWorkingHours.setParent(item); @@ -430,11 +430,6 @@ public class OrderElementController extends GenericForwardComposer { Listcell cellCriterion = new Listcell(); cellCriterion.setParent(item); - // Add a new column on the HoursGroup table - Listheader headerCriterion = new Listheader(); - headerCriterion.setLabel(criterionType.getName()); - headerCriterion.setParent(header); - // Add a new Listbox for each CriterionType final Listbox criterionListbox = new Listbox(); criterionListbox.setRows(1); @@ -530,10 +525,6 @@ public class OrderElementController extends GenericForwardComposer { Listcell cellFixedPercentage = new Listcell(); cellFixedPercentage.setParent(item); - Listheader headerFixedPercentage = new Listheader(); - headerFixedPercentage.setLabel("Fixed percentage"); - headerFixedPercentage.setParent(header); - Checkbox fixedPercentage = Util.bind(new Checkbox(), new Util.Getter() { @@ -572,11 +563,6 @@ public class OrderElementController extends GenericForwardComposer { Listcell cellCriterion = new Listcell(); cellCriterion.setParent(item); - // Add a new column on the HoursGroup table - Listheader headerCriterion = new Listheader(); - headerCriterion.setLabel(criterionType.getName()); - headerCriterion.setParent(header); - // Add a new Listbox for each CriterionType final Listbox criterionListbox = new Listbox(); criterionListbox.setRows(1); @@ -631,6 +617,39 @@ public class OrderElementController extends GenericForwardComposer { } } + /** + * Generates the {@link Listhead} depending on the {@link CriterionType} + * selected. + * + * @param listhead + * A {@link Listhead} to be updated + */ + private void generateListhead(Listhead listhead) { + // Remove the current header + listhead.getChildren().clear(); + + // Generate basi headers + Listheader hours = new Listheader("Hours"); + listhead.appendChild(hours); + Listheader percentage = new Listheader("%"); + listhead.appendChild(percentage); + + // If it's a leaf add Fixed percentage column + if (getOrderElement() instanceof OrderLine) { + Listheader headerFixedPercentage = new Listheader( + "Fixed percentage"); + listhead.appendChild(headerFixedPercentage); + } + + // For each CriterionType selected + for (CriterionType criterionType : getSelectedCriterionTypes()) { + // Add a new column on the HoursGroup table + Listheader headerCriterion = new Listheader(); + headerCriterion.setLabel(criterionType.getName()); + listhead.appendChild(headerCriterion); + } + } + /** * Disable workingHours and percentage components depending on the * policy selected by the user.