Package org.jemmy.awt

Source Code of org.jemmy.awt.FrameOperator

/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2007-2009 Sun Microsystems, Inc. All rights reserved.
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at LICENSE.html or
* http://www.sun.com/cddl.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this License Header
* Notice in each file.
*
* If applicable, add the following below the
* License Header, with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* Contributor(s): Alexandre (Shura) Iline. (shurymury@gmail.com)
*
* The Original Software is the Jemmy library.
* The Initial Developer of the Original Software is Alexandre Iline.
* All Rights Reserved.
*
*/

package org.jemmy.awt;

import java.awt.Component;
import org.jemmy.Dimension;
import java.awt.Frame;
import javax.xml.soap.Node;
import org.jemmy.Point;
import org.jemmy.Rectangle;
import org.jemmy.control.ControlInterfaces;
import org.jemmy.control.ControlType;
import org.jemmy.control.MethodProperties;
import org.jemmy.dock.DefaultParent;
import org.jemmy.dock.ObjectLookup;
import org.jemmy.env.Environment;
import org.jemmy.input.WindowImpl;
import org.jemmy.interfaces.Window;
import org.jemmy.image.Utils;
import org.jemmy.interfaces.Parent;
import org.jemmy.lookup.Any;
import org.jemmy.lookup.ByStringLookup;
import org.jemmy.lookup.LookupCriteria;
import org.jemmy.resources.StringComparePolicy;

/**
*
* @param <T>
* @author shura
*/
@ControlType (Frame.class)
@ControlInterfaces(value = {Parent.class, Window.class}, encapsulates=Component.class)
@MethodProperties("getTitle")
public class FrameOperator<T extends Frame> extends ContainerOperator<T> implements Window {
   
    @ObjectLookup("title")
    public static <B extends Frame> LookupCriteria<B> titleLookup(Class<B> tp, String param) {
        return new ByTitleFrameLookup<B>(param);
    }
   
    @ObjectLookup("title and comparison policy")
    public static <B extends Frame> LookupCriteria<B> sensitiveTitleLookup(Class<B> tp, String param, StringComparePolicy policy) {
        return new ByTextTextLookup<B>(param, policy);
    }

    private static class ByTitleFrameLookup<B extends Frame> extends ByStringLookup<B> {

        public ByTitleFrameLookup(String text) {
            super(text);
        }

        public ByTitleFrameLookup(String text, StringComparePolicy policy) {
            super(text, policy);
        }

        @Override
        public String getText(Frame control) {
            return control.getTitle();
        }

    }
   
    WindowImpl resizer;

    /**
     *
     * @param env
     * @param node
     */
    public FrameOperator(Environment env, T node) {
        super(env, node);
        resizer = new WindowImpl(this, 2);
    }

    @Override
    public Rectangle getScreenBounds() {
        return Utils.convert(getControl().getBounds());
    }

    @Override
    public Point getClickPoint() {
        return new Point(getControl().getWidth() / 2, 9); // TODO: On Windows Vista with Aero 5 is not enough (it resizes height only)
    }

    public void move(Point dest) {
        resizer.move(dest);
    }

    public void resize(Dimension size, Direction direction) {
        resizer.resize(size, direction);
    }

    /*
    @Property(Control.TEXT_PROP_NAME)
    public String getTitle() {
        return getControl().getTitle();
    }
     */

TOP

Related Classes of org.jemmy.awt.FrameOperator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.