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.JTabMouseDriver;
062: import org.netbeans.jemmy.drivers.lists.JListMouseDriver;
063: import org.netbeans.jemmy.drivers.lists.ListKeyboardDriver;
064:
065: import org.netbeans.jemmy.drivers.menus.DefaultJMenuDriver;
066: import org.netbeans.jemmy.drivers.menus.QueueJMenuDriver;
067:
068: import org.netbeans.jemmy.drivers.scrolling.JScrollBarDriver;
069: import org.netbeans.jemmy.drivers.scrolling.JSliderDriver;
070: import org.netbeans.jemmy.drivers.scrolling.JSplitPaneDriver;
071: import org.netbeans.jemmy.drivers.scrolling.ScrollbarDriver;
072: import org.netbeans.jemmy.drivers.scrolling.ScrollPaneDriver;
073:
074: import org.netbeans.jemmy.drivers.tables.JTableMouseDriver;
075:
076: import org.netbeans.jemmy.drivers.trees.JTreeMouseDriver;
077:
078: import org.netbeans.jemmy.drivers.text.AWTTextKeyboardDriver;
079: import org.netbeans.jemmy.drivers.text.SwingTextKeyboardDriver;
080:
081: import org.netbeans.jemmy.drivers.windows.DefaultFrameDriver;
082: import org.netbeans.jemmy.drivers.windows.DefaultInternalFrameDriver;
083: import org.netbeans.jemmy.drivers.windows.DefaultWindowDriver;
084:
085: /**
086: * Installs all necessary drivers for Jemmy operators except
087: * low-level drivers which are installed by
088: * <a href="InputDriverInstaller.java">InputDriverInstaller</a>.
089: *
090: * @author Alexandre Iline(alexandre.iline@sun.com)
091: */
092:
093: public class DefaultDriverInstaller extends ArrayDriverInstaller {
094:
095: /**
096: * Constructs a DefaultDriverInstaller object.
097: * @param shortcutEvents Signals whether shortcut mode is used.
098: */
099: public DefaultDriverInstaller(boolean shortcutEvents) {
100: super (new String[] { DriverManager.LIST_DRIVER_ID,
101: DriverManager.MULTISELLIST_DRIVER_ID,
102: DriverManager.TREE_DRIVER_ID,
103: DriverManager.TEXT_DRIVER_ID,
104: DriverManager.TEXT_DRIVER_ID,
105: DriverManager.SCROLL_DRIVER_ID,
106: DriverManager.SCROLL_DRIVER_ID,
107: DriverManager.SCROLL_DRIVER_ID,
108: DriverManager.SCROLL_DRIVER_ID,
109: DriverManager.SCROLL_DRIVER_ID,
110: DriverManager.SCROLL_DRIVER_ID,
111: DriverManager.BUTTON_DRIVER_ID,
112: DriverManager.LIST_DRIVER_ID,
113: DriverManager.LIST_DRIVER_ID,
114: DriverManager.MULTISELLIST_DRIVER_ID,
115: DriverManager.LIST_DRIVER_ID,
116: DriverManager.LIST_DRIVER_ID,
117: DriverManager.MULTISELLIST_DRIVER_ID,
118: DriverManager.TABLE_DRIVER_ID,
119: DriverManager.LIST_DRIVER_ID,
120: DriverManager.FRAME_DRIVER_ID,
121: DriverManager.WINDOW_DRIVER_ID,
122: DriverManager.FRAME_DRIVER_ID,
123: DriverManager.INTERNAL_FRAME_DRIVER_ID,
124: DriverManager.WINDOW_DRIVER_ID,
125: DriverManager.FOCUS_DRIVER_ID,
126: DriverManager.FOCUS_DRIVER_ID,
127: DriverManager.MENU_DRIVER_ID,
128: DriverManager.ORDEREDLIST_DRIVER_ID }, new Object[] {
129: new JTreeMouseDriver(),
130: new JTreeMouseDriver(),
131: new JTreeMouseDriver(),
132: new AWTTextKeyboardDriver(),
133: new SwingTextKeyboardDriver(),
134: new ScrollbarDriver(),
135: new ScrollPaneDriver(),
136: new JScrollBarDriver(),
137: new JSplitPaneDriver(),
138: new JSliderDriver(),
139: createSpinnerDriver(),
140: new ButtonMouseDriver(),
141: new JTabMouseDriver(),
142: new ListKeyboardDriver(),
143: new ListKeyboardDriver(),
144: new JComboMouseDriver(),
145: new JListMouseDriver(),
146: new JListMouseDriver(),
147: new JTableMouseDriver(),
148: new ChoiceDriver(),
149: new DefaultFrameDriver(),
150: new DefaultWindowDriver(),
151: new DefaultInternalFrameDriver(),
152: new DefaultInternalFrameDriver(),
153: new DefaultInternalFrameDriver(),
154: new APIFocusDriver(),
155: new MouseFocusDriver(),
156: (shortcutEvents ? ((Object) new QueueJMenuDriver())
157: : ((Object) new DefaultJMenuDriver())),
158: new JTableHeaderDriver() });
159: }
160:
161: /**
162: * Constructs a DefaultDriverInstaller object with shortcut mode flag
163: * taken from <code>JemmyProperties</code>.
164: */
165: public DefaultDriverInstaller() {
166: this (
167: (JemmyProperties.getCurrentDispatchingModel() & JemmyProperties.SHORTCUT_MODEL_MASK) != 0);
168: }
169:
170: private static LightDriver createSpinnerDriver() {
171: if (System.getProperty("java.specification.version").compareTo(
172: "1.3") > 0) {
173: try {
174: return ((LightDriver) new ClassReference(
175: "org.netbeans.jemmy.drivers.scrolling.JSpinnerDriver")
176: .newInstance(null, null));
177: } catch (ClassNotFoundException e) {
178: JemmyProperties
179: .getCurrentOutput()
180: .printErrLine(
181: "ATTENTION! you are using Jemmy built by Java earlier then 1.4, under "
182: + "Java 1.4. \nImpossible to create JSpinnerDriver");
183: return (createEmptyDriver());
184: } catch (Exception e) {
185: throw (new JemmyException(
186: "Impossible to create JSpinnerDriver although java version is "
187: + System.getProperty("java.version"), e));
188: }
189: } else {
190: return (createEmptyDriver());
191: }
192: }
193:
194: private static LightDriver createEmptyDriver() {
195: return (new LightDriver() {
196: public String[] getSupported() {
197: return (new String[] { Object.class.getName() });
198: }
199: });
200: }
201: }
|