source: trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/visitors/ContainsEventVisitor.java @ 1293

Last change on this file since 1293 was 1293, checked in by adeicke, 11 years ago

Added possibility to consider event target in interaction patterns.

  • Property svn:mime-type set to text/plain
File size: 3.2 KB
Line 
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
15package de.ugoe.cs.autoquest.usability.rules.patterns.visitors;
16
17import java.util.List;
18
19import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration;
20import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional;
21import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence;
22import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
23import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPatternVisitor;
24import de.ugoe.cs.autoquest.usability.taskmodel.filter.types.EventTargetFilter;
25import de.ugoe.cs.autoquest.usability.taskmodel.filter.types.EventTypeFilter;
26import de.ugoe.cs.autoquest.usability.taskmodel.filter.types.TaskTypeFilter;
27
28/**
29 * <p>
30 * TODO comment
31 * </p>
32 *
33 * @author Alexander Deicke
34 */
35public class ContainsEventVisitor extends InteractionPatternVisitor {
36
37    /**
38     * <p>
39     * TODO: comment
40     * </p>
41     *
42     * @param containsType
43     */
44    public ContainsEventVisitor(EventTypeFilter containsType, TaskTypeFilter taskType) {
45        this.eventType = containsType;
46        this.taskType = taskType;
47    }
48
49        public ContainsEventVisitor(EventTypeFilter eventType,
50                        EventTargetFilter eventTarget, TaskTypeFilter taskType) {
51                this.eventType = eventType;
52                this.eventTarget = eventTarget;
53                this.taskType = taskType;
54        }
55
56        /*
57     * (non-Javadoc)
58     *
59     * @see
60     * de.ugoe.cs.autoquest.tasktrees.treeifc.NodeVisitor#visit(de.ugoe.cs.autoquest.tasktrees.treeifc
61     * .IIteration)
62     */
63    public void visit(IIteration iteration) {
64        checkTaskAndReturnIfPatternIsPresent(iteration.getMarkedTask());
65    }
66
67    /*
68     * (non-Javadoc)
69     *
70     * @see
71     * de.ugoe.cs.autoquest.tasktrees.treeifc.TaskVisitor#visit(de.ugoe.cs.autoquest.tasktrees.treeifc
72     * .IOptional)
73     */
74    public void visit(IOptional optional) {
75        checkTaskAndReturnIfPatternIsPresent(optional.getMarkedTask());
76    }
77
78    /*
79     * (non-Javadoc)
80     *
81     * @see
82     * de.ugoe.cs.autoquest.tasktrees.treeifc.NodeVisitor#visit(de.ugoe.cs.autoquest.tasktrees.treeifc
83     * .ISequence)
84     */
85    public void visit(ISequence sequence) {
86        checkAllChildrenAndReturnIfPatternIsPresent(sequence.getChildren());
87    }
88
89    private void checkAllChildrenAndReturnIfPatternIsPresent(List<ITask> children) {
90        for (ITask task : children) {
91            if (checkTaskAndReturnIfPatternIsPresent(task)) {
92                break;
93            }
94        }
95    }
96
97    /**
98     *
99     */
100    private boolean checkTaskAndReturnIfPatternIsPresent(ITask task) {
101        task.accept(this);
102        return this.present;
103    }
104}
Note: See TracBrowser for help on using the repository browser.