ItEr27S06CUAsignacionGrupoRecursosAPlanificacionItEr26S07: Adding apply button. It is enabled and disabled when required.

This commit is contained in:
Óscar González Fernández 2009-09-23 00:31:34 +02:00
parent fe078f7369
commit 893a5deebc
3 changed files with 54 additions and 0 deletions

View file

@ -2,8 +2,14 @@ package org.navalplanner.web.planner.allocation;
import org.navalplanner.business.planner.entities.AggregateOfResourceAllocations;
import org.navalplanner.business.planner.entities.CalculatedValue;
import org.zkoss.zk.ui.Component;
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.Button;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Intbox;
import org.zkoss.zul.impl.api.InputElement;
class FormBinder {
@ -16,6 +22,23 @@ class FormBinder {
private Intbox taskElapsedDays;
private Button applyButton;
private EventListener onChangeEnableApply = new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
Component target = event.getTarget();
if (target instanceof InputElement) {
InputElement inputElement = (InputElement) target;
if (inputElement.isDisabled()) {
return;
}
}
applyButton.setDisabled(false);
}
};
public FormBinder(
ResourceAllocationsBeingEdited resourceAllocationsBeingEdited) {
this.resourceAllocationsBeingEdited = resourceAllocationsBeingEdited;
@ -27,6 +50,7 @@ class FormBinder {
this.assignedHoursComponent = assignedHoursComponent;
assignedHoursComponentDisabilityRule();
this.assignedHoursComponent.setValue(aggregate.getTotalHours());
onChangeEnableApply(assignedHoursComponent);
}
private void assignedHoursComponentDisabilityRule() {
@ -45,6 +69,7 @@ class FormBinder {
}
resourceAllocationsBeingEdited.setCalculatedValue(calculatedValue);
applyDisabledRules();
applyButton.setDisabled(false);
}
private void applyDisabledRules() {
@ -61,6 +86,11 @@ class FormBinder {
this.taskStartDateBox.setDisabled(true);
this.taskStartDateBox.setValue(resourceAllocationsBeingEdited.getTask()
.getStartDate());
onChangeEnableApply(taskStartDateBox);
}
private void onChangeEnableApply(InputElement inputElement) {
inputElement.addEventListener(Events.ON_CHANGE, onChangeEnableApply);
}
public void setTaskElapsedDays(Intbox taskElapsedDays) {
@ -68,10 +98,30 @@ class FormBinder {
taskElapsedDaysDisabilityRule();
this.taskElapsedDays.setValue(resourceAllocationsBeingEdited.getTask()
.getDaysDuration());
onChangeEnableApply(taskElapsedDays);
}
private void taskElapsedDaysDisabilityRule() {
this.taskElapsedDays.setDisabled(true);
}
private void doApply() {
// TODO implement
}
public void setApplyButton(Button applyButton) {
this.applyButton = applyButton;
this.applyButton.setDisabled(true);
this.applyButton.addEventListener(Events.ON_CLICK, new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
doApply();
FormBinder.this.applyButton.setDisabled(true);
}
});
}
}

View file

@ -79,6 +79,8 @@ public class ResourceAllocationController extends GenericForwardComposer {
private Intbox taskElapsedDays;
private Button applyButton;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
@ -101,6 +103,7 @@ public class ResourceAllocationController extends GenericForwardComposer {
formBinder.setAssignedHoursComponent(assignedHoursComponent);
formBinder.setTaskStartDateBox(taskStartDateBox);
formBinder.setTaskElapsedDays(taskElapsedDays);
formBinder.setApplyButton(applyButton);
CalculationTypeRadio calculationTypeRadio = CalculationTypeRadio
.from(formBinder.getCalculatedValue());
calculationTypeRadio.doTheSelectionOn(calculationTypeSelector);

View file

@ -128,6 +128,7 @@
<hbox>
<button label="${i18n:_('Accept')}" onClick="allocationController.save()" />
<button label="${i18n:_('Apply')}" id="applyButton"/>
<button label="${i18n:_('Cancel')}" onClick="allocationController.cancel()" />
<button label="${i18n:_('Search resources...')}"
onClick="allocationController.showSearchResources()" />