Isolate 'Allocation Configuration' group box into a component, and embed it into 'Resource allocation'
FEA: ItEr68OTS03XestionRecursosEstratexicosItEr67OTS03
This commit is contained in:
parent
b51c351cc3
commit
9b8782645e
4 changed files with 237 additions and 79 deletions
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* 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 org.apache.commons.lang.Validate;
|
||||
import org.navalplanner.business.planner.entities.CalculatedValue;
|
||||
import org.navalplanner.web.planner.allocation.ResourceAllocationController.CalculationTypeRadio;
|
||||
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.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zul.Grid;
|
||||
import org.zkoss.zul.Intbox;
|
||||
import org.zkoss.zul.Label;
|
||||
import org.zkoss.zul.ListModelList;
|
||||
import org.zkoss.zul.Radiogroup;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Diego Pino García <dpino@igalia.com>
|
||||
*
|
||||
*/
|
||||
public class AllocationConfiguration extends HtmlMacroComponent {
|
||||
|
||||
private Label lbTaskStart;
|
||||
|
||||
private Label lbTaskEnd;
|
||||
|
||||
private Intbox taskWorkableDays;
|
||||
|
||||
private Radiogroup calculationTypeSelector;
|
||||
|
||||
private Grid calculationTypesGrid;
|
||||
|
||||
private FormBinder formBinder;
|
||||
|
||||
@Override
|
||||
public void afterCompose() {
|
||||
super.afterCompose();
|
||||
this.setVariable("allocationConfigurationController", this, true);
|
||||
|
||||
lbTaskStart = (Label) getFellowIfAny("lbTaskStart");
|
||||
lbTaskEnd = (Label) getFellowIfAny("lbTaskEnd");
|
||||
taskWorkableDays = (Intbox) getFellowIfAny("taskWorkableDays");
|
||||
initializeCalculationTypeSelector();
|
||||
initializeCalculationTypesGrid();
|
||||
}
|
||||
|
||||
private void initializeCalculationTypeSelector() {
|
||||
calculationTypeSelector = (Radiogroup) getFellowIfAny("calculationTypeSelector");
|
||||
calculationTypeSelector.addEventListener(Events.ON_CHECK, new EventListener() {
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
setCalculationTypeSelected(calculationTypeSelector
|
||||
.getSelectedItem().getValue());
|
||||
}
|
||||
|
||||
private void setCalculationTypeSelected(String calculationType) {
|
||||
Validate.notNull(formBinder);
|
||||
formBinder.setCalculatedValue(getCalculatedValue(calculationType));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void initializeCalculationTypesGrid() {
|
||||
calculationTypesGrid = (Grid) getFellowIfAny("calculationTypesGrid");
|
||||
calculationTypesGrid.setModel(new ListModelList(Arrays
|
||||
.asList(CalculationTypeRadio.values())));
|
||||
calculationTypesGrid.setRowRenderer(OnColumnsRowRenderer.create(
|
||||
calculationTypesRenderer(), Arrays.asList(0)));
|
||||
}
|
||||
|
||||
private ICellForDetailItemRenderer<Integer, CalculationTypeRadio> calculationTypesRenderer() {
|
||||
return new ICellForDetailItemRenderer<Integer, CalculationTypeRadio>() {
|
||||
|
||||
@Override
|
||||
public Component cellFor(Integer column, CalculationTypeRadio data) {
|
||||
return data.createRadio(getCalculationTypeRadio());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private CalculationTypeRadio getCalculationTypeRadio() {
|
||||
if (formBinder != null) {
|
||||
return CalculationTypeRadio.from(formBinder.getCalculatedValue());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Intbox getTaskWorkableDays() {
|
||||
return taskWorkableDays;
|
||||
}
|
||||
|
||||
public Label getTaskStart() {
|
||||
return lbTaskStart;
|
||||
}
|
||||
|
||||
public Label getTaskEnd() {
|
||||
return lbTaskEnd;
|
||||
}
|
||||
|
||||
public Radiogroup getCalculationTypeSelector() {
|
||||
return calculationTypeSelector;
|
||||
}
|
||||
|
||||
public void setFormBinder(FormBinder formBinder) {
|
||||
this.formBinder = formBinder;
|
||||
}
|
||||
|
||||
private CalculatedValue getCalculatedValue(String enumName) {
|
||||
return CalculationTypeRadio.valueOf(enumName).getCalculatedValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -68,7 +68,6 @@ import org.zkoss.zul.Grid;
|
|||
import org.zkoss.zul.Hbox;
|
||||
import org.zkoss.zul.Intbox;
|
||||
import org.zkoss.zul.Label;
|
||||
import org.zkoss.zul.ListModelList;
|
||||
import org.zkoss.zul.Radio;
|
||||
import org.zkoss.zul.Radiogroup;
|
||||
import org.zkoss.zul.Row;
|
||||
|
|
@ -96,6 +95,8 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
|
||||
private TaskInformation taskInformation;
|
||||
|
||||
private AllocationConfiguration allocationConfiguration;
|
||||
|
||||
private Grid allocationsGrid;
|
||||
|
||||
private FormBinder formBinder;
|
||||
|
|
@ -104,14 +105,8 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
|
||||
private Intbox assignedHoursComponent;
|
||||
|
||||
private Grid calculationTypesGrid;
|
||||
|
||||
private Radiogroup calculationTypeSelector;
|
||||
|
||||
private Checkbox extendedViewCheckbox;
|
||||
|
||||
private Intbox taskWorkableDays;
|
||||
|
||||
private Decimalbox allResourcesPerDay;
|
||||
|
||||
private Label allOriginalHours;
|
||||
|
|
@ -159,7 +154,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
newAllocationSelectorCombo.setLimitingResourceFilter(false);
|
||||
initAllocationLabels();
|
||||
makeReadyInputsForCalculationTypes();
|
||||
prepareCalculationTypesGrid();
|
||||
}
|
||||
|
||||
private void initAllocationLabels() {
|
||||
|
|
@ -176,30 +170,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
assignedHoursComponent.setWidth("80px");
|
||||
}
|
||||
|
||||
private void prepareCalculationTypesGrid() {
|
||||
calculationTypesGrid.setModel(new ListModelList(Arrays
|
||||
.asList(CalculationTypeRadio.values())));
|
||||
calculationTypesGrid.setRowRenderer(OnColumnsRowRenderer.create(
|
||||
calculationTypesRenderer(), Arrays.asList(0)));
|
||||
}
|
||||
|
||||
private ICellForDetailItemRenderer<Integer, CalculationTypeRadio> calculationTypesRenderer() {
|
||||
return new ICellForDetailItemRenderer<Integer, CalculationTypeRadio>() {
|
||||
|
||||
@Override
|
||||
public Component cellFor(Integer column, CalculationTypeRadio data) {
|
||||
return data.createRadio(getCalculationTypeRadio());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private CalculationTypeRadio getCalculationTypeRadio() {
|
||||
if (formBinder != null) {
|
||||
return CalculationTypeRadio.from(formBinder.getCalculatedValue());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ResourceAllocationController getController() {
|
||||
return this;
|
||||
}
|
||||
|
|
@ -234,8 +204,8 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
|
||||
TaskPropertiesController taskPropertiesController = editTaskController
|
||||
.getTaskPropertiesController();
|
||||
formBinder.setWorkableDays(taskWorkableDays,
|
||||
taskPropertiesController, lbTaskStart, lbTaskEnd);
|
||||
formBinder.setWorkableDays(getTaskWorkableDays(),
|
||||
taskPropertiesController, getTaskStart(), getTaskEnd());
|
||||
|
||||
formBinder.setApplyButton(applyButton);
|
||||
formBinder.setAllocationsGrid(allocationsGrid);
|
||||
|
|
@ -245,10 +215,11 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
.setNewAllocationSelectorCombo(newAllocationSelectorCombo);
|
||||
|
||||
initializeTaskInformationComponent();
|
||||
initializeAllocationConfigurationComponent();
|
||||
|
||||
CalculationTypeRadio calculationTypeRadio = CalculationTypeRadio
|
||||
.from(formBinder.getCalculatedValue());
|
||||
calculationTypeRadio.doTheSelectionOn(calculationTypeSelector);
|
||||
calculationTypeRadio.doTheSelectionOn(getCalculationTypeSelector());
|
||||
|
||||
tbResourceAllocation.setSelected(true);
|
||||
|
||||
|
|
@ -261,6 +232,22 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
}
|
||||
}
|
||||
|
||||
private Intbox getTaskWorkableDays() {
|
||||
return allocationConfiguration.getTaskWorkableDays();
|
||||
}
|
||||
|
||||
private Label getTaskStart() {
|
||||
return allocationConfiguration.getTaskStart();
|
||||
}
|
||||
|
||||
private Label getTaskEnd() {
|
||||
return allocationConfiguration.getTaskEnd();
|
||||
}
|
||||
|
||||
private Radiogroup getCalculationTypeSelector() {
|
||||
return allocationConfiguration.getCalculationTypeSelector();
|
||||
}
|
||||
|
||||
private void initializeTaskInformationComponent() {
|
||||
taskInformation.initializeGridTaskRows(resourceAllocationModel
|
||||
.getHoursAggregatedByCriterions());
|
||||
|
|
@ -275,9 +262,9 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
});
|
||||
}
|
||||
|
||||
private Label lbTaskStart;
|
||||
|
||||
private Label lbTaskEnd;
|
||||
private void initializeAllocationConfigurationComponent() {
|
||||
allocationConfiguration.setFormBinder(formBinder);
|
||||
}
|
||||
|
||||
public enum HoursRendererColumn {
|
||||
|
||||
|
|
@ -396,7 +383,7 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
@Override
|
||||
public Component input(
|
||||
ResourceAllocationController resourceAllocationController) {
|
||||
return resourceAllocationController.taskWorkableDays;
|
||||
return resourceAllocationController.getTaskWorkableDays();
|
||||
}
|
||||
},
|
||||
NUMBER_OF_HOURS(CalculatedValue.NUMBER_OF_HOURS) {
|
||||
|
|
@ -492,6 +479,7 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
public CalculatedValue getCalculatedValue() {
|
||||
return calculatedValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum DerivedAllocationColumn implements IConvertibleToColumn {
|
||||
|
|
@ -566,12 +554,12 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
return Arrays.asList(CalculationTypeRadio.values());
|
||||
}
|
||||
|
||||
public void setCalculationTypeSelected(String enumName) {
|
||||
CalculationTypeRadio calculationTypeRadio = CalculationTypeRadio
|
||||
.valueOf(enumName);
|
||||
formBinder
|
||||
.setCalculatedValue(calculationTypeRadio.getCalculatedValue());
|
||||
}
|
||||
// public void setCalculationTypeSelected(String enumName) {
|
||||
// CalculationTypeRadio calculationTypeRadio = CalculationTypeRadio
|
||||
// .valueOf(enumName);
|
||||
// formBinder
|
||||
// .setCalculatedValue(calculationTypeRadio.getCalculatedValue());
|
||||
// }
|
||||
|
||||
public List<? extends Object> getResourceAllocations() {
|
||||
return formBinder != null ? plusAggregatingRow(formBinder
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
<!--
|
||||
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 sclass="assignedresources" closable="false" width="340px" height="170px" >
|
||||
|
||||
<caption label="${i18n:_('Allocation configuration')}" />
|
||||
|
||||
<hbox>
|
||||
<!-- Planned Task Start -->
|
||||
<label style="font-weight: bold" value="${i18n:_('Planned start :')}" />
|
||||
<label id="lbTaskStart" />
|
||||
|
||||
<!-- Planned Task End -->
|
||||
<label style="font-weight: bold" value="${i18n:_('Planned end :')}" />
|
||||
<label id="lbTaskEnd" />
|
||||
</hbox>
|
||||
|
||||
<hbox>
|
||||
<!-- Planned Workable Days -->
|
||||
<label style="font-weight: bold" value="${i18n:_('Planned workable days :')}" />
|
||||
<intbox id="taskWorkableDays" width="90px" />
|
||||
</hbox>
|
||||
|
||||
<separator orient="horizontal" spacing="10px"/>
|
||||
|
||||
<radiogroup id="calculationTypeSelector" >
|
||||
<grid id="calculationTypesGrid">
|
||||
<columns>
|
||||
<column />
|
||||
</columns>
|
||||
</grid>
|
||||
</radiogroup>
|
||||
|
||||
</groupbox>
|
||||
|
||||
</zk>
|
||||
|
|
@ -32,6 +32,10 @@
|
|||
class="org.navalplanner.web.planner.allocation.TaskInformation"
|
||||
macroURI="_taskInformation.zul" ?>
|
||||
|
||||
<?component name="allocationConfiguration"
|
||||
class="org.navalplanner.web.planner.allocation.AllocationConfiguration"
|
||||
macroURI="_allocationConfiguration.zul" ?>
|
||||
|
||||
<tabpanel id="resourceAllocationTabpanel">
|
||||
<tabbox mold="accordion">
|
||||
<tabs>
|
||||
|
|
@ -42,40 +46,11 @@
|
|||
<tabpanel>
|
||||
<hbox align="end">
|
||||
|
||||
<!-- Task Information -->
|
||||
<taskInformation id="taskInformation" />
|
||||
<!-- Task Information -->
|
||||
<taskInformation id="taskInformation" />
|
||||
|
||||
<groupbox sclass="assignedresources" closable="false" width="340px" height="170px" >
|
||||
<caption label="${i18n:_('Allocation configuration')}" />
|
||||
|
||||
<hbox>
|
||||
<!-- Planned Task Start -->
|
||||
<label style="font-weight: bold" value="${i18n:_('Planned start :')}" />
|
||||
<label id="lbTaskStart" />
|
||||
|
||||
<!-- Planned Task End -->
|
||||
<label style="font-weight: bold" value="${i18n:_('Planned end :')}" />
|
||||
<label id="lbTaskEnd" />
|
||||
|
||||
</hbox>
|
||||
<!-- Planned Workable Days -->
|
||||
<label style="font-weight: bold" value="${i18n:_('Planned workable days :')}" />
|
||||
<intbox id="taskWorkableDays" width="90px" />
|
||||
<hbox>
|
||||
|
||||
</hbox>
|
||||
|
||||
<separator orient="horizontal" spacing="10px"/>
|
||||
|
||||
<radiogroup id="calculationTypeSelector"
|
||||
onCheck="allocationController.calculationTypeSelected = self.selectedItem.value;">
|
||||
<grid id="calculationTypesGrid">
|
||||
<columns>
|
||||
<column />
|
||||
</columns>
|
||||
</grid>
|
||||
</radiogroup>
|
||||
</groupbox>
|
||||
<!-- Allocation Configuration -->
|
||||
<allocationConfiguration id="allocationConfiguration" />
|
||||
|
||||
</hbox>
|
||||
|
||||
|
|
@ -120,7 +95,7 @@
|
|||
</columns>
|
||||
</grid>
|
||||
</groupbox>
|
||||
</tabpanel>
|
||||
</tabpanel>
|
||||
|
||||
<!-- Worker search -->
|
||||
<tabpanel>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue