- Timestamp:
- 08/14/13 17:04:42 (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
r1275 r1294 18 18 import java.util.Collections; 19 19 import java.util.Comparator; 20 import java.util.HashSet;21 20 import java.util.LinkedList; 22 21 import java.util.List; 23 import java.util.Set;24 22 25 23 import org.eclipse.swt.SWT; … … 39 37 40 38 import de.ugoe.cs.autoquest.tasktrees.treeifc.IMarkingTemporalRelationship; 39 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 40 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 41 41 import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship; 42 42 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; … … 173 173 * convenience method for creating the display of the instances 174 174 */ 175 private void buildInstanceTree(TreeItem currentParent, I TaskInstanceList taskInstanceList) {175 private void buildInstanceTree(TreeItem currentParent, IUserSession session) { 176 176 TreeItem child = new TreeItem(currentParent, SWT.NULL); 177 child.setText(taskInstanceList.toString()); 178 child.setData(taskInstanceList); 179 180 for (ITaskInstanceList childTask : taskInstanceList) { 181 buildInstanceTree(child, childTask); 177 child.setText(session.toString()); 178 child.setData(session); 179 180 for (ITaskInstance childInstance : session) { 181 buildInstanceTree(child, childInstance); 182 } 183 } 184 185 /** 186 * convenience method for creating the display of the instances 187 */ 188 private void buildInstanceTree(TreeItem currentParent, ITaskInstance taskInstance) { 189 TreeItem child = new TreeItem(currentParent, SWT.NULL); 190 child.setText(taskInstance.toString()); 191 child.setData(taskInstance); 192 193 if (taskInstance instanceof ITaskInstanceList) { 194 for (ITaskInstance childInstance : (ITaskInstanceList) taskInstance) { 195 buildInstanceTree(child, childInstance); 196 } 197 } 198 else if (taskInstance instanceof ISelectionInstance) { 199 buildInstanceTree(child, ((ISelectionInstance) taskInstance).getChild()); 200 } 201 else if (taskInstance instanceof IOptionalInstance) { 202 buildInstanceTree(child, ((IOptionalInstance) taskInstance).getChild()); 182 203 } 183 204 } … … 229 250 230 251 /** 231 * reduces the list of tasks in a model so that it only contains root nodes and that it is 232 * sorted starting with the most complex task first 252 * sort the list of tasks so that it contain those occurring most often first 233 253 */ 234 254 private List<ITask> createSortedTaskList(Collection<ITask> tasks) { 235 Set<ITask> resultSet = new HashSet<ITask>(tasks);255 /*Set<ITask> resultSet = new HashSet<ITask>(tasks); 236 256 237 257 for (ITask task : tasks) { 238 258 removeChildren(task, resultSet); 239 } 240 241 List<ITask> result = new LinkedList<ITask>( resultSet);259 }*/ 260 261 List<ITask> result = new LinkedList<ITask>(tasks); 242 262 243 263 Collections.sort(result, new Comparator<ITask>() { 244 264 @Override 245 265 public int compare(ITask task1, ITask task2) { 246 return depth(task2) - depth(task1); 247 } 248 249 private int depth(ITask task) { 266 return taskModel.getTaskInfo(task2).getCount() - 267 taskModel.getTaskInfo(task1).getCount(); 268 } 269 270 /*private int depth(ITask task) { 250 271 int maxChildDepth = 0; 251 272 if (task instanceof IStructuringTemporalRelationship) { … … 259 280 } 260 281 return maxChildDepth + 1; 261 } 282 }*/ 262 283 }); 263 284 … … 268 289 * convenience method for removed all non root tasks of the provided list 269 290 */ 270 private void removeChildren(ITask task, Set<ITask> result) {291 /*private void removeChildren(ITask task, Set<ITask> result) { 271 292 if (task instanceof IStructuringTemporalRelationship) { 272 293 for (ITask child : ((IStructuringTemporalRelationship) task).getChildren()) { … … 277 298 result.remove(((IMarkingTemporalRelationship) task).getMarkedTask()); 278 299 } 279 } 300 }*/ 280 301 281 302 /** … … 338 359 private void createTreeItemFor(ITask task, TreeItem parent) { 339 360 TreeItem item = new TreeItem(parent, SWT.NULL); 340 item.setText(task.toString() );361 item.setText(task.toString() + " (" + taskModel.getTaskInfo(task).getCount() + ")"); 341 362 item.setData(task); 342 363
Note: See TracChangeset
for help on using the changeset viewer.