source: trunk/autoquest-plugin-usability2/src/main/java/de/ugoe/cs/autoquest/plugin/usability2/rules/operator/filter/KeyPressFilter.java @ 1326

Last change on this file since 1326 was 1326, checked in by khartmann, 10 years ago

Moved alexanders code into a new plugin project.
First commit of my experimental code (needs a lot of cleanup).

File size: 1.1 KB
Line 
1package de.ugoe.cs.autoquest.plugin.usability2.rules.operator.filter;
2
3import de.ugoe.cs.autoquest.eventcore.IEventType;
4import de.ugoe.cs.autoquest.eventcore.gui.KeyInteraction;
5import de.ugoe.cs.autoquest.eventcore.gui.KeyPressed;
6import de.ugoe.cs.autoquest.keyboardmaps.VirtualKey;
7import de.ugoe.cs.autoquest.plugin.usability2.rules.results.IResult;
8import de.ugoe.cs.autoquest.plugin.usability2.rules.results.UnmatchableResult;
9import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
10
11public class KeyPressFilter extends EventTypeFilter {
12    VirtualKey key;
13   
14    public KeyPressFilter(VirtualKey key) {
15        super(KeyPressed.class);
16        this.key = key;
17    }
18
19    @Override
20    public IResult match(ITask task) {
21        IResult match = super.match(task);
22        if(match.isPresent()) {
23            IEventType type = getType(task);
24            if (type instanceof KeyInteraction) {
25                VirtualKey key = ((KeyInteraction) type).getKey();
26                if(key.equals(this.key))
27                    return match;
28            }
29        }
30        return UnmatchableResult.NO_MATCH_FOUND;
31    }
32
33}
Note: See TracBrowser for help on using the repository browser.