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-test-utils/src/main/java/de/ugoe/cs/autoquest/tasktrees/TaskTreeDecoder.java

    r1212 r1294  
    2626import de.ugoe.cs.autoquest.eventcore.StringEventType; 
    2727import de.ugoe.cs.autoquest.eventcore.gui.TextInput; 
     28import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 
     29import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 
    2830import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 
     31import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 
    2932import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 
     33import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 
    3034import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
     35import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 
    3136import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
     37import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 
    3238import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    3339import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 
     
    173179            } 
    174180            else { 
    175                 task = createUserInteractionTask(matcher); 
     181                task = createUserInteractionTaskInstance(matcher).getTask(); 
    176182            }   
    177183            tasks.put(id, task); 
    178184        } 
    179185         
    180         if ((matcher.group(5) != null) && (!"".equals(matcher.group(5).trim()))) { 
    181             taskBuilder.setDescription(task, matcher.group(5).trim()); 
    182         } 
    183  
    184         ITaskInstance instance = taskFactory.createNewTaskInstance(task); 
     186        ITaskInstance instance; 
     187         
     188        if (task instanceof ISequence) { 
     189            instance = taskFactory.createNewTaskInstance((ISequence) task); 
     190        } 
     191        else if (task instanceof ISelection) { 
     192            instance = taskFactory.createNewTaskInstance((ISelection) task); 
     193        } 
     194        else if (task instanceof IIteration) { 
     195            instance = taskFactory.createNewTaskInstance((IIteration) task); 
     196        } 
     197        else if (task instanceof IOptional) { 
     198            instance = taskFactory.createNewTaskInstance((IOptional) task); 
     199        } 
     200        else { 
     201            instance = taskFactory.createNewTaskInstance 
     202                 ((IEventTask) task, 
     203                  ((IEventTaskInstance) task.getInstances().iterator().next()).getEvent()); 
     204        }   
    185205         
    186206        while (taskMatcher.find() && !"}".equals(taskMatcher.group(0))) { 
     
    216236            } 
    217237             
    218             taskBuilder.addChild(instance, childInstance); 
     238            if (instance instanceof ISequenceInstance) { 
     239                taskBuilder.addChild((ISequenceInstance) instance, childInstance); 
     240            } 
     241            else if (instance instanceof ISelectionInstance) { 
     242                taskBuilder.setChild((ISelectionInstance) instance, childInstance); 
     243            } 
     244            else if (instance instanceof IIterationInstance) { 
     245                taskBuilder.addChild((IIterationInstance) instance, childInstance); 
     246            } 
     247            else if (instance instanceof IOptionalInstance) { 
     248                taskBuilder.setChild((IOptionalInstance) instance, childInstance); 
     249            } 
    219250        } 
    220251 
     
    229260     * @return 
    230261     */ 
    231     private ITask createUserInteractionTask(Matcher matcher) { 
     262    private ITaskInstance createUserInteractionTaskInstance(Matcher matcher) { 
    232263        String evenType = matcher.group(1); 
    233264        String id = matcher.group(2); 
    234         IEventTarget evenTarget = targets.get(id); 
    235         if (evenTarget == null) { 
    236             evenTarget = determineTarget(evenType, id, matcher.group(4)); 
    237             targets.put(id, evenTarget); 
     265        IEventTarget eventTarget = targets.get(id); 
     266        if (eventTarget == null) { 
     267            eventTarget = determineTarget(evenType, id, matcher.group(4)); 
     268            targets.put(id, eventTarget); 
    238269        } 
    239270        IEventType eventType = determineType(evenType, matcher.group(4)); 
    240         return taskFactory.createNewEventTask(eventType, evenTarget); 
     271        IEventTask task = taskFactory.createNewEventTask(eventType + " --> " + eventTarget); 
     272         
     273        return taskFactory.createNewTaskInstance(task, new Event(eventType, eventTarget)); 
    241274    } 
    242275 
Note: See TracChangeset for help on using the changeset viewer.