ItEr58S17AsignacionConsolidacion: add constraint to the resource allocation.

if the task has got some consolidation, the resource allocation type can not be changed.
This commit is contained in:
Susana Montes Pedreira 2010-05-20 17:49:24 +02:00 committed by Javier Moran Rua
parent c03cd0f5a0
commit d899ae17ac
2 changed files with 31 additions and 2 deletions

View file

@ -31,6 +31,7 @@ import org.navalplanner.business.planner.entities.CalculatedValue;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.TaskElement;
import org.navalplanner.web.common.IMessagesForUser;
import org.navalplanner.web.common.Level;
import org.navalplanner.web.common.MessagesForUser;
import org.navalplanner.web.common.Util;
import org.navalplanner.web.planner.allocation.AllocationResult;
@ -50,6 +51,7 @@ import org.zkoss.ganttz.TaskComponent;
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.api.Tab;
import org.zkoss.zul.api.Tabbox;
import org.zkoss.zul.api.Tabpanel;
@ -398,4 +400,14 @@ public class EditTaskController extends GenericForwardComposer {
}
}
public void showNonPermitChangeResourceAllocationType() {
String message = _("The task has got advance consolidations.It must delete all consolidations to change the resource allocation type ");
try {
Messagebox.show(message, _("Information"), Messagebox.OK,
Messagebox.INFORMATION);
} catch (InterruptedException e) {
messagesForUser.showMessage(Level.INFO, message);
}
}
}

View file

@ -326,8 +326,14 @@ public class TaskPropertiesController extends GenericForwardComposer {
final ResourceAllocationTypeEnum oldState = getOldState();
ResourceAllocationTypeEnum newState = getSelectedValue(new ArrayList(se.getSelectedItems()));
if (thereIsTransition(newState)) {
changeResourceAllocationType(oldState, newState);
if (thereIsTransition(newState)) {
if (isConsolidatedTask()) {
restoreOldState();
editTaskController
.showNonPermitChangeResourceAllocationType();
} else {
changeResourceAllocationType(oldState, newState);
}
}
if (oldState == null) {
setOldState(newState);
@ -340,6 +346,10 @@ public class TaskPropertiesController extends GenericForwardComposer {
return ResourceAllocationTypeEnum.asEnum(cell.getLabel());
}
private void restoreOldState() {
Util.reloadBindings(lbResourceAllocationType);
}
});
}
@ -594,4 +604,11 @@ public class TaskPropertiesController extends GenericForwardComposer {
return ResourceAllocationTypeEnum.asEnum(cell.getLabel());
}
public boolean isConsolidatedTask() {
Task task = asTask(currentTaskElement);
if (task != null) {
return task.hasConsolidations();
}
return false;
}
}