Add new button to adapt planning according to timesheets

It has been added a new method ICommand.isPlannerCommand() to define if a button
should be added in the planner toolbar or in the common toolbar (save and cancel
buttons).

For the moment, we are using a hard-coded value to know how many buttons we
should add in the plannerToolbar. At this moment we have 2 buttons: reassign and
adapt planning.

FEA: ItEr77S12AdaptPlanningAccordingTimesheets
This commit is contained in:
Manuel Rego Casasnovas 2012-11-05 09:40:45 +01:00
parent 82bad8a1a7
commit e9365ed1b0
9 changed files with 145 additions and 3 deletions

View file

@ -509,9 +509,11 @@ public class Planner extends HtmlMacroComponent {
}
for (CommandContextualized<?> c : contextualizedGlobalCommands) {
// Comparison through icon as name is internationalized
if (c.getCommand().getImage()
.equals("/common/img/ico_reassign.png")) {
if (plannerToolbar.getChildren().isEmpty()) {
if (c.getCommand().isPlannerCommand()) {
// FIXME Avoid hard-coding the number of planner commands
// At this moment we have 2 planner commands: reassign and adapt
// planning
if (plannerToolbar.getChildren().size() < 2) {
plannerToolbar.appendChild(c.toButton());
}
} else {

View file

@ -86,6 +86,11 @@ public class PlannerConfiguration<T> implements IDisabilityConfiguration {
return false;
}
@Override
public boolean isPlannerCommand() {
return false;
}
}
private static class NullCommandOnTask<T> implements ICommandOnTask<T> {

View file

@ -39,4 +39,10 @@ public interface ICommand<T> {
boolean isDisabled();
/**
* Describes if a command is for the planner toolbar. Otherwise it'll be
* inserted in the common toolbar.
*/
boolean isPlannerCommand();
}

View file

@ -0,0 +1,69 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2012 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.libreplan.web.planner.adaptplanning;
import static org.libreplan.web.I18nHelper._;
import org.libreplan.business.planner.entities.TaskElement;
import org.libreplan.web.planner.order.PlanningStateCreator.PlanningState;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.zkoss.ganttz.extensions.IContext;
/**
* @author Manuel Rego Casasnovas <rego@igalia.com>
*/
@Component
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class AdaptPlanningCommand implements IAdaptPlanningCommand {
private PlanningState planningState;
@Override
public String getName() {
return _("Adapt planning acording to timesheets");
}
@Override
public void doAction(IContext<TaskElement> context) {
// TODO Auto-generated method stub
}
@Override
public String getImage() {
return "/common/img/ico_adapt_planning.png";
}
@Override
public boolean isDisabled() {
return false;
}
@Override
public void setState(PlanningState planningState) {
this.planningState = planningState;
}
@Override
public boolean isPlannerCommand() {
return true;
}
}

View file

@ -0,0 +1,35 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2012 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.libreplan.web.planner.adaptplanning;
import org.libreplan.business.planner.entities.TaskElement;
import org.libreplan.web.planner.order.PlanningStateCreator.PlanningState;
import org.zkoss.ganttz.extensions.ICommand;
/**
* Command to adapt planning of a project taking into account information from
* the timesheets.
*
* @author Manuel Rego Casasnovas <rego@igalia.com>
*/
public interface IAdaptPlanningCommand extends ICommand<TaskElement> {
public void setState(PlanningState planningState);
}

View file

@ -71,6 +71,7 @@ import org.libreplan.business.users.entities.UserRole;
import org.libreplan.business.workingday.EffortDuration;
import org.libreplan.web.calendars.BaseCalendarModel;
import org.libreplan.web.common.ViewSwitcher;
import org.libreplan.web.planner.adaptplanning.IAdaptPlanningCommand;
import org.libreplan.web.planner.advances.AdvanceAssignmentPlanningController;
import org.libreplan.web.planner.advances.IAdvanceAssignmentPlanningCommand;
import org.libreplan.web.planner.allocation.IAdvancedAllocationCommand;
@ -222,6 +223,9 @@ public class OrderPlanningModel implements IOrderPlanningModel {
@Autowired
private IReassignCommand reassignCommand;
@Autowired
private IAdaptPlanningCommand adaptPlanningCommand;
@Autowired
private IResourceAllocationCommand resourceAllocationCommand;
@ -332,6 +336,7 @@ public class OrderPlanningModel implements IOrderPlanningModel {
configuration.addGlobalCommand(buildReassigningCommand());
configuration.addGlobalCommand(buildCancelEditionCommand());
configuration.addGlobalCommand(buildAdaptPlanningCommand());
NullSeparatorCommandOnTask<TaskElement> separator = new NullSeparatorCommandOnTask<TaskElement>();
@ -1055,6 +1060,11 @@ public class OrderPlanningModel implements IOrderPlanningModel {
return reassignCommand;
}
private ICommand<TaskElement> buildAdaptPlanningCommand() {
adaptPlanningCommand.setState(planningState);
return adaptPlanningCommand;
}
private ICommand<TaskElement> buildCancelEditionCommand() {
return new ICommand<TaskElement>() {
@ -1097,6 +1107,11 @@ public class OrderPlanningModel implements IOrderPlanningModel {
return false;
}
@Override
public boolean isPlannerCommand() {
return false;
}
};
}

View file

@ -1038,6 +1038,11 @@ public class SaveCommandBuilder {
return disabled;
}
@Override
public boolean isPlannerCommand() {
return false;
}
}
private static final class LabelCreatorForInvalidValues implements

View file

@ -375,4 +375,9 @@ public class ReassignCommand implements IReassignCommand {
return false;
}
@Override
public boolean isPlannerCommand() {
return true;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 830 B