Changeset 2147 for trunk/autoquest-ui-swt/src/main/java/de
- Timestamp:
- 05/19/17 11:33:37 (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
r2127 r2147 28 28 import java.util.LinkedList; 29 29 import java.util.List; 30 import java.util.TreeMap; 30 31 31 32 import org.eclipse.swt.SWT; … … 613 614 Collection<ITask> allTasks = taskModel.getTasks(); 614 615 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>();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<>(); 620 621 621 622 TreeItem root = new TreeItem(modelTree, SWT.NULL); … … 623 624 root.setData(taskModel); 624 625 625 createSortedTask Lists(allTasks, sequences, iterations, selections, optionals, others);626 createSortedTaskMaps(allTasks, sequences, iterations, selections, optionals, others); 626 627 627 628 //allTasks = createSortedTaskList(allTasks); … … 639 640 * 640 641 */ 641 private void createSortedTask Lists(Collection<ITask>allTasks,642 List<ITask>sequences,643 List<ITask>iterations,644 List<ITask>selections,645 List<ITask>optionals,646 List<ITask>others)642 private void createSortedTaskMaps(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) 647 648 { 648 List<ITask> toAdd;649 TreeMap<Integer, ITask> toAdd; 649 650 650 651 for (ITask task : allTasks) { … … 666 667 667 668 int taskValue = taskModel.getTaskInfo(task).getMeasureValue(TaskMetric.EVENT_COVERAGE); 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); 669 toAdd.put(taskValue, task); 702 670 } 703 671 } … … 877 845 * 878 846 */ 879 private void createModelTreeItemFor(List<ITask> taskList, String name, TreeItem parent) { 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 880 867 TreeItem item = new TreeItem(parent, SWT.NULL); 881 868 item.setText(name);
Note: See TracChangeset
for help on using the changeset viewer.