ItEr17S07RFComportamentoGraficoPlanificadorItEr16S09:When pressing arrow down at a taskDetail it goes to one of its

children(if present and the task is expanded) instead of the next sibling.
This commit is contained in:
Óscar González Fernández 2009-07-13 14:01:40 +02:00 committed by Javier Moran Rua
parent ec017fffd7
commit 2c812f4d65

View file

@ -37,7 +37,7 @@ public class ListDetails extends HtmlMacroComponent {
taskBean);
String cssClass = "depth_" + path.length;
TaskDetail taskDetail = TaskDetail.create(taskBean,
new TreeNavigator(tasksTreeModel, path));
new TreeNavigator(tasksTreeModel, taskBean));
if (taskBean instanceof TaskContainerBean) {
expandWhenOpened((TaskContainerBean) taskBean, item);
}
@ -101,9 +101,12 @@ public class ListDetails extends HtmlMacroComponent {
private final class TreeNavigator implements ITaskDetailNavigator {
private final int[] pathToNode;
private final TaskBean task;
private TreeNavigator(TreeModel treemodel, int[] pathToNode) {
this.pathToNode = pathToNode;
private TreeNavigator(TreeModel treemodel, TaskBean task) {
this.task = task;
this.pathToNode = tasksTreeModel.getPath(tasksTreeModel.getRoot(),
task);
}
@Override
@ -129,12 +132,26 @@ public class ListDetails extends HtmlMacroComponent {
int childCount = tasksTreeModel.getChildCount(parent);
int lastPosition = pathToNode[pathToNode.length - 1];
int belowPosition = lastPosition + 1;
if (belowPosition < childCount) {
if (isExpanded() && hasChildren()) {
return getChild(task, 0);
} else if (belowPosition < childCount) {
return getChild(parent, belowPosition);
}
return null;
}
private boolean hasChildren() {
return task instanceof TaskContainerBean
&& ((TaskContainerBean) task).getTasks().size() > 0;
}
private boolean isExpanded() {
if (task instanceof TaskContainerBean) {
return ((TaskContainerBean) task).isExpanded();
}
return false;
}
private TaskBean getParent(int[] path) {
TaskBean current = tasksTreeModel.getRoot();
for (int i = 0; i < path.length - 1; i++) {