Fix bug for all elements affected by the allocation of a 'LimitingResourceQueueElement', remove all its dependency components before refreshing its queue

The method assignLimitingResourceQueueElement() allocates an limiting
resource queue element from the list of new queue elements to a queue.
Queue elements already in a queue might be affected by this allocation
(may change their position due to dependency constraints) and need to
redraw.

For redrawing each element, its queue is refreshing. Refreshing the
queueu causes to paint the elements in a new position an create new
dependency components, however the old dependecy components need to be
removed before.

FEA: ItEr65OTS04CorreccionsRecursosLimitantes
This commit is contained in:
Diego Pino Garcia 2010-12-15 17:38:59 +01:00
parent 745fad2d7c
commit b916a3a50c
3 changed files with 27 additions and 2 deletions

View file

@ -470,8 +470,11 @@ public class LimitingResourcesController extends GenericForwardComposer {
for (LimitingResourceQueueElement each : inserted) {
// FIXME visually wrong if an element jumps from a queue to
// another
limitingResourcesPanel.refreshQueue(each
.getLimitingResourceQueue());
LimitingResourceQueue queue = each.getLimitingResourceQueue();
// Remove all dependency components associated to element
limitingResourcesPanel.removeDependencyComponentsFor(each);
// Dependencies will be created again on refreshing queue
limitingResourcesPanel.refreshQueue(queue);
}
} else {
showErrorMessage(_("Cannot allocate selected element. There is not any queue " +

View file

@ -429,6 +429,11 @@ public class LimitingResourcesPanel extends HtmlMacroComponent {
.getLimitingResourceQueueElement());
}
public void removeDependencyComponentsFor(LimitingResourceQueueElement element) {
QueueTask queueTask = queueListComponent.getQueueTask(element);
dependencyList.removeDependencyComponents(queueTask);
}
public void refreshQueue(LimitingResourceQueue queue) {
queueListComponent.refreshQueue(queue);
}

View file

@ -142,6 +142,23 @@ public class QueueListComponent extends HtmlMacroComponent implements
return result;
}
/**
* Returns {@link QueueTask} associated to element
*
* @param element
* @return
*/
public QueueTask getQueueTask(LimitingResourceQueueElement element) {
QueueComponent queue = fromQueueToComponent.get(element.getLimitingResourceQueue());
for (QueueTask each: queue.getQueueTasks()) {
LimitingResourceQueueElement target = each.getLimitingResourceQueueElement();
if (element.getId().equals(target.getId())) {
return each;
}
}
return null;
}
public Map<LimitingResourceQueueElement, QueueTask> getLimitingResourceElementToQueueTaskMap() {
Map<LimitingResourceQueueElement, QueueTask> result = new HashMap<LimitingResourceQueueElement, QueueTask>();
for (QueueTask each : getQueueTasks()) {