ItEr43S18CUMarcarUnidadeTraballoExportableItEr42S25: Merged resource allocation window in one tab of edit task window.
This commit is contained in:
parent
1f07fb016c
commit
46008bf9c7
11 changed files with 293 additions and 257 deletions
|
|
@ -64,7 +64,7 @@ import org.zkoss.zul.SimpleConstraint;
|
|||
import org.zkoss.zul.Tab;
|
||||
import org.zkoss.zul.impl.api.InputElement;
|
||||
|
||||
class FormBinder {
|
||||
public class FormBinder {
|
||||
|
||||
private Intbox allHoursInput;
|
||||
|
||||
|
|
@ -349,7 +349,7 @@ class FormBinder {
|
|||
return list;
|
||||
}
|
||||
|
||||
void doApply() {
|
||||
public void doApply() {
|
||||
lastAllocation = resourceAllocationModel
|
||||
.onAllocationContext(new IResourceAllocationContext<AllocationResult>() {
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ package org.navalplanner.web.planner.allocation;
|
|||
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.web.planner.order.PlanningState;
|
||||
import org.navalplanner.web.planner.taskedition.EditTaskController;
|
||||
import org.zkoss.ganttz.extensions.ICommandOnTask;
|
||||
|
||||
/**
|
||||
|
|
@ -31,7 +32,7 @@ import org.zkoss.ganttz.extensions.ICommandOnTask;
|
|||
*/
|
||||
public interface IResourceAllocationCommand extends ICommandOnTask<TaskElement> {
|
||||
|
||||
void initialize(ResourceAllocationController resourceAllocationController,
|
||||
void initialize(EditTaskController editTaskController,
|
||||
PlanningState state);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,10 @@ 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.IEditTaskUtilities;
|
||||
import org.navalplanner.web.planner.order.PlanningState;
|
||||
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;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -39,18 +42,23 @@ import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
|
|||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class ResourceAllocationCommand implements IResourceAllocationCommand {
|
||||
|
||||
private ResourceAllocationController resourceAllocationController;
|
||||
private EditTaskController editTaskController;
|
||||
private PlanningState planningState;
|
||||
|
||||
@Autowired
|
||||
private IEditTaskUtilities editTaskUtilities;
|
||||
|
||||
public ResourceAllocationCommand() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAction(IContextWithPlannerTask<TaskElement> context,
|
||||
TaskElement task) {
|
||||
editTaskUtilities.reattach(task);
|
||||
|
||||
if (isApplicableTo(task)) {
|
||||
this.resourceAllocationController.showWindow(context, (Task) task,
|
||||
planningState);
|
||||
this.editTaskController.showEditFormResourceAllocation(context,
|
||||
(Task) task, planningState);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -61,9 +69,9 @@ public class ResourceAllocationCommand implements IResourceAllocationCommand {
|
|||
|
||||
@Override
|
||||
public void initialize(
|
||||
ResourceAllocationController resourceAllocationController,
|
||||
EditTaskController editTaskController,
|
||||
PlanningState planningState) {
|
||||
this.resourceAllocationController = resourceAllocationController;
|
||||
this.editTaskController = editTaskController;
|
||||
this.planningState = planningState;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,22 +30,16 @@ import java.util.List;
|
|||
import org.apache.commons.lang.Validate;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.joda.time.LocalDate;
|
||||
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.DerivedAllocation;
|
||||
import org.navalplanner.business.planner.entities.ResourceAllocation;
|
||||
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;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.navalplanner.web.common.ViewSwitcher;
|
||||
import org.navalplanner.web.common.components.NewAllocationSelector;
|
||||
import org.navalplanner.web.planner.allocation.AdvancedAllocationController.IAdvanceAllocationResultReceiver;
|
||||
import org.navalplanner.web.planner.allocation.AdvancedAllocationController.Restriction;
|
||||
import org.navalplanner.web.planner.allocation.AdvancedAllocationController.Restriction.IRestrictionSource;
|
||||
import org.navalplanner.web.planner.order.PlanningState;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
|
@ -56,7 +50,6 @@ import org.zkoss.ganttz.timetracker.OnColumnsRowRenderer;
|
|||
import org.zkoss.ganttz.util.OnZKDesktopRegistry;
|
||||
import org.zkoss.ganttz.util.script.IScriptsRegister;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.SuspendNotAllowedException;
|
||||
import org.zkoss.zk.ui.WrongValueException;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
|
|
@ -77,7 +70,6 @@ import org.zkoss.zul.Row;
|
|||
import org.zkoss.zul.RowRenderer;
|
||||
import org.zkoss.zul.SimpleListModel;
|
||||
import org.zkoss.zul.Tab;
|
||||
import org.zkoss.zul.api.Window;
|
||||
|
||||
/**
|
||||
* Controller for {@link ResourceAllocation} view.
|
||||
|
|
@ -99,14 +91,8 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
|
||||
private ResourceAllocationRenderer resourceAllocationRenderer = new ResourceAllocationRenderer();
|
||||
|
||||
private Component messagesContainer;
|
||||
|
||||
private IMessagesForUser messagesForUser;
|
||||
|
||||
private Grid allocationsGrid;
|
||||
|
||||
private Window window;
|
||||
|
||||
private FormBinder formBinder;
|
||||
|
||||
private AllocationRowsHandler allocationRows;
|
||||
|
|
@ -146,8 +132,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
this.window = (Window) comp;
|
||||
messagesForUser = new MessagesForUser(messagesContainer);
|
||||
allResourcesPerDay = new Decimalbox();
|
||||
makeReadyInputsForCalculationTypes();
|
||||
prepareCalculationTypesGrid();
|
||||
|
|
@ -182,14 +166,13 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
* @param ganttTask
|
||||
* @param planningState
|
||||
*/
|
||||
public void showWindow(IContextWithPlannerTask<TaskElement> context,
|
||||
public void init(IContextWithPlannerTask<TaskElement> context,
|
||||
org.navalplanner.business.planner.entities.Task task,
|
||||
PlanningState planningState) {
|
||||
PlanningState planningState, IMessagesForUser messagesForUser) {
|
||||
try {
|
||||
if (formBinder != null) {
|
||||
formBinder.detach();
|
||||
}
|
||||
window.setTitle(task.getName());
|
||||
allocationRows = resourceAllocationModel.initAllocationsFor(task,
|
||||
context, planningState);
|
||||
formBinder = allocationRows
|
||||
|
|
@ -211,7 +194,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
resourceAllocationModel.getHoursAggregatedByCriterions()));
|
||||
orderElementHoursGrid.setRowRenderer(createOrderElementHoursRenderer());
|
||||
newAllocationSelector.setAllocationsAdder(resourceAllocationModel);
|
||||
showWindow();
|
||||
} catch (WrongValueException e) {
|
||||
LOG.error("there was a WrongValueException initializing window", e);
|
||||
throw e;
|
||||
|
|
@ -280,17 +262,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
hoursCellRenderer, Arrays.asList(HoursRendererColumn.values()));
|
||||
}
|
||||
|
||||
private void showWindow() {
|
||||
Util.reloadBindings(window);
|
||||
try {
|
||||
window.doModal();
|
||||
} catch (SuspendNotAllowedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pick resources selected from {@link NewAllocationSelector} and add them to
|
||||
* resource allocation list
|
||||
|
|
@ -317,53 +288,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
newAllocationSelector.clearAll();
|
||||
}
|
||||
|
||||
private final class AdvanceAllocationResultReceiver implements
|
||||
IAdvanceAllocationResultReceiver {
|
||||
|
||||
private final AllocationResult allocation;
|
||||
|
||||
private AdvanceAllocationResultReceiver(AllocationResult allocation) {
|
||||
this.allocation = allocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
showWindow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accepted(AggregateOfResourceAllocations aggregate) {
|
||||
resourceAllocationModel.accept(allocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Restriction createRestriction() {
|
||||
return Restriction.build(new IRestrictionSource() {
|
||||
|
||||
@Override
|
||||
public int getTotalHours() {
|
||||
return allocation.getAggregate().getTotalHours();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate getStart() {
|
||||
return allocation.getStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate getEnd() {
|
||||
return getStart()
|
||||
.plusDays(allocation.getDaysDuration());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CalculatedValue getCalculatedValue() {
|
||||
return allocation.getCalculatedValue();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public enum CalculationTypeRadio {
|
||||
|
||||
NUMBER_OF_HOURS(CalculatedValue.NUMBER_OF_HOURS) {
|
||||
|
|
@ -546,14 +470,8 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
public void cancel() {
|
||||
close();
|
||||
resourceAllocationModel.cancel();
|
||||
}
|
||||
|
||||
|
||||
private void close() {
|
||||
window.setVisible(false);
|
||||
clear();
|
||||
resourceAllocationModel.cancel();
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
|
|
@ -563,23 +481,7 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
|
||||
public void accept() {
|
||||
resourceAllocationModel.accept();
|
||||
close();
|
||||
}
|
||||
|
||||
public void goToAdvancedAllocation() {
|
||||
AllocationResult allocationResult = formBinder.getLastAllocation();
|
||||
if (allocationResult.getAggregate().isEmpty()) {
|
||||
formBinder.doApply();
|
||||
allocationResult = formBinder.getLastAllocation();
|
||||
}
|
||||
switcher.goToAdvancedAllocation(allocationResult,
|
||||
createResultReceiver(allocationResult));
|
||||
window.setVisible(false);
|
||||
}
|
||||
|
||||
private IAdvanceAllocationResultReceiver createResultReceiver(
|
||||
final AllocationResult allocation) {
|
||||
return new AdvanceAllocationResultReceiver(allocation);
|
||||
clear();
|
||||
}
|
||||
|
||||
private class ResourceAllocationRenderer implements RowRenderer {
|
||||
|
|
@ -650,4 +552,13 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
public void setSwitcher(ViewSwitcher switcher) {
|
||||
this.switcher = switcher;
|
||||
}
|
||||
|
||||
public FormBinder getFormBinder() {
|
||||
return formBinder;
|
||||
}
|
||||
|
||||
public void accept(AllocationResult allocation) {
|
||||
resourceAllocationModel.accept(allocation);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.zkoss.ganttz.extensions.ICommandOnTask;
|
|||
*/
|
||||
public interface ISubcontractCommand extends ICommandOnTask<TaskElement> {
|
||||
|
||||
void setEditTaskController(EditTaskController editTaskController);
|
||||
void initialize(EditTaskController editTaskController,
|
||||
PlanningState planningState);
|
||||
|
||||
}
|
||||
|
|
@ -67,7 +67,6 @@ import org.navalplanner.web.common.ViewSwitcher;
|
|||
import org.navalplanner.web.planner.ITaskElementAdapter;
|
||||
import org.navalplanner.web.planner.ITaskElementAdapter.IOnMoveListener;
|
||||
import org.navalplanner.web.planner.allocation.IResourceAllocationCommand;
|
||||
import org.navalplanner.web.planner.allocation.ResourceAllocationController;
|
||||
import org.navalplanner.web.planner.calendar.CalendarAllocationController;
|
||||
import org.navalplanner.web.planner.calendar.ICalendarAllocationCommand;
|
||||
import org.navalplanner.web.planner.chart.Chart;
|
||||
|
|
@ -201,8 +200,7 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
ISaveCommand saveCommand = buildSaveCommand();
|
||||
configuration.addGlobalCommand(saveCommand);
|
||||
|
||||
final IResourceAllocationCommand resourceAllocationCommand = buildResourceAllocationCommand(editTaskController
|
||||
.getResourceAllocationController());
|
||||
final IResourceAllocationCommand resourceAllocationCommand = buildResourceAllocationCommand(editTaskController);
|
||||
configuration.addCommandOnTask(resourceAllocationCommand);
|
||||
configuration.addCommandOnTask(buildMilestoneCommand());
|
||||
configuration.addCommandOnTask(buildDeleteMilestoneCommand());
|
||||
|
|
@ -549,8 +547,8 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
private ITaskPropertiesCommand buildTaskPropertiesCommand(
|
||||
EditTaskController editTaskController) {
|
||||
ITaskPropertiesCommand taskPropertiesCommand = getTaskPropertiesCommand();
|
||||
taskPropertiesCommand
|
||||
.setEditTaskController(editTaskController);
|
||||
taskPropertiesCommand.initialize(editTaskController,
|
||||
planningState);
|
||||
return taskPropertiesCommand;
|
||||
}
|
||||
|
||||
|
|
@ -561,9 +559,9 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
}
|
||||
|
||||
private IResourceAllocationCommand buildResourceAllocationCommand(
|
||||
ResourceAllocationController resourceAllocationController) {
|
||||
EditTaskController editTaskController) {
|
||||
IResourceAllocationCommand resourceAllocationCommand = getResourceAllocationCommand();
|
||||
resourceAllocationCommand.initialize(resourceAllocationController,
|
||||
resourceAllocationCommand.initialize(editTaskController,
|
||||
planningState);
|
||||
return resourceAllocationCommand;
|
||||
}
|
||||
|
|
@ -1030,7 +1028,8 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
private ISubcontractCommand buildSubcontractCommand(
|
||||
EditTaskController editTaskController) {
|
||||
ISubcontractCommand subcontractCommand = getSubcontractCommand();
|
||||
subcontractCommand.setEditTaskController(editTaskController);
|
||||
subcontractCommand.initialize(editTaskController,
|
||||
planningState);
|
||||
return subcontractCommand;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
|
|||
public class SubcontractCommand implements ISubcontractCommand {
|
||||
|
||||
private EditTaskController editTaskController;
|
||||
private PlanningState planningState;
|
||||
|
||||
@Autowired
|
||||
private IEditTaskUtilities editTaskUtilities;
|
||||
|
|
@ -68,13 +69,16 @@ public class SubcontractCommand implements ISubcontractCommand {
|
|||
editTaskUtilities.reattach(task);
|
||||
|
||||
if (isApplicableTo(task)) {
|
||||
editTaskController.showEditFormSubcontract(context, task);
|
||||
editTaskController.showEditFormSubcontract(context, task,
|
||||
planningState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEditTaskController(EditTaskController editTaskController) {
|
||||
public void initialize(EditTaskController editTaskController,
|
||||
PlanningState planningState) {
|
||||
this.editTaskController = editTaskController;
|
||||
this.planningState = planningState;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -20,13 +20,24 @@
|
|||
|
||||
package org.navalplanner.web.planner.taskedition;
|
||||
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.planner.entities.AggregateOfResourceAllocations;
|
||||
import org.navalplanner.business.planner.entities.CalculatedValue;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.web.common.IMessagesForUser;
|
||||
import org.navalplanner.web.common.MessagesForUser;
|
||||
import org.navalplanner.web.common.Util;
|
||||
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.allocation.AdvancedAllocationController.IAdvanceAllocationResultReceiver;
|
||||
import org.navalplanner.web.planner.allocation.AdvancedAllocationController.Restriction;
|
||||
import org.navalplanner.web.planner.allocation.AdvancedAllocationController.Restriction.IRestrictionSource;
|
||||
import org.navalplanner.web.planner.order.PlanningState;
|
||||
import org.navalplanner.web.planner.order.SubcontractController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
|
|
@ -63,6 +74,7 @@ public class EditTaskController extends GenericForwardComposer {
|
|||
private Tab resourceAllocationTab;
|
||||
private Tab subcontractTab;
|
||||
private Tabpanel taskPropertiesTabpanel;
|
||||
private Tabpanel resourceAllocationTabpanel;
|
||||
private Tabpanel subcontractTabpanel;
|
||||
private Component messagesContainer;
|
||||
|
||||
|
|
@ -72,11 +84,14 @@ public class EditTaskController extends GenericForwardComposer {
|
|||
|
||||
private IContextWithPlannerTask<TaskElement> context;
|
||||
|
||||
private PlanningState planningState;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
window = (Window) comp;
|
||||
taskPropertiesController.doAfterCompose(taskPropertiesTabpanel);
|
||||
resourceAllocationController.doAfterCompose(resourceAllocationTabpanel);
|
||||
subcontractController.doAfterCompose(subcontractTabpanel);
|
||||
messagesForUser = new MessagesForUser(messagesContainer);
|
||||
}
|
||||
|
|
@ -94,17 +109,23 @@ public class EditTaskController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
private void showEditForm(IContextWithPlannerTask<TaskElement> context,
|
||||
TaskElement taskElement) {
|
||||
TaskElement taskElement, PlanningState planningState) {
|
||||
this.taskElement = taskElement;
|
||||
this.context = context;
|
||||
this.planningState = planningState;
|
||||
|
||||
taskPropertiesController.init(context, taskElement);
|
||||
if (taskElement.isSubcontracted()) {
|
||||
subcontractController.init((Task) taskElement, context);
|
||||
if (taskElement instanceof Task) {
|
||||
resourceAllocationController.init(context, (Task) taskElement,
|
||||
planningState, messagesForUser);
|
||||
if (taskElement.isSubcontracted()) {
|
||||
subcontractController.init((Task) taskElement, context);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Util.reloadBindings(window);
|
||||
window.setTitle(_("Edit task: {0}", taskElement.getName()));
|
||||
window.setMode("modal");
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
|
@ -113,23 +134,42 @@ public class EditTaskController extends GenericForwardComposer {
|
|||
|
||||
public void showEditFormTaskProperties(
|
||||
IContextWithPlannerTask<TaskElement> context,
|
||||
TaskElement taskElement) {
|
||||
TaskElement taskElement, PlanningState planningState) {
|
||||
editTaskTabbox.setSelectedPanelApi(taskPropertiesTabpanel);
|
||||
showEditForm(context, taskElement);
|
||||
showEditForm(context, taskElement, planningState);
|
||||
}
|
||||
|
||||
public void showEditFormResourceAllocation(
|
||||
IContextWithPlannerTask<TaskElement> context,
|
||||
TaskElement taskElement, PlanningState planningState) {
|
||||
if (isNotSubcontractedAndIsTask()) {
|
||||
editTaskTabbox.setSelectedPanelApi(resourceAllocationTabpanel);
|
||||
} else {
|
||||
editTaskTabbox.setSelectedPanelApi(taskPropertiesTabpanel);
|
||||
}
|
||||
showEditForm(context, taskElement, planningState);
|
||||
}
|
||||
|
||||
public void showEditFormSubcontract(
|
||||
IContextWithPlannerTask<TaskElement> context,
|
||||
TaskElement taskElement) {
|
||||
if (taskElement.isSubcontracted()) {
|
||||
TaskElement taskElement, PlanningState planningState) {
|
||||
if (isSubcontractedAndIsTask()) {
|
||||
editTaskTabbox.setSelectedPanelApi(subcontractTabpanel);
|
||||
} else {
|
||||
editTaskTabbox.setSelectedPanelApi(taskPropertiesTabpanel);
|
||||
}
|
||||
showEditForm(context, taskElement);
|
||||
showEditForm(context, taskElement, planningState);
|
||||
}
|
||||
|
||||
public void accept() {
|
||||
try {
|
||||
editTaskTabbox.setSelectedPanelApi(taskPropertiesTabpanel);
|
||||
taskPropertiesController.accept();
|
||||
|
||||
editTaskTabbox.setSelectedPanelApi(resourceAllocationTabpanel);
|
||||
resourceAllocationController.accept();
|
||||
|
||||
editTaskTabbox.setSelectedPanelApi(subcontractTabpanel);
|
||||
subcontractController.accept();
|
||||
|
||||
taskElement = null;
|
||||
|
|
@ -144,6 +184,7 @@ public class EditTaskController extends GenericForwardComposer {
|
|||
public void cancel() {
|
||||
taskPropertiesController.cancel();
|
||||
subcontractController.cancel();
|
||||
resourceAllocationController.cancel();
|
||||
|
||||
taskElement = null;
|
||||
context = null;
|
||||
|
|
@ -165,15 +206,92 @@ public class EditTaskController extends GenericForwardComposer {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isSubcontracted() {
|
||||
public boolean isSubcontractedAndIsTask() {
|
||||
if (taskElement == null) {
|
||||
return false;
|
||||
}
|
||||
if (!isTask()) {
|
||||
return false;
|
||||
}
|
||||
return taskElement.isSubcontracted();
|
||||
}
|
||||
|
||||
public boolean isNotSubcontracted() {
|
||||
return !isSubcontracted();
|
||||
public boolean isNotSubcontractedAndIsTask() {
|
||||
if (taskElement == null) {
|
||||
return false;
|
||||
}
|
||||
if (!isTask()) {
|
||||
return false;
|
||||
}
|
||||
return !taskElement.isSubcontracted();
|
||||
}
|
||||
|
||||
public void goToAdvancedAllocation() {
|
||||
FormBinder formBinder = resourceAllocationController.getFormBinder();
|
||||
|
||||
AllocationResult allocationResult = formBinder.getLastAllocation();
|
||||
if (allocationResult.getAggregate().isEmpty()) {
|
||||
formBinder.doApply();
|
||||
allocationResult = formBinder.getLastAllocation();
|
||||
}
|
||||
resourceAllocationController.getSwitcher().goToAdvancedAllocation(
|
||||
allocationResult, createResultReceiver(allocationResult));
|
||||
window.setVisible(false);
|
||||
}
|
||||
|
||||
private IAdvanceAllocationResultReceiver createResultReceiver(
|
||||
final AllocationResult allocation) {
|
||||
return new AdvanceAllocationResultReceiver(allocation);
|
||||
}
|
||||
|
||||
private final class AdvanceAllocationResultReceiver implements
|
||||
IAdvanceAllocationResultReceiver {
|
||||
|
||||
private final AllocationResult allocation;
|
||||
|
||||
private AdvanceAllocationResultReceiver(AllocationResult allocation) {
|
||||
this.allocation = allocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
showEditFormResourceAllocation(context, taskElement, planningState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accepted(AggregateOfResourceAllocations aggregate) {
|
||||
resourceAllocationController.accept(allocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Restriction createRestriction() {
|
||||
return Restriction.build(new IRestrictionSource() {
|
||||
|
||||
@Override
|
||||
public int getTotalHours() {
|
||||
return allocation.getAggregate().getTotalHours();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate getStart() {
|
||||
return allocation.getStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate getEnd() {
|
||||
return getStart().plusDays(allocation.getDaysDuration());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CalculatedValue getCalculatedValue() {
|
||||
return allocation.getCalculatedValue();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isTask() {
|
||||
return (taskElement instanceof Task);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
package org.navalplanner.web.planner.taskedition;
|
||||
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.web.planner.order.PlanningState;
|
||||
import org.zkoss.ganttz.extensions.ICommandOnTask;
|
||||
|
||||
/**
|
||||
|
|
@ -30,6 +31,7 @@ import org.zkoss.ganttz.extensions.ICommandOnTask;
|
|||
*/
|
||||
public interface ITaskPropertiesCommand extends ICommandOnTask<TaskElement> {
|
||||
|
||||
void setEditTaskController(EditTaskController editTaskController);
|
||||
void initialize(EditTaskController editTaskController,
|
||||
PlanningState planningState);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import static org.navalplanner.web.I18nHelper._;
|
|||
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.web.planner.order.IEditTaskUtilities;
|
||||
import org.navalplanner.web.planner.order.PlanningState;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
|
@ -40,6 +41,7 @@ import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
|
|||
public class TaskPropertiesCommand implements ITaskPropertiesCommand {
|
||||
|
||||
private EditTaskController editTaskController;
|
||||
private PlanningState planningState;
|
||||
|
||||
@Autowired
|
||||
private IEditTaskUtilities editTaskUtilities;
|
||||
|
|
@ -49,7 +51,8 @@ public class TaskPropertiesCommand implements ITaskPropertiesCommand {
|
|||
TaskElement taskElement) {
|
||||
editTaskUtilities.reattach(taskElement);
|
||||
|
||||
editTaskController.showEditFormTaskProperties(context, taskElement);
|
||||
editTaskController.showEditFormTaskProperties(context, taskElement,
|
||||
planningState);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -58,9 +61,10 @@ public class TaskPropertiesCommand implements ITaskPropertiesCommand {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setEditTaskController(
|
||||
EditTaskController editTaskController) {
|
||||
public void initialize(EditTaskController editTaskController,
|
||||
PlanningState planningState) {
|
||||
this.editTaskController = editTaskController;
|
||||
this.planningState = planningState;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
</div>
|
||||
|
||||
<window id="editTaskWindow" apply="${editController}" border="normal"
|
||||
title="${i18n:_('Task properties')}" width="650px" visible="false">
|
||||
width="650px" visible="false">
|
||||
|
||||
<vbox id="messagesContainer" />
|
||||
|
||||
|
|
@ -52,9 +52,9 @@
|
|||
<tabs>
|
||||
<tab id="taskPropertiesTab" label="${i18n:_('Task properties')}" />
|
||||
<tab id="resourceAllocationTab" label="${i18n:_('Resource allocation')}"
|
||||
visible="@{editController.isNotSubcontracted}" />
|
||||
visible="@{editController.isNotSubcontractedAndIsTask}" />
|
||||
<tab id="subcontractTab" label="${i18n:_('Subcontract')}"
|
||||
visible="@{editController.isSubcontracted}" />
|
||||
visible="@{editController.isSubcontractedAndIsTask}" />
|
||||
</tabs>
|
||||
<tabpanels>
|
||||
<tabpanel id="taskPropertiesTabpanel">
|
||||
|
|
@ -94,7 +94,7 @@
|
|||
<datebox id="startConstraintDate" constraint ="no empty"/>
|
||||
</vbox>
|
||||
</row>
|
||||
<row id="subcontract">
|
||||
<row id="subcontract" visible="@{editController.isTask}">
|
||||
<label value="${i18n:_('Subcontract')}" />
|
||||
<checkbox id="subcontractCheckbox" label="${i18n:_('Is subcontracted')}"
|
||||
onCheck="editController.subcontract(self.checked);" />
|
||||
|
|
@ -102,7 +102,111 @@
|
|||
</rows>
|
||||
</grid>
|
||||
</tabpanel>
|
||||
<tabpanel id="resourceAllocationTabpanel">TODO</tabpanel>
|
||||
<tabpanel id="resourceAllocationTabpanel">
|
||||
<tabbox mold="accordion">
|
||||
<tabs>
|
||||
<tab id="tbResourceAllocation" label="${i18n:_('Resource allocation')}" image="common/img/collapse.gif" />
|
||||
<tab id="workerSearchTab" label="${i18n:_('Resources search')}" image="common/img/collapse.gif"/>
|
||||
</tabs>
|
||||
<tabpanels>
|
||||
<tabpanel>
|
||||
<groupbox mold="3d" closable="false">
|
||||
<caption label="${i18n:_('Order Element Information')}:" />
|
||||
<grid id="orderElementHoursGrid">
|
||||
<columns>
|
||||
<column width="200px" label="${i18n:_('Criteria')}"/>
|
||||
<column width="200px" label="${i18n:_('Type')}"/>
|
||||
<column label="${i18n:_('Hours')}" />
|
||||
</columns>
|
||||
</grid>
|
||||
<grid>
|
||||
<columns>
|
||||
<column width="200px" />
|
||||
<column width="200px" />
|
||||
<column />
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label />
|
||||
<label value="${i18n:_('Total Estimated hours')}:" />
|
||||
<intbox value="@{allocationController.orderHours}" disabled="${true}" />
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</groupbox>
|
||||
<groupbox mold="3d" style="margin-top: 5px" closable="false">
|
||||
<caption label="${i18n:_('Task information')}:" />
|
||||
<grid>
|
||||
<columns>
|
||||
<column width="200px" />
|
||||
<column />
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label value="${i18n:_('Start')}" />
|
||||
<datebox id="taskStartDateBox" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('End')}" />
|
||||
<datebox id="taskEndDate" />
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</groupbox>
|
||||
<groupbox mold="3d" style="margin-top: 5px" closable="false">
|
||||
<caption label="${i18n:_('Calculation type')}:" />
|
||||
<radiogroup id="calculationTypeSelector"
|
||||
onCheck="allocationController.calculationTypeSelected = self.selectedItem.value;">
|
||||
<grid id="calculationTypesGrid">
|
||||
<columns>
|
||||
<column />
|
||||
</columns>
|
||||
</grid>
|
||||
</radiogroup>
|
||||
<hbox>
|
||||
<checkbox id="recommendedAllocationCheckbox" label="${i18n:_('Recommended Allocation')}"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
|
||||
<groupbox mold="3d" style="margin-top: 5px" sclass="assignedresources" closable="false">
|
||||
<caption label="${i18n:_('Allocations')}" />
|
||||
<grid id="allocationsGrid"
|
||||
model="@{allocationController.resourceAllocations}"
|
||||
rowRenderer="@{allocationController.resourceAllocationRenderer}"
|
||||
style="margin-bottom: 5px" fixedLayout="true">
|
||||
<columns>
|
||||
<column />
|
||||
<column label="${i18n:_('Name')}" />
|
||||
<column
|
||||
label="${i18n:_('Hours')}" />
|
||||
<column
|
||||
label="${i18n:_('Resources Per Day')}" />
|
||||
<column
|
||||
label="${i18n:_('Operations')}" />
|
||||
</columns>
|
||||
</grid>
|
||||
</groupbox>
|
||||
</tabpanel>
|
||||
|
||||
<!-- Worker search -->
|
||||
<tabpanel>
|
||||
<newAllocationSelector id="newAllocationSelector"/>
|
||||
<!-- Select worker -->
|
||||
<hbox>
|
||||
<button label="${i18n:_('Select')}" onClick="allocationController.onSelectWorkers(event)" />
|
||||
<button label="${i18n:_('Close')}" onClick="allocationController.onCloseSelectWorkers()" />
|
||||
</hbox>
|
||||
</tabpanel>
|
||||
</tabpanels>
|
||||
</tabbox>
|
||||
|
||||
<!-- Control buttons -->
|
||||
<hbox>
|
||||
<button label="${i18n:_('Apply tab changes')}" id="applyButton" sclass="global-action" />
|
||||
<button label="${i18n:_('Go to advanced Allocation')}"
|
||||
onClick="editController.goToAdvancedAllocation();" sclass="global-action" />
|
||||
</hbox>
|
||||
</tabpanel>
|
||||
<tabpanel id="subcontractTabpanel">
|
||||
<grid>
|
||||
<rows>
|
||||
|
|
@ -171,122 +275,6 @@
|
|||
</hbox>
|
||||
</window>
|
||||
|
||||
<window id="resourceAllocationWindow"
|
||||
apply="${allocationController}" closable="true"
|
||||
title="${i18n:_('Resource allocation')}" width="650px" visible="false"
|
||||
border="normal">
|
||||
|
||||
<tabbox mold="accordion">
|
||||
<tabs>
|
||||
<tab id="tbResourceAllocation" label="${i18n:_('Resource allocation')}" image="common/img/collapse.gif" />
|
||||
<tab id="workerSearchTab" label="${i18n:_('Resources search')}" image="common/img/collapse.gif"/>
|
||||
</tabs>
|
||||
<tabpanels>
|
||||
<tabpanel>
|
||||
<groupbox mold="3d" closable="false">
|
||||
<caption label="${i18n:_('Order Element Information')}:" />
|
||||
<grid id="orderElementHoursGrid">
|
||||
<columns>
|
||||
<column width="200px" label="${i18n:_('Criteria')}"/>
|
||||
<column width="200px" label="${i18n:_('Type')}"/>
|
||||
<column label="${i18n:_('Hours')}" />
|
||||
</columns>
|
||||
</grid>
|
||||
<grid>
|
||||
<columns>
|
||||
<column width="200px" />
|
||||
<column width="200px" />
|
||||
<column />
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label />
|
||||
<label value="${i18n:_('Total Estimated hours')}:" />
|
||||
<intbox value="@{allocationController.orderHours}" disabled="${true}" />
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</groupbox>
|
||||
<groupbox mold="3d" style="margin-top: 5px" closable="false">
|
||||
<caption label="${i18n:_('Task information')}:" />
|
||||
<grid>
|
||||
<columns>
|
||||
<column width="200px" />
|
||||
<column />
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label value="${i18n:_('Start')}" />
|
||||
<datebox id="taskStartDateBox" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('End')}" />
|
||||
<datebox id="taskEndDate" />
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</groupbox>
|
||||
<groupbox mold="3d" style="margin-top: 5px" closable="false">
|
||||
<caption label="${i18n:_('Calculation type')}:" />
|
||||
<radiogroup id="calculationTypeSelector"
|
||||
onCheck="allocationController.calculationTypeSelected = self.selectedItem.value;">
|
||||
<grid id="calculationTypesGrid">
|
||||
<columns>
|
||||
<column />
|
||||
</columns>
|
||||
</grid>
|
||||
</radiogroup>
|
||||
<hbox>
|
||||
<checkbox id="recommendedAllocationCheckbox" label="${i18n:_('Recommended Allocation')}"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
|
||||
<vbox id="messagesContainer"></vbox>
|
||||
|
||||
<groupbox mold="3d" style="margin-top: 5px" sclass="assignedresources" closable="false">
|
||||
<caption label="${i18n:_('Allocations')}" />
|
||||
<grid id="allocationsGrid"
|
||||
model="@{allocationController.resourceAllocations}"
|
||||
rowRenderer="@{allocationController.resourceAllocationRenderer}"
|
||||
style="margin-bottom: 5px" fixedLayout="true">
|
||||
<columns>
|
||||
<column />
|
||||
<column label="${i18n:_('Name')}" />
|
||||
<column
|
||||
label="${i18n:_('Hours')}" />
|
||||
<column
|
||||
label="${i18n:_('Resources Per Day')}" />
|
||||
<column
|
||||
label="${i18n:_('Operations')}" />
|
||||
</columns>
|
||||
</grid>
|
||||
</groupbox>
|
||||
</tabpanel>
|
||||
|
||||
<!-- Worker search -->
|
||||
<tabpanel>
|
||||
<newAllocationSelector id="newAllocationSelector"/>
|
||||
<!-- Select worker -->
|
||||
<hbox>
|
||||
<button label="${i18n:_('Select')}" onClick="allocationController.onSelectWorkers(event)" />
|
||||
<button label="${i18n:_('Close')}" onClick="allocationController.onCloseSelectWorkers()" />
|
||||
</hbox>
|
||||
</tabpanel>
|
||||
</tabpanels>
|
||||
</tabbox>
|
||||
|
||||
<!-- Control buttons -->
|
||||
<hbox>
|
||||
<button label="${i18n:_('Accept')}"
|
||||
onClick="allocationController.accept()" sclass="save-button global-action" />
|
||||
<button label="${i18n:_('Apply')}" id="applyButton" sclass="global-action" />
|
||||
<button label="${i18n:_('Cancel')}"
|
||||
onClick="allocationController.cancel()" sclass="cancel-button global-action" />
|
||||
<button label="${i18n:_('Advanced Allocation')}"
|
||||
onClick="allocationController.goToAdvancedAllocation();" sclass="global-action" />
|
||||
</hbox>
|
||||
</window>
|
||||
|
||||
<window id="calendarAllocationWindow"
|
||||
apply="${calendarController}"
|
||||
title="${i18n:_('Calendar allocation')}" width="600px"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue