ItEr42S25CUMarcarUnidadeTraballoExportable: Added subcontract command.

This commit is contained in:
Manuel Rego Casasnovas 2010-01-13 13:41:46 +01:00 committed by Javier Moran Rua
parent 0cb85eeb43
commit b4a02d39fc
8 changed files with 218 additions and 1 deletions

View file

@ -41,6 +41,7 @@ public interface IOrderPlanningModel {
ResourceAllocationController resourceAllocationController,
TaskPropertiesController taskPropertiesController,
CalendarAllocationController calendarAllocationController,
SubcontractController subcontractController,
List<ICommand<TaskElement>> additional);
}

View file

@ -0,0 +1,35 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package org.navalplanner.web.planner.order;
import org.navalplanner.business.planner.entities.TaskElement;
import org.zkoss.ganttz.extensions.ICommandOnTask;
/**
* Contract for {@link SubcontractCommand}.
*
* @author Manuel Rego Casasnovas <mrego@igalia.com>
*/
public interface ISubcontractCommand extends ICommandOnTask<TaskElement> {
void setSubcontractController(SubcontractController subcontractController);
}

View file

@ -75,6 +75,9 @@ public class OrderPlanningController implements Composer {
@Autowired
private CalendarAllocationController calendarAllocationController;
@Autowired
private SubcontractController subcontractController;
private Order order;
private List<ICommand<TaskElement>> additional = new ArrayList<ICommand<TaskElement>>();
@ -120,7 +123,12 @@ public class OrderPlanningController implements Composer {
private void updateConfiguration() {
model.setConfigurationToPlanner(planner, order, viewSwitcher,
resourceAllocationController, taskPropertiesController,
calendarAllocationController, additional);
calendarAllocationController, subcontractController,
additional);
}
public SubcontractController getSubcontractController() {
return subcontractController;
}
}

View file

@ -183,6 +183,7 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
ResourceAllocationController resourceAllocationController,
TaskPropertiesController taskPropertiesController,
CalendarAllocationController calendarAllocationController,
SubcontractController subcontractController,
List<ICommand<TaskElement>> additional) {
Order orderReloaded = reload(order);
if (!orderReloaded.isSomeTaskElementScheduled()) {
@ -202,6 +203,8 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
.addCommandOnTask(buildCalendarAllocationCommand(calendarAllocationController));
configuration
.addCommandOnTask(buildTaskPropertiesCommand(taskPropertiesController));
configuration
.addCommandOnTask(buildSubcontractCommand(subcontractController));
configuration.setDoubleClickCommand(resourceAllocationCommand);
addPrintSupport(configuration, order);
Tabbox chartComponent = new Tabbox();
@ -976,4 +979,13 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
}
private ISubcontractCommand buildSubcontractCommand(
SubcontractController subcontractController) {
ISubcontractCommand subcontractCommand = getSubcontractCommand();
subcontractCommand.setSubcontractController(subcontractController);
return subcontractCommand;
}
protected abstract ISubcontractCommand getSubcontractCommand();
}

View file

@ -0,0 +1,72 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
package org.navalplanner.web.planner.order;
import static org.navalplanner.web.I18nHelper._;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.TaskElement;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
/**
* Command to subcontract a {@link TaskElement} as XML.
*
* @author Manuel Rego Casasnovas <mrego@igalia.com>
*/
@Component
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class SubcontractCommand implements ISubcontractCommand {
private SubcontractController subcontractController;
@Override
public String getName() {
return _("Subcontract");
}
@Override
public String getIcon() {
return null;
}
@Override
public boolean isApplicableTo(TaskElement task) {
return (task instanceof Task);
}
@Override
public void doAction(IContextWithPlannerTask<TaskElement> context,
final TaskElement task) {
if (isApplicableTo(task)) {
subcontractController.showWindow((Task) task, context.getTask());
}
}
@Override
public void setSubcontractController(
SubcontractController subcontractController) {
this.subcontractController = subcontractController;
}
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
package org.navalplanner.web.planner.order;
import org.navalplanner.business.planner.entities.Task;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.SuspendNotAllowedException;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Window;
/**
* Controller for subcontract a task.
*
* @author Manuel Rego Casasnovas <mrego@igalia.com>
*/
@org.springframework.stereotype.Component("subcontractController")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class SubcontractController extends GenericForwardComposer {
private Window window;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
window = (Window) comp;
}
public void showWindow(Task task, org.zkoss.ganttz.data.Task task2) {
try {
window.doModal();
} catch (SuspendNotAllowedException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
public void accept() {
window.setVisible(false);
}
public void cancel() {
window.setVisible(false);
}
}

View file

@ -31,6 +31,7 @@
<lookup-method name="getCalendarAllocationCommand" bean="calendarAllocationCommand"/>
<lookup-method name="getAddMilestoneCommand" bean="addMilestoneCommand"/>
<lookup-method name="getDeleteMilestoneCommand" bean="deleteMilestoneCommand"/>
<lookup-method name="getSubcontractCommand" bean="subcontractCommand"/>
</bean>
<bean class="org.navalplanner.web.planner.company.CompanyPlanningModel" scope="prototype">

View file

@ -32,6 +32,7 @@
calendarController = planningController.calendarAllocationController;
switcher = planningController.viewSwitcher;
allocationController.switcher = switcher;
subController = planningController.subcontractController;
]]>
</zscript>
<div>
@ -225,5 +226,26 @@
</vbox>
</window>
<window id="subcontractWindow"
apply="${subController}"
title="${i18n:_('Subcontract')}" width="600px"
closable="true" visible="false">
<vbox>
<label value="${i18n:_('TODO')}" />
<hbox>
<button label="${i18n:_('Accept')}"
onClick="subController.accept();" />
<button label="${i18n:_('Cancel')}"
onClick="subController.cancel();" />
</hbox>
</vbox>
</window>
</div>
</zk>