ItEr36S11CUCreacionUnidadesPlanificacionItEr35S12: The user is informed of the allocations that couldn't be added using a MessagesForUser

This commit is contained in:
Óscar González Fernández 2009-11-25 00:10:19 +01:00
parent f074106ab9
commit 570129aea3
3 changed files with 21 additions and 11 deletions

View file

@ -34,6 +34,8 @@ import org.navalplanner.business.planner.entities.AggregateOfResourceAllocations
import org.navalplanner.business.planner.entities.CalculatedValue;
import org.navalplanner.business.resources.entities.Criterion;
import org.navalplanner.business.resources.entities.Resource;
import org.navalplanner.web.common.IMessagesForUser;
import org.navalplanner.web.common.Level;
import org.navalplanner.web.resourceload.ResourceLoadModel;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.WrongValueException;
@ -88,6 +90,8 @@ class FormBinder {
private List<InputElement> inputsAssociatedWithOnChangeEnableApply = new ArrayList<InputElement>();
private IMessagesForUser messagesForUser;
public FormBinder(
ResourceAllocationsBeingEdited resourceAllocationsBeingEdited) {
this.resourceAllocationsBeingEdited = resourceAllocationsBeingEdited;
@ -235,8 +239,8 @@ class FormBinder {
_("it must be greater than zero"));
}
public void markRepeatedResource(List<Resource> resources) {
throw new WrongValueException(allocationsList, _(
public void markRepeatedResources(List<Resource> resources) {
messagesForUser.showMessage(Level.ERROR, _(
"{0} already assigned to resource allocation list", StringUtils
.join(getResourcesDescriptions(resources), ", ")));
}
@ -251,13 +255,19 @@ class FormBinder {
public void markNoWorkersMatchedByCriterions(
Collection<? extends Criterion> criterions) {
throw new WrongValueException(
allocationsList,
_(
messagesForUser
.showMessage(
Level.ERROR,
_(
"there are no workers for required criteria: {0}. So the generic allocation can't be added",
ResourceLoadModel.getName(criterions)));
}
public void markThereisAlreadyAssignmentWith(Set<Criterion> criterions) {
messagesForUser.showMessage(Level.ERROR,
_("for criterions {0} already exists an allocation"));
}
public void markThereMustBeAtLeastOneNoEmptyAllocation() {
throw new WrongValueException(allocationsList,
_("at least one no empty allocation is needed"));
@ -267,6 +277,10 @@ class FormBinder {
this.allocationsList = allocationsList;
}
public void setMessagesForUser(IMessagesForUser messages) {
this.messagesForUser = messages;
}
public void detach() {
this.applyButton.removeEventListener(Events.ON_CLICK,
applyButtonListener);
@ -276,9 +290,4 @@ class FormBinder {
}
}
public void markThereisAlreadyAssignmentWith(Set<Criterion> criterions) {
throw new WrongValueException(allocationsList,
_("for criterions {0} already exists an allocation"));
}
}

View file

@ -153,6 +153,7 @@ public class ResourceAllocationController extends GenericForwardComposer {
formBinder.setTaskElapsedDays(taskElapsedDays);
formBinder.setApplyButton(applyButton);
formBinder.setAllocationsList(allocationsList);
formBinder.setMessagesForUser(messagesForUser);
CalculationTypeRadio calculationTypeRadio = CalculationTypeRadio
.from(formBinder.getCalculatedValue());
calculationTypeRadio.doTheSelectionOn(calculationTypeSelector);

View file

@ -101,7 +101,7 @@ public class ResourceAllocationsBeingEdited {
}
}
if (!alreadyPresent.isEmpty()) {
formBinder.markRepeatedResource(alreadyPresent);
formBinder.markRepeatedResources(alreadyPresent);
}
}