Ignore:
Timestamp:
09/03/12 12:05:42 (12 years ago)
Author:
sherbold
Message:
  • TextInput? events can now be configured to support a specific type of equality: Lexical, Syntactical, and Semantical
  • the command detextTestInputEvents now allows the definition of the equality of the generated TextInput? events (see above)
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  
    1515 */ 
    1616public class TextInput implements IInteraction { 
     17     
     18    public enum TextEquality {LEXICAL, SYNTACTICAL, SEMANTICAL}; 
    1719 
    1820    /**  */ 
     
    2426    /** the text input events that caused the entering of the text */ 
    2527    private List<Event> textInputEvents; 
     28     
     29    private final TextEquality equalityType; 
    2630 
    2731    /** 
     
    3438     */ 
    3539    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) { 
    3653        this.enteredText = enteredText; 
    3754        this.textInputEvents = textInputEvents; 
     55        this.equalityType = equalityType; 
    3856    } 
    3957 
     
    100118        } 
    101119        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            } 
    105131        } 
    106132        return false; 
     
    114140    @Override 
    115141    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; 
    117150    } 
    118151 
  • trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/gui/TextInputDetector.java

    r709 r751  
    1111import de.ugoe.cs.quest.eventcore.gui.KeyPressed; 
    1212import de.ugoe.cs.quest.eventcore.gui.KeyReleased; 
     13import de.ugoe.cs.quest.eventcore.gui.TextInput.TextEquality; 
    1314import de.ugoe.cs.quest.eventcore.guimodel.ITextArea; 
    1415import de.ugoe.cs.quest.eventcore.guimodel.ITextField; 
     
    3435    /** the keys pressed in parallel */ 
    3536    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    } 
    3647 
    3748    /** 
     
    156167         
    157168        if ((enteredText != null) && (!"".equals(enteredText))) { 
    158             TextInput textInput = new TextInput(enteredText, textInputEvents); 
     169            TextInput textInput = new TextInput(enteredText, textInputEvents, textEqualityType); 
    159170            return new Event(textInput, eventTarget); 
    160171        } 
Note: See TracChangeset for help on using the changeset viewer.