Bug #1320: Recalculate position of siblings when moving a task
When a task is moved in the Gantt, the constraint changes and it could causes that some of its siblings should be moved, because of the parent element is moved too. FEA: ItEr77S04BugFixing
This commit is contained in:
parent
1bde8c76be
commit
125146ebd2
3 changed files with 25 additions and 21 deletions
|
|
@ -24,6 +24,8 @@ package org.zkoss.ganttz;
|
|||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -373,6 +375,24 @@ public class TaskComponent extends Div implements AfterCompose {
|
|||
startBeforeMoving);
|
||||
if (remainsInOriginalPosition) {
|
||||
updateProperties();
|
||||
} else {
|
||||
recalculatePositionOfSiblings();
|
||||
}
|
||||
}
|
||||
|
||||
public void recalculatePositionOfSiblings() {
|
||||
Task task = getTask();
|
||||
|
||||
FunctionalityExposedForExtensions<?> context = getTaskList()
|
||||
.getFunctionalityExposedForExtensionsContext();
|
||||
List<TaskContainer> parents = new ArrayList<TaskContainer>(context
|
||||
.getMapper().getParents(task));
|
||||
for (TaskContainer parent : parents) {
|
||||
if (parent.contains(task)) {
|
||||
for (Task child : parent.getTasks()) {
|
||||
context.getDiagramGraph().enforceRestrictions(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -409,4 +409,8 @@ public class TaskList extends XulElement implements AfterCompose {
|
|||
reload(false);
|
||||
}
|
||||
|
||||
public FunctionalityExposedForExtensions<?> getFunctionalityExposedForExtensionsContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,6 @@ package org.libreplan.web.planner.taskedition;
|
|||
|
||||
import static org.libreplan.web.I18nHelper._;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.libreplan.business.common.exceptions.ValidationException;
|
||||
import org.libreplan.business.planner.entities.ITaskPositionConstrained;
|
||||
import org.libreplan.business.planner.entities.Task;
|
||||
|
|
@ -43,7 +40,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.zkoss.ganttz.TaskComponent;
|
||||
import org.zkoss.ganttz.data.TaskContainer;
|
||||
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
|
|
@ -322,23 +318,7 @@ public class EditTaskController extends GenericForwardComposer {
|
|||
.getRelativeTo();
|
||||
taskComponent.updateProperties();
|
||||
taskComponent.invalidate();
|
||||
|
||||
recalculatePositionOfSiblings(taskComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void recalculatePositionOfSiblings(TaskComponent taskComponent) {
|
||||
org.zkoss.ganttz.data.Task task = taskComponent.getTask();
|
||||
|
||||
List<TaskContainer> parents = new ArrayList<TaskContainer>(context
|
||||
.getMapper().getParents(task));
|
||||
for (TaskContainer parent : parents) {
|
||||
if (parent.contains(task)) {
|
||||
for (org.zkoss.ganttz.data.Task child : parent.getTasks()) {
|
||||
context.recalculatePosition(context.getMapper()
|
||||
.findAssociatedDomainObject(child));
|
||||
}
|
||||
taskComponent.recalculatePositionOfSiblings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue