AccessibilityChooser.java revision 13978:1993af50385d
1193323Sed/*
2193323Sed * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3193323Sed * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4193323Sed *
5193323Sed * This code is free software; you can redistribute it and/or modify it
6193323Sed * under the terms of the GNU General Public License version 2 only, as
7193323Sed * published by the Free Software Foundation.
8193323Sed *
9193323Sed * This code is distributed in the hope that it will be useful, but WITHOUT
10193323Sed * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11193323Sed * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12193323Sed * version 2 for more details (a copy is included in the LICENSE file that
13193323Sed * accompanied this code).
14193323Sed *
15193323Sed * You should have received a copy of the GNU General Public License version
16193323Sed * 2 along with this work; if not, write to the Free Software Foundation,
17193323Sed * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18193323Sed *
19193323Sed * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20193323Sed * or visit www.oracle.com if you need additional information or have any
21193323Sed * questions.
22193323Sed */
23193323Sedpackage org.netbeans.jemmy.accessibility;
24193323Sed
25193323Sedimport java.awt.Component;
26193323Sed
27193323Sedimport javax.accessibility.AccessibleContext;
28193323Sedimport javax.swing.JComponent;
29193323Sedimport javax.swing.JDialog;
30198090Srdivackyimport javax.swing.JFrame;
31193323Sedimport javax.swing.JWindow;
32193323Sed
33193323Sedimport org.netbeans.jemmy.ComponentChooser;
34193323Sed
35193323Sedpublic abstract class AccessibilityChooser implements ComponentChooser {
36193323Sed
37193323Sed    @Override
38193323Sed    public final boolean checkComponent(Component comp) {
39193323Sed        if (comp instanceof JComponent) {
40193323Sed            return checkContext(comp.getAccessibleContext());
41193323Sed        } else if (comp instanceof JDialog) {
42193323Sed            return checkContext(comp.getAccessibleContext());
43193323Sed        } else if (comp instanceof JFrame) {
44193323Sed            return checkContext(comp.getAccessibleContext());
45193323Sed        } else if (comp instanceof JWindow) {
46193323Sed            return checkContext(comp.getAccessibleContext());
47193323Sed        } else {
48193323Sed            return false;
49193323Sed        }
50193323Sed    }
51193323Sed
52193323Sed    public abstract boolean checkContext(AccessibleContext context);
53193323Sed}
54193323Sed