From cbf874189e989398a75dd4bbcdc32d20f2b551d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Sun, 24 Jan 2010 23:23:28 +0100 Subject: [PATCH] ItEr44S16CUAsignacionRecursosEspecificosAPlanificacionItEr37S10: Moving out inner classes from AdvancedAllocationController. Since AdvancedAllocationController is very big, some classes are moved out. --- .../AdvancedAllocationController.java | 59 +++---------- .../IAssignmentFunctionConfiguration.java | 36 ++++++++ .../StrechesFunctionConfiguration.java | 83 +++++++++++++++++++ 3 files changed, 129 insertions(+), 49 deletions(-) create mode 100644 navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/IAssignmentFunctionConfiguration.java create mode 100644 navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StrechesFunctionConfiguration.java diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AdvancedAllocationController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AdvancedAllocationController.java index 928b5e726..5d6994512 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AdvancedAllocationController.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AdvancedAllocationController.java @@ -44,14 +44,11 @@ import org.navalplanner.business.planner.entities.CalculatedValue; import org.navalplanner.business.planner.entities.GenericResourceAllocation; import org.navalplanner.business.planner.entities.ResourceAllocation; import org.navalplanner.business.planner.entities.SpecificResourceAllocation; -import org.navalplanner.business.planner.entities.StretchesFunction; import org.navalplanner.business.planner.entities.TaskElement; import org.navalplanner.web.common.IMessagesForUser; import org.navalplanner.web.common.Level; import org.navalplanner.web.common.MessagesForUser; -import org.navalplanner.web.common.Util; -import org.navalplanner.web.planner.allocation.streches.StretchesFunctionController; -import org.navalplanner.web.planner.allocation.streches.StretchesFunctionModel; +import org.navalplanner.web.planner.allocation.streches.StrechesFunctionConfiguration; import org.navalplanner.web.resourceload.ResourceLoadModel; import org.zkoss.ganttz.timetracker.ICellForDetailItemRenderer; import org.zkoss.ganttz.timetracker.IConvertibleToColumn; @@ -65,7 +62,6 @@ import org.zkoss.ganttz.timetracker.zoom.IZoomLevelChangedListener; import org.zkoss.ganttz.timetracker.zoom.ZoomLevel; import org.zkoss.ganttz.util.Interval; import org.zkoss.zk.ui.Component; -import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.WrongValueException; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; @@ -84,7 +80,6 @@ import org.zkoss.zul.ListModel; import org.zkoss.zul.Messagebox; import org.zkoss.zul.SimpleListModel; import org.zkoss.zul.api.Column; -import org.zkoss.zul.api.Window; public class AdvancedAllocationController extends GenericForwardComposer { @@ -656,6 +651,8 @@ interface CellChangedListener { class Row { + + static Row createRow(IMessagesForUser messages, AdvancedAllocationController.Restriction restriction, String name, int level, @@ -835,19 +832,6 @@ class Row { }); } - public interface IAssignmentFunctionConfiguration { - - public boolean isTargetedTo(AssignmentFunction function); - - public void applyDefaultFunction( - ResourceAllocation resourceAllocation); - - public String getName(); - - public void goToConfigure(); - - } - private IAssignmentFunctionConfiguration none = new IAssignmentFunctionConfiguration() { @Override @@ -878,46 +862,23 @@ class Row { } }; - private IAssignmentFunctionConfiguration strechesFunction = new IAssignmentFunctionConfiguration() { + private IAssignmentFunctionConfiguration strechesFunction = new StrechesFunctionConfiguration() { @Override - public void goToConfigure() { - StretchesFunctionController stretchesFunctionController = new StretchesFunctionController(); - - HashMap args = new HashMap(); - args - .put("stretchesFunctionController", - stretchesFunctionController); - Window window = (Window) Executions.createComponents( - "/planner/stretches_function.zul", allHoursInput - .getParent(), args); - Util.createBindingsFor(window); - - stretchesFunctionController.setResourceAllocation(getAllocation()); - stretchesFunctionController.showWindow(); - getAllocation().setAssignmentFunction( - stretchesFunctionController.getAssignmentFunction()); + protected void assignmentFunctionChanged() { reloadHoursSameRowForDetailItems(); reloadAllHours(); fireCellChanged(); } - public String getName() { - return _("Streches"); + @Override + protected ResourceAllocation getAllocation() { + return Row.this.getAllocation(); } @Override - public boolean isTargetedTo(AssignmentFunction function) { - return function instanceof StretchesFunction; - } - - @Override - public void applyDefaultFunction( - ResourceAllocation resourceAllocation) { - StretchesFunction stretchesFunction = StretchesFunctionModel - .createDefaultStretchesFunction(resourceAllocation - .getTask().getEndDate()); - resourceAllocation.setAssignmentFunction(stretchesFunction); + protected Component getParentOnWhichOpenWindow() { + return allHoursInput.getParent(); } }; diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/IAssignmentFunctionConfiguration.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/IAssignmentFunctionConfiguration.java new file mode 100644 index 000000000..a6ec62236 --- /dev/null +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/IAssignmentFunctionConfiguration.java @@ -0,0 +1,36 @@ +/* + * 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 . + */ +package org.navalplanner.web.planner.allocation; + +import org.navalplanner.business.planner.entities.AssignmentFunction; +import org.navalplanner.business.planner.entities.ResourceAllocation; + +public interface IAssignmentFunctionConfiguration { + + public boolean isTargetedTo(AssignmentFunction function); + + public void applyDefaultFunction( + ResourceAllocation resourceAllocation); + + public String getName(); + + public void goToConfigure(); + +} \ No newline at end of file diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StrechesFunctionConfiguration.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StrechesFunctionConfiguration.java new file mode 100644 index 000000000..29c1882ac --- /dev/null +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StrechesFunctionConfiguration.java @@ -0,0 +1,83 @@ +/* + * 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 . + */ +package org.navalplanner.web.planner.allocation.streches; + +import static org.navalplanner.web.I18nHelper._; + +import java.util.HashMap; + +import org.navalplanner.business.planner.entities.AssignmentFunction; +import org.navalplanner.business.planner.entities.ResourceAllocation; +import org.navalplanner.business.planner.entities.StretchesFunction; +import org.navalplanner.web.common.Util; +import org.navalplanner.web.planner.allocation.IAssignmentFunctionConfiguration; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.Executions; +import org.zkoss.zul.api.Window; + +/** + * @author Óscar González Fernández + * + */ +public abstract class StrechesFunctionConfiguration implements + IAssignmentFunctionConfiguration { + + @Override + public void goToConfigure() { + StretchesFunctionController stretchesFunctionController = new StretchesFunctionController(); + + HashMap args = new HashMap(); + args.put("stretchesFunctionController", stretchesFunctionController); + Window window = (Window) Executions.createComponents( + "/planner/stretches_function.zul", + getParentOnWhichOpenWindow(), args); + Util.createBindingsFor(window); + + stretchesFunctionController.setResourceAllocation(getAllocation()); + stretchesFunctionController.showWindow(); + getAllocation().setAssignmentFunction( + stretchesFunctionController.getAssignmentFunction()); + assignmentFunctionChanged(); + } + + protected abstract ResourceAllocation getAllocation(); + + protected abstract void assignmentFunctionChanged(); + + protected abstract Component getParentOnWhichOpenWindow(); + + public String getName() { + return _("Streches"); + } + + @Override + public boolean isTargetedTo(AssignmentFunction function) { + return function instanceof StretchesFunction; + } + + @Override + public void applyDefaultFunction(ResourceAllocation resourceAllocation) { + StretchesFunction stretchesFunction = StretchesFunctionModel + .createDefaultStretchesFunction(resourceAllocation.getTask() + .getEndDate()); + resourceAllocation.setAssignmentFunction(stretchesFunction); + } + +}