< prev index next >

src/org/netbeans/jemmy/operators/WindowOperator.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation. Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package org.netbeans.jemmy.operators;
  26 
  27 import java.awt.Component;
  28 import java.awt.Window;
  29 import java.awt.event.WindowListener;
  30 import java.lang.reflect.InvocationTargetException;
  31 import java.util.ResourceBundle;
  32 
  33 import org.netbeans.jemmy.ClassReference;
  34 import org.netbeans.jemmy.ComponentChooser;
  35 import org.netbeans.jemmy.ComponentSearcher;
  36 import org.netbeans.jemmy.JemmyException;
  37 import org.netbeans.jemmy.JemmyProperties;
  38 import org.netbeans.jemmy.Outputable;

  39 import org.netbeans.jemmy.TestOut;
  40 import org.netbeans.jemmy.TimeoutExpiredException;
  41 import org.netbeans.jemmy.Timeouts;
  42 import org.netbeans.jemmy.WindowWaiter;
  43 import org.netbeans.jemmy.drivers.DriverManager;
  44 import org.netbeans.jemmy.drivers.WindowDriver;
  45 
  46 /**
  47  * <BR><BR>Timeouts used: <BR>
  48  * WindowWaiter.WaitWindowTimeout - time to wait window displayed <BR>
  49  * WindowWaiter.AfterWindowTimeout - time to sleep after window has been
  50  * dispayed <BR>.
  51  *
  52  * @see org.netbeans.jemmy.Timeouts
  53  *
  54  * @author Alexandre Iline (alexandre.iline@oracle.com)
  55  *
  56  */
  57 public class WindowOperator extends ContainerOperator<Window>
  58         implements Outputable {


 568         runMapping(new MapVoidAction("toBack") {
 569             @Override
 570             public void map() {
 571                 ((Window) getSource()).toBack();
 572             }
 573         });
 574     }
 575 
 576     /**
 577      * Maps {@code Window.toFront()} through queue
 578      */
 579     public void toFront() {
 580         runMapping(new MapVoidAction("toFront") {
 581             @Override
 582             public void map() {
 583                 ((Window) getSource()).toFront();
 584             }
 585         });
 586     }
 587 















 588     //End of mapping                                      //
 589     ////////////////////////////////////////////////////////
 590     ////////////////////////////////////////////////////////
 591     //Mapping 1.4                                         //
 592     /**
 593      * Maps {@code Window.isFocused()} through queue.
 594      *
 595      * @return result of the mapped method
 596      */
 597     public boolean isFocused() {
 598         if (System.getProperty("java.specification.version").compareTo("1.3") > 0) {
 599             return (runMapping(new MapBooleanAction("isFocused") {
 600                 @Override
 601                 public boolean map() {
 602                     try {
 603                         return (((Boolean) new ClassReference(getSource()).
 604                                 invokeMethod("isFocused", null, null)).booleanValue());
 605                     } catch (InvocationTargetException e) {
 606                         return false;
 607                     } catch (NoSuchMethodException e) {


   1 /*
   2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation. Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package org.netbeans.jemmy.operators;
  26 
  27 import java.awt.Component;
  28 import java.awt.Window;
  29 import java.awt.event.WindowListener;
  30 import java.lang.reflect.InvocationTargetException;
  31 import java.util.ResourceBundle;
  32 
  33 import org.netbeans.jemmy.ClassReference;
  34 import org.netbeans.jemmy.ComponentChooser;
  35 import org.netbeans.jemmy.ComponentSearcher;
  36 import org.netbeans.jemmy.JemmyException;
  37 import org.netbeans.jemmy.JemmyProperties;
  38 import org.netbeans.jemmy.Outputable;
  39 import org.netbeans.jemmy.QueueTool;
  40 import org.netbeans.jemmy.TestOut;
  41 import org.netbeans.jemmy.TimeoutExpiredException;
  42 import org.netbeans.jemmy.Timeouts;
  43 import org.netbeans.jemmy.WindowWaiter;
  44 import org.netbeans.jemmy.drivers.DriverManager;
  45 import org.netbeans.jemmy.drivers.WindowDriver;
  46 
  47 /**
  48  * <BR><BR>Timeouts used: <BR>
  49  * WindowWaiter.WaitWindowTimeout - time to wait window displayed <BR>
  50  * WindowWaiter.AfterWindowTimeout - time to sleep after window has been
  51  * dispayed <BR>.
  52  *
  53  * @see org.netbeans.jemmy.Timeouts
  54  *
  55  * @author Alexandre Iline (alexandre.iline@oracle.com)
  56  *
  57  */
  58 public class WindowOperator extends ContainerOperator<Window>
  59         implements Outputable {


 569         runMapping(new MapVoidAction("toBack") {
 570             @Override
 571             public void map() {
 572                 ((Window) getSource()).toBack();
 573             }
 574         });
 575     }
 576 
 577     /**
 578      * Maps {@code Window.toFront()} through queue
 579      */
 580     public void toFront() {
 581         runMapping(new MapVoidAction("toFront") {
 582             @Override
 583             public void map() {
 584                 ((Window) getSource()).toFront();
 585             }
 586         });
 587     }
 588 
 589     /**
 590      * Maps {@code Window.getWindows()} through queue
 591      *
 592      * @return result of {@code Window.getWindows()}
 593      */
 594     public static Window[] getWindows() {
 595         return new QueueTool().invokeSmoothly(
 596                 new QueueTool.QueueAction<Window[]>("getWindows") {
 597                     @Override
 598                     public Window[] launch() throws Exception {
 599                         return Window.getWindows();
 600                     }
 601                 });
 602     }
 603 
 604     //End of mapping                                      //
 605     ////////////////////////////////////////////////////////
 606     ////////////////////////////////////////////////////////
 607     //Mapping 1.4                                         //
 608     /**
 609      * Maps {@code Window.isFocused()} through queue.
 610      *
 611      * @return result of the mapped method
 612      */
 613     public boolean isFocused() {
 614         if (System.getProperty("java.specification.version").compareTo("1.3") > 0) {
 615             return (runMapping(new MapBooleanAction("isFocused") {
 616                 @Override
 617                 public boolean map() {
 618                     try {
 619                         return (((Boolean) new ClassReference(getSource()).
 620                                 invokeMethod("isFocused", null, null)).booleanValue());
 621                     } catch (InvocationTargetException e) {
 622                         return false;
 623                     } catch (NoSuchMethodException e) {


< prev index next >