Ignore:
Timestamp:
08/14/13 17:04:42 (11 years ago)
Author:
pharms
Message:
  • rework of task model to move event instance stuff to task instances
  • introduction of sequence, selection, iteration and optional instances
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ShowTaskTreeDialog.java

    r1275 r1294  
    1818import java.util.Collections; 
    1919import java.util.Comparator; 
    20 import java.util.HashSet; 
    2120import java.util.LinkedList; 
    2221import java.util.List; 
    23 import java.util.Set; 
    2422 
    2523import org.eclipse.swt.SWT; 
     
    3937 
    4038import de.ugoe.cs.autoquest.tasktrees.treeifc.IMarkingTemporalRelationship; 
     39import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 
     40import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 
    4141import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship; 
    4242import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     
    173173     * convenience method for creating the display of the instances 
    174174     */ 
    175     private void buildInstanceTree(TreeItem currentParent, ITaskInstanceList taskInstanceList) { 
     175    private void buildInstanceTree(TreeItem currentParent, IUserSession session) { 
    176176        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()); 
    182203        } 
    183204    } 
     
    229250 
    230251    /** 
    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 
    233253     */ 
    234254    private List<ITask> createSortedTaskList(Collection<ITask> tasks) { 
    235         Set<ITask> resultSet = new HashSet<ITask>(tasks); 
     255        /*Set<ITask> resultSet = new HashSet<ITask>(tasks); 
    236256         
    237257        for (ITask task : tasks) { 
    238258            removeChildren(task, resultSet); 
    239         } 
    240          
    241         List<ITask> result = new LinkedList<ITask>(resultSet); 
     259        }*/ 
     260         
     261        List<ITask> result = new LinkedList<ITask>(tasks); 
    242262         
    243263        Collections.sort(result, new Comparator<ITask>() { 
    244264            @Override 
    245265            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) { 
    250271                int maxChildDepth = 0; 
    251272                if (task instanceof IStructuringTemporalRelationship) { 
     
    259280                } 
    260281                return maxChildDepth + 1; 
    261             } 
     282            }*/ 
    262283        }); 
    263284         
     
    268289     * convenience method for removed all non root tasks of the provided list 
    269290     */ 
    270     private void removeChildren(ITask task, Set<ITask> result) { 
     291    /*private void removeChildren(ITask task, Set<ITask> result) { 
    271292        if (task instanceof IStructuringTemporalRelationship) { 
    272293            for (ITask child : ((IStructuringTemporalRelationship) task).getChildren()) { 
     
    277298            result.remove(((IMarkingTemporalRelationship) task).getMarkedTask()); 
    278299        } 
    279     } 
     300    }*/ 
    280301 
    281302    /** 
     
    338359    private void createTreeItemFor(ITask task, TreeItem parent) { 
    339360        TreeItem item = new TreeItem(parent, SWT.NULL); 
    340         item.setText(task.toString()); 
     361        item.setText(task.toString() + " (" + taskModel.getTaskInfo(task).getCount() + ")"); 
    341362        item.setData(task); 
    342363         
Note: See TracChangeset for help on using the changeset viewer.