Changeset 751 for trunk/quest-core-events/src/main/java
- Timestamp:
- 09/03/12 12:05:42 (12 years ago)
- Location:
- trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/gui
- Files:
-
- 2 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 }
Note: See TracChangeset
for help on using the changeset viewer.