- Timestamp:
- 04/30/13 17:50:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/tasktrees/TaskTreeDecoder.java
r1146 r1202 15 15 package de.ugoe.cs.autoquest.tasktrees; 16 16 17 import java.util.ArrayList; 17 18 import java.util.HashMap; 18 19 import java.util.Map; … … 20 21 import java.util.regex.Pattern; 21 22 23 import de.ugoe.cs.autoquest.eventcore.Event; 22 24 import de.ugoe.cs.autoquest.eventcore.IEventTarget; 25 import de.ugoe.cs.autoquest.eventcore.IEventType; 23 26 import de.ugoe.cs.autoquest.eventcore.StringEventType; 27 import de.ugoe.cs.autoquest.eventcore.gui.TextInput; 24 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 25 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; … … 33 37 import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 34 38 import de.ugoe.cs.autoquest.test.DummyGUIElement; 39 import de.ugoe.cs.autoquest.test.DummyTextField; 35 40 36 41 /** … … 47 52 /** */ 48 53 private static Pattern taskInstanceDetailsPattern = 49 Pattern.compile("\\s*(\\w*)\\s*([\\w\\(\\)\"]*)\\s*( (\\w*)|(\".*\"))?");50 54 Pattern.compile("\\s*(\\w*)\\s*([\\w\\(\\)\"]*)\\s*(\\(([\\w*\\s*]*)\\))?((\\w*)|(\".*\"))?"); 55 51 56 /** */ 52 57 private ITaskFactory taskFactory; … … 168 173 } 169 174 else { 170 IEventTarget target = targets.get(id); 171 172 if (target == null) { 173 target = new DummyGUIElement(id); 174 targets.put(id, target); 175 } 176 177 task = taskFactory.createNewEventTask(new StringEventType(type), target); 178 } 179 175 task = createUserInteractionTask(matcher); 176 } 180 177 tasks.put(id, task); 181 178 } … … 225 222 } 226 223 224 private ITask createUserInteractionTask(Matcher matcher) { 225 String evenType = matcher.group(1); 226 String id = matcher.group(2); 227 IEventTarget evenTarget = targets.get(id); 228 if(evenTarget == null) { 229 evenTarget = determineTarget(evenType, id, matcher.group(4)); 230 targets.put(id, evenTarget); 231 } 232 IEventType eventType = determineType(evenType, matcher.group(4)); 233 return taskFactory.createNewEventTask(eventType, evenTarget); 234 } 235 236 private IEventTarget determineTarget(String type, String id, String enteredText) { 237 if ("TextInput".equals(type) && enteredText != null) { 238 return new DummyTextField(enteredText); 239 } else { 240 return new DummyGUIElement(id); 241 } 242 } 243 244 private IEventType determineType(String type, String enteredText) { 245 if ("TextInput".equals(type) && enteredText != null) { 246 return new TextInput(enteredText, new ArrayList<Event>()); 247 } else { 248 return new StringEventType(type); 249 } 250 } 251 227 252 }
Note: See TracChangeset
for help on using the changeset viewer.