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