Changeset 1126 for trunk/autoquest-core-tasktrees
- Timestamp:
- 03/18/13 11:50:04 (12 years ago)
- Location:
- trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskTreeBuilder.java
r1114 r1126 34 34 35 35 /** 36 * 37 * @param parent 38 * @param i 39 */ 40 void setChild(ISequence parent, int index, ITaskTreeNode child); 41 42 /** 36 43 * @param sequence 37 44 * @param task … … 45 52 */ 46 53 void setChild(IIteration iteration, ITaskTreeNode newChild); 54 55 /** 56 * 57 * @param optional 58 * @param newChild 59 */ 60 void setChild(IOptional optional, ITaskTreeNode newChild); 47 61 48 62 /** … … 61 75 62 76 /** 77 * 78 * @param parent 79 * @param i 80 */ 81 void replaceChild(ISelection parent, ITaskTreeNode oldChild, ITaskTreeNode newChild); 82 83 /** 63 84 * 64 85 * @param parent -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskTreeNodeFactory.java
r1114 r1126 51 51 * @return 52 52 */ 53 IOptional createNewOptional(); 54 55 /** 56 * 57 * @return 58 */ 53 59 ISelection createNewSelection(); 54 60 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/EventTask.java
r1113 r1126 39 39 */ 40 40 EventTask(IEventType eventType, IEventTarget eventTarget) { 41 super(eventType. getName() + "(" + eventTarget + ")");42 super.setDescription( eventType + "on " + eventTarget);41 super(eventType.toString()); 42 super.setDescription("executed on " + eventTarget); 43 43 this.eventType = eventType; 44 44 this.eventTarget = eventTarget; -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/Iteration.java
r1113 r1126 42 42 // adding more children is not allowed 43 43 throw new UnsupportedOperationException 44 ("iterations may not have a list of children. Use setChild() instead.");44 ("iterations may not have a list of children. Use setChild() instead."); 45 45 } 46 46 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskTreeBuilder.java
r1113 r1126 15 15 package de.ugoe.cs.autoquest.tasktrees.treeimpl; 16 16 17 import java.util.List; 18 17 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 18 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 19 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; … … 59 62 } 60 63 64 /* (non-Javadoc) 65 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder#setChild(de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence, int, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode) 66 */ 67 @Override 68 public void setChild(ISequence parent, int index, ITaskTreeNode child) { 69 if (!(parent instanceof Sequence)) { 70 throw new IllegalArgumentException 71 ("illegal type of task tree node provided: " + parent.getClass()); 72 } 73 74 ((TaskTreeNode) parent).removeChild(index); 75 addChildInternal(parent, index, child); 76 } 77 61 78 /* 62 79 * (non-Javadoc) … … 94 111 } 95 112 113 /* (non-Javadoc) 114 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder#setChild(de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode) 115 */ 116 @Override 117 public void setChild(IOptional optional, ITaskTreeNode newChild) { 118 if (!(optional instanceof Optional)) { 119 throw new IllegalArgumentException 120 ("illegal type of optional provided: " + optional.getClass()); 121 } 122 123 if (!(newChild instanceof TaskTreeNode)) { 124 throw new IllegalArgumentException 125 ("illegal type of task tree node provided: " + newChild.getClass()); 126 } 127 128 ((Optional) optional).setChild(newChild); 129 } 130 96 131 /* 97 132 * (non-Javadoc) … … 121 156 } 122 157 123 for (int i = 0; i < parent.getChildren().size(); i++) { 124 if ((parent.getChildren().get(i) == child) || 125 ((parent.getChildren().get(i) != null) && 126 (parent.getChildren().get(i).equals(child)))) 158 List<ITaskTreeNode> children = parent.getChildren(); 159 160 for (int i = 0; i < children.size(); i++) { 161 if ((children.get(i) == child) || 162 ((children.get(i) != null) && (children.get(i).equals(child)))) 127 163 { 128 164 ((TaskTreeNode) parent).removeChild(i); … … 132 168 } 133 169 170 /* (non-Javadoc) 171 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder#replaceChild(de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode) 172 */ 173 @Override 174 public void replaceChild(ISelection parent, ITaskTreeNode oldChild, ITaskTreeNode newChild) { 175 if (!(parent instanceof TaskTreeNode)) { 176 throw new IllegalArgumentException 177 ("illegal type of task tree node provided: " + parent.getClass()); 178 } 179 180 List<ITaskTreeNode> children = parent.getChildren(); 181 182 for (int i = 0; i < children.size(); i++) { 183 if ((children.get(i) == oldChild) || 184 ((children.get(i) != null) && (children.get(i).equals(oldChild)))) 185 { 186 ((TaskTreeNode) parent).removeChild(i); 187 ((TaskTreeNode) parent).addChild(i, newChild); 188 break; 189 } 190 } 191 } 192 134 193 /* 135 194 * (non-Javadoc) -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskTreeNode.java
r1113 r1126 15 15 package de.ugoe.cs.autoquest.tasktrees.treeimpl; 16 16 17 import java.util.ArrayList; 17 import java.util.Collections; 18 import java.util.LinkedList; 18 19 import java.util.List; 19 20 … … 85 86 public synchronized List<ITaskTreeNode> getChildren() { 86 87 if ((children == null) || (children.size() == 0)) { 87 return new ArrayList<ITaskTreeNode>();88 } 89 90 return children.subList(0, children.size());88 return new LinkedList<ITaskTreeNode>(); 89 } 90 91 return Collections.unmodifiableList(children); 91 92 } 92 93 … … 154 155 @Override 155 156 public synchronized String toString() { 156 if (children == null) { 157 return name + "(" + id + ")"; 158 } 159 else { 160 return name + "(" + id + ", " + children.size() + " children)"; 161 } 157 StringBuffer result = new StringBuffer(); 158 result.append(name); 159 result.append('('); 160 result.append(id); 161 162 if (description != null) { 163 result.append(", "); 164 result.append(description); 165 } 166 167 if (children != null) { 168 result.append(", "); 169 result.append(children.size()); 170 result.append(" children"); 171 } 172 173 result.append(')'); 174 return result.toString(); 162 175 } 163 176 … … 177 190 synchronized void addChild(ITaskTreeNode child) { 178 191 if (children == null) { 179 children = new ArrayList<ITaskTreeNode>();192 children = new LinkedList<ITaskTreeNode>(); 180 193 } 181 194 … … 188 201 synchronized void addChild(int index, ITaskTreeNode child) { 189 202 if (children == null) { 190 children = new ArrayList<ITaskTreeNode>();203 children = new LinkedList<ITaskTreeNode>(); 191 204 } 192 205 … … 216 229 217 230 if (children != null) { 218 clone.children = new ArrayList<ITaskTreeNode>();231 clone.children = new LinkedList<ITaskTreeNode>(); 219 232 220 233 for (ITaskTreeNode child : children) { -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskTreeNodeFactory.java
r1113 r1126 19 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 20 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 21 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 22 23 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; … … 63 64 } 64 65 66 /* (non-Javadoc) 67 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory#createNewOptional() 68 */ 69 @Override 70 public IOptional createNewOptional() { 71 return new Optional(); 72 } 73 65 74 /* 66 75 * (non-Javadoc)
Note: See TracChangeset
for help on using the changeset viewer.