diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/milestone/DeleteMilestoneCommand.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/milestone/DeleteMilestoneCommand.java new file mode 100644 index 000000000..715748a28 --- /dev/null +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/milestone/DeleteMilestoneCommand.java @@ -0,0 +1,66 @@ +/* + * 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.milestone; + +import static org.navalplanner.web.I18nHelper._; + +import org.navalplanner.business.planner.entities.TaskElement; +import org.navalplanner.business.planner.entities.TaskMilestone; +import org.navalplanner.web.planner.order.PlanningState; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +import org.zkoss.ganttz.extensions.IContextWithPlannerTask; + +/** + * @author Óscar González Fernández + * + */ +@Component +@Scope(BeanDefinition.SCOPE_PROTOTYPE) +public class DeleteMilestoneCommand implements IDeleteMilestoneCommand { + + private PlanningState planningState; + + @Override + public void doAction(IContextWithPlannerTask context, + TaskElement task) { + if (task instanceof TaskMilestone) { + planningState.removed(task); + context.remove(task); + } + } + + @Override + public String getIcon() { + return null; + } + + @Override + public String getName() { + return (_("Delete Milestone")); + } + + @Override + public void setState(PlanningState planningState) { + this.planningState = planningState; + } + +} diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/milestone/IDeleteMilestoneCommand.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/milestone/IDeleteMilestoneCommand.java new file mode 100644 index 000000000..d52901eec --- /dev/null +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/milestone/IDeleteMilestoneCommand.java @@ -0,0 +1,34 @@ +/* + * 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.milestone; + +import org.navalplanner.business.planner.entities.TaskElement; +import org.navalplanner.web.planner.order.PlanningState; +import org.zkoss.ganttz.extensions.ICommandOnTask; + +/** + * @author Óscar González Fernández + * + */ +public interface IDeleteMilestoneCommand extends ICommandOnTask { + + void setState(PlanningState planningState); + +} diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/order/OrderPlanningModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/order/OrderPlanningModel.java index 2eac985e9..259e2f890 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/order/OrderPlanningModel.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/order/OrderPlanningModel.java @@ -69,6 +69,7 @@ import org.navalplanner.web.planner.chart.EarnedValueChartFiller; import org.navalplanner.web.planner.chart.IChartFiller; 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.IEditTaskCommand; @@ -191,6 +192,7 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel { final IResourceAllocationCommand resourceAllocationCommand = buildResourceAllocationCommand(resourceAllocationController); configuration.addCommandOnTask(resourceAllocationCommand); configuration.addCommandOnTask(buildMilestoneCommand()); + configuration.addCommandOnTask(buildDeleteMilestoneCommand()); configuration .addCommandOnTask(buildCalendarAllocationCommand(calendarAllocationController)); configuration @@ -225,6 +227,12 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel { setEventListenerConfigurationCheckboxes(earnedValueChart); } + private IDeleteMilestoneCommand buildDeleteMilestoneCommand() { + IDeleteMilestoneCommand result = getDeleteMilestoneCommand(); + result.setState(planningState); + return result; + } + private void showDeadlineIfExists(Order orderReloaded, PlannerConfiguration configuration) { if (orderReloaded.getDeadline() != null) { @@ -653,6 +661,8 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel { protected abstract IAddMilestoneCommand getAddMilestoneCommand(); + protected abstract IDeleteMilestoneCommand getDeleteMilestoneCommand(); + protected abstract IEditTaskCommand getEditTaskCommand(); protected abstract ICalendarAllocationCommand getCalendarAllocationCommand(); diff --git a/navalplanner-webapp/src/main/resources/navalplanner-webapp-spring-config.xml b/navalplanner-webapp/src/main/resources/navalplanner-webapp-spring-config.xml index 4fe79f7fb..0433300aa 100644 --- a/navalplanner-webapp/src/main/resources/navalplanner-webapp-spring-config.xml +++ b/navalplanner-webapp/src/main/resources/navalplanner-webapp-spring-config.xml @@ -30,6 +30,7 @@ +