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.drivers.windows; 26 27 import java.awt.Frame; 28 import java.awt.Window; 29 import java.awt.event.WindowEvent; 30 31 import org.netbeans.jemmy.drivers.FrameDriver; 32 import org.netbeans.jemmy.drivers.LightSupportiveDriver; 33 import org.netbeans.jemmy.drivers.input.EventDriver; 34 import org.netbeans.jemmy.operators.ComponentOperator; 35 import org.netbeans.jemmy.operators.FrameOperator; 36 37 public class DefaultFrameDriver extends LightSupportiveDriver implements FrameDriver { 38 39 EventDriver eDriver; 40 DefaultFrameDriver()41 public DefaultFrameDriver() { 42 super(new String[]{"org.netbeans.jemmy.operators.FrameOperator"}); 43 eDriver = new EventDriver(); 44 } 45 46 @Override iconify(ComponentOperator oper)47 public void iconify(ComponentOperator oper) { 48 checkSupported(oper); 49 eDriver.dispatchEvent(oper.getSource(), 50 new WindowEvent((Window) oper.getSource(), 51 WindowEvent.WINDOW_ICONIFIED)); 52 ((FrameOperator) oper).setState(Frame.ICONIFIED); 53 } 54 55 @Override deiconify(ComponentOperator oper)56 public void deiconify(ComponentOperator oper) { 57 checkSupported(oper); 58 eDriver.dispatchEvent(oper.getSource(), 59 new WindowEvent((Window) oper.getSource(), 60 WindowEvent.WINDOW_DEICONIFIED)); 61 ((FrameOperator) oper).setState(Frame.NORMAL); 62 } 63 64 /** Maximizes the frame. 65 * 66 * @param oper Frame operator. 67 * @throws UnsupportedOperatorException if operator class name is not in 68 * the list of supported classes names 69 */ 70 @Override maximize(ComponentOperator oper)71 public void maximize(ComponentOperator oper) { 72 checkSupported(oper); 73 ((FrameOperator) oper).setExtendedState(Frame.MAXIMIZED_BOTH); 74 } 75 76 /** Demaximizes the frame. 77 * 78 * @param oper Frame operator. 79 * @throws UnsupportedOperatorException if operator class name is not in 80 * the list of supported classes names 81 */ 82 @Override demaximize(ComponentOperator oper)83 public void demaximize(ComponentOperator oper) { 84 checkSupported(oper); 85 ((FrameOperator) oper).setExtendedState(Frame.NORMAL); 86 } 87 88 } 89