Source Code Cross Referenced for JListOperator.java in  » Testing » jemmy » org » netbeans » jemmy » operators » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » jemmy » org.netbeans.jemmy.operators 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003:         *
0004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0005:         *
0006:         * The contents of this file are subject to the terms of either the GNU
0007:         * General Public License Version 2 only ("GPL") or the Common
0008:         * Development and Distribution License("CDDL") (collectively, the
0009:         * "License"). You may not use this file except in compliance with the
0010:         * License. You can obtain a copy of the License at
0011:         * http://www.netbeans.org/cddl-gplv2.html
0012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
0013:         * specific language governing permissions and limitations under the
0014:         * License.  When distributing the software, include this License Header
0015:         * Notice in each file and include the License file at
0016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
0017:         * particular file as subject to the "Classpath" exception as provided
0018:         * by Sun in the GPL Version 2 section of the License file that
0019:         * accompanied this code. If applicable, add the following below the
0020:         * License Header, with the fields enclosed by brackets [] replaced by
0021:         * your own identifying information:
0022:         * "Portions Copyrighted [year] [name of copyright owner]"
0023:         *
0024:         * Contributor(s): Alexandre Iline.
0025:         *
0026:         * The Original Software is the Jemmy library.
0027:         * The Initial Developer of the Original Software is Alexandre Iline.
0028:         * All Rights Reserved.
0029:         *
0030:         * If you wish your version of this file to be governed by only the CDDL
0031:         * or only the GPL Version 2, indicate your decision by adding
0032:         * "[Contributor] elects to include this software in this distribution
0033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
0034:         * single choice of license, a recipient has the option to distribute
0035:         * your version of this file under either the CDDL, the GPL Version 2 or
0036:         * to extend the choice of license to its licensees as provided above.
0037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
0038:         * Version 2 license, then the option applies only if the new code is
0039:         * made subject to such option by the copyright holder.
0040:         *
0041:         *
0042:         *
0043:         * $Id: JListOperator.java,v 1.16 2007/10/05 11:35:33 jskrivanek Exp $ $Revision: 1.16 $ $Date: 2007/10/05 11:35:33 $
0044:         *
0045:         */
0046:
0047:        package org.netbeans.jemmy.operators;
0048:
0049:        import org.netbeans.jemmy.ComponentChooser;
0050:        import org.netbeans.jemmy.ComponentSearcher;
0051:        import org.netbeans.jemmy.JemmyInputException;
0052:        import org.netbeans.jemmy.Outputable;
0053:        import org.netbeans.jemmy.QueueTool;
0054:        import org.netbeans.jemmy.TestOut;
0055:        import org.netbeans.jemmy.TimeoutExpiredException;
0056:
0057:        import org.netbeans.jemmy.util.EmptyVisualizer;
0058:
0059:        import org.netbeans.jemmy.drivers.DriverManager;
0060:        import org.netbeans.jemmy.drivers.MultiSelListDriver;
0061:
0062:        import java.awt.Color;
0063:        import java.awt.Component;
0064:        import java.awt.Container;
0065:        import java.awt.Dimension;
0066:        import java.awt.Point;
0067:        import java.awt.Rectangle;
0068:
0069:        import java.util.Hashtable;
0070:        import java.util.Vector;
0071:
0072:        import javax.swing.JList;
0073:        import javax.swing.JScrollPane;
0074:        import javax.swing.ListCellRenderer;
0075:        import javax.swing.ListModel;
0076:        import javax.swing.ListSelectionModel;
0077:
0078:        import javax.swing.event.ListSelectionListener;
0079:
0080:        import javax.swing.plaf.ListUI;
0081:
0082:        /**
0083:         * <BR><BR>Timeouts used: <BR>
0084:         * ComponentOperator.WaitComponentTimeout - time to wait component displayed <BR>
0085:         * ComponentOperator.WaitStateTimeout - time to wait for item, and for item to be selected <BR>
0086:         * JScrollBarOperator.OneScrollClickTimeout - time for one scroll click <BR>
0087:         * JScrollBarOperator.WholeScrollTimeout - time for the whole scrolling <BR>.
0088:         *
0089:         * @see org.netbeans.jemmy.Timeouts
0090:         *
0091:         * @author Alexandre Iline (alexandre.iline@sun.com)
0092:         *	
0093:         */
0094:
0095:        public class JListOperator extends JComponentOperator implements 
0096:                Outputable {
0097:
0098:            /**
0099:             * Identifier for a "item" properties.
0100:             * @see #getDump
0101:             */
0102:            public static final String ITEM_PREFIX_DPROP = "Item";
0103:
0104:            /**
0105:             * Identifier for a "selected item" property.
0106:             * @see #getDump
0107:             */
0108:            public static final String SELECTED_ITEM_PREFIX_DPROP = "SelectedItem";
0109:
0110:            private TestOut output;
0111:            private MultiSelListDriver driver;
0112:
0113:            /**
0114:             * Constructor.
0115:             * @param b a component
0116:             */
0117:            public JListOperator(JList b) {
0118:                super (b);
0119:                driver = DriverManager.getMultiSelListDriver(getClass());
0120:            }
0121:
0122:            /**
0123:             * Constructs a JListOperator object.
0124:             * @param cont a container
0125:             * @param chooser a component chooser specifying searching criteria.
0126:             * @param index an index between appropriate ones.
0127:             */
0128:            public JListOperator(ContainerOperator cont,
0129:                    ComponentChooser chooser, int index) {
0130:                this ((JList) cont.waitSubComponent(new JListFinder(chooser),
0131:                        index));
0132:                copyEnvironment(cont);
0133:            }
0134:
0135:            /**
0136:             * Constructs a JListOperator object.
0137:             * @param cont a container
0138:             * @param chooser a component chooser specifying searching criteria.
0139:             */
0140:            public JListOperator(ContainerOperator cont,
0141:                    ComponentChooser chooser) {
0142:                this (cont, chooser, 0);
0143:            }
0144:
0145:            /**
0146:             * Constructor.
0147:             * Waits item text first.
0148:             * Uses cont's timeout and output for waiting and to init operator.
0149:             * @param cont a container
0150:             * @param text Text of item which is currently selected. 
0151:             * @param itemIndex Item index.
0152:             * @param index Ordinal component index.
0153:             * 
0154:             */
0155:            public JListOperator(ContainerOperator cont, String text,
0156:                    int itemIndex, int index) {
0157:                this ((JList) waitComponent(cont, new JListByItemFinder(text,
0158:                        itemIndex, cont.getComparator()), index));
0159:                copyEnvironment(cont);
0160:            }
0161:
0162:            /**
0163:             * Constructor.
0164:             * Waits component by selected item text first.
0165:             * Uses cont's timeout and output for waiting and to init operator.
0166:             * @param cont a container
0167:             * @param text Text of item which is currently selected. 
0168:             * @param index Ordinal component index.
0169:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
0170:             * 
0171:             */
0172:            public JListOperator(ContainerOperator cont, String text, int index) {
0173:                this (cont, text, -1, index);
0174:            }
0175:
0176:            /**
0177:             * Constructor.
0178:             * Waits component in container first.
0179:             * Uses cont's timeout and output for waiting and to init operator.
0180:             * @param cont a container
0181:             * @param text Text of item which is currently selected. 
0182:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
0183:             * 
0184:             */
0185:            public JListOperator(ContainerOperator cont, String text) {
0186:                this (cont, text, 0);
0187:            }
0188:
0189:            /**
0190:             * Constructor.
0191:             * Waits component in container first.
0192:             * Uses cont's timeout and output for waiting and to init operator.
0193:             * @param cont a container
0194:             * @param index Ordinal component index.
0195:             * 
0196:             */
0197:            public JListOperator(ContainerOperator cont, int index) {
0198:                this ((JList) waitComponent(cont, new JListFinder(), index));
0199:                copyEnvironment(cont);
0200:            }
0201:
0202:            /**
0203:             * Constructor.
0204:             * Waits component in container first.
0205:             * Uses cont's timeout and output for waiting and to init operator.
0206:             * @param cont a container
0207:             * 
0208:             */
0209:            public JListOperator(ContainerOperator cont) {
0210:                this (cont, 0);
0211:            }
0212:
0213:            /**
0214:             * Searches JList in container.
0215:             * @param cont Container to search component in.
0216:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
0217:             * @param index Ordinal component index.
0218:             * @return JList instance or null if component was not found.
0219:             */
0220:            public static JList findJList(Container cont,
0221:                    ComponentChooser chooser, int index) {
0222:                return ((JList) findComponent(cont, new JListFinder(chooser),
0223:                        index));
0224:            }
0225:
0226:            /**
0227:             * Searches 0'th JList in container.
0228:             * @param cont Container to search component in.
0229:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
0230:             * @return JList instance or null if component was not found.
0231:             */
0232:            public static JList findJList(Container cont,
0233:                    ComponentChooser chooser) {
0234:                return (findJList(cont, chooser, 0));
0235:            }
0236:
0237:            /**
0238:             * Searches JList by item.
0239:             * @param cont Container to search component in.
0240:             * @param text Item text. If null, contents is not checked.
0241:             * @param ce Compare text exactly.
0242:             * @param ccs Compare text case sensitively.
0243:             * @param itemIndex Index of item to compare text. If -1, selected item is checked.
0244:             * @param index Ordinal component index.
0245:             * @return JList instance or null if component was not found.
0246:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
0247:             */
0248:            public static JList findJList(Container cont, String text,
0249:                    boolean ce, boolean ccs, int itemIndex, int index) {
0250:                return (findJList(cont, new JListByItemFinder(text, itemIndex,
0251:                        new DefaultStringComparator(ce, ccs)), index));
0252:            }
0253:
0254:            /**
0255:             * Searches JList by item.
0256:             * @param cont Container to search component in.
0257:             * @param text Item text. If null, contents is not checked.
0258:             * @param ce Compare text exactly.
0259:             * @param ccs Compare text case sensitively.
0260:             * @param itemIndex Index of item to compare text. If -1, selected item is checked.
0261:             * @return JList instance or null if component was not found.
0262:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
0263:             */
0264:            public static JList findJList(Container cont, String text,
0265:                    boolean ce, boolean ccs, int itemIndex) {
0266:                return (findJList(cont, text, ce, ccs, itemIndex, 0));
0267:            }
0268:
0269:            /**
0270:             * Waits JList in container.
0271:             * @param cont Container to search component in.
0272:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
0273:             * @param index Ordinal component index.
0274:             * @return JList instance or null if component was not found.
0275:             * 
0276:             */
0277:            public static JList waitJList(Container cont,
0278:                    ComponentChooser chooser, int index) {
0279:                return ((JList) waitComponent(cont, new JListFinder(chooser),
0280:                        index));
0281:            }
0282:
0283:            /**
0284:             * Waits 0'th JList in container.
0285:             * @param cont Container to search component in.
0286:             * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
0287:             * @return JList instance or null if component was not found.
0288:             * 
0289:             */
0290:            public static JList waitJList(Container cont,
0291:                    ComponentChooser chooser) {
0292:                return (waitJList(cont, chooser, 0));
0293:            }
0294:
0295:            /**
0296:             * Waits JList by item.
0297:             * @param cont Container to search component in.
0298:             * @param text Item text. If null, contents is not checked.
0299:             * @param ce Compare text exactly.
0300:             * @param ccs Compare text case sensitively.
0301:             * @param itemIndex Index of item to compare text. If -1, selected item is checked.
0302:             * @param index Ordinal component index.
0303:             * @return JList instance or null if component was not found.
0304:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
0305:             * 
0306:             */
0307:            public static JList waitJList(Container cont, String text,
0308:                    boolean ce, boolean ccs, int itemIndex, int index) {
0309:                return (waitJList(cont, new JListByItemFinder(text, itemIndex,
0310:                        new DefaultStringComparator(ce, ccs)), index));
0311:            }
0312:
0313:            /**
0314:             * Waits JList by item.
0315:             * @param cont Container to search component in.
0316:             * @param text Item text. If null, contents is not checked.
0317:             * @param ce Compare text exactly.
0318:             * @param ccs Compare text case sensitively.
0319:             * @param itemIndex Index of item to compare text. If -1, selected item is checked.
0320:             * @return JList instance or null if component was not found.
0321:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
0322:             * 
0323:             */
0324:            public static JList waitJList(Container cont, String text,
0325:                    boolean ce, boolean ccs, int itemIndex) {
0326:                return (waitJList(cont, text, ce, ccs, itemIndex, 0));
0327:            }
0328:
0329:            public void setOutput(TestOut output) {
0330:                super .setOutput(output.createErrorOutput());
0331:                this .output = output;
0332:            }
0333:
0334:            public TestOut getOutput() {
0335:                return (output);
0336:            }
0337:
0338:            public void copyEnvironment(Operator anotherOperator) {
0339:                super .copyEnvironment(anotherOperator);
0340:                driver = (MultiSelListDriver) DriverManager.getDriver(
0341:                        DriverManager.MULTISELLIST_DRIVER_ID, getClass(),
0342:                        anotherOperator.getProperties());
0343:            }
0344:
0345:            /**
0346:             * Gets point to click on itemIndex'th item.
0347:             * @param itemIndex an index of an item to click.
0348:             * @return a Point in component's coordinate system.
0349:             */
0350:            public Point getClickPoint(int itemIndex) {
0351:                Rectangle rect = getCellBounds(itemIndex, itemIndex);
0352:                return (new Point(rect.x + rect.width / 2, rect.y + rect.height
0353:                        / 2));
0354:            }
0355:
0356:            /**
0357:             * Ask renderer for component to be displayed.
0358:             * @param itemIndex Item index.
0359:             * @param isSelected True if the specified cell was selected.
0360:             * @param cellHasFocus True if the specified cell has the focus.
0361:             * @return Component to be displayed.
0362:             */
0363:            public Component getRenderedComponent(int itemIndex,
0364:                    boolean isSelected, boolean cellHasFocus) {
0365:                return (getCellRenderer().getListCellRendererComponent(
0366:                        (JList) getSource(),
0367:                        getModel().getElementAt(itemIndex), itemIndex,
0368:                        isSelected, cellHasFocus));
0369:            }
0370:
0371:            /**
0372:             * Ask renderer for component to be displayed.
0373:             * Uses isSelectedIndex(itemIndex) to determine whether item is selected.
0374:             * Supposes item do not have focus.
0375:             * @param itemIndex Item index.
0376:             * @return Component to be displayed.
0377:             */
0378:            public Component getRenderedComponent(int itemIndex) {
0379:                return (getRenderedComponent(itemIndex,
0380:                        isSelectedIndex(itemIndex), false));
0381:            }
0382:
0383:            /**
0384:             * Searches for index'th item good from chooser's point of view.
0385:             * @param chooser Item verifying object.
0386:             * @param index Ordinal item index.
0387:             * @return Item index or -1 if search was insuccessful.
0388:             */
0389:            public int findItemIndex(ListItemChooser chooser, int index) {
0390:                ListModel model = getModel();
0391:                int count = 0;
0392:                for (int i = 0; i < model.getSize(); i++) {
0393:                    if (chooser.checkItem(this , i)) {
0394:                        if (count == index) {
0395:                            return (i);
0396:                        } else {
0397:                            count++;
0398:                        }
0399:                    }
0400:                }
0401:                return (-1);
0402:            }
0403:
0404:            /**
0405:             * Searches for an item good from chooser's point of view.
0406:             * @param chooser Item verifying object.
0407:             * @return Item index or -1 if serch was insuccessful.
0408:             * @see #findItemIndex(JListOperator.ListItemChooser, int)
0409:             * @see #findItemIndex(String, boolean, boolean)
0410:             */
0411:            public int findItemIndex(ListItemChooser chooser) {
0412:                return (findItemIndex(chooser, 0));
0413:            }
0414:
0415:            /**
0416:             * Searches for an item good from chooser's point of view.
0417:             * @param item a text pattern
0418:             * @param comparator a string comparision algorithm
0419:             * @param index Ordinal item index.
0420:             * @return Item index or -1 if serch was insuccessful.
0421:             * @see #findItemIndex(JListOperator.ListItemChooser, int)
0422:             * @see #findItemIndex(String, boolean, boolean)
0423:             */
0424:            public int findItemIndex(String item, StringComparator comparator,
0425:                    int index) {
0426:                return (findItemIndex(new BySubStringListItemChooser(item,
0427:                        comparator), index));
0428:            }
0429:
0430:            /**
0431:             * Searched for index'th item by text.
0432:             * @param item a text pattern
0433:             * @param ce Compare text exactly.
0434:             * @param cc Compare text case sensitively.
0435:             * @param index Ordinal item index.
0436:             * @return Item index or -1 if serch was insuccessful.
0437:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
0438:             * @deprecated Use findItemIndex(String, int) or findItemIndex(String, StringComparator, int)
0439:             */
0440:            public int findItemIndex(String item, boolean ce, boolean cc,
0441:                    int index) {
0442:                return (findItemIndex(item,
0443:                        new DefaultStringComparator(ce, cc), index));
0444:            }
0445:
0446:            /**
0447:             * Searched for index'th item by text.
0448:             * Uses StringComparator assigned to this object.
0449:             * @param item a text pattern
0450:             * @param index Ordinal item index.
0451:             * @return Item index or -1 if search was insuccessful.
0452:             */
0453:            public int findItemIndex(String item, int index) {
0454:                return (findItemIndex(item, getComparator(), index));
0455:            }
0456:
0457:            /**
0458:             * Searches for an item good from chooser's point of view.
0459:             * @param item a text pattern
0460:             * @param comparator a string comparision algorithm
0461:             * @return Item index or -1 if serch was insuccessful.
0462:             * @see #findItemIndex(JListOperator.ListItemChooser, int)
0463:             * @see #findItemIndex(String, boolean, boolean)
0464:             */
0465:            public int findItemIndex(String item, StringComparator comparator) {
0466:                return (findItemIndex(item, comparator, 0));
0467:            }
0468:
0469:            /**
0470:             * Searched  item by text.
0471:             * @param item a text pattern
0472:             * @param ce Compare text exactly.
0473:             * @param cc Compare text case sensitively.
0474:             * @return Item index or -1 if search was insuccessful.
0475:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
0476:             * @deprecated Use findItemIndex(String) or findItemIndex(String, StringComparator)
0477:             */
0478:            public int findItemIndex(String item, boolean ce, boolean cc) {
0479:                return (findItemIndex(item, ce, cc, 0));
0480:            }
0481:
0482:            /**
0483:             * Searched for first item by text.
0484:             * Uses StringComparator assigned to this object.
0485:             * @param item a text pattern
0486:             * @return Item index or -1 if search was insuccessful.
0487:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
0488:             */
0489:            public int findItemIndex(String item) {
0490:                return (findItemIndex(item, 0));
0491:            }
0492:
0493:            /**
0494:             * Searches for index'th item by rendered component.
0495:             * @param chooser Component verifying object.
0496:             * @param index Ordinal item index.
0497:             * @return Item index or -1 if serch was insuccessful.
0498:             * @see #getRenderedComponent(int, boolean, boolean)
0499:             */
0500:            public int findItemIndex(ComponentChooser chooser, int index) {
0501:                return (findItemIndex(new ByRenderedComponentListItemChooser(
0502:                        chooser), index));
0503:            }
0504:
0505:            /**
0506:             * Searches for an item by rendered component.
0507:             * @param chooser Component verifying object.
0508:             * @return Item index or -1 if serch was insuccessful.
0509:             * @see #getRenderedComponent(int, boolean, boolean)
0510:             */
0511:            public int findItemIndex(ComponentChooser chooser) {
0512:                return (findItemIndex(chooser, 0));
0513:            }
0514:
0515:            /**
0516:             * Clicks on item by item index.
0517:             * @param itemIndex Item index.
0518:             * @param clickCount count click.
0519:             * @return Click point or null if list does not contains itemIndex'th item.
0520:             * @throws NoSuchItemException
0521:             */
0522:            public Object clickOnItem(final int itemIndex, final int clickCount) {
0523:                output.printLine("Click " + Integer.toString(clickCount)
0524:                        + " times on JList\n    : " + toStringSource());
0525:                output.printGolden("Click " + Integer.toString(clickCount)
0526:                        + " times on JList");
0527:                checkIndex(itemIndex);
0528:                try {
0529:                    scrollToItem(itemIndex);
0530:                } catch (TimeoutExpiredException e) {
0531:                    output.printStackTrace(e);
0532:                }
0533:                if (((JList) getSource()).getModel().getSize() <= itemIndex) {
0534:                    output.printErrLine("JList " + toStringSource()
0535:                            + " does not contain "
0536:                            + Integer.toString(itemIndex) + "'th item");
0537:                    return (null);
0538:                }
0539:                if (((JList) getSource()).getAutoscrolls()) {
0540:                    ((JList) getSource()).ensureIndexIsVisible(itemIndex);
0541:                }
0542:                return (getQueueTool()
0543:                        .invokeSmoothly(new QueueTool.QueueAction(
0544:                                "Path selecting") {
0545:                            public Object launch() {
0546:                                Rectangle rect = getCellBounds(itemIndex,
0547:                                        itemIndex);
0548:                                if (rect == null) {
0549:                                    output
0550:                                            .printErrLine("Impossible to determine click point for "
0551:                                                    + Integer
0552:                                                            .toString(itemIndex)
0553:                                                    + "'th item");
0554:                                    return (null);
0555:                                }
0556:                                Point point = new Point(
0557:                                        (int) (rect.getX() + rect.getWidth() / 2),
0558:                                        (int) (rect.getY() + rect.getHeight() / 2));
0559:                                Object result = getModel().getElementAt(
0560:                                        itemIndex);
0561:                                clickMouse(point.x, point.y, clickCount);
0562:                                return (result);
0563:                            }
0564:                        }));
0565:            }
0566:
0567:            /**
0568:             * Finds item by item text, and do mouse click on it.
0569:             * @param item Item text.
0570:             * @param comparator a string comparision algorithm
0571:             * @param clickCount count click.
0572:             * @return Click point or null if list does not contains itemIndex'th item.
0573:             * @throws NoSuchItemException
0574:             */
0575:            public Object clickOnItem(final String item,
0576:                    final StringComparator comparator, final int clickCount) {
0577:                scrollToItem(findItemIndex(item, comparator, 0));
0578:                return (getQueueTool()
0579:                        .invokeSmoothly(new QueueTool.QueueAction(
0580:                                "Path selecting") {
0581:                            public Object launch() {
0582:                                int index = findItemIndex(item, comparator, 0);
0583:                                if (index != -1) {
0584:                                    return (clickOnItem(index, clickCount));
0585:                                } else {
0586:                                    throw (new NoSuchItemException(item));
0587:                                }
0588:                            }
0589:                        }));
0590:            }
0591:
0592:            /**
0593:             * Finds item by item text, and do mouse click on it.
0594:             * @param item Item text.
0595:             * @param ce Compare exactly.
0596:             * @param cc Compare case sensitively.
0597:             * @param clickCount count click.
0598:             * @return Click point or null if list does not contains itemIndex'th item.
0599:             * @throws NoSuchItemException
0600:             * @deprecated Use clickOnItem(String, int) or clickOnItem(String, StringComparator, int)
0601:             */
0602:            public Object clickOnItem(String item, boolean ce, boolean cc,
0603:                    int clickCount) {
0604:                return (clickOnItem(item, new DefaultStringComparator(ce, cc),
0605:                        clickCount));
0606:            }
0607:
0608:            /**
0609:             * Finds item by item text, and do mouse click on it.
0610:             * Uses StringComparator assigned to this object.
0611:             * @param item Item text.
0612:             * @param clickCount count click.
0613:             * @return Click point or null if list does not contains itemIndex'th item.
0614:             * @throws NoSuchItemException
0615:             */
0616:            public Object clickOnItem(String item, int clickCount) {
0617:                return (clickOnItem(item, getComparator(), clickCount));
0618:            }
0619:
0620:            /**
0621:             * Finds item by item text, and do simple mouse click on it.
0622:             * Uses StringComparator assigned to this object.
0623:             * @param item Item text.
0624:             * @param comparator a string comparision algorithm
0625:             * @return Click point or null if list does not contains itemIndex'th item.
0626:             * @throws NoSuchItemException
0627:             */
0628:            public Object clickOnItem(String item, StringComparator comparator) {
0629:                return (clickOnItem(item, comparator, 1));
0630:            }
0631:
0632:            /**
0633:             * Finds item by item text, and do simple mouse click on it.
0634:             * @param item Item text.
0635:             * @param ce Compare exactly.
0636:             * @param cc Compare case sensitively.
0637:             * @return Click point or null if list does not contains itemIndex'th item.
0638:             * @throws NoSuchItemException
0639:             * @deprecated Use clickOnItem(String) or clickOnItem(String, StringComparator)
0640:             */
0641:            public Object clickOnItem(String item, boolean ce, boolean cc) {
0642:                return (clickOnItem(item, ce, cc, 1));
0643:            }
0644:
0645:            /**
0646:             * Finds item by item text, and do simple mouse click on it.
0647:             * Uses StringComparator assigned to this object.
0648:             * @param item Item text.
0649:             * @return Click point or null if list does not contains itemIndex'th item.
0650:             * @throws NoSuchItemException
0651:             */
0652:            public Object clickOnItem(String item) {
0653:                return (clickOnItem(item, 0));
0654:            }
0655:
0656:            /**
0657:             * Scrolls to an item if the list is on a JScrollPane component.
0658:             * @param itemIndex an item index.
0659:             * @see #scrollToItem(String, boolean, boolean)
0660:             * 
0661:             * @throws NoSuchItemException
0662:             */
0663:            public void scrollToItem(int itemIndex) {
0664:                output.printTrace("Scroll JList to "
0665:                        + Integer.toString(itemIndex) + "'th item\n    : "
0666:                        + toStringSource());
0667:                output.printGolden("Scroll JList to "
0668:                        + Integer.toString(itemIndex) + "'th item");
0669:                checkIndex(itemIndex);
0670:                makeComponentVisible();
0671:                //try to find JScrollPane under.
0672:                JScrollPane scroll = (JScrollPane) getContainer(new JScrollPaneOperator.JScrollPaneFinder(
0673:                        ComponentSearcher.getTrueChooser("JScrollPane")));
0674:                if (scroll == null) {
0675:                    return;
0676:                }
0677:                JScrollPaneOperator scroller = new JScrollPaneOperator(scroll);
0678:                scroller.copyEnvironment(this );
0679:                scroller.setVisualizer(new EmptyVisualizer());
0680:                Rectangle rect = getCellBounds(itemIndex, itemIndex);
0681:                scroller.scrollToComponentRectangle(getSource(), (int) rect
0682:                        .getX(), (int) rect.getY(), (int) rect.getWidth(),
0683:                        (int) rect.getHeight());
0684:            }
0685:
0686:            /**
0687:             * Scrolls to an item if the list is on a JScrollPane component.
0688:             * @param item Item text
0689:             * @param comparator a string comparision algorithm
0690:             * @see #scrollToItem(String, boolean, boolean)
0691:             * 
0692:             */
0693:            public void scrollToItem(String item, StringComparator comparator) {
0694:                scrollToItem(findItemIndex(item, comparator));
0695:            }
0696:
0697:            /**
0698:             * Scrolls to an item if the list is on a JScrollPane component.
0699:             * @param item Item text
0700:             * @param ce Compare exactly.
0701:             * @param cc Compare case sensitively.
0702:             * @see #scrollToItem(String, boolean, boolean)
0703:             * 
0704:             * @deprecated Use scrollToItem(String) or scrollToItem(String, StringComparator)
0705:             */
0706:            public void scrollToItem(String item, boolean ce, boolean cc) {
0707:                scrollToItem(findItemIndex(item, ce, cc));
0708:            }
0709:
0710:            /**
0711:             * Selects an item by index.
0712:             * @param index an item index.
0713:             */
0714:            public void selectItem(int index) {
0715:                checkIndex(index);
0716:                driver.selectItem(this , index);
0717:                if (getVerification()) {
0718:                    waitItemSelection(index, true);
0719:                }
0720:            }
0721:
0722:            /**
0723:             * Selects an item by text.
0724:             * @param item an item text.
0725:             */
0726:            public void selectItem(final String item) {
0727:                scrollToItem(findItemIndex(item));
0728:                getQueueTool().invokeSmoothly(
0729:                        new QueueTool.QueueAction("Path selecting") {
0730:                            public Object launch() {
0731:                                driver.selectItem(JListOperator.this ,
0732:                                        findItemIndex(item));
0733:                                return (null);
0734:                            }
0735:                        });
0736:            }
0737:
0738:            /**
0739:             * Selects items by indices.
0740:             * @param indices item indices.
0741:             */
0742:            public void selectItems(int[] indices) {
0743:                checkIndices(indices);
0744:                driver.selectItems(this , indices);
0745:                if (getVerification()) {
0746:                    waitItemsSelection(indices, true);
0747:                }
0748:            }
0749:
0750:            /**
0751:             * Selects items by texts.
0752:             * @param items item texts.
0753:             */
0754:            public void selectItem(String[] items) {
0755:                int[] indices = new int[items.length];
0756:                for (int i = 0; i < items.length; i++) {
0757:                    indices[i] = findItemIndex(items[i]);
0758:                }
0759:                selectItems(indices);
0760:            }
0761:
0762:            /**
0763:             * Waits for items to be selected.
0764:             * @param itemIndices item indices to be selected
0765:             * @param selected Selected (true) or unselected (false).
0766:             */
0767:            public void waitItemsSelection(final int[] itemIndices,
0768:                    final boolean selected) {
0769:                getOutput().printLine(
0770:                        "Wait items to be " + (selected ? "" : "un")
0771:                                + "selected in component \n    : "
0772:                                + toStringSource());
0773:                getOutput().printGolden(
0774:                        "Wait items to be " + (selected ? "" : "un")
0775:                                + "selected");
0776:                waitState(new ComponentChooser() {
0777:                    public boolean checkComponent(Component comp) {
0778:                        int[] indices = getSelectedIndices();
0779:                        for (int i = 0; i < indices.length; i++) {
0780:                            if (indices[i] != itemIndices[i]) {
0781:                                return (false);
0782:                            }
0783:                        }
0784:                        return (true);
0785:                    }
0786:
0787:                    public String getDescription() {
0788:                        return ("Item has been " + (selected ? "" : "un") + "selected");
0789:                    }
0790:                });
0791:            }
0792:
0793:            /**
0794:             * Waits for item to be selected.
0795:             * @param itemIndex an item needs to be selected
0796:             * @param selected Selected (true) or unselected (false).
0797:             */
0798:            public void waitItemSelection(final int itemIndex,
0799:                    final boolean selected) {
0800:                waitItemsSelection(new int[] { itemIndex }, selected);
0801:            }
0802:
0803:            /**
0804:             * Waits for item. Uses getComparator() comparator.
0805:             * @param item an item text
0806:             * @param itemIndex Index of item to check or -1 to check selected item.
0807:             */
0808:            public void waitItem(String item, int itemIndex) {
0809:                getOutput().printLine(
0810:                        "Wait \"" + item + "\" at the "
0811:                                + Integer.toString(itemIndex)
0812:                                + " position in component \n    : "
0813:                                + toStringSource());
0814:                getOutput().printGolden(
0815:                        "Wait \"" + item + "\" at the "
0816:                                + Integer.toString(itemIndex) + " position");
0817:                waitState(new JListByItemFinder(item, itemIndex,
0818:                        getComparator()));
0819:            }
0820:
0821:            /**
0822:             * Returns information about component.
0823:             */
0824:            public Hashtable getDump() {
0825:                Hashtable result = super .getDump();
0826:                String[] items = new String[((JList) getSource()).getModel()
0827:                        .getSize()];
0828:                for (int i = 0; i < ((JList) getSource()).getModel().getSize(); i++) {
0829:                    items[i] = ((JList) getSource()).getModel().getElementAt(i)
0830:                            .toString();
0831:                }
0832:                int[] selectedIndices = ((JList) getSource())
0833:                        .getSelectedIndices();
0834:                String[] selectedItems = new String[selectedIndices.length];
0835:                for (int i = 0; i < selectedIndices.length; i++) {
0836:                    selectedItems[i] = items[selectedIndices[i]];
0837:                }
0838:                addToDump(result, ITEM_PREFIX_DPROP, items);
0839:                addToDump(result, SELECTED_ITEM_PREFIX_DPROP, selectedItems);
0840:                return (result);
0841:            }
0842:
0843:            ////////////////////////////////////////////////////////
0844:            //Mapping                                             //
0845:
0846:            /**Maps <code>JList.addListSelectionListener(ListSelectionListener)</code> through queue*/
0847:            public void addListSelectionListener(
0848:                    final ListSelectionListener listSelectionListener) {
0849:                runMapping(new MapVoidAction("addListSelectionListener") {
0850:                    public void map() {
0851:                        ((JList) getSource())
0852:                                .addListSelectionListener(listSelectionListener);
0853:                    }
0854:                });
0855:            }
0856:
0857:            /**Maps <code>JList.addSelectionInterval(int, int)</code> through queue*/
0858:            public void addSelectionInterval(final int i, final int i1) {
0859:                runMapping(new MapVoidAction("addSelectionInterval") {
0860:                    public void map() {
0861:                        ((JList) getSource()).addSelectionInterval(i, i1);
0862:                    }
0863:                });
0864:            }
0865:
0866:            /**Maps <code>JList.clearSelection()</code> through queue*/
0867:            public void clearSelection() {
0868:                runMapping(new MapVoidAction("clearSelection") {
0869:                    public void map() {
0870:                        ((JList) getSource()).clearSelection();
0871:                    }
0872:                });
0873:            }
0874:
0875:            /**Maps <code>JList.ensureIndexIsVisible(int)</code> through queue*/
0876:            public void ensureIndexIsVisible(final int i) {
0877:                runMapping(new MapVoidAction("ensureIndexIsVisible") {
0878:                    public void map() {
0879:                        ((JList) getSource()).ensureIndexIsVisible(i);
0880:                    }
0881:                });
0882:            }
0883:
0884:            /**Maps <code>JList.getAnchorSelectionIndex()</code> through queue*/
0885:            public int getAnchorSelectionIndex() {
0886:                return (runMapping(new MapIntegerAction(
0887:                        "getAnchorSelectionIndex") {
0888:                    public int map() {
0889:                        return (((JList) getSource()).getAnchorSelectionIndex());
0890:                    }
0891:                }));
0892:            }
0893:
0894:            /**Maps <code>JList.getCellBounds(int, int)</code> through queue*/
0895:            public Rectangle getCellBounds(final int i, final int i1) {
0896:                return ((Rectangle) runMapping(new MapAction("getCellBounds") {
0897:                    public Object map() {
0898:                        return (((JList) getSource()).getCellBounds(i, i1));
0899:                    }
0900:                }));
0901:            }
0902:
0903:            /**Maps <code>JList.getCellRenderer()</code> through queue*/
0904:            public ListCellRenderer getCellRenderer() {
0905:                return ((ListCellRenderer) runMapping(new MapAction(
0906:                        "getCellRenderer") {
0907:                    public Object map() {
0908:                        return (((JList) getSource()).getCellRenderer());
0909:                    }
0910:                }));
0911:            }
0912:
0913:            /**Maps <code>JList.getFirstVisibleIndex()</code> through queue*/
0914:            public int getFirstVisibleIndex() {
0915:                return (runMapping(new MapIntegerAction("getFirstVisibleIndex") {
0916:                    public int map() {
0917:                        return (((JList) getSource()).getFirstVisibleIndex());
0918:                    }
0919:                }));
0920:            }
0921:
0922:            /**Maps <code>JList.getFixedCellHeight()</code> through queue*/
0923:            public int getFixedCellHeight() {
0924:                return (runMapping(new MapIntegerAction("getFixedCellHeight") {
0925:                    public int map() {
0926:                        return (((JList) getSource()).getFixedCellHeight());
0927:                    }
0928:                }));
0929:            }
0930:
0931:            /**Maps <code>JList.getFixedCellWidth()</code> through queue*/
0932:            public int getFixedCellWidth() {
0933:                return (runMapping(new MapIntegerAction("getFixedCellWidth") {
0934:                    public int map() {
0935:                        return (((JList) getSource()).getFixedCellWidth());
0936:                    }
0937:                }));
0938:            }
0939:
0940:            /**Maps <code>JList.getLastVisibleIndex()</code> through queue*/
0941:            public int getLastVisibleIndex() {
0942:                return (runMapping(new MapIntegerAction("getLastVisibleIndex") {
0943:                    public int map() {
0944:                        return (((JList) getSource()).getLastVisibleIndex());
0945:                    }
0946:                }));
0947:            }
0948:
0949:            /**Maps <code>JList.getLeadSelectionIndex()</code> through queue*/
0950:            public int getLeadSelectionIndex() {
0951:                return (runMapping(new MapIntegerAction("getLeadSelectionIndex") {
0952:                    public int map() {
0953:                        return (((JList) getSource()).getLeadSelectionIndex());
0954:                    }
0955:                }));
0956:            }
0957:
0958:            /**Maps <code>JList.getMaxSelectionIndex()</code> through queue*/
0959:            public int getMaxSelectionIndex() {
0960:                return (runMapping(new MapIntegerAction("getMaxSelectionIndex") {
0961:                    public int map() {
0962:                        return (((JList) getSource()).getMaxSelectionIndex());
0963:                    }
0964:                }));
0965:            }
0966:
0967:            /**Maps <code>JList.getMinSelectionIndex()</code> through queue*/
0968:            public int getMinSelectionIndex() {
0969:                return (runMapping(new MapIntegerAction("getMinSelectionIndex") {
0970:                    public int map() {
0971:                        return (((JList) getSource()).getMinSelectionIndex());
0972:                    }
0973:                }));
0974:            }
0975:
0976:            /**Maps <code>JList.getModel()</code> through queue*/
0977:            public ListModel getModel() {
0978:                return ((ListModel) runMapping(new MapAction("getModel") {
0979:                    public Object map() {
0980:                        return (((JList) getSource()).getModel());
0981:                    }
0982:                }));
0983:            }
0984:
0985:            /**Maps <code>JList.getPreferredScrollableViewportSize()</code> through queue*/
0986:            public Dimension getPreferredScrollableViewportSize() {
0987:                return ((Dimension) runMapping(new MapAction(
0988:                        "getPreferredScrollableViewportSize") {
0989:                    public Object map() {
0990:                        return (((JList) getSource())
0991:                                .getPreferredScrollableViewportSize());
0992:                    }
0993:                }));
0994:            }
0995:
0996:            /**Maps <code>JList.getPrototypeCellValue()</code> through queue*/
0997:            public Object getPrototypeCellValue() {
0998:                return ((Object) runMapping(new MapAction(
0999:                        "getPrototypeCellValue") {
1000:                    public Object map() {
1001:                        return (((JList) getSource()).getPrototypeCellValue());
1002:                    }
1003:                }));
1004:            }
1005:
1006:            /**Maps <code>JList.getScrollableBlockIncrement(Rectangle, int, int)</code> through queue*/
1007:            public int getScrollableBlockIncrement(final Rectangle rectangle,
1008:                    final int i, final int i1) {
1009:                return (runMapping(new MapIntegerAction(
1010:                        "getScrollableBlockIncrement") {
1011:                    public int map() {
1012:                        return (((JList) getSource())
1013:                                .getScrollableBlockIncrement(rectangle, i, i1));
1014:                    }
1015:                }));
1016:            }
1017:
1018:            /**Maps <code>JList.getScrollableTracksViewportHeight()</code> through queue*/
1019:            public boolean getScrollableTracksViewportHeight() {
1020:                return (runMapping(new MapBooleanAction(
1021:                        "getScrollableTracksViewportHeight") {
1022:                    public boolean map() {
1023:                        return (((JList) getSource())
1024:                                .getScrollableTracksViewportHeight());
1025:                    }
1026:                }));
1027:            }
1028:
1029:            /**Maps <code>JList.getScrollableTracksViewportWidth()</code> through queue*/
1030:            public boolean getScrollableTracksViewportWidth() {
1031:                return (runMapping(new MapBooleanAction(
1032:                        "getScrollableTracksViewportWidth") {
1033:                    public boolean map() {
1034:                        return (((JList) getSource())
1035:                                .getScrollableTracksViewportWidth());
1036:                    }
1037:                }));
1038:            }
1039:
1040:            /**Maps <code>JList.getScrollableUnitIncrement(Rectangle, int, int)</code> through queue*/
1041:            public int getScrollableUnitIncrement(final Rectangle rectangle,
1042:                    final int i, final int i1) {
1043:                return (runMapping(new MapIntegerAction(
1044:                        "getScrollableUnitIncrement") {
1045:                    public int map() {
1046:                        return (((JList) getSource())
1047:                                .getScrollableUnitIncrement(rectangle, i, i1));
1048:                    }
1049:                }));
1050:            }
1051:
1052:            /**Maps <code>JList.getSelectedIndex()</code> through queue*/
1053:            public int getSelectedIndex() {
1054:                return (runMapping(new MapIntegerAction("getSelectedIndex") {
1055:                    public int map() {
1056:                        return (((JList) getSource()).getSelectedIndex());
1057:                    }
1058:                }));
1059:            }
1060:
1061:            /**Maps <code>JList.getSelectedIndices()</code> through queue*/
1062:            public int[] getSelectedIndices() {
1063:                return ((int[]) runMapping(new MapAction("getSelectedIndices") {
1064:                    public Object map() {
1065:                        return (((JList) getSource()).getSelectedIndices());
1066:                    }
1067:                }));
1068:            }
1069:
1070:            /**Maps <code>JList.getSelectedValue()</code> through queue*/
1071:            public Object getSelectedValue() {
1072:                return ((Object) runMapping(new MapAction("getSelectedValue") {
1073:                    public Object map() {
1074:                        return (((JList) getSource()).getSelectedValue());
1075:                    }
1076:                }));
1077:            }
1078:
1079:            /**Maps <code>JList.getSelectedValues()</code> through queue*/
1080:            public Object[] getSelectedValues() {
1081:                return ((Object[]) runMapping(new MapAction("getSelectedValues") {
1082:                    public Object map() {
1083:                        return (((JList) getSource()).getSelectedValues());
1084:                    }
1085:                }));
1086:            }
1087:
1088:            /**Maps <code>JList.getSelectionBackground()</code> through queue*/
1089:            public Color getSelectionBackground() {
1090:                return ((Color) runMapping(new MapAction(
1091:                        "getSelectionBackground") {
1092:                    public Object map() {
1093:                        return (((JList) getSource()).getSelectionBackground());
1094:                    }
1095:                }));
1096:            }
1097:
1098:            /**Maps <code>JList.getSelectionForeground()</code> through queue*/
1099:            public Color getSelectionForeground() {
1100:                return ((Color) runMapping(new MapAction(
1101:                        "getSelectionForeground") {
1102:                    public Object map() {
1103:                        return (((JList) getSource()).getSelectionForeground());
1104:                    }
1105:                }));
1106:            }
1107:
1108:            /**Maps <code>JList.getSelectionMode()</code> through queue*/
1109:            public int getSelectionMode() {
1110:                return (runMapping(new MapIntegerAction("getSelectionMode") {
1111:                    public int map() {
1112:                        return (((JList) getSource()).getSelectionMode());
1113:                    }
1114:                }));
1115:            }
1116:
1117:            /**Maps <code>JList.getSelectionModel()</code> through queue*/
1118:            public ListSelectionModel getSelectionModel() {
1119:                return ((ListSelectionModel) runMapping(new MapAction(
1120:                        "getSelectionModel") {
1121:                    public Object map() {
1122:                        return (((JList) getSource()).getSelectionModel());
1123:                    }
1124:                }));
1125:            }
1126:
1127:            /**Maps <code>JList.getUI()</code> through queue*/
1128:            public ListUI getUI() {
1129:                return ((ListUI) runMapping(new MapAction("getUI") {
1130:                    public Object map() {
1131:                        return (((JList) getSource()).getUI());
1132:                    }
1133:                }));
1134:            }
1135:
1136:            /**Maps <code>JList.getValueIsAdjusting()</code> through queue*/
1137:            public boolean getValueIsAdjusting() {
1138:                return (runMapping(new MapBooleanAction("getValueIsAdjusting") {
1139:                    public boolean map() {
1140:                        return (((JList) getSource()).getValueIsAdjusting());
1141:                    }
1142:                }));
1143:            }
1144:
1145:            /**Maps <code>JList.getVisibleRowCount()</code> through queue*/
1146:            public int getVisibleRowCount() {
1147:                return (runMapping(new MapIntegerAction("getVisibleRowCount") {
1148:                    public int map() {
1149:                        return (((JList) getSource()).getVisibleRowCount());
1150:                    }
1151:                }));
1152:            }
1153:
1154:            /**Maps <code>JList.indexToLocation(int)</code> through queue*/
1155:            public Point indexToLocation(final int i) {
1156:                return ((Point) runMapping(new MapAction("indexToLocation") {
1157:                    public Object map() {
1158:                        return (((JList) getSource()).indexToLocation(i));
1159:                    }
1160:                }));
1161:            }
1162:
1163:            /**Maps <code>JList.isSelectedIndex(int)</code> through queue*/
1164:            public boolean isSelectedIndex(final int i) {
1165:                return (runMapping(new MapBooleanAction("isSelectedIndex") {
1166:                    public boolean map() {
1167:                        return (((JList) getSource()).isSelectedIndex(i));
1168:                    }
1169:                }));
1170:            }
1171:
1172:            /**Maps <code>JList.isSelectionEmpty()</code> through queue*/
1173:            public boolean isSelectionEmpty() {
1174:                return (runMapping(new MapBooleanAction("isSelectionEmpty") {
1175:                    public boolean map() {
1176:                        return (((JList) getSource()).isSelectionEmpty());
1177:                    }
1178:                }));
1179:            }
1180:
1181:            /**Maps <code>JList.locationToIndex(Point)</code> through queue*/
1182:            public int locationToIndex(final Point point) {
1183:                return (runMapping(new MapIntegerAction("locationToIndex") {
1184:                    public int map() {
1185:                        return (((JList) getSource()).locationToIndex(point));
1186:                    }
1187:                }));
1188:            }
1189:
1190:            /**Maps <code>JList.removeListSelectionListener(ListSelectionListener)</code> through queue*/
1191:            public void removeListSelectionListener(
1192:                    final ListSelectionListener listSelectionListener) {
1193:                runMapping(new MapVoidAction("removeListSelectionListener") {
1194:                    public void map() {
1195:                        ((JList) getSource())
1196:                                .removeListSelectionListener(listSelectionListener);
1197:                    }
1198:                });
1199:            }
1200:
1201:            /**Maps <code>JList.removeSelectionInterval(int, int)</code> through queue*/
1202:            public void removeSelectionInterval(final int i, final int i1) {
1203:                runMapping(new MapVoidAction("removeSelectionInterval") {
1204:                    public void map() {
1205:                        ((JList) getSource()).removeSelectionInterval(i, i1);
1206:                    }
1207:                });
1208:            }
1209:
1210:            /**Maps <code>JList.setCellRenderer(ListCellRenderer)</code> through queue*/
1211:            public void setCellRenderer(final ListCellRenderer listCellRenderer) {
1212:                runMapping(new MapVoidAction("setCellRenderer") {
1213:                    public void map() {
1214:                        ((JList) getSource()).setCellRenderer(listCellRenderer);
1215:                    }
1216:                });
1217:            }
1218:
1219:            /**Maps <code>JList.setFixedCellHeight(int)</code> through queue*/
1220:            public void setFixedCellHeight(final int i) {
1221:                runMapping(new MapVoidAction("setFixedCellHeight") {
1222:                    public void map() {
1223:                        ((JList) getSource()).setFixedCellHeight(i);
1224:                    }
1225:                });
1226:            }
1227:
1228:            /**Maps <code>JList.setFixedCellWidth(int)</code> through queue*/
1229:            public void setFixedCellWidth(final int i) {
1230:                runMapping(new MapVoidAction("setFixedCellWidth") {
1231:                    public void map() {
1232:                        ((JList) getSource()).setFixedCellWidth(i);
1233:                    }
1234:                });
1235:            }
1236:
1237:            /**Maps <code>JList.setListData(Vector)</code> through queue*/
1238:            public void setListData(final Vector vector) {
1239:                runMapping(new MapVoidAction("setListData") {
1240:                    public void map() {
1241:                        ((JList) getSource()).setListData(vector);
1242:                    }
1243:                });
1244:            }
1245:
1246:            /**Maps <code>JList.setListData(Object[])</code> through queue*/
1247:            public void setListData(final Object[] object) {
1248:                runMapping(new MapVoidAction("setListData") {
1249:                    public void map() {
1250:                        ((JList) getSource()).setListData(object);
1251:                    }
1252:                });
1253:            }
1254:
1255:            /**Maps <code>JList.setModel(ListModel)</code> through queue*/
1256:            public void setModel(final ListModel listModel) {
1257:                runMapping(new MapVoidAction("setModel") {
1258:                    public void map() {
1259:                        ((JList) getSource()).setModel(listModel);
1260:                    }
1261:                });
1262:            }
1263:
1264:            /**Maps <code>JList.setPrototypeCellValue(Object)</code> through queue*/
1265:            public void setPrototypeCellValue(final Object object) {
1266:                runMapping(new MapVoidAction("setPrototypeCellValue") {
1267:                    public void map() {
1268:                        ((JList) getSource()).setPrototypeCellValue(object);
1269:                    }
1270:                });
1271:            }
1272:
1273:            /**Maps <code>JList.setSelectedIndex(int)</code> through queue*/
1274:            public void setSelectedIndex(final int i) {
1275:                runMapping(new MapVoidAction("setSelectedIndex") {
1276:                    public void map() {
1277:                        ((JList) getSource()).setSelectedIndex(i);
1278:                    }
1279:                });
1280:            }
1281:
1282:            /**Maps <code>JList.setSelectedIndices(int[])</code> through queue*/
1283:            public void setSelectedIndices(final int[] i) {
1284:                runMapping(new MapVoidAction("setSelectedIndices") {
1285:                    public void map() {
1286:                        ((JList) getSource()).setSelectedIndices(i);
1287:                    }
1288:                });
1289:            }
1290:
1291:            /**Maps <code>JList.setSelectedValue(Object, boolean)</code> through queue*/
1292:            public void setSelectedValue(final Object object, final boolean b) {
1293:                runMapping(new MapVoidAction("setSelectedValue") {
1294:                    public void map() {
1295:                        ((JList) getSource()).setSelectedValue(object, b);
1296:                    }
1297:                });
1298:            }
1299:
1300:            /**Maps <code>JList.setSelectionBackground(Color)</code> through queue*/
1301:            public void setSelectionBackground(final Color color) {
1302:                runMapping(new MapVoidAction("setSelectionBackground") {
1303:                    public void map() {
1304:                        ((JList) getSource()).setSelectionBackground(color);
1305:                    }
1306:                });
1307:            }
1308:
1309:            /**Maps <code>JList.setSelectionForeground(Color)</code> through queue*/
1310:            public void setSelectionForeground(final Color color) {
1311:                runMapping(new MapVoidAction("setSelectionForeground") {
1312:                    public void map() {
1313:                        ((JList) getSource()).setSelectionForeground(color);
1314:                    }
1315:                });
1316:            }
1317:
1318:            /**Maps <code>JList.setSelectionInterval(int, int)</code> through queue*/
1319:            public void setSelectionInterval(final int i, final int i1) {
1320:                runMapping(new MapVoidAction("setSelectionInterval") {
1321:                    public void map() {
1322:                        ((JList) getSource()).setSelectionInterval(i, i1);
1323:                    }
1324:                });
1325:            }
1326:
1327:            /**Maps <code>JList.setSelectionMode(int)</code> through queue*/
1328:            public void setSelectionMode(final int i) {
1329:                runMapping(new MapVoidAction("setSelectionMode") {
1330:                    public void map() {
1331:                        ((JList) getSource()).setSelectionMode(i);
1332:                    }
1333:                });
1334:            }
1335:
1336:            /**Maps <code>JList.setSelectionModel(ListSelectionModel)</code> through queue*/
1337:            public void setSelectionModel(
1338:                    final ListSelectionModel listSelectionModel) {
1339:                runMapping(new MapVoidAction("setSelectionModel") {
1340:                    public void map() {
1341:                        ((JList) getSource())
1342:                                .setSelectionModel(listSelectionModel);
1343:                    }
1344:                });
1345:            }
1346:
1347:            /**Maps <code>JList.setUI(ListUI)</code> through queue*/
1348:            public void setUI(final ListUI listUI) {
1349:                runMapping(new MapVoidAction("setUI") {
1350:                    public void map() {
1351:                        ((JList) getSource()).setUI(listUI);
1352:                    }
1353:                });
1354:            }
1355:
1356:            /**Maps <code>JList.setValueIsAdjusting(boolean)</code> through queue*/
1357:            public void setValueIsAdjusting(final boolean b) {
1358:                runMapping(new MapVoidAction("setValueIsAdjusting") {
1359:                    public void map() {
1360:                        ((JList) getSource()).setValueIsAdjusting(b);
1361:                    }
1362:                });
1363:            }
1364:
1365:            /**Maps <code>JList.setVisibleRowCount(int)</code> through queue*/
1366:            public void setVisibleRowCount(final int i) {
1367:                runMapping(new MapVoidAction("setVisibleRowCount") {
1368:                    public void map() {
1369:                        ((JList) getSource()).setVisibleRowCount(i);
1370:                    }
1371:                });
1372:            }
1373:
1374:            //End of mapping                                      //
1375:            ////////////////////////////////////////////////////////
1376:
1377:            private void checkIndex(int index) {
1378:                if (index < 0 || index >= getModel().getSize()) {
1379:                    throw (new NoSuchItemException(index));
1380:                }
1381:            }
1382:
1383:            private void checkIndices(int[] indices) {
1384:                for (int i = 0; i < indices.length; i++) {
1385:                    checkIndex(indices[i]);
1386:                }
1387:            }
1388:
1389:            /**
1390:             * Iterface to choose list item.
1391:             */
1392:            public interface ListItemChooser {
1393:                /**
1394:                 * Should be true if item is good.
1395:                 * @param oper Operator used to search item.
1396:                 * @param index Index of an item be checked.
1397:                 * @return true if the item fits the criteria
1398:                 */
1399:                public boolean checkItem(JListOperator oper, int index);
1400:
1401:                /**
1402:                 * Item description.
1403:                 * @return a description.
1404:                 */
1405:                public String getDescription();
1406:            }
1407:
1408:            /**
1409:             * Can be throught during item selecting if list does not have
1410:             * item requested.
1411:             */
1412:            public class NoSuchItemException extends JemmyInputException {
1413:                /**
1414:                 * Constructor.
1415:                 * @param item an item's text
1416:                 */
1417:                public NoSuchItemException(String item) {
1418:                    super ("No such item as \"" + item + "\"", getSource());
1419:                }
1420:
1421:                /**
1422:                 * Constructor.
1423:                 * @param index an item's index
1424:                 */
1425:                public NoSuchItemException(int index) {
1426:                    super ("List does not contain " + index + "'th item",
1427:                            getSource());
1428:                }
1429:            }
1430:
1431:            private class BySubStringListItemChooser implements  ListItemChooser {
1432:                String subString;
1433:                StringComparator comparator;
1434:
1435:                public BySubStringListItemChooser(String subString,
1436:                        StringComparator comparator) {
1437:                    this .subString = subString;
1438:                    this .comparator = comparator;
1439:                }
1440:
1441:                public boolean checkItem(JListOperator oper, int index) {
1442:                    return (comparator.equals(oper.getModel().getElementAt(
1443:                            index).toString(), subString));
1444:                }
1445:
1446:                public String getDescription() {
1447:                    return ("Item containing \"" + subString + "\" string");
1448:                }
1449:            }
1450:
1451:            private class ByRenderedComponentListItemChooser implements 
1452:                    ListItemChooser {
1453:                ComponentChooser chooser;
1454:
1455:                public ByRenderedComponentListItemChooser(
1456:                        ComponentChooser chooser) {
1457:                    this .chooser = chooser;
1458:                }
1459:
1460:                public boolean checkItem(JListOperator oper, int index) {
1461:                    return (chooser.checkComponent(oper
1462:                            .getRenderedComponent(index)));
1463:                }
1464:
1465:                public String getDescription() {
1466:                    return (chooser.getDescription());
1467:                }
1468:            }
1469:
1470:            /**
1471:             * Allows to find component by an item.
1472:             */
1473:            public static class JListByItemFinder implements  ComponentChooser {
1474:                String label;
1475:                int itemIndex;
1476:                StringComparator comparator;
1477:
1478:                /**
1479:                 * Constructs JListByItemFinder.
1480:                 * @param lb a text pattern
1481:                 * @param ii item index to check. If equal to -1, selected item is checked.
1482:                 * @param comparator specifies string comparision algorithm.
1483:                 */
1484:                public JListByItemFinder(String lb, int ii,
1485:                        StringComparator comparator) {
1486:                    label = lb;
1487:                    itemIndex = ii;
1488:                    this .comparator = comparator;
1489:                }
1490:
1491:                /**
1492:                 * Constructs JListByItemFinder.
1493:                 * @param lb a text pattern
1494:                 * @param ii item index to check. If equal to -1, selected item is checked.
1495:                 */
1496:                public JListByItemFinder(String lb, int ii) {
1497:                    this (lb, ii, Operator.getDefaultStringComparator());
1498:                }
1499:
1500:                public boolean checkComponent(Component comp) {
1501:                    if (comp instanceof  JList) {
1502:                        if (label == null) {
1503:                            return (true);
1504:                        }
1505:                        if (((JList) comp).getModel().getSize() > itemIndex) {
1506:                            int ii = itemIndex;
1507:                            if (ii == -1) {
1508:                                ii = ((JList) comp).getSelectedIndex();
1509:                                if (ii == -1) {
1510:                                    return (false);
1511:                                }
1512:                            }
1513:                            return (comparator.equals(((JList) comp).getModel()
1514:                                    .getElementAt(ii).toString(), label));
1515:                        }
1516:                    }
1517:                    return (false);
1518:                }
1519:
1520:                public String getDescription() {
1521:                    return ("JList with text \"" + label + "\" in "
1522:                            + (new Integer(itemIndex)).toString() + "'th item");
1523:                }
1524:            }
1525:
1526:            /**
1527:             * Checks component type.
1528:             */
1529:            public static class JListFinder extends Finder {
1530:                /**
1531:                 * Constructs JListFinder.
1532:                 * @param sf other searching criteria.
1533:                 */
1534:                public JListFinder(ComponentChooser sf) {
1535:                    super (JList.class, sf);
1536:                }
1537:
1538:                /**
1539:                 * Constructs JListFinder.
1540:                 */
1541:                public JListFinder() {
1542:                    super (JList.class);
1543:                }
1544:            }
1545:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.