001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s): Alexandre Iline.
025: *
026: * The Original Software is the Jemmy library.
027: * The Initial Developer of the Original Software is Alexandre Iline.
028: * All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: *
041: *
042: *
043: * $Id$ $Revision$ $Date$
044: *
045: */
046:
047: package org.netbeans.jemmy.drivers;
048:
049: import org.netbeans.jemmy.ClassReference;
050: import org.netbeans.jemmy.JemmyException;
051: import org.netbeans.jemmy.JemmyProperties;
052:
053: import org.netbeans.jemmy.drivers.buttons.ButtonMouseDriver;
054:
055: import org.netbeans.jemmy.drivers.focus.APIFocusDriver;
056: import org.netbeans.jemmy.drivers.focus.MouseFocusDriver;
057:
058: import org.netbeans.jemmy.drivers.lists.ChoiceDriver;
059: import org.netbeans.jemmy.drivers.lists.JComboMouseDriver;
060: import org.netbeans.jemmy.drivers.lists.JTableHeaderDriver;
061: import org.netbeans.jemmy.drivers.lists.JTabAPIDriver;
062: import org.netbeans.jemmy.drivers.lists.JListMouseDriver;
063: import org.netbeans.jemmy.drivers.lists.ListKeyboardDriver;
064: import org.netbeans.jemmy.drivers.menus.AppleMenuDriver;
065:
066: import org.netbeans.jemmy.drivers.menus.DefaultJMenuDriver;
067: import org.netbeans.jemmy.drivers.menus.QueueJMenuDriver;
068:
069: import org.netbeans.jemmy.drivers.scrolling.JScrollBarAPIDriver;
070: import org.netbeans.jemmy.drivers.scrolling.JSliderAPIDriver;
071: import org.netbeans.jemmy.drivers.scrolling.JSplitPaneDriver;
072: import org.netbeans.jemmy.drivers.scrolling.ScrollbarDriver;
073: import org.netbeans.jemmy.drivers.scrolling.ScrollPaneDriver;
074:
075: import org.netbeans.jemmy.drivers.tables.JTableMouseDriver;
076:
077: import org.netbeans.jemmy.drivers.trees.JTreeAPIDriver;
078:
079: import org.netbeans.jemmy.drivers.text.AWTTextKeyboardDriver;
080: import org.netbeans.jemmy.drivers.text.SwingTextKeyboardDriver;
081:
082: import org.netbeans.jemmy.drivers.windows.DefaultFrameDriver;
083: import org.netbeans.jemmy.drivers.windows.DefaultInternalFrameDriver;
084: import org.netbeans.jemmy.drivers.windows.DefaultWindowDriver;
085:
086: /**
087: * Installs all necessary drivers for Jemmy operators except
088: * low-level drivers which are installed by
089: * <a href="InputDriverInstaller.java">InputDriverInstaller</a>.
090: *
091: * @author Alexandre Iline(alexandre.iline@sun.com)
092: */
093:
094: public class APIDriverInstaller extends ArrayDriverInstaller {
095:
096: /**
097: * Constructs a DefaultDriverInstaller object.
098: * @param shortcutEvents Signals whether shortcut mode is used.
099: */
100: public APIDriverInstaller(boolean shortcutEvents) {
101: super (
102: new String[] { DriverManager.LIST_DRIVER_ID,
103: DriverManager.MULTISELLIST_DRIVER_ID,
104: DriverManager.TREE_DRIVER_ID,
105: DriverManager.TEXT_DRIVER_ID,
106: DriverManager.TEXT_DRIVER_ID,
107: DriverManager.SCROLL_DRIVER_ID,
108: DriverManager.SCROLL_DRIVER_ID,
109: DriverManager.SCROLL_DRIVER_ID,
110: DriverManager.SCROLL_DRIVER_ID,
111: DriverManager.SCROLL_DRIVER_ID,
112: DriverManager.SCROLL_DRIVER_ID,
113: DriverManager.BUTTON_DRIVER_ID,
114: DriverManager.LIST_DRIVER_ID,
115: DriverManager.LIST_DRIVER_ID,
116: DriverManager.MULTISELLIST_DRIVER_ID,
117: DriverManager.LIST_DRIVER_ID,
118: DriverManager.LIST_DRIVER_ID,
119: DriverManager.MULTISELLIST_DRIVER_ID,
120: DriverManager.TABLE_DRIVER_ID,
121: DriverManager.LIST_DRIVER_ID,
122: DriverManager.FRAME_DRIVER_ID,
123: DriverManager.WINDOW_DRIVER_ID,
124: DriverManager.FRAME_DRIVER_ID,
125: DriverManager.INTERNAL_FRAME_DRIVER_ID,
126: DriverManager.WINDOW_DRIVER_ID,
127: DriverManager.FOCUS_DRIVER_ID,
128: DriverManager.FOCUS_DRIVER_ID,
129: DriverManager.MENU_DRIVER_ID,
130: DriverManager.MENU_DRIVER_ID,
131: DriverManager.ORDEREDLIST_DRIVER_ID },
132: new Object[] {
133: new JTreeAPIDriver(),
134: new JTreeAPIDriver(),
135: new JTreeAPIDriver(),
136: new AWTTextKeyboardDriver(),
137: new SwingTextKeyboardDriver(),
138: new ScrollbarDriver(),
139: new ScrollPaneDriver(),
140: new JScrollBarAPIDriver(),
141: new JSplitPaneDriver(),
142: new JSliderAPIDriver(),
143: createSpinnerDriver(),
144: new ButtonMouseDriver(),
145: new JTabAPIDriver(),
146: new ListKeyboardDriver(),
147: new ListKeyboardDriver(),
148: new JComboMouseDriver(),
149: new JListMouseDriver(),
150: new JListMouseDriver(),
151: new JTableMouseDriver(),
152: new ChoiceDriver(),
153: new DefaultFrameDriver(),
154: new DefaultWindowDriver(),
155: new DefaultInternalFrameDriver(),
156: new DefaultInternalFrameDriver(),
157: new DefaultInternalFrameDriver(),
158: new APIFocusDriver(),
159: new MouseFocusDriver(),
160: (shortcutEvents ? ((Object) new QueueJMenuDriver())
161: : ((Object) new DefaultJMenuDriver())),
162: ((System
163: .getProperty("apple.laf.useScreenMenuBar") != null && System
164: .getProperty(
165: "apple.laf.useScreenMenuBar")
166: .equals("true")) ? new AppleMenuDriver()
167: : (shortcutEvents ? ((Object) new QueueJMenuDriver())
168: : ((Object) new DefaultJMenuDriver()))),
169: new JTableHeaderDriver() });
170: }
171:
172: /**
173: * Constructs a DefaultDriverInstaller object with shortcut mode flag
174: * taken from <code>JemmyProperties</code>.
175: */
176: public APIDriverInstaller() {
177: this (
178: (JemmyProperties.getCurrentDispatchingModel() & JemmyProperties.SHORTCUT_MODEL_MASK) != 0);
179: }
180:
181: private static LightDriver createSpinnerDriver() {
182: if (System.getProperty("java.specification.version").compareTo(
183: "1.3") > 0) {
184: try {
185: return ((LightDriver) new ClassReference(
186: "org.netbeans.jemmy.drivers.scrolling.JSpinnerDriver")
187: .newInstance(null, null));
188: } catch (ClassNotFoundException e) {
189: JemmyProperties
190: .getCurrentOutput()
191: .printErrLine(
192: "ATTENTION! you are using Jemmy built by Java earlier then 1.4, under "
193: + "Java 1.4. \nImpossible to create JSpinnerDriver");
194: return (createEmptyDriver());
195: } catch (Exception e) {
196: throw (new JemmyException(
197: "Impossible to create JSpinnerDriver although java version is "
198: + System.getProperty("java.version"), e));
199: }
200: } else {
201: return (createEmptyDriver());
202: }
203: }
204:
205: private static LightDriver createEmptyDriver() {
206: return (new LightDriver() {
207: public String[] getSupported() {
208: return (new String[] { Object.class.getName() });
209: }
210: });
211: }
212: }
|