1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package org.openoffice.java.accessibility; 25 26 27 public class FocusTraversalPolicy extends java.awt.FocusTraversalPolicy { 28 getSelectedAccessibleChild(javax.accessibility.Accessible a)29 protected javax.accessibility.Accessible getSelectedAccessibleChild(javax.accessibility.Accessible a) { 30 javax.accessibility.AccessibleContext ac = a.getAccessibleContext(); 31 if (ac != null) { 32 javax.accessibility.AccessibleSelection as = ac.getAccessibleSelection(); 33 if (as != null) { 34 return as.getAccessibleSelection(0); 35 } 36 } 37 return null; 38 } 39 40 /** Returns the Component that should receive the focus after aComponent */ getComponentAfter(java.awt.Container focusCycleRoot, java.awt.Component aComponent)41 public java.awt.Component getComponentAfter(java.awt.Container focusCycleRoot, 42 java.awt.Component aComponent) { 43 return null; 44 } 45 46 /** Returns the Component that should receive the focus before aComponent */ getComponentBefore(java.awt.Container focusCycleRoot, java.awt.Component aComponent)47 public java.awt.Component getComponentBefore(java.awt.Container focusCycleRoot, 48 java.awt.Component aComponent) { 49 return null; 50 } 51 52 /** Returns the default Component to focus */ getDefaultComponent(java.awt.Container focusCycleRoot)53 public java.awt.Component getDefaultComponent(java.awt.Container focusCycleRoot) { 54 // getDefaultComponent must not return null for Windows to make them focusable. 55 if (focusCycleRoot instanceof NativeFrame) { 56 java.awt.Component c = ((NativeFrame) focusCycleRoot).getInitialComponent(); 57 if (c != null) { 58 return c; 59 } 60 } 61 62 if (focusCycleRoot instanceof javax.accessibility.Accessible) { 63 return (java.awt.Component) getSelectedAccessibleChild((javax.accessibility.Accessible) focusCycleRoot); 64 } 65 return null; 66 } 67 68 /** Returns the first Component in the traversal cycle */ getFirstComponent(java.awt.Container focusCycleRoot)69 public java.awt.Component getFirstComponent(java.awt.Container focusCycleRoot) { 70 return null; 71 } 72 73 /** Returns the Component that should receive the focus when a Window is made visible for the first time */ getInitialComponent(java.awt.Window window)74 public java.awt.Component getInitialComponent(java.awt.Window window) { 75 if (window instanceof NativeFrame) { 76 return ((NativeFrame) window).getInitialComponent(); 77 } 78 return null; 79 } 80 81 /** Returns the last Component in the traversal cycle */ getLastComponent(java.awt.Container focusCycleRoot)82 public java.awt.Component getLastComponent(java.awt.Container focusCycleRoot) { 83 return null; 84 } 85 } 86