Isolate 'Task Information' group box into a component, and embed it into 'Resource allocation' and 'Limiting Resource allocation'
FEA: ItEr68OTS03XestionRecursosEstratexicosItEr67OTS03
This commit is contained in:
parent
4d7e98e4a0
commit
b51c351cc3
7 changed files with 230 additions and 117 deletions
|
|
@ -650,9 +650,8 @@ public class FormBinder {
|
|||
}
|
||||
}
|
||||
|
||||
public void setRecommendedAllocation(Button recommendedAllocation) {
|
||||
this.btnRecommendedAllocation = recommendedAllocation;
|
||||
btnRecommendedAllocation.addEventListener(Events.ON_CLICK, new EventListener() {
|
||||
public EventListener getRecommendedAllocationListener() {
|
||||
return new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
recommendedAllocationIsPressed = !recommendedAllocationIsPressed;
|
||||
|
|
@ -662,7 +661,7 @@ public class FormBinder {
|
|||
deactivatingRecommendedAllocation();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
private void activatingRecommendedAllocation() {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import org.navalplanner.web.common.Util;
|
|||
import org.navalplanner.web.common.components.AllocationSelector;
|
||||
import org.navalplanner.web.common.components.NewAllocationSelector;
|
||||
import org.navalplanner.web.common.components.NewAllocationSelectorCombo;
|
||||
import org.navalplanner.web.planner.allocation.TaskInformation.ITotalHoursCalculationListener;
|
||||
import org.navalplanner.web.planner.order.PlanningState;
|
||||
import org.navalplanner.web.planner.taskedition.EditTaskController;
|
||||
import org.navalplanner.web.planner.taskedition.TaskPropertiesController;
|
||||
|
|
@ -91,10 +92,10 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
|
||||
private IResourceAllocationModel resourceAllocationModel;
|
||||
|
||||
private Grid orderElementHoursGrid;
|
||||
|
||||
private ResourceAllocationRenderer resourceAllocationRenderer = new ResourceAllocationRenderer();
|
||||
|
||||
private TaskInformation taskInformation;
|
||||
|
||||
private Grid allocationsGrid;
|
||||
|
||||
private FormBinder formBinder;
|
||||
|
|
@ -107,8 +108,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
|
||||
private Radiogroup calculationTypeSelector;
|
||||
|
||||
private Button btnRecommendedAllocation;
|
||||
|
||||
private Checkbox extendedViewCheckbox;
|
||||
|
||||
private Intbox taskWorkableDays;
|
||||
|
|
@ -244,16 +243,15 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
formBinder.setWorkerSearchTab(workerSearchTab);
|
||||
formBinder
|
||||
.setNewAllocationSelectorCombo(newAllocationSelectorCombo);
|
||||
formBinder.setRecommendedAllocation(btnRecommendedAllocation);
|
||||
|
||||
initializeTaskInformationComponent();
|
||||
|
||||
CalculationTypeRadio calculationTypeRadio = CalculationTypeRadio
|
||||
.from(formBinder.getCalculatedValue());
|
||||
calculationTypeRadio.doTheSelectionOn(calculationTypeSelector);
|
||||
|
||||
tbResourceAllocation.setSelected(true);
|
||||
orderElementHoursGrid.setModel(new ListModelList(
|
||||
resourceAllocationModel.getHoursAggregatedByCriterions()));
|
||||
orderElementHoursGrid.setRowRenderer(createOrderElementHoursRenderer());
|
||||
|
||||
newAllocationSelector.setAllocationsAdder(resourceAllocationModel);
|
||||
newAllocationSelectorCombo
|
||||
.setAllocationsAdder(resourceAllocationModel);
|
||||
|
|
@ -263,6 +261,20 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
}
|
||||
}
|
||||
|
||||
private void initializeTaskInformationComponent() {
|
||||
taskInformation.initializeGridTaskRows(resourceAllocationModel
|
||||
.getHoursAggregatedByCriterions());
|
||||
taskInformation.onRecomendAllocation(formBinder
|
||||
.getRecommendedAllocationListener());
|
||||
taskInformation.onCalculateTotalHours(new ITotalHoursCalculationListener() {
|
||||
|
||||
@Override
|
||||
public Integer getTotalHours() {
|
||||
return resourceAllocationModel.getOrderHours();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Label lbTaskStart;
|
||||
|
||||
private Label lbTaskEnd;
|
||||
|
|
@ -308,22 +320,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
AggregatedHoursGroup data);
|
||||
}
|
||||
|
||||
private static final ICellForDetailItemRenderer<HoursRendererColumn, AggregatedHoursGroup> hoursCellRenderer = new ICellForDetailItemRenderer<HoursRendererColumn, AggregatedHoursGroup>() {
|
||||
|
||||
@Override
|
||||
public Component cellFor(
|
||||
HoursRendererColumn column,
|
||||
AggregatedHoursGroup data) {
|
||||
return column.cell(column, data);
|
||||
}
|
||||
};
|
||||
|
||||
private RowRenderer createOrderElementHoursRenderer() {
|
||||
return OnColumnsRowRenderer
|
||||
.create(
|
||||
hoursCellRenderer, Arrays.asList(HoursRendererColumn.values()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Pick resources selected from {@link NewAllocationSelector} and add them to
|
||||
* resource allocation list
|
||||
|
|
@ -577,10 +573,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
.setCalculatedValue(calculationTypeRadio.getCalculatedValue());
|
||||
}
|
||||
|
||||
public Integer getOrderHours() {
|
||||
return resourceAllocationModel.getOrderHours();
|
||||
}
|
||||
|
||||
public List<? extends Object> getResourceAllocations() {
|
||||
return formBinder != null ? plusAggregatingRow(formBinder
|
||||
.getCurrentRows()) : Collections
|
||||
|
|
|
|||
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* This file is part of NavalPlan
|
||||
*
|
||||
* Copyright (C) 2011 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.navalplanner.web.planner.allocation;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.orders.entities.AggregatedHoursGroup;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.navalplanner.web.planner.allocation.ResourceAllocationController.HoursRendererColumn;
|
||||
import org.zkoss.ganttz.timetracker.ICellForDetailItemRenderer;
|
||||
import org.zkoss.ganttz.timetracker.OnColumnsRowRenderer;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.HtmlMacroComponent;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zul.Button;
|
||||
import org.zkoss.zul.Footer;
|
||||
import org.zkoss.zul.Grid;
|
||||
import org.zkoss.zul.RowRenderer;
|
||||
import org.zkoss.zul.SimpleListModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Diego Pino Garcia<dpino@igalia.com>
|
||||
*
|
||||
*/
|
||||
public class TaskInformation extends HtmlMacroComponent {
|
||||
|
||||
private Grid gridTaskRows;
|
||||
|
||||
private Button btnRecommendedAllocation;
|
||||
|
||||
private Footer totalEstimatedHours;
|
||||
|
||||
private ITotalHoursCalculationListener totalHoursCalculation;
|
||||
|
||||
|
||||
@Override
|
||||
public void afterCompose() {
|
||||
super.afterCompose();
|
||||
this.setVariable("taskInformationController", this, true);
|
||||
|
||||
btnRecommendedAllocation = (Button) getFellowIfAny("btnRecommendedAllocation");
|
||||
gridTaskRows = (Grid) getFellowIfAny("gridTaskRows");
|
||||
totalEstimatedHours = (Footer) getFellowIfAny("totalEstimatedHours");
|
||||
}
|
||||
|
||||
public Integer getTotalHours() {
|
||||
if (totalHoursCalculation != null) {
|
||||
return totalHoursCalculation.getTotalHours();
|
||||
}
|
||||
return Integer.valueOf(0);
|
||||
}
|
||||
|
||||
public void initializeGridTaskRows(List<AggregatedHoursGroup> rows) {
|
||||
gridTaskRows.setModel(new SimpleListModel(rows));
|
||||
gridTaskRows.setRowRenderer(newTaskRowsRenderer());
|
||||
}
|
||||
|
||||
public void onRecomendAllocation(EventListener event) {
|
||||
btnRecommendedAllocation.addEventListener(Events.ON_CLICK, event);
|
||||
}
|
||||
|
||||
public void showRecomendedAllocationButton() {
|
||||
btnRecommendedAllocation.setVisible(true);
|
||||
}
|
||||
|
||||
public void hideRecomendedAllocationButton() {
|
||||
btnRecommendedAllocation.setVisible(false);
|
||||
}
|
||||
|
||||
private RowRenderer newTaskRowsRenderer() {
|
||||
return OnColumnsRowRenderer.create(hoursCellRenderer,
|
||||
Arrays.asList(HoursRendererColumn.values()));
|
||||
}
|
||||
|
||||
private static final ICellForDetailItemRenderer<HoursRendererColumn, AggregatedHoursGroup> hoursCellRenderer = new ICellForDetailItemRenderer<HoursRendererColumn, AggregatedHoursGroup>() {
|
||||
|
||||
@Override
|
||||
public Component cellFor(HoursRendererColumn column,
|
||||
AggregatedHoursGroup data) {
|
||||
return column.cell(column, data);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* Listener for calculating total number of hours
|
||||
*
|
||||
* @author Diego Pino Garcia <dpino@igalia.com>
|
||||
*
|
||||
*/
|
||||
public interface ITotalHoursCalculationListener {
|
||||
|
||||
public Integer getTotalHours();
|
||||
|
||||
}
|
||||
|
||||
public void onCalculateTotalHours(ITotalHoursCalculationListener totalHoursCalculation) {
|
||||
this.totalHoursCalculation = totalHoursCalculation;
|
||||
}
|
||||
|
||||
public void refreshTotalHours() {
|
||||
Util.reloadBindings(totalEstimatedHours);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -20,26 +20,23 @@
|
|||
|
||||
package org.navalplanner.web.planner.limiting.allocation;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.navalplanner.business.orders.entities.AggregatedHoursGroup;
|
||||
import org.navalplanner.business.planner.entities.ResourceAllocation;
|
||||
import org.navalplanner.web.common.IMessagesForUser;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.navalplanner.web.common.components.AllocationSelector;
|
||||
import org.navalplanner.web.common.components.NewAllocationSelector;
|
||||
import org.navalplanner.web.common.components.NewAllocationSelectorCombo;
|
||||
import org.navalplanner.web.planner.allocation.ResourceAllocationController.HoursRendererColumn;
|
||||
import org.navalplanner.web.planner.allocation.TaskInformation;
|
||||
import org.navalplanner.web.planner.allocation.TaskInformation.ITotalHoursCalculationListener;
|
||||
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.zkoss.ganttz.timetracker.ICellForDetailItemRenderer;
|
||||
import org.zkoss.ganttz.timetracker.OnColumnsRowRenderer;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
|
|
@ -47,7 +44,6 @@ import org.zkoss.zk.ui.util.GenericForwardComposer;
|
|||
import org.zkoss.zul.Grid;
|
||||
import org.zkoss.zul.Intbox;
|
||||
import org.zkoss.zul.Label;
|
||||
import org.zkoss.zul.ListModelList;
|
||||
import org.zkoss.zul.Listbox;
|
||||
import org.zkoss.zul.Listcell;
|
||||
import org.zkoss.zul.Listitem;
|
||||
|
|
@ -76,12 +72,10 @@ public class LimitingResourceAllocationController extends GenericForwardComposer
|
|||
|
||||
private Tab tabLimitingWorkerSearch;
|
||||
|
||||
private Grid gridLimitingOrderElementHours;
|
||||
private TaskInformation limitingTaskInformation;
|
||||
|
||||
private Grid gridLimitingAllocations;
|
||||
|
||||
private Label totalEstimatedHours;
|
||||
|
||||
private boolean disableHours = true;
|
||||
|
||||
private NewAllocationSelectorCombo limitingNewAllocationSelectorCombo;
|
||||
|
|
@ -125,33 +119,28 @@ public class LimitingResourceAllocationController extends GenericForwardComposer
|
|||
limitingNewAllocationSelector.setAllocationsAdder(resourceAllocationModel);
|
||||
limitingNewAllocationSelectorCombo
|
||||
.setAllocationsAdder(resourceAllocationModel);
|
||||
gridLimitingOrderElementHours.setModel(new ListModelList(
|
||||
resourceAllocationModel.getHoursAggregatedByCriteria()));
|
||||
gridLimitingOrderElementHours.setRowRenderer(createOrderElementHoursRenderer());
|
||||
|
||||
initializeTaskInformationComponent();
|
||||
|
||||
Util.reloadBindings(gridLimitingAllocations);
|
||||
Util.reloadBindings(totalEstimatedHours);
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
private static final ICellForDetailItemRenderer<HoursRendererColumn, AggregatedHoursGroup> hoursCellRenderer =
|
||||
new ICellForDetailItemRenderer<HoursRendererColumn, AggregatedHoursGroup>() {
|
||||
private void initializeTaskInformationComponent() {
|
||||
limitingTaskInformation.initializeGridTaskRows(resourceAllocationModel
|
||||
.getHoursAggregatedByCriteria());
|
||||
limitingTaskInformation.hideRecomendedAllocationButton();
|
||||
limitingTaskInformation
|
||||
.onCalculateTotalHours(new ITotalHoursCalculationListener() {
|
||||
|
||||
@Override
|
||||
public Component cellFor(HoursRendererColumn column,
|
||||
AggregatedHoursGroup data) {
|
||||
return column.cell(column, data);
|
||||
}
|
||||
};
|
||||
|
||||
private RowRenderer createOrderElementHoursRenderer() {
|
||||
return OnColumnsRowRenderer.create(hoursCellRenderer, Arrays
|
||||
.asList(HoursRendererColumn.values()));
|
||||
}
|
||||
|
||||
public Integer getOrderHours() {
|
||||
return resourceAllocationModel.getOrderHours();
|
||||
@Override
|
||||
public Integer getTotalHours() {
|
||||
return resourceAllocationModel.getOrderHours();
|
||||
}
|
||||
});
|
||||
limitingTaskInformation.refreshTotalHours();
|
||||
}
|
||||
|
||||
public List<LimitingAllocationRow> getResourceAllocationRows() {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@
|
|||
class="org.navalplanner.web.common.components.NewAllocationSelector"
|
||||
macroURI="/resources/search/allocation_selector.zul" ?>
|
||||
|
||||
<?component name="taskInformation"
|
||||
class="org.navalplanner.web.planner.allocation.TaskInformation"
|
||||
macroURI="_taskInformation.zul" ?>
|
||||
|
||||
<tabpanel id="${arg.id}">
|
||||
<tabbox mold="accordion">
|
||||
<tabs>
|
||||
|
|
@ -37,33 +41,9 @@
|
|||
</tabs>
|
||||
<tabpanels>
|
||||
<tabpanel>
|
||||
<!-- Order element information -->
|
||||
<panel title="${i18n:_('Task Information')}:" border="normal">
|
||||
<panelchildren>
|
||||
|
||||
<grid id="gridLimitingOrderElementHours">
|
||||
<columns>
|
||||
<column label="${i18n:_('Criteria')}" width="200px" align="center"/>
|
||||
<column label="${i18n:_('Type')}" width="200px" align="center"/>
|
||||
<column label="${i18n:_('Hours')}" align="center"/>
|
||||
</columns>
|
||||
</grid>
|
||||
<grid>
|
||||
<columns>
|
||||
<column width="200px" align="center"/>
|
||||
<column width="200px" align="center"/>
|
||||
<column align="center"/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label />
|
||||
<label value="${i18n:_('Total Estimated hours')}:" />
|
||||
<label id="totalEstimatedHours" value="@{limitingAllocationController.orderHours}" />
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</panelchildren>
|
||||
</panel>
|
||||
<!-- Order element information -->
|
||||
<taskInformation id="limitingTaskInformation" />
|
||||
|
||||
<!-- Allocations -->
|
||||
<panel style="margin-top: 5px" sclass="assignedresources" closable="false" title="${i18n:_('Allocations')}">
|
||||
|
|
|
|||
|
|
@ -25,9 +25,13 @@
|
|||
macroURI="/resources/search/allocation_selector_combo.zul" ?>
|
||||
|
||||
<?component name="newAllocationSelector"
|
||||
class="org.navalplanner.web.common.components.NewAllocationSelector"
|
||||
class="org.navalplanner.web.common.components.NewAllocationSelector"
|
||||
macroURI="/resources/search/allocation_selector.zul" ?>
|
||||
|
||||
<?component name="taskInformation"
|
||||
class="org.navalplanner.web.planner.allocation.TaskInformation"
|
||||
macroURI="_taskInformation.zul" ?>
|
||||
|
||||
<tabpanel id="resourceAllocationTabpanel">
|
||||
<tabbox mold="accordion">
|
||||
<tabs>
|
||||
|
|
@ -37,36 +41,9 @@
|
|||
<tabpanels>
|
||||
<tabpanel>
|
||||
<hbox align="end">
|
||||
<groupbox closable="false" height="170px">
|
||||
<caption label="${i18n:_('Task Information')}" />
|
||||
<vbox align="center">
|
||||
<grid id="orderElementHoursGrid">
|
||||
<columns>
|
||||
<column width="200px" label="${i18n:_('Criteria')}" align="center"/>
|
||||
<column width="150px" label="${i18n:_('Type')}" align="center"/>
|
||||
<column width="100px" label="${i18n:_('Hours')}" align="center"/>
|
||||
</columns>
|
||||
</grid>
|
||||
<grid>
|
||||
<columns>
|
||||
<column width="200px" align="center"/>
|
||||
<column width="150px" align="center"/>
|
||||
<column width="100px" align="center"/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label />
|
||||
<label value="${i18n:_('Total Estimated hours')}:" />
|
||||
<label value="@{allocationController.orderHours}"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</vbox>
|
||||
|
||||
<vbox align="bottom">
|
||||
<button id="btnRecommendedAllocation" label="${i18n:_('Recommended Allocation')}" />
|
||||
</vbox>
|
||||
</groupbox>
|
||||
<!-- Task Information -->
|
||||
<taskInformation id="taskInformation" />
|
||||
|
||||
<groupbox sclass="assignedresources" closable="false" width="340px" height="170px" >
|
||||
<caption label="${i18n:_('Allocation configuration')}" />
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
<!--
|
||||
This file is part of NavalPlan
|
||||
|
||||
Copyright (C) 2011 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/>.
|
||||
-->
|
||||
|
||||
<?taglib uri="/WEB-INF/tld/i18n.tld" prefix="i18n" ?>
|
||||
|
||||
<!-- Task Information -->
|
||||
<zk id="${arg.id}" >
|
||||
|
||||
<groupbox height="170px" closable="false" >
|
||||
|
||||
<caption label="${i18n:_('Task Information')}" />
|
||||
|
||||
<!-- Task rows -->
|
||||
<grid id="gridTaskRows">
|
||||
<columns>
|
||||
<column label="${i18n:_('Criteria')}" width="200px" align="center"/>
|
||||
<column label="${i18n:_('Type')}" width="200px" align="center"/>
|
||||
<column label="${i18n:_('Hours')}" align="center"/>
|
||||
</columns>
|
||||
<foot>
|
||||
<footer label=""/>
|
||||
<footer label="${i18n:_('Total estimated hours')}:"/>
|
||||
<footer id="totalEstimatedHours" label="@{taskInformationController.totalHours}"/>
|
||||
</foot>
|
||||
</grid>
|
||||
|
||||
<separator />
|
||||
|
||||
<!-- Recommended Allocation -->
|
||||
<vbox align="bottom">
|
||||
<button id="btnRecommendedAllocation" label="${i18n:_('Recommended allocation')}" />
|
||||
</vbox>
|
||||
|
||||
</groupbox>
|
||||
</zk>
|
||||
Loading…
Add table
Reference in a new issue