Changeset 751
- Timestamp:
- 09/03/12 12:05:42 (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/gui/TextInput.java
r687 r751 15 15 */ 16 16 public class TextInput implements IInteraction { 17 18 public enum TextEquality {LEXICAL, SYNTACTICAL, SEMANTICAL}; 17 19 18 20 /** */ … … 24 26 /** the text input events that caused the entering of the text */ 25 27 private List<Event> textInputEvents; 28 29 private final TextEquality equalityType; 26 30 27 31 /** … … 34 38 */ 35 39 public TextInput(String enteredText, List<Event> textInputEvents) { 40 this(enteredText, textInputEvents, TextEquality.LEXICAL); 41 } 42 43 /** 44 * <p> 45 * TODO: comment 46 * </p> 47 * 48 * @param enteredText 49 * @param textInputEvents 50 * @param equalityType 51 */ 52 public TextInput(String enteredText, List<Event> textInputEvents, TextEquality equalityType) { 36 53 this.enteredText = enteredText; 37 54 this.textInputEvents = textInputEvents; 55 this.equalityType = equalityType; 38 56 } 39 57 … … 100 118 } 101 119 else if (obj instanceof TextInput) { 102 return 103 enteredText.equals(((TextInput) obj).enteredText) && 104 textInputEvents.equals(((TextInput) obj).textInputEvents); 120 switch (equalityType) 121 { 122 case LEXICAL: 123 return textInputEvents.equals(((TextInput) obj).textInputEvents); 124 case SYNTACTICAL: 125 return enteredText.equals(((TextInput) obj).enteredText); 126 case SEMANTICAL: 127 return true; 128 default: 129 throw new AssertionError("reached source code that should be unreachable"); 130 } 105 131 } 106 132 return false; … … 114 140 @Override 115 141 public int hashCode() { 116 return getClass().hashCode() + enteredText.hashCode() + textInputEvents.size(); 142 int hashCode = getClass().hashCode(); 143 if( equalityType==TextEquality.LEXICAL) { 144 hashCode += enteredText.hashCode() + textInputEvents.size(); 145 } 146 else if( equalityType==TextEquality.SYNTACTICAL) { 147 hashCode += enteredText.hashCode(); 148 } 149 return hashCode; 117 150 } 118 151 -
trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/gui/TextInputDetector.java
r709 r751 11 11 import de.ugoe.cs.quest.eventcore.gui.KeyPressed; 12 12 import de.ugoe.cs.quest.eventcore.gui.KeyReleased; 13 import de.ugoe.cs.quest.eventcore.gui.TextInput.TextEquality; 13 14 import de.ugoe.cs.quest.eventcore.guimodel.ITextArea; 14 15 import de.ugoe.cs.quest.eventcore.guimodel.ITextField; … … 34 35 /** the keys pressed in parallel */ 35 36 List<VirtualKey> pressedKeys = new ArrayList<VirtualKey>(); 37 38 private final TextEquality textEqualityType; 39 40 public TextInputDetector() { 41 this(TextEquality.LEXICAL); 42 } 43 44 public TextInputDetector(TextEquality textEqualityType) { 45 this.textEqualityType = textEqualityType; 46 } 36 47 37 48 /** … … 156 167 157 168 if ((enteredText != null) && (!"".equals(enteredText))) { 158 TextInput textInput = new TextInput(enteredText, textInputEvents );169 TextInput textInput = new TextInput(enteredText, textInputEvents, textEqualityType); 159 170 return new Event(textInput, eventTarget); 160 171 } -
trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDdetectTextInputEvents.java
r750 r751 10 10 import de.ugoe.cs.quest.SequenceInstanceOf; 11 11 import de.ugoe.cs.quest.eventcore.Event; 12 import de.ugoe.cs.quest.eventcore.gui.TextInput.TextEquality; 12 13 import de.ugoe.cs.quest.eventcore.gui.TextInputDetector; 13 14 import de.ugoe.cs.util.console.Command; 15 import de.ugoe.cs.util.console.Console; 14 16 import de.ugoe.cs.util.console.GlobalDataContainer; 15 17 … … 31 33 @Override 32 34 public String help() { 33 return "detectTextInputEvents <sequences> {<new sequences>} ";35 return "detectTextInputEvents <sequences> {<new sequences>} {<textEqualityType>}"; 34 36 } 35 37 … … 44 46 String sequencesName; 45 47 String newSequencesName; 48 String textEqualityTypeString = "LEXICAL"; 46 49 try { 47 50 sequencesName = (String) parameters.get(0); … … 51 54 else { 52 55 newSequencesName = sequencesName; 56 } 57 if( parameters.size() > 2) { 58 textEqualityTypeString = (String) parameters.get(2); 53 59 } 54 60 } … … 67 73 return; 68 74 } 75 76 TextEquality textEqualityType = null; 77 try { 78 textEqualityType = TextEquality.valueOf(textEqualityTypeString); 79 } 80 catch (IllegalArgumentException e) { 81 Console.printerrln("Invalid mode. Only LEXICAL, SYNTACTICAL, and SEMANTICAL are allowed values!"); 82 return; 83 } 69 84 70 85 sequences = (Collection<List<Event>>) dataObject; … … 73 88 74 89 for (List<Event> sequence : sequences) { 75 newSequences.add(new TextInputDetector( ).detectTextInputs(sequence));90 newSequences.add(new TextInputDetector(textEqualityType).detectTextInputs(sequence)); 76 91 } 77 92
Note: See TracChangeset
for help on using the changeset viewer.