ItEr43S09ImplantacionAplicacionItEr42S13: Adding call to reloadCharts when doing a resource allocation

This commit is contained in:
Óscar González Fernández 2010-01-11 14:30:25 +01:00
parent e4c80b485d
commit cf2ec63014
4 changed files with 20 additions and 11 deletions

View file

@ -25,7 +25,9 @@ import java.util.List;
import org.navalplanner.business.common.ProportionalDistributor;
import org.navalplanner.business.orders.entities.AggregatedHoursGroup;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.TaskElement;
import org.navalplanner.web.planner.order.PlanningState;
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
/**
* Contract for {@link Task}.
@ -56,7 +58,7 @@ public interface IResourceAllocationModel extends INewAllocationsAdder {
* @param planningState
*/
AllocationRowsHandler initAllocationsFor(Task task,
org.zkoss.ganttz.data.Task ganttTask,
IContextWithPlannerTask<TaskElement> context,
PlanningState planningState);
void accept(AllocationResult modifiedAllocationResult);

View file

@ -49,8 +49,8 @@ public class ResourceAllocationCommand implements IResourceAllocationCommand {
public void doAction(IContextWithPlannerTask<TaskElement> context,
TaskElement task) {
if (isApplicableTo(task)) {
this.resourceAllocationController.showWindow((Task) task, context
.getTask(), planningState);
this.resourceAllocationController.showWindow(context, (Task) task,
planningState);
}
}

View file

@ -36,7 +36,7 @@ import org.navalplanner.business.planner.entities.AggregateOfResourceAllocations
import org.navalplanner.business.planner.entities.CalculatedValue;
import org.navalplanner.business.planner.entities.DerivedAllocation;
import org.navalplanner.business.planner.entities.ResourceAllocation;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.TaskElement;
import org.navalplanner.business.resources.entities.ResourceEnum;
import org.navalplanner.web.common.IMessagesForUser;
import org.navalplanner.web.common.MessagesForUser;
@ -49,6 +49,7 @@ import org.navalplanner.web.planner.allocation.AdvancedAllocationController.Rest
import org.navalplanner.web.planner.order.PlanningState;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
import org.zkoss.ganttz.timetracker.ICellForDetailItemRenderer;
import org.zkoss.ganttz.timetracker.IConvertibleToColumn;
import org.zkoss.ganttz.timetracker.OnColumnsRowRenderer;
@ -181,15 +182,16 @@ public class ResourceAllocationController extends GenericForwardComposer {
* @param ganttTask
* @param planningState
*/
public void showWindow(Task task, org.zkoss.ganttz.data.Task ganttTask,
public void showWindow(IContextWithPlannerTask<TaskElement> context,
org.navalplanner.business.planner.entities.Task task,
PlanningState planningState) {
try {
if (formBinder != null) {
formBinder.detach();
}
window.setTitle(task.getName());
allocationRows = resourceAllocationModel.initAllocationsFor(
task, ganttTask, planningState);
allocationRows = resourceAllocationModel.initAllocationsFor(task,
context, planningState);
formBinder = allocationRows
.createFormBinder(resourceAllocationModel);
formBinder.setAssignedHoursComponent(assignedHoursComponent);

View file

@ -40,6 +40,7 @@ import org.navalplanner.business.planner.entities.DerivedAllocation;
import org.navalplanner.business.planner.entities.GenericResourceAllocation;
import org.navalplanner.business.planner.entities.ResourceAllocation;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.TaskElement;
import org.navalplanner.business.planner.entities.DerivedAllocationGenerator.IWorkerFinder;
import org.navalplanner.business.resources.daos.ICriterionDAO;
import org.navalplanner.business.resources.daos.IResourceDAO;
@ -56,6 +57,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
/**
* Model for UI operations related to {@link Task}
@ -80,8 +82,6 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
private Task task;
private org.zkoss.ganttz.data.Task ganttTask;
@Autowired
private IBaseCalendarDAO calendarDAO;
@ -92,6 +92,8 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
private AllocationRowsHandler allocationRowsHandler;
private IContextWithPlannerTask<TaskElement> context;
@Override
@Transactional(readOnly = true)
public void addSpecific(Collection<? extends Resource> resources) {
@ -198,18 +200,21 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
}
private void applyAllocationResult(AllocationResult allocationResult) {
org.zkoss.ganttz.data.Task ganttTask = context.getTask();
Date previousStartDate = ganttTask.getBeginDate();
long previousLength = ganttTask.getLengthMilliseconds();
allocationResult.applyTo(task);
ganttTask.fireChangesForPreviousValues(previousStartDate,
previousLength);
context.reloadCharts();
}
@Override
@Transactional(readOnly = true)
public AllocationRowsHandler initAllocationsFor(Task task,
org.zkoss.ganttz.data.Task ganttTask, PlanningState planningState) {
this.ganttTask = ganttTask;
IContextWithPlannerTask<TaskElement> context,
PlanningState planningState) {
this.context = context;
this.task = task;
this.planningState = planningState;
planningState.reassociateResourcesWithSession(resourceDAO);