1*ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ef39d40dSAndrew Rist * distributed with this work for additional information 6*ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9*ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15*ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17*ef39d40dSAndrew Rist * specific language governing permissions and limitations 18*ef39d40dSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package util; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import com.sun.star.awt.Point; 27cdf0e10cSrcweir import com.sun.star.awt.XTopWindow; 28cdf0e10cSrcweir import com.sun.star.awt.XWindow; 29cdf0e10cSrcweir import com.sun.star.text.XTextDocument; 30cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 31cdf0e10cSrcweir 32cdf0e10cSrcweir import com.sun.star.frame.XModel; 33cdf0e10cSrcweir import com.sun.star.uno.XInterface; 34cdf0e10cSrcweir import com.sun.star.accessibility.XAccessible; 35cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleAction; 36cdf0e10cSrcweir import com.sun.star.accessibility.AccessibleRole; 37cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleComponent; 38cdf0e10cSrcweir import com.sun.star.awt.XExtendedToolkit; 39cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleContext; 40cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleEditableText; 41cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleSelection; 42cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleText; 43cdf0e10cSrcweir import com.sun.star.accessibility.XAccessibleValue; 44cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 45cdf0e10cSrcweir import java.awt.Robot; 46cdf0e10cSrcweir import java.awt.event.InputEvent; 47cdf0e10cSrcweir import java.io.PrintWriter; 48cdf0e10cSrcweir import java.util.Vector; 49cdf0e10cSrcweir import util.AccessibilityTools; 50cdf0e10cSrcweir 51cdf0e10cSrcweir 52cdf0e10cSrcweir /** 53cdf0e10cSrcweir * This class supports some functions to handle easily accessible objects 54cdf0e10cSrcweir */ 55cdf0e10cSrcweir public class UITools { 56cdf0e10cSrcweir 57cdf0e10cSrcweir private static final AccessibilityTools mAT = new AccessibilityTools(); 58cdf0e10cSrcweir private final XAccessible mXRoot; 59cdf0e10cSrcweir private final XMultiServiceFactory mMSF; 60cdf0e10cSrcweir UITools(XMultiServiceFactory msf, XModel xModel)61cdf0e10cSrcweir public UITools(XMultiServiceFactory msf, XModel xModel) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir mMSF = msf; 64cdf0e10cSrcweir mXRoot = makeRoot(mMSF, xModel); 65cdf0e10cSrcweir } 66cdf0e10cSrcweir UITools(XMultiServiceFactory msf, XTextDocument xTextDoc)67cdf0e10cSrcweir public UITools(XMultiServiceFactory msf, XTextDocument xTextDoc) 68cdf0e10cSrcweir { 69cdf0e10cSrcweir mMSF = msf; 70cdf0e10cSrcweir XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xTextDoc); 71cdf0e10cSrcweir mXRoot = makeRoot(mMSF, xModel); 72cdf0e10cSrcweir } 73cdf0e10cSrcweir UITools(XMultiServiceFactory msf, XWindow xWindow)74cdf0e10cSrcweir public UITools(XMultiServiceFactory msf, XWindow xWindow) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir mMSF = msf; 77cdf0e10cSrcweir mXRoot = makeRoot(xWindow); 78cdf0e10cSrcweir } 79cdf0e10cSrcweir makeRoot(XMultiServiceFactory msf, XModel aModel)80cdf0e10cSrcweir private static XAccessible makeRoot(XMultiServiceFactory msf, XModel aModel) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir XWindow xWindow = mAT.getCurrentWindow(msf, aModel); 83cdf0e10cSrcweir return mAT.getAccessibleObject(xWindow); 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir getString(XInterface xInt)87cdf0e10cSrcweir private static String getString(XInterface xInt) 88cdf0e10cSrcweir { 89cdf0e10cSrcweir XAccessibleText oText = (XAccessibleText) 90cdf0e10cSrcweir UnoRuntime.queryInterface(XAccessibleText.class, xInt); 91cdf0e10cSrcweir return oText.getText(); 92cdf0e10cSrcweir } 93cdf0e10cSrcweir setString(XInterface xInt, String cText)94cdf0e10cSrcweir private static void setString(XInterface xInt, String cText) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir XAccessibleEditableText oText = (XAccessibleEditableText) 97cdf0e10cSrcweir UnoRuntime.queryInterface(XAccessibleEditableText.class, xInt); 98cdf0e10cSrcweir 99cdf0e10cSrcweir oText.setText(cText); 100cdf0e10cSrcweir } 101cdf0e10cSrcweir getValue(XInterface xInt)102cdf0e10cSrcweir private static Object getValue(XInterface xInt) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir XAccessibleValue oValue = (XAccessibleValue) 105cdf0e10cSrcweir UnoRuntime.queryInterface(XAccessibleValue.class, xInt); 106cdf0e10cSrcweir return oValue.getCurrentValue(); 107cdf0e10cSrcweir } 108cdf0e10cSrcweir makeRoot(XWindow xWindow)109cdf0e10cSrcweir private static XAccessible makeRoot(XWindow xWindow) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir return mAT.getAccessibleObject(xWindow); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir /** 115cdf0e10cSrcweir * get the root element of the accessible tree 116cdf0e10cSrcweir * @return the root element 117cdf0e10cSrcweir */ getRoot()118cdf0e10cSrcweir public XAccessible getRoot() 119cdf0e10cSrcweir { 120cdf0e10cSrcweir return mXRoot; 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir /** 124cdf0e10cSrcweir * Helper mathod: set a text into AccessibleEdit field 125cdf0e10cSrcweir * @param textfiledName is the name of the text field 126cdf0e10cSrcweir * @param stringToSet is the string to set 127cdf0e10cSrcweir * @throws java.lang.Exception if something fail 128cdf0e10cSrcweir */ setTextEditFiledText(String textfiledName, String stringToSet)129cdf0e10cSrcweir public void setTextEditFiledText(String textfiledName, String stringToSet) 130cdf0e10cSrcweir throws java.lang.Exception 131cdf0e10cSrcweir { 132cdf0e10cSrcweir XInterface oTextField = mAT.getAccessibleObjectForRole(mXRoot, 133cdf0e10cSrcweir AccessibleRole.TEXT, textfiledName); 134cdf0e10cSrcweir setString(oTextField, stringToSet); 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir /** 138cdf0e10cSrcweir * returns the button by the given name 139cdf0e10cSrcweir * @param buttonName is name name of the button to get 140cdf0e10cSrcweir * @return a XAccessibleContext of the button 141cdf0e10cSrcweir * @throws java.lang.Exception if something fail 142cdf0e10cSrcweir */ getButton(String buttonName)143cdf0e10cSrcweir public XAccessibleContext getButton(String buttonName) throws java.lang.Exception 144cdf0e10cSrcweir { 145cdf0e10cSrcweir return mAT.getAccessibleObjectForRole 146cdf0e10cSrcweir (mXRoot, AccessibleRole.PUSH_BUTTON, buttonName); 147cdf0e10cSrcweir } 148cdf0e10cSrcweir 149cdf0e10cSrcweir /** 150cdf0e10cSrcweir * Helper method: gets button via accessibility and 'click' it</code> 151cdf0e10cSrcweir * @param buttonName is name name of the button to click 152cdf0e10cSrcweir * @throws java.lang.Exception if something fail 153cdf0e10cSrcweir */ 154cdf0e10cSrcweir clickButton(String buttonName)155cdf0e10cSrcweir public void clickButton(String buttonName) throws java.lang.Exception 156cdf0e10cSrcweir { 157cdf0e10cSrcweir 158cdf0e10cSrcweir XAccessibleContext oButton =mAT.getAccessibleObjectForRole 159cdf0e10cSrcweir (mXRoot, AccessibleRole.PUSH_BUTTON, buttonName); 160cdf0e10cSrcweir if (oButton == null){ 161cdf0e10cSrcweir throw new Exception("Could not get button '" + buttonName + "'"); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir XAccessibleAction oAction = (XAccessibleAction) 164cdf0e10cSrcweir UnoRuntime.queryInterface(XAccessibleAction.class, oButton); 165cdf0e10cSrcweir 166cdf0e10cSrcweir // "click" the button 167cdf0e10cSrcweir try{ 168cdf0e10cSrcweir oAction.doAccessibleAction(0); 169cdf0e10cSrcweir } catch (com.sun.star.lang.IndexOutOfBoundsException e) { 170cdf0e10cSrcweir throw new Exception("Could not do accessible action with '" + 171cdf0e10cSrcweir buttonName + "'" + e.toString()); 172cdf0e10cSrcweir } 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir 176cdf0e10cSrcweir 177cdf0e10cSrcweir /** 178cdf0e10cSrcweir * Helper method: gets button via accessibility and 'click' it 179cdf0e10cSrcweir * @param buttonName The name of the button in the accessibility tree 180cdf0e10cSrcweir * @param toBePressed desired state of the toggle button 181cdf0e10cSrcweir * 182cdf0e10cSrcweir * @return true if the state of the button could be changed in the desired manner 183cdf0e10cSrcweir */ clickToggleButton(String buttonName, boolean toBePressed)184cdf0e10cSrcweir private boolean clickToggleButton(String buttonName, boolean toBePressed) 185cdf0e10cSrcweir { 186cdf0e10cSrcweir XAccessibleContext oButton =mAT.getAccessibleObjectForRole 187cdf0e10cSrcweir (mXRoot, AccessibleRole.TOGGLE_BUTTON, buttonName); 188cdf0e10cSrcweir 189cdf0e10cSrcweir if (oButton != null){ 190cdf0e10cSrcweir boolean isChecked = oButton.getAccessibleStateSet().contains(com.sun.star.accessibility.AccessibleStateType.CHECKED); 191cdf0e10cSrcweir if((isChecked && !toBePressed) || (!isChecked && toBePressed)){ 192cdf0e10cSrcweir XAccessibleAction oAction = (XAccessibleAction) 193cdf0e10cSrcweir UnoRuntime.queryInterface(XAccessibleAction.class, oButton); 194cdf0e10cSrcweir try{ 195cdf0e10cSrcweir // "click" the button 196cdf0e10cSrcweir oAction.doAccessibleAction(0); 197cdf0e10cSrcweir return true; 198cdf0e10cSrcweir } catch (com.sun.star.lang.IndexOutOfBoundsException e) { 199cdf0e10cSrcweir System.out.println("Could not do accessible action with '" 200cdf0e10cSrcweir + buttonName + "'" + e.toString()); 201cdf0e10cSrcweir return false; 202cdf0e10cSrcweir } 203cdf0e10cSrcweir }else 204cdf0e10cSrcweir //no need to press togglebar, do nothing 205cdf0e10cSrcweir return true; 206cdf0e10cSrcweir } else{ 207cdf0e10cSrcweir System.out.println("Could not get button '" + buttonName + "'"); 208cdf0e10cSrcweir return false; 209cdf0e10cSrcweir } 210cdf0e10cSrcweir } 211cdf0e10cSrcweir 212cdf0e10cSrcweir /** 213cdf0e10cSrcweir * Deactivates toggle button via Accessibility 214cdf0e10cSrcweir * @param buttonName The name of the button in the Accessibility tree 215cdf0e10cSrcweir * 216cdf0e10cSrcweir * @return true if the button could be set to deactivated 217cdf0e10cSrcweir */ deactivateToggleButton(String buttonName)218cdf0e10cSrcweir public boolean deactivateToggleButton(String buttonName){ 219cdf0e10cSrcweir return clickToggleButton(buttonName, false); 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir /** 223cdf0e10cSrcweir * Activates toggle button via Accessibility 224cdf0e10cSrcweir * @param buttonName The name of the button in the Accessibility tree 225cdf0e10cSrcweir * 226cdf0e10cSrcweir * @return true if the button could be set to activated 227cdf0e10cSrcweir */ activateToggleButton(String buttonName)228cdf0e10cSrcweir public boolean activateToggleButton(String buttonName){ 229cdf0e10cSrcweir return clickToggleButton(buttonName, true); 230cdf0e10cSrcweir } 231cdf0e10cSrcweir 232cdf0e10cSrcweir /** 233cdf0e10cSrcweir * returns the value of named radio button 234cdf0e10cSrcweir * @param buttonName the name of the button to get the value of 235cdf0e10cSrcweir * @throws java.lang.Exception if something fail 236cdf0e10cSrcweir * @return Integer 237cdf0e10cSrcweir */ getRadioButtonValue(String buttonName)238cdf0e10cSrcweir public Integer getRadioButtonValue(String buttonName) 239cdf0e10cSrcweir throws java.lang.Exception 240cdf0e10cSrcweir { 241cdf0e10cSrcweir try { 242cdf0e10cSrcweir XInterface xRB =mAT.getAccessibleObjectForRole(mXRoot, 243cdf0e10cSrcweir AccessibleRole.RADIO_BUTTON, buttonName); 244cdf0e10cSrcweir 245cdf0e10cSrcweir return (Integer) getValue(xRB); 246cdf0e10cSrcweir } catch (Exception e) { 247cdf0e10cSrcweir throw new Exception("Could not get value from RadioButton '" 248cdf0e10cSrcweir + buttonName + "' : " + e.toString()); 249cdf0e10cSrcweir } 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir /** 253cdf0e10cSrcweir * returns the named graphic 254cdf0e10cSrcweir * @param GraphicName the name of the graphic 255cdf0e10cSrcweir * @return XInterface 256cdf0e10cSrcweir * @throws java.lang.Exception if something fail 257cdf0e10cSrcweir */ getGraphic(String GraphicName)258cdf0e10cSrcweir public XInterface getGraphic(String GraphicName) throws java.lang.Exception 259cdf0e10cSrcweir { 260cdf0e10cSrcweir return mAT.getAccessibleObjectForRole(mXRoot, AccessibleRole.GRAPHIC, 261cdf0e10cSrcweir GraphicName); 262cdf0e10cSrcweir } 263cdf0e10cSrcweir 264cdf0e10cSrcweir 265cdf0e10cSrcweir /** 266cdf0e10cSrcweir * set a named radio button the a given value 267cdf0e10cSrcweir * @param buttonName the name of the button to set 268cdf0e10cSrcweir * @param iValue the value to set 269cdf0e10cSrcweir * @throws java.lang.Exception if something fail 270cdf0e10cSrcweir */ setRadioButtonValue(String buttonName, int iValue)271cdf0e10cSrcweir public void setRadioButtonValue(String buttonName, int iValue) 272cdf0e10cSrcweir throws java.lang.Exception 273cdf0e10cSrcweir { 274cdf0e10cSrcweir try { 275cdf0e10cSrcweir XInterface xRB =mAT.getAccessibleObjectForRole(mXRoot, AccessibleRole.RADIO_BUTTON, buttonName); 276cdf0e10cSrcweir if(xRB == null) 277cdf0e10cSrcweir System.out.println("AccessibleObjectForRole couldn't be found for " + buttonName); 278cdf0e10cSrcweir XAccessibleValue oValue = (XAccessibleValue) 279cdf0e10cSrcweir UnoRuntime.queryInterface(XAccessibleValue.class, xRB); 280cdf0e10cSrcweir if(oValue == null) 281cdf0e10cSrcweir System.out.println("XAccessibleValue couldn't be queried for " + buttonName); 282cdf0e10cSrcweir oValue.setCurrentValue(new Integer(iValue)); 283cdf0e10cSrcweir } catch (Exception e) { 284cdf0e10cSrcweir e.printStackTrace(); 285cdf0e10cSrcweir 286cdf0e10cSrcweir throw new Exception("Could not set value to RadioButton '" 287cdf0e10cSrcweir + buttonName + "' : " + e.toString()); 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir } 291cdf0e10cSrcweir 292cdf0e10cSrcweir /** 293cdf0e10cSrcweir * select an item in nanmed listbox 294cdf0e10cSrcweir * @param ListBoxName the name of the listbox 295cdf0e10cSrcweir * @param nChildIndex the index of the item to set 296cdf0e10cSrcweir * @throws java.lang.Exception if something fail 297cdf0e10cSrcweir */ selectListboxItem(String ListBoxName, int nChildIndex)298cdf0e10cSrcweir public void selectListboxItem(String ListBoxName, int nChildIndex) 299cdf0e10cSrcweir throws java.lang.Exception 300cdf0e10cSrcweir { 301cdf0e10cSrcweir try { 302cdf0e10cSrcweir XAccessibleContext xListBox = null; 303cdf0e10cSrcweir 304cdf0e10cSrcweir xListBox =mAT.getAccessibleObjectForRole(mXRoot, 305cdf0e10cSrcweir AccessibleRole.COMBO_BOX, ListBoxName); 306cdf0e10cSrcweir if (xListBox == null){ 307cdf0e10cSrcweir xListBox =mAT.getAccessibleObjectForRole(mXRoot, 308cdf0e10cSrcweir AccessibleRole.PANEL, ListBoxName); 309cdf0e10cSrcweir } 310cdf0e10cSrcweir XAccessible xListBoxAccess = (XAccessible) 311cdf0e10cSrcweir UnoRuntime.queryInterface(XAccessible.class, xListBox); 312cdf0e10cSrcweir 313cdf0e10cSrcweir // if a List is not pulled to be open all entries are not visiblle, therefore the 314cdf0e10cSrcweir // boolean argument 315cdf0e10cSrcweir XAccessibleContext xList =mAT.getAccessibleObjectForRole( 316cdf0e10cSrcweir xListBoxAccess, AccessibleRole.LIST, true); 317cdf0e10cSrcweir XAccessibleSelection xListSelect = (XAccessibleSelection) 318cdf0e10cSrcweir UnoRuntime.queryInterface(XAccessibleSelection.class, xList); 319cdf0e10cSrcweir 320cdf0e10cSrcweir xListSelect.selectAccessibleChild(nChildIndex); 321cdf0e10cSrcweir 322cdf0e10cSrcweir } catch (Exception e) { 323cdf0e10cSrcweir throw new Exception("Could not select item '" +nChildIndex+ 324cdf0e10cSrcweir "' in listbox '" + ListBoxName + "' : " + e.toString()); 325cdf0e10cSrcweir } 326cdf0e10cSrcweir } 327cdf0e10cSrcweir 328cdf0e10cSrcweir /** 329cdf0e10cSrcweir * This method returns all entries as XInterface of a list box 330cdf0e10cSrcweir * @param ListBoxName the name of the listbox 331cdf0e10cSrcweir * @return Object[] containing XInterface 332cdf0e10cSrcweir * @throws java.lang.Exception if something fail 333cdf0e10cSrcweir */ 334cdf0e10cSrcweir getListBoxObjects(String ListBoxName)335cdf0e10cSrcweir public Object[] getListBoxObjects(String ListBoxName) 336cdf0e10cSrcweir throws java.lang.Exception 337cdf0e10cSrcweir { 338cdf0e10cSrcweir Vector Items = new Vector(); 339cdf0e10cSrcweir try { 340cdf0e10cSrcweir XAccessibleContext xListBox = null; 341cdf0e10cSrcweir XAccessibleContext xList = null; 342cdf0e10cSrcweir 343cdf0e10cSrcweir xListBox =mAT.getAccessibleObjectForRole(mXRoot, 344cdf0e10cSrcweir AccessibleRole.COMBO_BOX, ListBoxName); 345cdf0e10cSrcweir if (xListBox == null){ 346cdf0e10cSrcweir xListBox =mAT.getAccessibleObjectForRole(mXRoot, 347cdf0e10cSrcweir AccessibleRole.PANEL, ListBoxName); 348cdf0e10cSrcweir } 349cdf0e10cSrcweir 350cdf0e10cSrcweir if (xListBox == null){ 351cdf0e10cSrcweir // get the list of TreeListBox 352cdf0e10cSrcweir xList =mAT.getAccessibleObjectForRole(mXRoot, 353cdf0e10cSrcweir AccessibleRole.TREE, ListBoxName); 354cdf0e10cSrcweir 355cdf0e10cSrcweir // all other list boxes have a children of kind of LIST 356cdf0e10cSrcweir } else { 357cdf0e10cSrcweir 358cdf0e10cSrcweir XAccessible xListBoxAccess = (XAccessible) 359cdf0e10cSrcweir UnoRuntime.queryInterface(XAccessible.class, xListBox); 360cdf0e10cSrcweir // if a List is not pulled to be open all entries are not visiblle, therefore the 361cdf0e10cSrcweir // boolean argument 362cdf0e10cSrcweir xList =mAT.getAccessibleObjectForRole( 363cdf0e10cSrcweir xListBoxAccess, AccessibleRole.LIST, true); 364cdf0e10cSrcweir } 365cdf0e10cSrcweir 366cdf0e10cSrcweir for (int i=0;i<xList.getAccessibleChildCount();i++) { 367cdf0e10cSrcweir try { 368cdf0e10cSrcweir XAccessible xChild = xList.getAccessibleChild(i); 369cdf0e10cSrcweir XAccessibleContext xChildCont = 370cdf0e10cSrcweir xChild.getAccessibleContext(); 371cdf0e10cSrcweir XInterface xChildInterface = (XInterface) 372cdf0e10cSrcweir UnoRuntime.queryInterface(XInterface.class, xChildCont); 373cdf0e10cSrcweir Items.add(xChildInterface); 374cdf0e10cSrcweir 375cdf0e10cSrcweir } catch (com.sun.star.lang.IndexOutOfBoundsException e) { 376cdf0e10cSrcweir throw new Exception("Could not get child form list of '" 377cdf0e10cSrcweir + ListBoxName + "' : " + e.toString()); 378cdf0e10cSrcweir } 379cdf0e10cSrcweir } 380cdf0e10cSrcweir 381cdf0e10cSrcweir } catch (Exception e) { 382cdf0e10cSrcweir throw new Exception("Could not get list of items from '" 383cdf0e10cSrcweir + ListBoxName + "' : " + e.toString()); 384cdf0e10cSrcweir } 385cdf0e10cSrcweir Object[]ret = new XInterface[Items.size()]; 386cdf0e10cSrcweir for (int i=0;i<Items.size();i++){ 387cdf0e10cSrcweir ret[i] = Items.get(i); 388cdf0e10cSrcweir } 389cdf0e10cSrcweir return ret; 390cdf0e10cSrcweir } 391cdf0e10cSrcweir 392cdf0e10cSrcweir /** 393cdf0e10cSrcweir * Helper method: returns the entry manes of a List-Box 394cdf0e10cSrcweir * @param ListBoxName the name of the listbox 395cdf0e10cSrcweir * @return the listbox entry names 396cdf0e10cSrcweir * @throws java.lang.Exception if something fail 397cdf0e10cSrcweir */ 398cdf0e10cSrcweir getListBoxItems(String ListBoxName)399cdf0e10cSrcweir public String[] getListBoxItems(String ListBoxName) 400cdf0e10cSrcweir throws java.lang.Exception 401cdf0e10cSrcweir { 402cdf0e10cSrcweir Vector Items = new Vector(); 403cdf0e10cSrcweir try { 404cdf0e10cSrcweir XAccessibleContext xListBox = null; 405cdf0e10cSrcweir XAccessibleContext xList = null; 406cdf0e10cSrcweir 407cdf0e10cSrcweir xListBox =mAT.getAccessibleObjectForRole(mXRoot, 408cdf0e10cSrcweir AccessibleRole.COMBO_BOX, ListBoxName); 409cdf0e10cSrcweir if (xListBox == null){ 410cdf0e10cSrcweir xListBox =mAT.getAccessibleObjectForRole(mXRoot, 411cdf0e10cSrcweir AccessibleRole.PANEL, ListBoxName); 412cdf0e10cSrcweir } 413cdf0e10cSrcweir 414cdf0e10cSrcweir if (xListBox == null){ 415cdf0e10cSrcweir // get the list of TreeListBox 416cdf0e10cSrcweir xList =mAT.getAccessibleObjectForRole(mXRoot, 417cdf0e10cSrcweir AccessibleRole.TREE, ListBoxName); 418cdf0e10cSrcweir 419cdf0e10cSrcweir // all other list boxes have a children of kind of LIST 420cdf0e10cSrcweir } else { 421cdf0e10cSrcweir 422cdf0e10cSrcweir XAccessible xListBoxAccess = (XAccessible) 423cdf0e10cSrcweir UnoRuntime.queryInterface(XAccessible.class, xListBox); 424cdf0e10cSrcweir // if a List is not pulled to be open all entries are not visiblle, therefore the 425cdf0e10cSrcweir // boolean argument 426cdf0e10cSrcweir xList =mAT.getAccessibleObjectForRole( 427cdf0e10cSrcweir xListBoxAccess, AccessibleRole.LIST, true); 428cdf0e10cSrcweir } 429cdf0e10cSrcweir 430cdf0e10cSrcweir for (int i=0;i<xList.getAccessibleChildCount();i++) { 431cdf0e10cSrcweir try { 432cdf0e10cSrcweir XAccessible xChild = xList.getAccessibleChild(i); 433cdf0e10cSrcweir XAccessibleContext xChildCont = 434cdf0e10cSrcweir xChild.getAccessibleContext(); 435cdf0e10cSrcweir XInterface xChildInterface = (XInterface) 436cdf0e10cSrcweir UnoRuntime.queryInterface(XInterface.class, xChildCont); 437cdf0e10cSrcweir Items.add(getString(xChildInterface)); 438cdf0e10cSrcweir 439cdf0e10cSrcweir } catch (com.sun.star.lang.IndexOutOfBoundsException e) { 440cdf0e10cSrcweir throw new Exception("Could not get child form list of '" 441cdf0e10cSrcweir + ListBoxName + "' : " + e.toString()); 442cdf0e10cSrcweir } 443cdf0e10cSrcweir } 444cdf0e10cSrcweir 445cdf0e10cSrcweir } catch (Exception e) { 446cdf0e10cSrcweir throw new Exception("Could not get list of items from '" 447cdf0e10cSrcweir + ListBoxName + "' : " + e.toString()); 448cdf0e10cSrcweir } 449cdf0e10cSrcweir String[]ret = new String[Items.size()]; 450cdf0e10cSrcweir return (String[])Items.toArray(ret); 451cdf0e10cSrcweir } 452cdf0e10cSrcweir /** 453cdf0e10cSrcweir * set to a named nureric filed a given value 454cdf0e10cSrcweir * @param NumericFieldName the name of the nureic field 455cdf0e10cSrcweir * @param cValue the value to set 456cdf0e10cSrcweir * @throws java.lang.Exception if something fail 457cdf0e10cSrcweir */ setNumericFieldValue(String NumericFieldName, String cValue)458cdf0e10cSrcweir public void setNumericFieldValue(String NumericFieldName, String cValue) 459cdf0e10cSrcweir throws java.lang.Exception 460cdf0e10cSrcweir { 461cdf0e10cSrcweir try{ 462cdf0e10cSrcweir XInterface xNumericField =mAT.getAccessibleObjectForRole( 463cdf0e10cSrcweir mXRoot, AccessibleRole.TEXT, NumericFieldName); 464cdf0e10cSrcweir //util.dbg.printInterfaces(xNumericField); 465cdf0e10cSrcweir XAccessibleEditableText oValue = (XAccessibleEditableText) 466cdf0e10cSrcweir UnoRuntime.queryInterface( 467cdf0e10cSrcweir XAccessibleEditableText.class, xNumericField); 468cdf0e10cSrcweir 469cdf0e10cSrcweir setString(xNumericField, cValue); 470cdf0e10cSrcweir } catch (Exception e) { 471cdf0e10cSrcweir throw new Exception("Could not set value '" + cValue + 472cdf0e10cSrcweir "' into NumericField '" + NumericFieldName + "' : " + e.toString()); 473cdf0e10cSrcweir } 474cdf0e10cSrcweir } 475cdf0e10cSrcweir 476cdf0e10cSrcweir /** 477cdf0e10cSrcweir * returns the value of a numeric field 478cdf0e10cSrcweir * @param NumericFieldName the name of the numreic field 479cdf0e10cSrcweir * @throws java.lang.Exception if something fail 480cdf0e10cSrcweir * @return the value of the named numeric filed 481cdf0e10cSrcweir */ getNumericFieldValue(String NumericFieldName)482cdf0e10cSrcweir public String getNumericFieldValue(String NumericFieldName) 483cdf0e10cSrcweir throws java.lang.Exception 484cdf0e10cSrcweir { 485cdf0e10cSrcweir try{ 486cdf0e10cSrcweir XInterface xNumericField =mAT.getAccessibleObjectForRole( 487cdf0e10cSrcweir mXRoot, AccessibleRole.TEXT, NumericFieldName); 488cdf0e10cSrcweir return (String) getString(xNumericField); 489cdf0e10cSrcweir 490cdf0e10cSrcweir } catch (Exception e) { 491cdf0e10cSrcweir throw new Exception("Could get value from NumericField '" 492cdf0e10cSrcweir + NumericFieldName + "' : " + e.toString()); 493cdf0e10cSrcweir } 494cdf0e10cSrcweir } 495cdf0e10cSrcweir removeCharactersFromCurrencyString(String stringVal)496cdf0e10cSrcweir private String removeCharactersFromCurrencyString(String stringVal) 497cdf0e10cSrcweir throws java.lang.Exception 498cdf0e10cSrcweir { 499cdf0e10cSrcweir try{ 500cdf0e10cSrcweir int beginIndex = 0; 501cdf0e10cSrcweir int endIndex = 0; 502cdf0e10cSrcweir boolean startFound = false; 503cdf0e10cSrcweir // find the first numeric character in stringVal 504cdf0e10cSrcweir for(int i = 0; i < stringVal.length(); i++){ 505cdf0e10cSrcweir int numVal = Character.getNumericValue(stringVal.charAt(i)); 506cdf0e10cSrcweir // if ascii is a numeric value 507cdf0e10cSrcweir if (numVal != -1){ 508cdf0e10cSrcweir beginIndex = i; 509cdf0e10cSrcweir break; 510cdf0e10cSrcweir } 511cdf0e10cSrcweir } 512cdf0e10cSrcweir // find the last numeric character in stringVal 513cdf0e10cSrcweir for(int i = stringVal.length()-1; i > 0; i--){ 514cdf0e10cSrcweir int numVal = Character.getNumericValue(stringVal.charAt(i)); 515cdf0e10cSrcweir if (numVal != -1){ 516cdf0e10cSrcweir endIndex = i+1; 517cdf0e10cSrcweir break; 518cdf0e10cSrcweir } 519cdf0e10cSrcweir } 520cdf0e10cSrcweir String currencyVal = stringVal.substring(beginIndex, endIndex); 521cdf0e10cSrcweir 522cdf0e10cSrcweir currencyVal = currencyVal.substring(0, currencyVal.length()-3) + 523cdf0e10cSrcweir "#" + currencyVal.substring(currencyVal.length()-2); 524cdf0e10cSrcweir 525cdf0e10cSrcweir currencyVal = utils.replaceAll13(currencyVal, ",", ""); 526cdf0e10cSrcweir currencyVal = utils.replaceAll13(currencyVal, "\\.", ""); 527cdf0e10cSrcweir currencyVal = utils.replaceAll13(currencyVal, "#", "."); 528cdf0e10cSrcweir 529cdf0e10cSrcweir return currencyVal; 530cdf0e10cSrcweir } catch (Exception e) { 531cdf0e10cSrcweir throw new Exception("Could get remove characters from currency string '" 532cdf0e10cSrcweir + stringVal + "' : " + e.toString()); 533cdf0e10cSrcweir } 534cdf0e10cSrcweir 535cdf0e10cSrcweir } 536cdf0e10cSrcweir 537cdf0e10cSrcweir /** 538cdf0e10cSrcweir * returns the numeric value of a numeric filed. This is needed ie. for 539cdf0e10cSrcweir * fileds include the moneytary unit. 540cdf0e10cSrcweir * @param NumericFieldName the name of the numeric filed 541cdf0e10cSrcweir * @return the value of the numeric filed 542cdf0e10cSrcweir * @throws java.lang.Exception if something fail 543cdf0e10cSrcweir */ getNumericFieldNumericValue(String NumericFieldName)544cdf0e10cSrcweir public Double getNumericFieldNumericValue(String NumericFieldName) 545cdf0e10cSrcweir throws java.lang.Exception 546cdf0e10cSrcweir { 547cdf0e10cSrcweir try{ 548cdf0e10cSrcweir Double retValue = null; 549cdf0e10cSrcweir String sValue = getNumericFieldValue(NumericFieldName); 550cdf0e10cSrcweir String sAmount = removeCharactersFromCurrencyString(sValue); 551cdf0e10cSrcweir retValue = retValue.valueOf(sAmount); 552cdf0e10cSrcweir 553cdf0e10cSrcweir return retValue; 554cdf0e10cSrcweir 555cdf0e10cSrcweir } catch (Exception e) { 556cdf0e10cSrcweir throw new Exception("Could get numeric value from NumericField '" 557cdf0e10cSrcweir + NumericFieldName + "' : " + e.toString()); 558cdf0e10cSrcweir } 559cdf0e10cSrcweir } 560cdf0e10cSrcweir 561cdf0e10cSrcweir 562cdf0e10cSrcweir /** 563cdf0e10cSrcweir * returns the content of a TextBox 564cdf0e10cSrcweir * @param TextFieldName the name of the textbox 565cdf0e10cSrcweir * @return the value of the text box 566cdf0e10cSrcweir * @throws java.lang.Exception if something fail 567cdf0e10cSrcweir */ getTextBoxText(String TextFieldName)568cdf0e10cSrcweir public String getTextBoxText(String TextFieldName) 569cdf0e10cSrcweir throws java.lang.Exception 570cdf0e10cSrcweir { 571cdf0e10cSrcweir String TextFieldText = null; 572cdf0e10cSrcweir try{ 573cdf0e10cSrcweir XAccessibleContext xTextField =mAT.getAccessibleObjectForRole(mXRoot, 574cdf0e10cSrcweir AccessibleRole.SCROLL_PANE, TextFieldName); 575cdf0e10cSrcweir XAccessible xTextFieldAccess = (XAccessible) 576cdf0e10cSrcweir UnoRuntime.queryInterface(XAccessible.class, xTextField); 577cdf0e10cSrcweir XAccessibleContext xFrame =mAT.getAccessibleObjectForRole( 578cdf0e10cSrcweir xTextFieldAccess, AccessibleRole.TEXT_FRAME); 579cdf0e10cSrcweir for (int i=0;i<xFrame.getAccessibleChildCount();i++) { 580cdf0e10cSrcweir try { 581cdf0e10cSrcweir XAccessible xChild = xFrame.getAccessibleChild(i); 582cdf0e10cSrcweir XAccessibleContext xChildCont = 583cdf0e10cSrcweir xChild.getAccessibleContext(); 584cdf0e10cSrcweir XInterface xChildInterface = (XInterface) 585cdf0e10cSrcweir UnoRuntime.queryInterface(XInterface.class, xChildCont); 586cdf0e10cSrcweir TextFieldText += (getString(xChildInterface)); 587cdf0e10cSrcweir 588cdf0e10cSrcweir } catch (com.sun.star.lang.IndexOutOfBoundsException e) { 589cdf0e10cSrcweir throw new Exception("Could not get child fom TextFrame of '" 590cdf0e10cSrcweir + TextFieldName + "' : " + e.toString()); 591cdf0e10cSrcweir } 592cdf0e10cSrcweir } 593cdf0e10cSrcweir return TextFieldText; 594cdf0e10cSrcweir } catch (Exception e) { 595cdf0e10cSrcweir throw new Exception("Could not get content fom Textbox '" 596cdf0e10cSrcweir + TextFieldName + "' : " + e.toString()); 597cdf0e10cSrcweir } 598cdf0e10cSrcweir } 599cdf0e10cSrcweir 600cdf0e10cSrcweir /** 601cdf0e10cSrcweir * set a value to a named check box 602cdf0e10cSrcweir * @param CheckBoxName the name of the check box 603cdf0e10cSrcweir * @param Value the value to set 604cdf0e10cSrcweir *<ul> 605cdf0e10cSrcweir * <li>0: not checked </li> 606cdf0e10cSrcweir * <li>1: checked </li> 607cdf0e10cSrcweir * <li>2: don't know </li> 608cdf0e10cSrcweir *</ul> 609cdf0e10cSrcweir * @throws java.lang.Exception if something fail 610cdf0e10cSrcweir */ setCheckBoxValue(String CheckBoxName, Integer Value)611cdf0e10cSrcweir public void setCheckBoxValue(String CheckBoxName, Integer Value) 612cdf0e10cSrcweir throws java.lang.Exception 613cdf0e10cSrcweir { 614cdf0e10cSrcweir try { 615cdf0e10cSrcweir XInterface xCheckBox =mAT.getAccessibleObjectForRole(mXRoot, 616cdf0e10cSrcweir AccessibleRole.CHECK_BOX, CheckBoxName); 617cdf0e10cSrcweir XAccessibleValue xCheckBoxValue = (XAccessibleValue) 618cdf0e10cSrcweir UnoRuntime.queryInterface(XAccessibleValue.class, xCheckBox); 619cdf0e10cSrcweir xCheckBoxValue.setCurrentValue(Value); 620cdf0e10cSrcweir 621cdf0e10cSrcweir } catch (Exception e) { 622cdf0e10cSrcweir throw new Exception("Could not set value to CheckBox '" 623cdf0e10cSrcweir + CheckBoxName + "' : " + e.toString()); 624cdf0e10cSrcweir } 625cdf0e10cSrcweir } 626cdf0e10cSrcweir 627cdf0e10cSrcweir /** 628cdf0e10cSrcweir * returns the value of the named check box 629cdf0e10cSrcweir * @param CheckBoxName the name of the check box 630cdf0e10cSrcweir * @return the value of the check box 631cdf0e10cSrcweir * @throws java.lang.Exception if something fail 632cdf0e10cSrcweir */ getCheckBoxValue(String CheckBoxName)633cdf0e10cSrcweir public Integer getCheckBoxValue(String CheckBoxName) 634cdf0e10cSrcweir throws java.lang.Exception 635cdf0e10cSrcweir { 636cdf0e10cSrcweir try { 637cdf0e10cSrcweir XInterface xCheckBox =mAT.getAccessibleObjectForRole(mXRoot, 638cdf0e10cSrcweir AccessibleRole.CHECK_BOX, CheckBoxName); 639cdf0e10cSrcweir XAccessibleValue xCheckBoxValue = (XAccessibleValue) 640cdf0e10cSrcweir UnoRuntime.queryInterface(XAccessibleValue.class, xCheckBox); 641cdf0e10cSrcweir 642cdf0e10cSrcweir return (Integer) xCheckBoxValue.getCurrentValue(); 643cdf0e10cSrcweir } catch (Exception e) { 644cdf0e10cSrcweir throw new Exception("Could not set value to CheckBox '" 645cdf0e10cSrcweir + CheckBoxName + "' : " + e.toString()); 646cdf0e10cSrcweir } 647cdf0e10cSrcweir } 648cdf0e10cSrcweir 649cdf0e10cSrcweir /** 650cdf0e10cSrcweir * returns the message of a Basic-MessageBox 651cdf0e10cSrcweir * @return the message of a Basic-MessageBox 652cdf0e10cSrcweir * @throws java.lang.Exception if something fail 653cdf0e10cSrcweir */ getMsgBoxText()654cdf0e10cSrcweir public String getMsgBoxText() 655cdf0e10cSrcweir throws java.lang.Exception 656cdf0e10cSrcweir { 657cdf0e10cSrcweir String cMessage = null; 658cdf0e10cSrcweir try{ 659cdf0e10cSrcweir XAccessibleContext xMessage =mAT.getAccessibleObjectForRole(mXRoot, 660cdf0e10cSrcweir AccessibleRole.LABEL); 661cdf0e10cSrcweir 662cdf0e10cSrcweir XInterface xMessageInterface = (XInterface) 663cdf0e10cSrcweir UnoRuntime.queryInterface(XInterface.class, xMessage); 664cdf0e10cSrcweir cMessage += (getString(xMessageInterface)); 665cdf0e10cSrcweir 666cdf0e10cSrcweir 667cdf0e10cSrcweir return cMessage; 668cdf0e10cSrcweir } catch (Exception e) { 669cdf0e10cSrcweir throw new Exception("Could not get message from Basic-MessageBox: " + e.toString()); 670cdf0e10cSrcweir } 671cdf0e10cSrcweir } 672cdf0e10cSrcweir 673cdf0e10cSrcweir /** 674cdf0e10cSrcweir * fetch the window which is equal to the given <CODE>WindowName</CODE> 675cdf0e10cSrcweir * @return the named window 676cdf0e10cSrcweir * @throws java.lang.Exception if something fail 677cdf0e10cSrcweir */ getTopWindow(String WindowName, boolean debug)678cdf0e10cSrcweir public XWindow getTopWindow(String WindowName, boolean debug) throws java.lang.Exception 679cdf0e10cSrcweir { 680cdf0e10cSrcweir XInterface xToolKit = null; 681cdf0e10cSrcweir try { 682cdf0e10cSrcweir xToolKit = (XInterface) mMSF.createInstance("com.sun.star.awt.Toolkit") ; 683cdf0e10cSrcweir } catch (com.sun.star.uno.Exception e) { 684cdf0e10cSrcweir throw new Exception("Could not toolkit: " + e.toString()); 685cdf0e10cSrcweir } 686cdf0e10cSrcweir XExtendedToolkit tk = (XExtendedToolkit) 687cdf0e10cSrcweir UnoRuntime.queryInterface(XExtendedToolkit.class, xToolKit); 688cdf0e10cSrcweir 689cdf0e10cSrcweir int count = tk.getTopWindowCount(); 690cdf0e10cSrcweir 691cdf0e10cSrcweir XTopWindow retWindow = null; 692cdf0e10cSrcweir 693cdf0e10cSrcweir if (debug) System.out.println("getTopWindow ->"); 694cdf0e10cSrcweir 695cdf0e10cSrcweir for (int i=0; i < count ; i++){ 696cdf0e10cSrcweir XTopWindow xTopWindow = tk.getTopWindow(i); 697cdf0e10cSrcweir XAccessible xAcc = mAT.getAccessibleObject(xTopWindow); 698cdf0e10cSrcweir String accName = xAcc.getAccessibleContext().getAccessibleName(); 699cdf0e10cSrcweir 700cdf0e10cSrcweir if (debug){ 701cdf0e10cSrcweir System.out.println("AccessibleName: " + accName); 702cdf0e10cSrcweir } 703cdf0e10cSrcweir 704cdf0e10cSrcweir if (WindowName.equals(accName)){ 705cdf0e10cSrcweir if (debug) System.out.println("-> found window with name '" + WindowName + "'"); 706cdf0e10cSrcweir retWindow = xTopWindow; 707cdf0e10cSrcweir } 708cdf0e10cSrcweir } 709cdf0e10cSrcweir 710cdf0e10cSrcweir 711cdf0e10cSrcweir if (debug) { 712cdf0e10cSrcweir if (retWindow == null) System.out.println("could not found window with name '" + WindowName + "'"); 713cdf0e10cSrcweir System.out.println("<- getTopWindow "); 714cdf0e10cSrcweir } 715cdf0e10cSrcweir return (XWindow) UnoRuntime.queryInterface(XWindow.class, retWindow); 716cdf0e10cSrcweir } 717cdf0e10cSrcweir clickMiddleOfAccessibleObject(short role, String name)718cdf0e10cSrcweir public void clickMiddleOfAccessibleObject(short role, String name){ 719cdf0e10cSrcweir 720cdf0e10cSrcweir XAccessibleContext xAcc =mAT.getAccessibleObjectForRole(mXRoot, role, name); 721cdf0e10cSrcweir XAccessibleComponent aComp = (XAccessibleComponent) UnoRuntime.queryInterface( 722cdf0e10cSrcweir XAccessibleComponent.class, xAcc); 723cdf0e10cSrcweir 724cdf0e10cSrcweir System.out.println(xAcc.getAccessibleRole() + "," + 725cdf0e10cSrcweir xAcc.getAccessibleName() + "(" + 726cdf0e10cSrcweir xAcc.getAccessibleDescription() + "):" + 727cdf0e10cSrcweir utils.getImplName(xAcc)); 728cdf0e10cSrcweir 729cdf0e10cSrcweir if (aComp != null) { 730cdf0e10cSrcweir Point location = aComp.getLocationOnScreen(); 731cdf0e10cSrcweir String bounds = "(" + aComp.getBounds().X + "," + 732cdf0e10cSrcweir aComp.getBounds().Y + ")" + " (" + 733cdf0e10cSrcweir aComp.getBounds().Width + "," + 734cdf0e10cSrcweir aComp.getBounds().Height + ")"; 735cdf0e10cSrcweir System.out.println("The boundary Rectangle is " + bounds); 736cdf0e10cSrcweir try { 737cdf0e10cSrcweir Robot rob = new Robot(); 738cdf0e10cSrcweir int x = aComp.getLocationOnScreen().X + (aComp.getBounds().Width / 2); 739cdf0e10cSrcweir int y = aComp.getLocationOnScreen().Y + (aComp.getBounds().Height / 2); 740cdf0e10cSrcweir System.out.println("try to click mouse button on x/y " + x + "/" + y); 741cdf0e10cSrcweir rob.mouseMove(x, y); 742cdf0e10cSrcweir rob.mousePress(InputEvent.BUTTON1_MASK); 743cdf0e10cSrcweir rob.mouseRelease(InputEvent.BUTTON1_MASK); 744cdf0e10cSrcweir } catch (java.awt.AWTException e) { 745cdf0e10cSrcweir System.out.println("couldn't press mouse button"); 746cdf0e10cSrcweir } 747cdf0e10cSrcweir 748cdf0e10cSrcweir } 749cdf0e10cSrcweir } 750cdf0e10cSrcweir doubleClickMiddleOfAccessibleObject(short role, String name)751cdf0e10cSrcweir public void doubleClickMiddleOfAccessibleObject(short role, String name) { 752cdf0e10cSrcweir XAccessibleContext xAcc =mAT.getAccessibleObjectForRole(mXRoot, role, name); 753cdf0e10cSrcweir XAccessibleComponent aComp = (XAccessibleComponent) UnoRuntime.queryInterface( 754cdf0e10cSrcweir XAccessibleComponent.class, xAcc); 755cdf0e10cSrcweir 756cdf0e10cSrcweir System.out.println(xAcc.getAccessibleRole() + "," + 757cdf0e10cSrcweir xAcc.getAccessibleName() + "(" + 758cdf0e10cSrcweir xAcc.getAccessibleDescription() + "):" + 759cdf0e10cSrcweir utils.getImplName(xAcc)); 760cdf0e10cSrcweir 761cdf0e10cSrcweir if (aComp != null) { 762cdf0e10cSrcweir Point location = aComp.getLocationOnScreen(); 763cdf0e10cSrcweir String bounds = "(" + aComp.getBounds().X + "," + 764cdf0e10cSrcweir aComp.getBounds().Y + ")" + " (" + 765cdf0e10cSrcweir aComp.getBounds().Width + "," + 766cdf0e10cSrcweir aComp.getBounds().Height + ")"; 767cdf0e10cSrcweir System.out.println("The boundary Rectangle is " + bounds); 768cdf0e10cSrcweir try { 769cdf0e10cSrcweir Robot rob = new Robot(); 770cdf0e10cSrcweir int x = aComp.getLocationOnScreen().X + (aComp.getBounds().Width / 2); 771cdf0e10cSrcweir int y = aComp.getLocationOnScreen().Y + (aComp.getBounds().Height / 2); 772cdf0e10cSrcweir System.out.println("try to double click mouse button on x/y " + x + "/" + y); 773cdf0e10cSrcweir rob.mouseMove(x, y); 774cdf0e10cSrcweir rob.mousePress(InputEvent.BUTTON1_MASK); 775cdf0e10cSrcweir rob.mouseRelease(InputEvent.BUTTON1_MASK); 776cdf0e10cSrcweir utils.shortWait(100); 777cdf0e10cSrcweir rob.mousePress(InputEvent.BUTTON1_MASK); 778cdf0e10cSrcweir rob.mouseRelease(InputEvent.BUTTON1_MASK); 779cdf0e10cSrcweir } catch (java.awt.AWTException e) { 780cdf0e10cSrcweir System.out.println("couldn't press mouse button"); 781cdf0e10cSrcweir } 782cdf0e10cSrcweir 783cdf0e10cSrcweir } 784cdf0e10cSrcweir } 785cdf0e10cSrcweir 786cdf0e10cSrcweir /** 787cdf0e10cSrcweir * <B>DEPRECATED</B> 788cdf0e10cSrcweir * Since <CODE>AccessibilityTools</CODE> handle parameter <CODE>debugIsActive</CODE> 789cdf0e10cSrcweir * this function does not work anymore. 790cdf0e10cSrcweir * @deprecated Since <CODE>AccessibilityTools</CODE> handle parameter <CODE>debugIsActive</CODE> 791cdf0e10cSrcweir * this function does not work anymore. 792cdf0e10cSrcweir * @param log logWriter 793cdf0e10cSrcweir */ printAccessibleTree(PrintWriter log)794cdf0e10cSrcweir public void printAccessibleTree(PrintWriter log) 795cdf0e10cSrcweir { 796cdf0e10cSrcweir mAT.printAccessibleTree(log, mXRoot); 797cdf0e10cSrcweir } 798cdf0e10cSrcweir 799cdf0e10cSrcweir 800cdf0e10cSrcweir /** 801cdf0e10cSrcweir * Prints the accessible tree to the <CODE>logWriter</CODE> only if <CODE>debugIsActive</CODE> 802cdf0e10cSrcweir * is set to <CODE>true</CODE> 803cdf0e10cSrcweir * @param log logWriter 804cdf0e10cSrcweir * @param debugIsActive prints only if this parameter is set to TRUE 805cdf0e10cSrcweir */ printAccessibleTree(PrintWriter log, boolean debugIsActive)806cdf0e10cSrcweir public void printAccessibleTree(PrintWriter log, boolean debugIsActive) { 807cdf0e10cSrcweir mAT.printAccessibleTree(log, mXRoot, debugIsActive); 808cdf0e10cSrcweir } 809cdf0e10cSrcweir 810cdf0e10cSrcweir } 811