ItEr43S18CUMarcarUnidadeTraballoExportableItEr42S25: Using a common controller for task properties, resource allocation and subcontract commands.

This commit is contained in:
Manuel Rego Casasnovas 2010-01-14 11:11:19 +01:00 committed by Javier Moran Rua
parent ecb28fd030
commit a693e1f42b
5 changed files with 80 additions and 36 deletions

View file

@ -25,9 +25,8 @@ import java.util.List;
import org.navalplanner.business.orders.entities.Order;
import org.navalplanner.business.planner.entities.TaskElement;
import org.navalplanner.web.common.ViewSwitcher;
import org.navalplanner.web.planner.allocation.ResourceAllocationController;
import org.navalplanner.web.planner.calendar.CalendarAllocationController;
import org.navalplanner.web.planner.taskedition.TaskPropertiesController;
import org.navalplanner.web.planner.taskedition.EditTaskController;
import org.zkoss.ganttz.Planner;
import org.zkoss.ganttz.extensions.ICommand;
@ -38,10 +37,8 @@ public interface IOrderPlanningModel {
void setConfigurationToPlanner(Planner planner, Order order,
ViewSwitcher viewSwitcher,
ResourceAllocationController resourceAllocationController,
TaskPropertiesController taskPropertiesController,
EditTaskController editTaskController,
CalendarAllocationController calendarAllocationController,
SubcontractController subcontractController,
List<ICommand<TaskElement>> additional);
}

View file

@ -31,7 +31,7 @@ import org.navalplanner.business.planner.entities.TaskElement;
import org.navalplanner.web.common.ViewSwitcher;
import org.navalplanner.web.planner.allocation.ResourceAllocationController;
import org.navalplanner.web.planner.calendar.CalendarAllocationController;
import org.navalplanner.web.planner.taskedition.TaskPropertiesController;
import org.navalplanner.web.planner.taskedition.EditTaskController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
@ -54,22 +54,8 @@ public class OrderPlanningController implements Composer {
@Autowired
private ViewSwitcher viewSwitcher;
@Autowired
private ResourceAllocationController resourceAllocationController;
public ResourceAllocationController getResourceAllocationController() {
return resourceAllocationController;
}
private Map<String, String[]> parameters;
@Autowired
private TaskPropertiesController taskPropertiesController;
public TaskPropertiesController getTaskPropertiesController() {
return taskPropertiesController;
}
@Autowired
private IOrderPlanningModel model;
@ -79,7 +65,7 @@ public class OrderPlanningController implements Composer {
private CalendarAllocationController calendarAllocationController;
@Autowired
private SubcontractController subcontractController;
private EditTaskController editTaskController;
private Order order;
@ -135,13 +121,11 @@ public class OrderPlanningController implements Composer {
private void updateConfiguration() {
model.setConfigurationToPlanner(planner, order, viewSwitcher,
resourceAllocationController, taskPropertiesController,
calendarAllocationController, subcontractController,
additional);
editTaskController, calendarAllocationController, additional);
}
public SubcontractController getSubcontractController() {
return subcontractController;
public EditTaskController getEditTaskController() {
return editTaskController;
}
public void setURLParameters(Map<String, String[]> parameters) {

View file

@ -78,6 +78,7 @@ import org.navalplanner.web.planner.chart.EarnedValueChartFiller.EarnedValueType
import org.navalplanner.web.planner.milestone.IAddMilestoneCommand;
import org.navalplanner.web.planner.milestone.IDeleteMilestoneCommand;
import org.navalplanner.web.planner.order.ISaveCommand.IAfterSaveListener;
import org.navalplanner.web.planner.taskedition.EditTaskController;
import org.navalplanner.web.planner.taskedition.ITaskPropertiesCommand;
import org.navalplanner.web.planner.taskedition.TaskPropertiesController;
import org.navalplanner.web.print.CutyPrint;
@ -188,10 +189,8 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
@Transactional(readOnly = true)
public void setConfigurationToPlanner(Planner planner, Order order,
ViewSwitcher switcher,
ResourceAllocationController resourceAllocationController,
TaskPropertiesController taskPropertiesController,
EditTaskController editTaskController,
CalendarAllocationController calendarAllocationController,
SubcontractController subcontractController,
List<ICommand<TaskElement>> additional) {
Order orderReloaded = reload(order);
if (!orderReloaded.isSomeTaskElementScheduled()) {
@ -203,16 +202,19 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
ISaveCommand saveCommand = buildSaveCommand();
configuration.addGlobalCommand(saveCommand);
final IResourceAllocationCommand resourceAllocationCommand = buildResourceAllocationCommand(resourceAllocationController);
final IResourceAllocationCommand resourceAllocationCommand = buildResourceAllocationCommand(editTaskController
.getResourceAllocationController());
configuration.addCommandOnTask(resourceAllocationCommand);
configuration.addCommandOnTask(buildMilestoneCommand());
configuration.addCommandOnTask(buildDeleteMilestoneCommand());
configuration
.addCommandOnTask(buildCalendarAllocationCommand(calendarAllocationController));
configuration
.addCommandOnTask(buildTaskPropertiesCommand(taskPropertiesController));
.addCommandOnTask(buildTaskPropertiesCommand(editTaskController
.getTaskPropertiesController()));
configuration
.addCommandOnTask(buildSubcontractCommand(subcontractController));
.addCommandOnTask(buildSubcontractCommand(editTaskController
.getSubcontractController()));
configuration.setDoubleClickCommand(resourceAllocationCommand);
addPrintSupport(configuration, order);
Tabbox chartComponent = new Tabbox();

View file

@ -0,0 +1,60 @@
/*
* This file is part of ###PROJECT_NAME###
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.navalplanner.web.planner.taskedition;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.web.planner.allocation.ResourceAllocationController;
import org.navalplanner.web.planner.order.SubcontractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.zkoss.zk.ui.util.GenericForwardComposer;
/**
* Controller for edit a {@link Task}.
*
* @author Manuel Rego Casasnovas <mrego@igalia.com>
*/
@org.springframework.stereotype.Component("editTaskController")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class EditTaskController extends GenericForwardComposer {
@Autowired
private TaskPropertiesController taskPropertiesController;
@Autowired
private ResourceAllocationController resourceAllocationController;
@Autowired
private SubcontractController subcontractController;
public TaskPropertiesController getTaskPropertiesController() {
return taskPropertiesController;
}
public ResourceAllocationController getResourceAllocationController() {
return resourceAllocationController;
}
public SubcontractController getSubcontractController() {
return subcontractController;
}
}

View file

@ -28,12 +28,13 @@
<zk>
<zscript><![CDATA[
planningController = arg.get("orderPlanningController");
propertiesController = planningController.taskPropertiesController;
allocationController = planningController.resourceAllocationController;
calendarController = planningController.calendarAllocationController;
switcher = planningController.viewSwitcher;
calendarController = planningController.calendarAllocationController;
editController = planningController.editTaskController;
propertiesController = editController.taskPropertiesController;
allocationController = editController.resourceAllocationController;
allocationController.switcher = switcher;
subController = planningController.subcontractController;
subController = editController.subcontractController;
]]>
</zscript>
<div>