Changeset 1262 for trunk/autoquest-ui-swt/src/main
- Timestamp:
- 07/25/13 14:47:05 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ShowTaskTreeDialog.java
r1185 r1262 16 16 17 17 import java.util.Collection; 18 import java.util.Collections; 19 import java.util.Comparator; 18 20 import java.util.HashSet; 21 import java.util.LinkedList; 19 22 import java.util.List; 20 23 import java.util.Set; … … 197 200 198 201 TreeItem root = new TreeItem(modelTree, SWT.NULL); 199 root.setText(tasks.size() + " tasks in model ");202 root.setText(tasks.size() + " tasks in model (showing only root tasks)"); 200 203 root.setData(taskModel); 201 204 202 tasks = determineRootTasks(tasks);205 tasks = createSortedTaskList(tasks); 203 206 204 207 for (ITask task : tasks) { … … 226 229 * 227 230 */ 228 private Collection<ITask> determineRootTasks(Collection<ITask> tasks) {229 Set<ITask> result = new HashSet<ITask>(tasks);231 private List<ITask> createSortedTaskList(Collection<ITask> tasks) { 232 Set<ITask> resultSet = new HashSet<ITask>(tasks); 230 233 231 234 for (ITask task : tasks) { 232 removeChildren(task, result); 233 } 235 removeChildren(task, resultSet); 236 } 237 238 List<ITask> result = new LinkedList<ITask>(resultSet); 239 240 Collections.sort(result, new Comparator<ITask>() { 241 @Override 242 public int compare(ITask task1, ITask task2) { 243 return depth(task1) - depth(task2); 244 } 245 246 private int depth(ITask task) { 247 int maxChildDepth = 0; 248 if (task instanceof IStructuringTemporalRelationship) { 249 for (ITask child : ((IStructuringTemporalRelationship) task).getChildren()) { 250 maxChildDepth = Math.max(maxChildDepth, depth(child)); 251 } 252 } 253 else if (task instanceof IMarkingTemporalRelationship) { 254 maxChildDepth = Math.max 255 (maxChildDepth, depth(((IMarkingTemporalRelationship) task).getMarkedTask())); 256 } 257 return maxChildDepth + 1; 258 } 259 }); 234 260 235 261 return result; … … 243 269 for (ITask child : ((IStructuringTemporalRelationship) task).getChildren()) { 244 270 result.remove(child); 271 //removeChildren(child, result); 245 272 } 246 273 } 247 274 else if (task instanceof IMarkingTemporalRelationship) { 248 275 result.remove(((IMarkingTemporalRelationship) task).getMarkedTask()); 276 //removeChildren(((IMarkingTemporalRelationship) task).getMarkedTask(), result); 249 277 } 250 278 }
Note: See TracChangeset
for help on using the changeset viewer.