source: trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filters/EventTypeFilter.java @ 1152

Last change on this file since 1152 was 1152, checked in by pharms, 11 years ago
  • complete refactoring of task tree model with a separation of task models and task instances
  • Property svn:mime-type set to text/plain
File size: 2.8 KB
RevLine 
[1040]1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
[1135]15package de.ugoe.cs.autoquest.usability.tasktree.filters;
[1030]16
17import com.google.common.base.Function;
18import com.google.common.base.Predicate;
19import com.google.common.base.Predicates;
20
21import de.ugoe.cs.autoquest.eventcore.IEventType;
[1040]22import de.ugoe.cs.autoquest.eventcore.gui.IInteraction;
[1030]23import de.ugoe.cs.autoquest.eventcore.gui.MouseButtonInteraction;
[1150]24import de.ugoe.cs.autoquest.eventcore.gui.MouseClick;
[1030]25import de.ugoe.cs.autoquest.eventcore.gui.MouseInteraction;
[1150]26import de.ugoe.cs.autoquest.eventcore.gui.Scroll;
[1030]27import de.ugoe.cs.autoquest.eventcore.gui.TextInput;
28import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask;
[1152]29import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
[1030]30
[1040]31/**
32 * <p>
33 * TODO comment
34 * </p>
35 *
36 * @author Alexander Deicke
37 */
[1152]38public enum EventTypeFilter implements TaskFilter<IEventType> {
[1040]39
40    MOUSE_BUTTON_INTERACTION(MouseButtonInteraction.class),
[1030]41   
[1150]42    MOUSE_CLICK(MouseClick.class),
43   
[1030]44    MOUSE_INTERACTION(MouseInteraction.class),
45   
[1040]46    TEXT_INPUT(TextInput.class),
[1030]47   
[1150]48    SCROLL(Scroll.class),
49   
[1040]50    USER_INTERACTION(IInteraction.class);
51
[1030]52    private Class<? extends IEventType> eventTypeClazz;
[1040]53
[1030]54    private EventTypeFilter(Class<? extends IEventType> eventTypeClazz) {
55        this.eventTypeClazz = eventTypeClazz;
56    }
[1150]57   
[1030]58    @SuppressWarnings("unchecked")
59    @Override
60    public Class<IEventType> clazz() {
61        return (Class<IEventType>) eventTypeClazz;
62    }
[1040]63
[1030]64    @SuppressWarnings("rawtypes")
65    @Override
66    public Predicate filterPredicate() {
67        Predicate<Object> instanceOfIEventTaskPredicate = Predicates.instanceOf(IEventTask.class);
[1152]68        Predicate<ITask> taskHoldsInstanceOfFilterArgument =
69            Predicates.compose(Predicates.instanceOf(eventTypeClazz), taskExtractionFunction());
70        return Predicates.and(instanceOfIEventTaskPredicate, taskHoldsInstanceOfFilterArgument);
[1030]71    }
[1040]72
[1152]73    private Function<ITask, IEventType> taskExtractionFunction() {
74        return new Function<ITask, IEventType>() {
[1040]75
[1030]76            @Override
[1152]77            public IEventType apply(ITask task) {
78                return ((IEventTask) task).getEventType();
[1030]79            }
80        };
81    }
[1040]82}
Note: See TracBrowser for help on using the repository browser.