From e39688d940515b4e88e23f0b4bf95579efdd6fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Mon, 7 Dec 2009 00:46:55 +0100 Subject: [PATCH] ItEr37S06ValidacionEProbasFuncionaisItEr36S07: Some UI rearragments at resource allocations forms --- .../ResourceAllocationController.java | 44 ++++-- .../src/main/webapp/planner/order.zul | 148 +++++++++--------- 2 files changed, 100 insertions(+), 92 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 6c39a44da..77015eb63 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 @@ -22,6 +22,7 @@ package org.navalplanner.web.planner.allocation; import static org.navalplanner.web.I18nHelper._; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -32,7 +33,6 @@ import org.navalplanner.business.orders.entities.AggregatedHoursGroup; import org.navalplanner.business.planner.entities.AggregateOfResourceAllocations; import org.navalplanner.business.planner.entities.CalculatedValue; import org.navalplanner.business.planner.entities.ResourceAllocation; -import org.navalplanner.business.planner.entities.SpecificResourceAllocation; import org.navalplanner.business.planner.entities.Task; import org.navalplanner.web.common.IMessagesForUser; import org.navalplanner.web.common.MessagesForUser; @@ -138,7 +138,6 @@ public class ResourceAllocationController extends GenericForwardComposer { super.doAfterCompose(comp); this.window = (Window) comp; messagesForUser = new MessagesForUser(messagesContainer); - taskEndDate = new Datebox(); allResourcesPerDay = new Decimalbox(); makeReadyInputsForCalculationTypes(); prepareCalculationTypesGrid(); @@ -148,14 +147,13 @@ public class ResourceAllocationController extends GenericForwardComposer { final String width = "300px"; taskEndDate.setWidth(width); assignedHoursComponent = new Intbox(); - assignedHoursComponent.setWidth(width); } private void prepareCalculationTypesGrid() { calculationTypesGrid.setModel(new ListModelList(Arrays .asList(CalculationTypeRadio.values()))); calculationTypesGrid.setRowRenderer(OnColumnsRowRenderer.create( - calculationTypesRenderer(), Arrays.asList(0, 1))); + calculationTypesRenderer(), Arrays.asList(0))); } private ICellForDetailItemRenderer calculationTypesRenderer() { @@ -163,11 +161,7 @@ public class ResourceAllocationController extends GenericForwardComposer { @Override public Component cellFor(Integer column, CalculationTypeRadio data) { - if (column == 0) { - return data.createRadio(); - } else { - return data.input(ResourceAllocationController.this); - } + return data.createRadio(); } }; } @@ -432,12 +426,18 @@ public class ResourceAllocationController extends GenericForwardComposer { return resourceAllocationModel.getOrderHours(); } - public List getResourceAllocations() { - return formBinder != null ? formBinder - .getCurrentRows() : Collections + public List getResourceAllocations() { + return formBinder != null ? plusAggregatingRow(formBinder + .getCurrentRows()) : Collections . emptyList(); } + private List plusAggregatingRow(List currentRows) { + List result = new ArrayList(currentRows); + result.add(null); + return result; + } + public ResourceAllocationRenderer getResourceAllocationRenderer() { return resourceAllocationRenderer; } @@ -485,15 +485,16 @@ public class ResourceAllocationController extends GenericForwardComposer { return new AdvanceAllocationResultReceiver(allocation); } - /** - * Renders a {@link SpecificResourceAllocation} item - * @author Diego Pino Garcia - */ private class ResourceAllocationRenderer implements ListitemRenderer { @Override public void render(Listitem item, Object data) throws Exception { - renderResourceAllocation(item, (AllocationRow) data); + if (data instanceof AllocationRow) { + AllocationRow row = (AllocationRow) data; + renderResourceAllocation(item, row); + } else { + renderAggregatingRow(item); + } } private void renderResourceAllocation(Listitem item, @@ -515,6 +516,15 @@ public class ResourceAllocationController extends GenericForwardComposer { }); } + private void renderAggregatingRow(Listitem item) { + ResourceAllocationController controller = ResourceAllocationController.this; + append(item, new Label()); + append(item, CalculationTypeRadio.NUMBER_OF_HOURS.input(controller)); + append(item, CalculationTypeRadio.RESOURCES_PER_DAY + .input(controller)); + append(item, new Label()); + } + private void removeAllocation(AllocationRow row) { allocationRows.remove(row); Util.reloadBindings(allocationsList); diff --git a/navalplanner-webapp/src/main/webapp/planner/order.zul b/navalplanner-webapp/src/main/webapp/planner/order.zul index 69b00a025..d1e015b84 100644 --- a/navalplanner-webapp/src/main/webapp/planner/order.zul +++ b/navalplanner-webapp/src/main/webapp/planner/order.zul @@ -92,81 +92,79 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +