Add "Advanced allocation" option in secondary menu of a task
FEA: ItEr75S23FixAllocationModel
This commit is contained in:
parent
30494391c4
commit
db0a40aa40
4 changed files with 141 additions and 12 deletions
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* This file is part of NavalPlan
|
||||
*
|
||||
* Copyright (C) 2011 Igalia, S.L.
|
||||
*
|
||||
* 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.allocation;
|
||||
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.web.planner.order.PlanningStateCreator.PlanningState;
|
||||
import org.navalplanner.web.planner.taskedition.EditTaskController;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
|
||||
|
||||
/**
|
||||
* A command that opens a window to make the advance allocation of a task.
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
@Component
|
||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class AdvancedAllocationCommand implements IAdvancedAllocationCommand {
|
||||
|
||||
private EditTaskController editTaskController;
|
||||
private PlanningState planningState;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return _("Advanced allocation");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIcon() {
|
||||
return "/common/img/ico_menu_advanced-assignment.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(IContextWithPlannerTask<TaskElement> context,
|
||||
TaskElement taskElement) {
|
||||
if (isApplicableTo(taskElement)) {
|
||||
editTaskController.showAdvancedAllocation((Task) taskElement,
|
||||
context, planningState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicableTo(TaskElement task) {
|
||||
return (task instanceof Task) && !task.isSubcontracted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(EditTaskController editTaskController,
|
||||
PlanningState state) {
|
||||
this.editTaskController = editTaskController;
|
||||
this.planningState = state;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* This file is part of NavalPlan
|
||||
*
|
||||
* Copyright (C) 2011 Igalia, S.L.
|
||||
*
|
||||
* 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.allocation;
|
||||
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.web.planner.order.PlanningStateCreator.PlanningState;
|
||||
import org.navalplanner.web.planner.taskedition.EditTaskController;
|
||||
import org.zkoss.ganttz.extensions.ICommandOnTask;
|
||||
|
||||
/**
|
||||
* Contract for {@link AdvancedAllocationCommand}.
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
public interface IAdvancedAllocationCommand extends ICommandOnTask<TaskElement> {
|
||||
|
||||
void initialize(EditTaskController editTaskController,
|
||||
PlanningState state);
|
||||
|
||||
}
|
||||
|
|
@ -78,6 +78,7 @@ import org.navalplanner.web.calendars.BaseCalendarModel;
|
|||
import org.navalplanner.web.common.ViewSwitcher;
|
||||
import org.navalplanner.web.planner.advances.AdvanceAssignmentPlanningController;
|
||||
import org.navalplanner.web.planner.advances.IAdvanceAssignmentPlanningCommand;
|
||||
import org.navalplanner.web.planner.allocation.IAdvancedAllocationCommand;
|
||||
import org.navalplanner.web.planner.allocation.IResourceAllocationCommand;
|
||||
import org.navalplanner.web.planner.calendar.CalendarAllocationController;
|
||||
import org.navalplanner.web.planner.calendar.ICalendarAllocationCommand;
|
||||
|
|
@ -224,6 +225,9 @@ public class OrderPlanningModel implements IOrderPlanningModel {
|
|||
@Autowired
|
||||
private IResourceAllocationCommand resourceAllocationCommand;
|
||||
|
||||
@Autowired
|
||||
private IAdvancedAllocationCommand advancedAllocationCommand;
|
||||
|
||||
@Autowired
|
||||
private IAddMilestoneCommand addMilestoneCommand;
|
||||
|
||||
|
|
@ -335,6 +339,8 @@ public class OrderPlanningModel implements IOrderPlanningModel {
|
|||
configuration
|
||||
.addCommandOnTask(buildTaskPropertiesCommand(editTaskController));
|
||||
configuration.addCommandOnTask(resourceAllocationCommand);
|
||||
configuration
|
||||
.addCommandOnTask(buildAdvancedAllocationCommand(editTaskController));
|
||||
configuration
|
||||
.addCommandOnTask(buildSubcontractCommand(editTaskController));
|
||||
configuration
|
||||
|
|
@ -982,6 +988,12 @@ public class OrderPlanningModel implements IOrderPlanningModel {
|
|||
return resourceAllocationCommand;
|
||||
}
|
||||
|
||||
private IAdvancedAllocationCommand buildAdvancedAllocationCommand(
|
||||
EditTaskController editTaskController) {
|
||||
advancedAllocationCommand.initialize(editTaskController, planningState);
|
||||
return advancedAllocationCommand;
|
||||
}
|
||||
|
||||
private ICommand<TaskElement> buildReassigningCommand() {
|
||||
reassignCommand.setState(planningState);
|
||||
return reassignCommand;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ import org.navalplanner.web.planner.allocation.AdvancedAllocationController.IAdv
|
|||
import org.navalplanner.web.planner.allocation.AdvancedAllocationController.Restriction;
|
||||
import org.navalplanner.web.planner.allocation.AdvancedAllocationController.Restriction.IRestrictionSource;
|
||||
import org.navalplanner.web.planner.allocation.AllocationResult;
|
||||
import org.navalplanner.web.planner.allocation.FormBinder;
|
||||
import org.navalplanner.web.planner.allocation.ResourceAllocationController;
|
||||
import org.navalplanner.web.planner.limiting.allocation.LimitingResourceAllocationController;
|
||||
import org.navalplanner.web.planner.order.PlanningStateCreator.PlanningState;
|
||||
|
|
@ -360,21 +359,24 @@ public class EditTaskController extends GenericForwardComposer {
|
|||
return (isTask(task) && !task.isSubcontracted());
|
||||
}
|
||||
|
||||
public void goToAdvancedAllocation() {
|
||||
FormBinder formBinder = resourceAllocationController.getFormBinder();
|
||||
public void showAdvancedAllocation(Task task,
|
||||
IContextWithPlannerTask<TaskElement> context,
|
||||
PlanningState planningState) {
|
||||
this.taskElement = task;
|
||||
this.context = context;
|
||||
this.planningState = planningState;
|
||||
|
||||
AllocationResult allocationResult = AllocationResult.createCurrent(
|
||||
planningState.getCurrentScenario(), task);
|
||||
|
||||
AllocationResult allocationResult = formBinder.getLastAllocation();
|
||||
if (allocationResult.getAggregate().isEmpty()) {
|
||||
formBinder.doApply();
|
||||
allocationResult = formBinder.getLastAllocation();
|
||||
}
|
||||
if (allocationResult.getAggregate().isEmpty()) {
|
||||
getMessagesForUser().showMessage(Level.WARNING,
|
||||
_("Some allocations needed"));
|
||||
return;
|
||||
}
|
||||
getSwitcher().goToAdvancedAllocation(
|
||||
allocationResult, createResultReceiver(allocationResult));
|
||||
|
||||
getSwitcher().goToAdvancedAllocation(allocationResult,
|
||||
createResultReceiver(allocationResult));
|
||||
window.setVisible(false);
|
||||
}
|
||||
|
||||
|
|
@ -432,12 +434,14 @@ public class EditTaskController extends GenericForwardComposer {
|
|||
|
||||
@Override
|
||||
public void cancel() {
|
||||
showEditFormResourceAllocation(context, taskElement, planningState);
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accepted(AggregateOfResourceAllocations aggregate) {
|
||||
resourceAllocationController.accept(allocation);
|
||||
allocation.applyTo(planningState.getCurrentScenario(),
|
||||
(Task) taskElement);
|
||||
askForReloads();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue