Changeset 2160 for trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs
- Timestamp:
- 05/30/17 12:32:35 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ShowTaskTreeDialog.java
r2147 r2160 28 28 import java.util.LinkedList; 29 29 import java.util.List; 30 import java.util.TreeMap;31 30 32 31 import org.eclipse.swt.SWT; … … 614 613 Collection<ITask> allTasks = taskModel.getTasks(); 615 614 616 TreeMap<Integer, ITask> sequences = new TreeMap<>();617 TreeMap<Integer, ITask> iterations = new TreeMap<>();618 TreeMap<Integer, ITask> selections = new TreeMap<>();619 TreeMap<Integer, ITask> optionals = new TreeMap<>();620 TreeMap<Integer, ITask> others = new TreeMap<>();615 List<ITask> sequences = new ArrayList<ITask>(); 616 List<ITask> iterations = new ArrayList<ITask>(); 617 List<ITask> selections = new ArrayList<ITask>(); 618 List<ITask> optionals = new ArrayList<ITask>(); 619 List<ITask> others = new ArrayList<ITask>(); 621 620 622 621 TreeItem root = new TreeItem(modelTree, SWT.NULL); … … 624 623 root.setData(taskModel); 625 624 626 createSortedTask Maps(allTasks, sequences, iterations, selections, optionals, others);625 createSortedTaskLists(allTasks, sequences, iterations, selections, optionals, others); 627 626 628 627 //allTasks = createSortedTaskList(allTasks); … … 640 639 * 641 640 */ 642 private void createSortedTask Maps(Collection<ITask>allTasks,643 TreeMap<Integer, ITask>sequences,644 TreeMap<Integer, ITask>iterations,645 TreeMap<Integer, ITask>selections,646 TreeMap<Integer, ITask>optionals,647 TreeMap<Integer, ITask>others)641 private void createSortedTaskLists(Collection<ITask> allTasks, 642 List<ITask> sequences, 643 List<ITask> iterations, 644 List<ITask> selections, 645 List<ITask> optionals, 646 List<ITask> others) 648 647 { 649 TreeMap<Integer,ITask> toAdd;648 List<ITask> toAdd; 650 649 651 650 for (ITask task : allTasks) { … … 667 666 668 667 int taskValue = taskModel.getTaskInfo(task).getMeasureValue(TaskMetric.EVENT_COVERAGE); 669 toAdd.put(taskValue, task); 668 int start = 0; 669 int end = toAdd.size(); 670 int center = 0; 671 int centerValue; 672 673 while (start != end) { 674 center = start + ((end - start) / 2); 675 676 if ((center != start) || (center != end)) { 677 //centerValue = toAdd.get(center).getInstances().size(); 678 centerValue = taskModel.getTaskInfo(toAdd.get(center)).getMeasureValue 679 (TaskMetric.EVENT_COVERAGE); 680 681 if (centerValue > taskValue) { 682 start = Math.max(center, start + 1); 683 } 684 else if (centerValue < taskValue) { 685 end = Math.min(center, end - 1); 686 } 687 else { 688 // add the event directly where the center is, as the count of the center 689 // and the new task are equal 690 end = center; 691 start = end; 692 break; 693 } 694 } 695 else { 696 // add the event to the position denoted by the add index 697 break; 698 } 699 } 700 701 toAdd.add(start, task); 670 702 } 671 703 } … … 845 877 * 846 878 */ 847 private void createModelTreeItemFor(TreeMap<Integer, ITask> taskMap, 848 String name, 849 TreeItem parent) 850 { 851 ITask[] tasks = new ITask[taskMap.size()]; 852 853 // reverse the order 854 int i = 1; 855 for (ITask task : taskMap.values()) { 856 tasks[tasks.length - i++] = task; 857 } 858 859 // create an array list for efficient access 860 List<ITask> taskList = new ArrayList<ITask>(); 861 862 for (ITask task : tasks) { 863 taskList.add(task); 864 } 865 866 879 private void createModelTreeItemFor(List<ITask> taskList, String name, TreeItem parent) { 867 880 TreeItem item = new TreeItem(parent, SWT.NULL); 868 881 item.setText(name);
Note: See TracChangeset
for help on using the changeset viewer.