From a6153296b9a39f092f40ee13a6c53c7bd367bb90 Mon Sep 17 00:00:00 2001 From: Manuel Rego Casasnovas Date: Thu, 7 Feb 2013 12:58:15 +0100 Subject: [PATCH] Get zoom from session in advanced allocation view Add a listener in order to update the value in the session when user changes the zoom. FEA: ItEr77S15FilteringEnhancements --- .../libreplan/web/common/ViewSwitcher.java | 18 ++++++++------ .../AdvancedAllocationController.java | 24 ++++++++++++------- .../tabs/AdvancedAllocationTabCreator.java | 5 ++-- .../AdvancedAllocationTaskController.java | 4 ++-- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/ViewSwitcher.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/ViewSwitcher.java index 7a68fca35..99aa36986 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/common/ViewSwitcher.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/ViewSwitcher.java @@ -25,11 +25,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.libreplan.business.orders.entities.Order; import org.libreplan.web.planner.allocation.AdvancedAllocationController; -import org.libreplan.web.planner.allocation.AllocationResult; import org.libreplan.web.planner.allocation.AdvancedAllocationController.AllocationInput; import org.libreplan.web.planner.allocation.AdvancedAllocationController.IAdvanceAllocationResultReceiver; import org.libreplan.web.planner.allocation.AdvancedAllocationController.IBack; +import org.libreplan.web.planner.allocation.AllocationResult; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -54,20 +55,23 @@ public class ViewSwitcher implements Composer { isInPlanningOrder = true; } - public void goToAdvancedAllocation(AllocationResult allocationResult, + public void goToAdvancedAllocation(Order order, + AllocationResult allocationResult, IAdvanceAllocationResultReceiver resultReceiver) { - planningOrder = ComponentsReplacer.replaceAllChildren(parent, - "advance_allocation.zul", createArgsForAdvancedAllocation( - allocationResult, resultReceiver)); + planningOrder = ComponentsReplacer.replaceAllChildren( + parent, + "advance_allocation.zul", + createArgsForAdvancedAllocation(order, allocationResult, + resultReceiver)); isInPlanningOrder = false; } - private Map createArgsForAdvancedAllocation( + private Map createArgsForAdvancedAllocation(Order order, AllocationResult allocationResult, IAdvanceAllocationResultReceiver resultReceiver) { Map result = new HashMap(); result.put("advancedAllocationController", - new AdvancedAllocationController(createBack(), + new AdvancedAllocationController(order, createBack(), asAllocationInput(allocationResult, resultReceiver))); return result; } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/AdvancedAllocationController.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/AdvancedAllocationController.java index 61409fda5..b0533e756 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/AdvancedAllocationController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/AdvancedAllocationController.java @@ -41,6 +41,7 @@ import org.apache.commons.lang.Validate; import org.joda.time.DateTime; import org.joda.time.LocalDate; import org.joda.time.Period; +import org.libreplan.business.orders.entities.Order; import org.libreplan.business.planner.entities.AggregateOfResourceAllocations; import org.libreplan.business.planner.entities.AssignmentFunction; import org.libreplan.business.planner.entities.AssignmentFunction.AssignmentFunctionName; @@ -56,6 +57,7 @@ import org.libreplan.business.planner.entities.TaskElement; import org.libreplan.business.resources.entities.Criterion; import org.libreplan.business.workingday.EffortDuration; import org.libreplan.web.common.EffortDurationBox; +import org.libreplan.web.common.FilterUtils; import org.libreplan.web.common.IMessagesForUser; import org.libreplan.web.common.MessagesForUser; import org.libreplan.web.common.OnlyOneVisible; @@ -377,24 +379,29 @@ public class AdvancedAllocationController extends GenericForwardComposer { private Listbox advancedAllocationHorizontalPagination; private Listbox advancedAllocationVerticalPagination; - private boolean fixedZoomByUser = false; private ZoomLevel zoomLevel; - public AdvancedAllocationController(IBack back, + private Order order; + + public AdvancedAllocationController(Order order, IBack back, List allocationInputs) { - setInputData(back, allocationInputs); + setInputData(order, back, allocationInputs); } - private void setInputData(IBack back, List allocationInputs) { + private void setInputData(Order order, IBack back, + List allocationInputs) { + Validate.notNull(order); Validate.notNull(back); Validate.noNullElements(allocationInputs); + this.order = order; this.back = back; this.allocationInputs = allocationInputs; } - public void reset(IBack back, List allocationInputs) { + public void reset(Order order, IBack back, + List allocationInputs) { rowsCached = null; - setInputData(back, allocationInputs); + setInputData(order, back, allocationInputs); loadAndInitializeComponents(); } @@ -576,7 +583,8 @@ public class AdvancedAllocationController extends GenericForwardComposer { private void createComponents() { timeTracker = new TimeTracker(addMarginTointerval(), self); paginatorFilter = new PaginatorFilter(); - if (fixedZoomByUser && (zoomLevel != null)) { + zoomLevel = FilterUtils.readZoomLevel(order); + if (zoomLevel != null) { timeTracker.setZoomLevel(zoomLevel); } paginatorFilter.setZoomLevel(timeTracker.getDetailLevel()); @@ -588,7 +596,7 @@ public class AdvancedAllocationController extends GenericForwardComposer { timeTracker.addZoomListener(new IZoomLevelChangedListener() { @Override public void zoomLevelChanged(ZoomLevel detailLevel) { - fixedZoomByUser = true; + FilterUtils.writeZoomLevel(order, detailLevel); zoomLevel = detailLevel; paginatorFilter.setZoomLevel(detailLevel); diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/AdvancedAllocationTabCreator.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/AdvancedAllocationTabCreator.java index 00c971542..2c6653dbe 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/AdvancedAllocationTabCreator.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/AdvancedAllocationTabCreator.java @@ -264,7 +264,8 @@ public class AdvancedAllocationTabCreator { private Map argsWithController(PlanningState planningState) { Map result = new HashMap(); - advancedAllocationController = new AdvancedAllocationController(onBack, + advancedAllocationController = new AdvancedAllocationController( + planningState.getOrder(), onBack, createAllocationInputsFor(planningState)); result.put("advancedAllocationController", advancedAllocationController); return result; @@ -297,7 +298,7 @@ public class AdvancedAllocationTabCreator { } private void resetController(PlanningState planningState) { - advancedAllocationController.reset(onBack, + advancedAllocationController.reset(planningState.getOrder(), onBack, createAllocationInputsFor(planningState)); } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/taskedition/AdvancedAllocationTaskController.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/taskedition/AdvancedAllocationTaskController.java index e5ead90be..4b3b57e96 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/taskedition/AdvancedAllocationTaskController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/taskedition/AdvancedAllocationTaskController.java @@ -78,8 +78,8 @@ public class AdvancedAllocationTaskController extends GenericForwardComposer { return; } - getSwitcher().goToAdvancedAllocation(allocationResult, - createResultReceiver(allocationResult)); + getSwitcher().goToAdvancedAllocation(planningState.getOrder(), + allocationResult, createResultReceiver(allocationResult)); }