Source Code Cross Referenced for JPopupMenuOperator.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: JPopupMenuOperator.java,v 1.23 2007/10/05 11:35:35 jskrivanek Exp $ $Revision: 1.23 $ $Date: 2007/10/05 11:35:35 $
0044:         *
0045:         */
0046:
0047:        package org.netbeans.jemmy.operators;
0048:
0049:        import org.netbeans.jemmy.Action;
0050:        import org.netbeans.jemmy.ComponentChooser;
0051:        import org.netbeans.jemmy.ComponentSearcher;
0052:        import org.netbeans.jemmy.JemmyException;
0053:        import org.netbeans.jemmy.JemmyProperties;
0054:        import org.netbeans.jemmy.QueueTool;
0055:        import org.netbeans.jemmy.TestOut;
0056:        import org.netbeans.jemmy.Timeoutable;
0057:        import org.netbeans.jemmy.TimeoutExpiredException;
0058:        import org.netbeans.jemmy.Timeouts;
0059:        import org.netbeans.jemmy.Outputable;
0060:        import org.netbeans.jemmy.WindowWaiter;
0061:
0062:        import org.netbeans.jemmy.drivers.MenuDriver;
0063:        import org.netbeans.jemmy.drivers.DriverManager;
0064:
0065:        import java.awt.Component;
0066:        import java.awt.Container;
0067:        import java.awt.Dimension;
0068:        import java.awt.Insets;
0069:        import java.awt.Window;
0070:
0071:        import java.awt.event.KeyEvent;
0072:        import java.awt.event.MouseEvent;
0073:
0074:        import java.util.Hashtable;
0075:
0076:        import javax.swing.JMenu;
0077:        import javax.swing.JMenuItem;
0078:        import javax.swing.JPopupMenu;
0079:        import javax.swing.MenuElement;
0080:        import javax.swing.MenuSelectionManager;
0081:        import javax.swing.SingleSelectionModel;
0082:
0083:        import javax.swing.event.PopupMenuListener;
0084:
0085:        import javax.swing.plaf.PopupMenuUI;
0086:
0087:        /**
0088:         * <BR><BR>Timeouts used: <BR>
0089:         * JMenuOperator.WaitBeforePopupTimeout - time to sleep before popup expanding <BR>
0090:         * JMenuOperator.WaitPopupTimeout - time to wait popup displayed <BR>
0091:         * ComponentOperator.WaitComponentTimeout - time to wait button displayed <BR>
0092:         * WindowWaiter.WaitWindowTimeout - time to wait popup window displayed <BR>
0093:         * WindowWaiter.AfterWindowTimeout - time to sleep after popup window has been dispayed <BR>.
0094:         *
0095:         * @see org.netbeans.jemmy.Timeouts
0096:         *
0097:         * @author Alexandre Iline (alexandre.iline@sun.com)
0098:         *	
0099:         */
0100:
0101:        public class JPopupMenuOperator extends JComponentOperator implements 
0102:                Outputable, Timeoutable {
0103:
0104:            /**
0105:             * Identifier for a "label" property.
0106:             * @see #getDump
0107:             */
0108:            public static final String LABEL_DPROP = "Label";
0109:
0110:            private TestOut output;
0111:            private Timeouts timeouts;
0112:            private MenuDriver driver;
0113:
0114:            /**
0115:             * Constructor.
0116:             * @param popup a component
0117:             */
0118:            public JPopupMenuOperator(JPopupMenu popup) {
0119:                super (popup);
0120:                driver = DriverManager.getMenuDriver(getClass());
0121:            }
0122:
0123:            /**
0124:             * Constructs a JPopupMenuOperator object.
0125:             * @param cont a container
0126:             * @param chooser a component chooser specifying searching criteria.
0127:             * @param index an index between appropriate ones.
0128:             */
0129:            public JPopupMenuOperator(ContainerOperator cont,
0130:                    ComponentChooser chooser, int index) {
0131:                this ((JPopupMenu) cont.waitSubComponent(new JPopupMenuFinder(
0132:                        chooser), index));
0133:                copyEnvironment(cont);
0134:            }
0135:
0136:            /**
0137:             * Constructs a JPopupMenuOperator object.
0138:             * @param cont a container
0139:             * @param chooser a component chooser specifying searching criteria.
0140:             */
0141:            public JPopupMenuOperator(ContainerOperator cont,
0142:                    ComponentChooser chooser) {
0143:                this (cont, chooser, 0);
0144:            }
0145:
0146:            /**
0147:             * Constructor.
0148:             * Waits component first.
0149:             * Constructor can be used in complicated cases when
0150:             * output or timeouts should differ from default.
0151:             * @param env an operator to copy environment from.
0152:             * @throws TimeoutExpiredException
0153:             */
0154:            public JPopupMenuOperator(Operator env) {
0155:                this ((JPopupMenu) waitComponent(WindowOperator.waitWindow(
0156:                        new JPopupWindowFinder(), 0, env.getTimeouts(), env
0157:                                .getOutput()), new JPopupMenuFinder(), 0, env
0158:                        .getTimeouts(), env.getOutput()));
0159:                copyEnvironment(env);
0160:            }
0161:
0162:            /**
0163:             * Constructor.
0164:             * Waits component in container first.
0165:             * Uses cont's timeout and output for waiting and to init operator.
0166:             * @param cont a container
0167:             * @throws TimeoutExpiredException
0168:             */
0169:            public JPopupMenuOperator(ContainerOperator cont) {
0170:                this (
0171:                        (JPopupMenu) waitComponent(cont,
0172:                                new JPopupMenuFinder(), 0));
0173:                copyEnvironment(cont);
0174:            }
0175:
0176:            /**
0177:             * Constructor.
0178:             * Waits component first.
0179:             * @throws TimeoutExpiredException
0180:             */
0181:            public JPopupMenuOperator() {
0182:                this (Operator.getEnvironmentOperator());
0183:            }
0184:
0185:            /**
0186:             * Searches JPopupMenu in container.
0187:             * @param cont Container to search component in.
0188:             * @param chooser a component chooser specifying searching criteria.
0189:             * @param index Ordinal component index.
0190:             * @return JPopupMenu instance or null if component was not found.
0191:             */
0192:            public static JPopupMenu findJPopupMenu(Container cont,
0193:                    ComponentChooser chooser, int index) {
0194:                return ((JPopupMenu) findComponent(cont, new JPopupMenuFinder(
0195:                        chooser), index));
0196:            }
0197:
0198:            /**
0199:             * Searches JPopupMenu in container.
0200:             * @param cont Container to search component in.
0201:             * @param chooser a component chooser specifying searching criteria.
0202:             * @return JPopupMenu instance or null if component was not found.
0203:             */
0204:            public static JPopupMenu findJPopupMenu(Container cont,
0205:                    ComponentChooser chooser) {
0206:                return (findJPopupMenu(cont, chooser, 0));
0207:            }
0208:
0209:            /**
0210:             * Waits JPopupMenu in container.
0211:             * @param cont Container to search component in.
0212:             * @param chooser a component chooser specifying searching criteria.
0213:             * @param index Ordinal component index.
0214:             * @return JPopupMenu instance.
0215:             * @throws TimeoutExpiredException
0216:             */
0217:            public static JPopupMenu waitJPopupMenu(Container cont,
0218:                    ComponentChooser chooser, int index) {
0219:                return ((JPopupMenu) waitComponent(cont, new JPopupMenuFinder(
0220:                        chooser), index));
0221:            }
0222:
0223:            /**
0224:             * Waits JPopupMenu in container.
0225:             * @param cont Container to search component in.
0226:             * @param chooser a component chooser specifying searching criteria.
0227:             * @return JPopupMenu instance.
0228:             * @throws TimeoutExpiredException
0229:             */
0230:            public static JPopupMenu waitJPopupMenu(Container cont,
0231:                    ComponentChooser chooser) {
0232:                return (waitJPopupMenu(cont, chooser, 0));
0233:            }
0234:
0235:            /**
0236:             * Searches for a window which contains JPopupMenu.
0237:             * @param chooser a component chooser specifying criteria for JPopupMenu.
0238:             * @return a window containing JPopupMenu.
0239:             */
0240:            public static Window findJPopupWindow(ComponentChooser chooser) {
0241:                return ((new WindowWaiter()).getWindow(new JPopupWindowFinder(
0242:                        chooser)));
0243:            }
0244:
0245:            /**
0246:             * Waits for a window which contains JPopupMenu.
0247:             * @param chooser a component chooser specifying criteria for JPopupMenu.
0248:             * @return a window containing JPopupMenu.
0249:             * @throws TimeoutExpiredException
0250:             */
0251:            public static Window waitJPopupWindow(ComponentChooser chooser) {
0252:                try {
0253:                    return ((new WindowWaiter())
0254:                            .waitWindow(new JPopupWindowFinder(chooser)));
0255:                } catch (InterruptedException e) {
0256:                    return (null);
0257:                }
0258:            }
0259:
0260:            /**
0261:             * Waits popup defined by <code>popupChooser</code> parameter.
0262:             * @param popupChooser a component chooser specifying criteria for JPopupMenu.
0263:             * @return a JPopupMenu fitting the criteria.
0264:             */
0265:            public static JPopupMenuOperator waitJPopupMenu(
0266:                    final ComponentChooser popupChooser) {
0267:                try {
0268:                    WindowOperator wind = new WindowOperator(new WindowWaiter()
0269:                            .waitWindow(new ComponentChooser() {
0270:                                public boolean checkComponent(Component comp) {
0271:                                    ComponentSearcher searcher = new ComponentSearcher(
0272:                                            (Container) comp);
0273:                                    searcher.setOutput(JemmyProperties
0274:                                            .getCurrentOutput()
0275:                                            .createErrorOutput());
0276:                                    return (searcher
0277:                                            .findComponent(popupChooser) != null);
0278:                                }
0279:
0280:                                public String getDescription() {
0281:                                    return ("Window containing \""
0282:                                            + popupChooser.getDescription() + "\" popup");
0283:                                }
0284:                            }));
0285:                    return (new JPopupMenuOperator(wind));
0286:                } catch (InterruptedException e) {
0287:                    throw (new JemmyException(
0288:                            "Popup waiting has been interrupted", e));
0289:                }
0290:            }
0291:
0292:            /**
0293:             * Waits popup containing menu item with <code>menuItemText</code> text.
0294:             * @param menuItemText a text of a menu item which supposed to be displayed inside the popup.
0295:             * @return a JPopupMenu fitting the criteria.
0296:             */
0297:            public static JPopupMenuOperator waitJPopupMenu(
0298:                    final String menuItemText) {
0299:                return (waitJPopupMenu(new ComponentChooser() {
0300:                    public boolean checkComponent(Component comp) {
0301:                        if (comp instanceof  JPopupMenu) {
0302:                            ComponentSearcher searcher = new ComponentSearcher(
0303:                                    (Container) comp);
0304:                            searcher.setOutput(JemmyProperties
0305:                                    .getCurrentOutput().createErrorOutput());
0306:                            return (searcher
0307:                                    .findComponent(new JMenuItemOperator.JMenuItemByLabelFinder(
0308:                                            menuItemText,
0309:                                            Operator
0310:                                                    .getDefaultStringComparator())) != null);
0311:                        } else {
0312:                            return (false);
0313:                        }
0314:                    }
0315:
0316:                    public String getDescription() {
0317:                        return ("Popup containing \"" + menuItemText + "\" menu item");
0318:                    }
0319:                }));
0320:            }
0321:
0322:            /**
0323:             * Calls popup by clicking on (x, y) point in component.
0324:             * @param oper Component operator to call popup on.
0325:             * @param x X coordinate of click point in the component coordinate system.
0326:             * @param y Y coordinate of click point in the component coordinate system.
0327:             * @param mouseButton Mouse button mask to call popup.
0328:             * @return an opened JPopupMenu
0329:             * @throws TimeoutExpiredException
0330:             */
0331:            public static JPopupMenu callPopup(final ComponentOperator oper,
0332:                    int x, int y, int mouseButton) {
0333:                oper.makeComponentVisible();
0334:                //1.5 workaround
0335:                if (System.getProperty("java.specification.version").compareTo(
0336:                        "1.4") > 0) {
0337:                    QueueTool qt = new QueueTool();
0338:                    qt.setOutput(oper.getOutput().createErrorOutput());
0339:                    qt.waitEmpty(10);
0340:                    qt.waitEmpty(10);
0341:                    qt.waitEmpty(10);
0342:                }
0343:                //end of 1.5 workaround
0344:                oper.clickForPopup(x, y, mouseButton);
0345:                oper.getTimeouts()
0346:                        .sleep("JMenuOperator.WaitBeforePopupTimeout");
0347:                return (waitJPopupMenu(waitJPopupWindow(new ComponentChooser() {
0348:                    public boolean checkComponent(Component cmp) {
0349:                        Component invoker = ((JPopupMenu) cmp).getInvoker();
0350:                        return (invoker == oper.getSource()
0351:                                || (invoker instanceof  Container && ((Container) invoker)
0352:                                        .isAncestorOf(oper.getSource())) || (oper
0353:                                .getSource() instanceof  Container && ((Container) oper
0354:                                .getSource()).isAncestorOf(invoker)));
0355:                    }
0356:
0357:                    public String getDescription() {
0358:                        return ("Popup menu");
0359:
0360:                    }
0361:                }), ComponentSearcher.getTrueChooser("Popup menu")));
0362:            }
0363:
0364:            /**
0365:             * Calls popup by clicking on (x, y) point in component.
0366:             * @param oper Component operator to call popup on.
0367:             * @param x X coordinate of click point in the component coordinate system.
0368:             * @param y Y coordinate of click point in the component coordinate system.
0369:             * @return an opened JPopupMenu
0370:             * @see ComponentOperator#getPopupMouseButton()
0371:             * @throws TimeoutExpiredException
0372:             */
0373:            public static JPopupMenu callPopup(ComponentOperator oper, int x,
0374:                    int y) {
0375:                return (callPopup(oper, x, y, getPopupMouseButton()));
0376:            }
0377:
0378:            /**
0379:             * Calls popup by clicking on (x, y) point in component.
0380:             * @param comp Component to call popup on.
0381:             * @param x X coordinate of click point in the component coordinate system.
0382:             * @param y Y coordinate of click point in the component coordinate system.
0383:             * @param mouseButton Mouse button mask to call popup.
0384:             * @return an opened JPopupMenu
0385:             * @throws TimeoutExpiredException
0386:             */
0387:            public static JPopupMenu callPopup(Component comp, int x, int y,
0388:                    int mouseButton) {
0389:                return (callPopup(new ComponentOperator(comp), x, y,
0390:                        mouseButton));
0391:            }
0392:
0393:            /**
0394:             * Calls popup by clicking on (x, y) point in component.
0395:             * @param comp Component to call popup on.
0396:             * @param x X coordinate of click point in the component coordinate system.
0397:             * @param y Y coordinate of click point in the component coordinate system.
0398:             * @return an opened JPopupMenu
0399:             * @see ComponentOperator#getPopupMouseButton()
0400:             * @throws TimeoutExpiredException
0401:             */
0402:            public static JPopupMenu callPopup(Component comp, int x, int y) {
0403:                return (callPopup(comp, x, y, getPopupMouseButton()));
0404:            }
0405:
0406:            /**
0407:             * Calls popup by clicking component center.
0408:             * @param comp Component to call popup on.
0409:             * @param mouseButton Mouse button mask to call popup.
0410:             * @return an opened JPopupMenu
0411:             * @throws TimeoutExpiredException
0412:             */
0413:            public static JPopupMenu callPopup(Component comp, int mouseButton) {
0414:                ComponentOperator co = new ComponentOperator(comp);
0415:                co.makeComponentVisible();
0416:                co.clickForPopup(mouseButton);
0417:                return (findJPopupMenu(waitJPopupWindow(ComponentSearcher
0418:                        .getTrueChooser("Popup menu window")),
0419:                        ComponentSearcher.getTrueChooser("Popup menu")));
0420:            }
0421:
0422:            /**
0423:             * Calls popup by clicking component center.
0424:             * @param comp Component to call popup on.
0425:             * @return an opened JPopupMenu
0426:             * @see ComponentOperator#getPopupMouseButton()
0427:             * @throws TimeoutExpiredException
0428:             */
0429:            public static JPopupMenu callPopup(Component comp) {
0430:                return (callPopup(comp, getPopupMouseButton()));
0431:            }
0432:
0433:            static {
0434:                //necessary to init timeouts
0435:                JMenuOperator.class.getName();
0436:            }
0437:
0438:            public void setOutput(TestOut out) {
0439:                super .setOutput(out);
0440:                output = out;
0441:            }
0442:
0443:            public TestOut getOutput() {
0444:                return (output);
0445:            }
0446:
0447:            public void setTimeouts(Timeouts times) {
0448:                super .setTimeouts(times);
0449:                timeouts = times;
0450:            }
0451:
0452:            public Timeouts getTimeouts() {
0453:                return (timeouts);
0454:            }
0455:
0456:            public void copyEnvironment(Operator anotherOperator) {
0457:                super .copyEnvironment(anotherOperator);
0458:                driver = DriverManager.getMenuDriver(this );
0459:            }
0460:
0461:            /**
0462:             * Pushes menu.
0463:             * @param choosers Array of choosers to find menuItems to push.
0464:             * @return Last pushed JMenuItem.
0465:             * @throws TimeoutExpiredException
0466:             */
0467:            public JMenuItem pushMenu(final ComponentChooser[] choosers) {
0468:                return ((JMenuItem) produceTimeRestricted(new Action() {
0469:                    public Object launch(Object obj) {
0470:                        //TDB 1.5 menu workaround
0471:                        getQueueTool().waitEmpty();
0472:                        Object result = driver.pushMenu(
0473:                                JPopupMenuOperator.this , JMenuOperator
0474:                                        .converChoosers(choosers));
0475:                        getQueueTool().waitEmpty();
0476:                        return (result);
0477:                    }
0478:
0479:                    public String getDescription() {
0480:                        return (JMenuOperator.createDescription(choosers));
0481:                    }
0482:                }, getTimeouts().getTimeout("JMenuOperator.PushMenuTimeout")));
0483:            }
0484:
0485:            /**
0486:             * Executes <code>pushMenu(choosers)</code> in a separate thread.
0487:             * @param choosers Array of choosers to find menuItems to push.
0488:             * @see #pushMenu(ComponentChooser[])
0489:             */
0490:            public void pushMenuNoBlock(final ComponentChooser[] choosers) {
0491:                produceNoBlocking(new NoBlockingAction("Menu pushing") {
0492:                    public Object doAction(Object param) {
0493:                        //TDB 1.5 menu workaround
0494:                        getQueueTool().waitEmpty();
0495:                        Object result = driver.pushMenu(
0496:                                JPopupMenuOperator.this , JMenuOperator
0497:                                        .converChoosers(choosers));
0498:                        getQueueTool().waitEmpty();
0499:                        return (result);
0500:                    }
0501:                });
0502:            }
0503:
0504:            /**
0505:             * Pushes menu.
0506:             * @param names an array of menu texts.
0507:             * @param comparator a string comparision algorithm
0508:             * @return Last pushed JMenuItem.
0509:             * @throws TimeoutExpiredException
0510:             */
0511:            public JMenuItem pushMenu(String[] names,
0512:                    StringComparator comparator) {
0513:                return (pushMenu(JMenuItemOperator.createChoosers(names,
0514:                        comparator)));
0515:            }
0516:
0517:            /**
0518:             * Pushes menu.
0519:             * @param names Menu items texts.
0520:             * @param ce Compare text exactly.
0521:             * @param ccs Compare text case sensitively.
0522:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
0523:             * @return Last pushed JMenuItem.
0524:             * @throws TimeoutExpiredException
0525:             * @deprecated Use pushMenu(String[]) or pushMenu(String[], StringComparator)
0526:             */
0527:            public JMenuItem pushMenu(String[] names, boolean ce, boolean ccs) {
0528:                return (pushMenu(names, new DefaultStringComparator(ce, ccs)));
0529:            }
0530:
0531:            /**
0532:             * Executes <code>pushMenu(names, ce, ccs)</code> in a separate thread.
0533:             * @param names an array of menu texts.
0534:             * @param comparator a string comparision algorithm
0535:             */
0536:            public void pushMenuNoBlock(String[] names,
0537:                    StringComparator comparator) {
0538:                pushMenuNoBlock(JMenuItemOperator.createChoosers(names,
0539:                        comparator));
0540:            }
0541:
0542:            /**
0543:             * Executes <code>pushMenu(names, ce, ccs)</code> in a separate thread.
0544:             * @param names Menu items texts.
0545:             * @param ce Compare text exactly.
0546:             * @param ccs Compare text case sensitively.
0547:             * @see #pushMenu(String[], boolean,boolean)
0548:             * @deprecated Use pushMenuNoBlock(String[]) or pushMenuNoBlock(String[], StringComparator)
0549:             */
0550:            public void pushMenuNoBlock(String[] names, boolean ce, boolean ccs) {
0551:                pushMenuNoBlock(names, new DefaultStringComparator(ce, ccs));
0552:            }
0553:
0554:            /**
0555:             * Pushes menu.
0556:             * @param names Menu items texts.
0557:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
0558:             * @return Last pushed JMenuItem.
0559:             * @throws TimeoutExpiredException
0560:             */
0561:            public JMenuItem pushMenu(String[] names) {
0562:                return (pushMenu(names, getComparator()));
0563:            }
0564:
0565:            /**
0566:             * Executes <code>pushMenu(names)</code> in a separate thread.
0567:             * @param names Menu items texts.
0568:             * @see #pushMenu(String[])
0569:             */
0570:            public void pushMenuNoBlock(String[] names) {
0571:                pushMenuNoBlock(names, getComparator());
0572:            }
0573:
0574:            /**
0575:             * Pushes menu.
0576:             * @param path a menu path.
0577:             * @param delim a path delimiter.
0578:             * @param comparator a string comparision algorithm
0579:             * @return Last pushed JMenuItem.
0580:             * @throws TimeoutExpiredException
0581:             */
0582:            public JMenuItem pushMenu(String path, String delim,
0583:                    StringComparator comparator) {
0584:                return (pushMenu(parseString(path, delim), comparator));
0585:            }
0586:
0587:            /**
0588:             * Pushes menu. Uses PathParser assigned to this operator.
0589:             * @param path a menu path.
0590:             * @param comparator a string comparision algorithm
0591:             * @return Last pushed JMenuItem.
0592:             * @throws TimeoutExpiredException
0593:             */
0594:            public JMenuItem pushMenu(String path, StringComparator comparator) {
0595:                return (pushMenu(parseString(path), comparator));
0596:            }
0597:
0598:            /**
0599:             * Pushes menu.
0600:             * @param path String menupath representation ("File/New", for example).
0601:             * @param delim String menupath divider ("/").
0602:             * @param ce Compare text exactly.
0603:             * @param ccs Compare text case sensitively.
0604:             * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
0605:             * @return Last pushed JMenuItem.
0606:             * @throws TimeoutExpiredException
0607:             * @deprecated Use pushMenu(String, String) or pushMenu(String, String, StringComparator)
0608:             */
0609:            public JMenuItem pushMenu(String path, String delim, boolean ce,
0610:                    boolean ccs) {
0611:                return (pushMenu(parseString(path, delim), ce, ccs));
0612:            }
0613:
0614:            /**
0615:             * Executes <code>pushMenu(names, delim, comparator)</code> in a separate thread.
0616:             * @param path a menu path.
0617:             * @param delim a path delimiter.
0618:             * @param comparator a string comparision algorithm
0619:             */
0620:            public void pushMenuNoBlock(String path, String delim,
0621:                    StringComparator comparator) {
0622:                pushMenuNoBlock(parseString(path, delim), comparator);
0623:            }
0624:
0625:            /**
0626:             * Executes <code>pushMenu(names, comparator)</code> in a separate thread.
0627:             * Uses PathParser assigned to this operator.
0628:             * @param path a menu path.
0629:             * @param comparator a string comparision algorithm
0630:             */
0631:            public void pushMenuNoBlock(String path, StringComparator comparator) {
0632:                pushMenuNoBlock(parseString(path), comparator);
0633:            }
0634:
0635:            /**
0636:             * Executes <code>pushMenu(path, delim, ce, ccs)</code> in a separate thread.
0637:             * @param path String menupath representation ("File/New", for example).
0638:             * @param delim String menupath divider ("/").
0639:             * @param ce Compare text exactly.
0640:             * @param ccs Compare text case sensitively.
0641:             * @see #pushMenu
0642:             * @deprecated Use pushMenuNoBlock(String, String) or pushMenuNoBlock(String, String, StringComparator)
0643:             */
0644:            public void pushMenuNoBlock(String path, String delim, boolean ce,
0645:                    boolean ccs) {
0646:                pushMenuNoBlock(parseString(path, delim), ce, ccs);
0647:            }
0648:
0649:            /**
0650:             * Pushes menu.
0651:             * @param path String menupath representation ("File/New", for example).
0652:             * @param delim String menupath divider ("/").
0653:             * @return Last pushed JMenuItem.
0654:             * @throws TimeoutExpiredException
0655:             */
0656:            public JMenuItem pushMenu(String path, String delim) {
0657:                return (pushMenu(parseString(path, delim)));
0658:            }
0659:
0660:            /**
0661:             * Pushes menu. Uses PathParser assigned to this operator.
0662:             * @param path String menupath representation ("File/New", for example).
0663:             * @return Last pushed JMenuItem.
0664:             * @throws TimeoutExpiredException
0665:             */
0666:            public JMenuItem pushMenu(String path) {
0667:                return (pushMenu(parseString(path)));
0668:            }
0669:
0670:            /**
0671:             * Executes <code>pushMenu(path, delim)</code> in a separate thread.
0672:             * @param path String menupath representation ("File/New", for example).
0673:             * @param delim String menupath divider ("/").
0674:             */
0675:            public void pushMenuNoBlock(String path, String delim) {
0676:                pushMenuNoBlock(parseString(path, delim));
0677:            }
0678:
0679:            /**
0680:             * Executes <code>pushMenu(path)</code> in a separate thread.
0681:             * @param path String menupath representation ("File/New", for example).
0682:             */
0683:            public void pushMenuNoBlock(String path) {
0684:                pushMenuNoBlock(parseString(path));
0685:            }
0686:
0687:            public JMenuItemOperator[] showMenuItems(ComponentChooser[] choosers) {
0688:                if (choosers == null || choosers.length == 0) {
0689:                    return (JMenuItemOperator.getMenuItems(
0690:                            (MenuElement) getSource(), this ));
0691:                } else {
0692:                    return (JMenuItemOperator.getMenuItems(
0693:                            (JMenu) pushMenu(choosers), this ));
0694:                }
0695:            }
0696:
0697:            /**
0698:             * Shows submenu of menu specified by a <code>path</code> parameter.
0699:             * @param path an array of menu texts.
0700:             * @param comparator a string comparision algorithm
0701:             * @return an array of operators created tor items from the submenu.
0702:             * @throws TimeoutExpiredException
0703:             */
0704:            public JMenuItemOperator[] showMenuItems(String[] path,
0705:                    StringComparator comparator) {
0706:                if (path == null || path.length == 0) {
0707:                    return (JMenuItemOperator.getMenuItems(
0708:                            (MenuElement) getSource(), this ));
0709:                } else {
0710:                    return (JMenuItemOperator.getMenuItems((JMenu) pushMenu(
0711:                            path, comparator), this ));
0712:                }
0713:            }
0714:
0715:            /**
0716:             * Shows submenu of menu specified by a <code>path</code> parameter.
0717:             * Uses StringComparator assigned to the operator.
0718:             * @param path an array of menu texts.
0719:             * @return an array of operators created tor items from the submenu.
0720:             * @throws TimeoutExpiredException
0721:             */
0722:            public JMenuItemOperator[] showMenuItems(String[] path) {
0723:                return (showMenuItems(path, getComparator()));
0724:            }
0725:
0726:            /**
0727:             * Shows submenu of menu specified by a <code>path</code> parameter.
0728:             * @param path a string identifying the menu path.
0729:             * @param delim a path delimiter.
0730:             * @param comparator a string comparision algorithm
0731:             * @return an array of operators created tor items from the submenu.
0732:             * @throws TimeoutExpiredException
0733:             */
0734:            public JMenuItemOperator[] showMenuItems(String path, String delim,
0735:                    StringComparator comparator) {
0736:                return (showMenuItems(parseString(path, delim), comparator));
0737:            }
0738:
0739:            /**
0740:             * Shows submenu of menu specified by a <code>path</code> parameter.
0741:             * Uses PathParser assigned to this operator.
0742:             * @param path a string identifying the menu path.
0743:             * @param comparator a string comparision algorithm
0744:             * @return an array of operators created tor items from the submenu.
0745:             * @throws TimeoutExpiredException
0746:             */
0747:            public JMenuItemOperator[] showMenuItems(String path,
0748:                    StringComparator comparator) {
0749:                return (showMenuItems(parseString(path), comparator));
0750:            }
0751:
0752:            /**
0753:             * Shows submenu of menu specified by a <code>path</code> parameter.
0754:             * Uses StringComparator assigned to the operator.
0755:             * @param path a string identifying the menu path.
0756:             * @param delim a path delimiter.
0757:             * @return an array of operators created tor items from the submenu.
0758:             * @throws TimeoutExpiredException
0759:             */
0760:            public JMenuItemOperator[] showMenuItems(String path, String delim) {
0761:                return (showMenuItems(path, delim, getComparator()));
0762:            }
0763:
0764:            /**
0765:             * Shows submenu of menu specified by a <code>path</code> parameter.
0766:             * Uses PathParser assigned to this operator.
0767:             * Uses StringComparator assigned to the operator.
0768:             * @param path a string identifying the menu path.
0769:             * @return an array of operators created tor items from the submenu.
0770:             * @throws TimeoutExpiredException
0771:             */
0772:            public JMenuItemOperator[] showMenuItems(String path) {
0773:                return (showMenuItems(path, getComparator()));
0774:            }
0775:
0776:            public JMenuItemOperator showMenuItem(ComponentChooser[] choosers) {
0777:                ComponentChooser[] parentPath = getParentPath(choosers);
0778:                JMenu menu;
0779:                ContainerOperator menuCont;
0780:                if (parentPath.length > 0) {
0781:                    menu = (JMenu) pushMenu(getParentPath(choosers));
0782:                    menuCont = new ContainerOperator(menu.getPopupMenu());
0783:                    menuCont.copyEnvironment(this );
0784:                } else {
0785:                    menuCont = this ;
0786:                }
0787:                JMenuItemOperator result = new JMenuItemOperator(menuCont,
0788:                        choosers[choosers.length - 1]);
0789:                result.copyEnvironment(this );
0790:                return (result);
0791:            }
0792:
0793:            /**
0794:             * Expends all menus to show menu item specified by a <code>path</code> parameter.
0795:             * @param path an array of menu texts.
0796:             * @param comparator a string comparision algorithm
0797:             * @return an operator for the last menu item in path.
0798:             * @throws TimeoutExpiredException
0799:             */
0800:            public JMenuItemOperator showMenuItem(String[] path,
0801:                    StringComparator comparator) {
0802:                String[] parentPath = getParentPath(path);
0803:                JMenu menu;
0804:                ContainerOperator menuCont;
0805:                if (parentPath.length > 0) {
0806:                    menu = (JMenu) pushMenu(getParentPath(path), comparator);
0807:                    menuCont = new ContainerOperator(menu.getPopupMenu());
0808:                    menuCont.copyEnvironment(this );
0809:                } else {
0810:                    menuCont = this ;
0811:                }
0812:                JMenuItemOperator result = new JMenuItemOperator(menuCont,
0813:                        path[path.length - 1]);
0814:                result.copyEnvironment(this );
0815:                return (result);
0816:            }
0817:
0818:            /**
0819:             * Expands all menus to show menu item specified by a <code>path</code> parameter.
0820:             * @param path an array of menu texts.
0821:             * @return an operator for the last menu item in path.
0822:             * @throws TimeoutExpiredException
0823:             */
0824:            public JMenuItemOperator showMenuItem(String[] path) {
0825:                return (showMenuItem(path, getComparator()));
0826:            }
0827:
0828:            /**
0829:             * Expands all menus to show menu item specified by a <code>path</code> parameter.
0830:             * @param path a string identifying the menu path.
0831:             * @param delim a path delimiter.
0832:             * @param comparator a string comparision algorithm
0833:             * @return an operator for the last menu item in path.
0834:             * @throws TimeoutExpiredException
0835:             */
0836:            public JMenuItemOperator showMenuItem(String path, String delim,
0837:                    StringComparator comparator) {
0838:                return (showMenuItem(parseString(path, delim), comparator));
0839:            }
0840:
0841:            /**
0842:             * Expands all menus to show menu item specified by a <code>path</code> parameter.
0843:             * Uses PathParser assigned to this operator.
0844:             * @param path a string identifying the menu path.
0845:             * @param comparator a string comparision algorithm
0846:             * @return an operator for the last menu item in path.
0847:             * @throws TimeoutExpiredException
0848:             */
0849:            public JMenuItemOperator showMenuItem(String path,
0850:                    StringComparator comparator) {
0851:                return (showMenuItem(parseString(path), comparator));
0852:            }
0853:
0854:            /**
0855:             * Expands all menus to show menu item specified by a <code>path</code> parameter.
0856:             * Uses StringComparator assigned to the operator.
0857:             * @param path a string identifying the menu path.
0858:             * @param delim a path delimiter.
0859:             * @return an operator for the last menu item in path.
0860:             * @throws TimeoutExpiredException
0861:             */
0862:            public JMenuItemOperator showMenuItem(String path, String delim) {
0863:                return (showMenuItem(path, delim, getComparator()));
0864:            }
0865:
0866:            /**
0867:             * Expands all menus to show menu item specified by a <code>path</code> parameter.
0868:             * Uses PathParser assigned to this operator.
0869:             * Uses StringComparator assigned to the operator.
0870:             * @param path a string identifying the menu path.
0871:             * @return an array of operators created tor items from the submenu.
0872:             * @throws TimeoutExpiredException
0873:             */
0874:            public JMenuItemOperator showMenuItem(String path) {
0875:                return (showMenuItem(path, getComparator()));
0876:            }
0877:
0878:            public Hashtable getDump() {
0879:                Hashtable result = super .getDump();
0880:                if (((JPopupMenu) getSource()).getLabel() != null) {
0881:                    result.put(LABEL_DPROP, ((JPopupMenu) getSource())
0882:                            .getLabel());
0883:                }
0884:                return (result);
0885:            }
0886:
0887:            ////////////////////////////////////////////////////////
0888:            //Mapping                                             //
0889:
0890:            /**Maps <code>JPopupMenu.add(String)</code> through queue*/
0891:            public JMenuItem add(final String string) {
0892:                return ((JMenuItem) runMapping(new MapAction("add") {
0893:                    public Object map() {
0894:                        return (((JPopupMenu) getSource()).add(string));
0895:                    }
0896:                }));
0897:            }
0898:
0899:            /**Maps <code>JPopupMenu.add(Action)</code> through queue*/
0900:            public JMenuItem add(final javax.swing.Action action) {
0901:                return ((JMenuItem) runMapping(new MapAction("add") {
0902:                    public Object map() {
0903:                        return (((JPopupMenu) getSource()).add(action));
0904:                    }
0905:                }));
0906:            }
0907:
0908:            /**Maps <code>JPopupMenu.add(JMenuItem)</code> through queue*/
0909:            public JMenuItem add(final JMenuItem jMenuItem) {
0910:                return ((JMenuItem) runMapping(new MapAction("add") {
0911:                    public Object map() {
0912:                        return (((JPopupMenu) getSource()).add(jMenuItem));
0913:                    }
0914:                }));
0915:            }
0916:
0917:            /**Maps <code>JPopupMenu.addPopupMenuListener(PopupMenuListener)</code> through queue*/
0918:            public void addPopupMenuListener(
0919:                    final PopupMenuListener popupMenuListener) {
0920:                runMapping(new MapVoidAction("addPopupMenuListener") {
0921:                    public void map() {
0922:                        ((JPopupMenu) getSource())
0923:                                .addPopupMenuListener(popupMenuListener);
0924:                    }
0925:                });
0926:            }
0927:
0928:            /**Maps <code>JPopupMenu.addSeparator()</code> through queue*/
0929:            public void addSeparator() {
0930:                runMapping(new MapVoidAction("addSeparator") {
0931:                    public void map() {
0932:                        ((JPopupMenu) getSource()).addSeparator();
0933:                    }
0934:                });
0935:            }
0936:
0937:            /**Maps <code>JPopupMenu.getComponentIndex(Component)</code> through queue*/
0938:            public int getComponentIndex(final Component component) {
0939:                return (runMapping(new MapIntegerAction("getComponentIndex") {
0940:                    public int map() {
0941:                        return (((JPopupMenu) getSource())
0942:                                .getComponentIndex(component));
0943:                    }
0944:                }));
0945:            }
0946:
0947:            /**Maps <code>JPopupMenu.getInvoker()</code> through queue*/
0948:            public Component getInvoker() {
0949:                return ((Component) runMapping(new MapAction("getInvoker") {
0950:                    public Object map() {
0951:                        return (((JPopupMenu) getSource()).getInvoker());
0952:                    }
0953:                }));
0954:            }
0955:
0956:            /**Maps <code>JPopupMenu.getLabel()</code> through queue*/
0957:            public String getLabel() {
0958:                return ((String) runMapping(new MapAction("getLabel") {
0959:                    public Object map() {
0960:                        return (((JPopupMenu) getSource()).getLabel());
0961:                    }
0962:                }));
0963:            }
0964:
0965:            /**Maps <code>JPopupMenu.getMargin()</code> through queue*/
0966:            public Insets getMargin() {
0967:                return ((Insets) runMapping(new MapAction("getMargin") {
0968:                    public Object map() {
0969:                        return (((JPopupMenu) getSource()).getMargin());
0970:                    }
0971:                }));
0972:            }
0973:
0974:            /**Maps <code>JPopupMenu.getSelectionModel()</code> through queue*/
0975:            public SingleSelectionModel getSelectionModel() {
0976:                return ((SingleSelectionModel) runMapping(new MapAction(
0977:                        "getSelectionModel") {
0978:                    public Object map() {
0979:                        return (((JPopupMenu) getSource()).getSelectionModel());
0980:                    }
0981:                }));
0982:            }
0983:
0984:            /**Maps <code>JPopupMenu.getSubElements()</code> through queue*/
0985:            public MenuElement[] getSubElements() {
0986:                return ((MenuElement[]) runMapping(new MapAction(
0987:                        "getSubElements") {
0988:                    public Object map() {
0989:                        return (((JPopupMenu) getSource()).getSubElements());
0990:                    }
0991:                }));
0992:            }
0993:
0994:            /**Maps <code>JPopupMenu.getUI()</code> through queue*/
0995:            public PopupMenuUI getUI() {
0996:                return ((PopupMenuUI) runMapping(new MapAction("getUI") {
0997:                    public Object map() {
0998:                        return (((JPopupMenu) getSource()).getUI());
0999:                    }
1000:                }));
1001:            }
1002:
1003:            /**Maps <code>JPopupMenu.insert(Component, int)</code> through queue*/
1004:            public void insert(final Component component, final int i) {
1005:                runMapping(new MapVoidAction("insert") {
1006:                    public void map() {
1007:                        ((JPopupMenu) getSource()).insert(component, i);
1008:                    }
1009:                });
1010:            }
1011:
1012:            /**Maps <code>JPopupMenu.insert(Action, int)</code> through queue*/
1013:            public void insert(final javax.swing.Action action, final int i) {
1014:                runMapping(new MapVoidAction("insert") {
1015:                    public void map() {
1016:                        ((JPopupMenu) getSource()).insert(action, i);
1017:                    }
1018:                });
1019:            }
1020:
1021:            /**Maps <code>JPopupMenu.isBorderPainted()</code> through queue*/
1022:            public boolean isBorderPainted() {
1023:                return (runMapping(new MapBooleanAction("isBorderPainted") {
1024:                    public boolean map() {
1025:                        return (((JPopupMenu) getSource()).isBorderPainted());
1026:                    }
1027:                }));
1028:            }
1029:
1030:            /**Maps <code>JPopupMenu.isLightWeightPopupEnabled()</code> through queue*/
1031:            public boolean isLightWeightPopupEnabled() {
1032:                return (runMapping(new MapBooleanAction(
1033:                        "isLightWeightPopupEnabled") {
1034:                    public boolean map() {
1035:                        return (((JPopupMenu) getSource())
1036:                                .isLightWeightPopupEnabled());
1037:                    }
1038:                }));
1039:            }
1040:
1041:            /**Maps <code>JPopupMenu.menuSelectionChanged(boolean)</code> through queue*/
1042:            public void menuSelectionChanged(final boolean b) {
1043:                runMapping(new MapVoidAction("menuSelectionChanged") {
1044:                    public void map() {
1045:                        ((JPopupMenu) getSource()).menuSelectionChanged(b);
1046:                    }
1047:                });
1048:            }
1049:
1050:            /**Maps <code>JPopupMenu.pack()</code> through queue*/
1051:            public void pack() {
1052:                runMapping(new MapVoidAction("pack") {
1053:                    public void map() {
1054:                        ((JPopupMenu) getSource()).pack();
1055:                    }
1056:                });
1057:            }
1058:
1059:            /**Maps <code>JPopupMenu.processKeyEvent(KeyEvent, MenuElement[], MenuSelectionManager)</code> through queue*/
1060:            public void processKeyEvent(final KeyEvent keyEvent,
1061:                    final MenuElement[] menuElement,
1062:                    final MenuSelectionManager menuSelectionManager) {
1063:                runMapping(new MapVoidAction("processKeyEvent") {
1064:                    public void map() {
1065:                        ((JPopupMenu) getSource()).processKeyEvent(keyEvent,
1066:                                menuElement, menuSelectionManager);
1067:                    }
1068:                });
1069:            }
1070:
1071:            /**Maps <code>JPopupMenu.processMouseEvent(MouseEvent, MenuElement[], MenuSelectionManager)</code> through queue*/
1072:            public void processMouseEvent(final MouseEvent mouseEvent,
1073:                    final MenuElement[] menuElement,
1074:                    final MenuSelectionManager menuSelectionManager) {
1075:                runMapping(new MapVoidAction("processMouseEvent") {
1076:                    public void map() {
1077:                        ((JPopupMenu) getSource()).processMouseEvent(
1078:                                mouseEvent, menuElement, menuSelectionManager);
1079:                    }
1080:                });
1081:            }
1082:
1083:            /**Maps <code>JPopupMenu.removePopupMenuListener(PopupMenuListener)</code> through queue*/
1084:            public void removePopupMenuListener(
1085:                    final PopupMenuListener popupMenuListener) {
1086:                runMapping(new MapVoidAction("removePopupMenuListener") {
1087:                    public void map() {
1088:                        ((JPopupMenu) getSource())
1089:                                .removePopupMenuListener(popupMenuListener);
1090:                    }
1091:                });
1092:            }
1093:
1094:            /**Maps <code>JPopupMenu.setBorderPainted(boolean)</code> through queue*/
1095:            public void setBorderPainted(final boolean b) {
1096:                runMapping(new MapVoidAction("setBorderPainted") {
1097:                    public void map() {
1098:                        ((JPopupMenu) getSource()).setBorderPainted(b);
1099:                    }
1100:                });
1101:            }
1102:
1103:            /**Maps <code>JPopupMenu.setInvoker(Component)</code> through queue*/
1104:            public void setInvoker(final Component component) {
1105:                runMapping(new MapVoidAction("setInvoker") {
1106:                    public void map() {
1107:                        ((JPopupMenu) getSource()).setInvoker(component);
1108:                    }
1109:                });
1110:            }
1111:
1112:            /**Maps <code>JPopupMenu.setLabel(String)</code> through queue*/
1113:            public void setLabel(final String string) {
1114:                runMapping(new MapVoidAction("setLabel") {
1115:                    public void map() {
1116:                        ((JPopupMenu) getSource()).setLabel(string);
1117:                    }
1118:                });
1119:            }
1120:
1121:            /**Maps <code>JPopupMenu.setLightWeightPopupEnabled(boolean)</code> through queue*/
1122:            public void setLightWeightPopupEnabled(final boolean b) {
1123:                runMapping(new MapVoidAction("setLightWeightPopupEnabled") {
1124:                    public void map() {
1125:                        ((JPopupMenu) getSource())
1126:                                .setLightWeightPopupEnabled(b);
1127:                    }
1128:                });
1129:            }
1130:
1131:            /**Maps <code>JPopupMenu.setPopupSize(int, int)</code> through queue*/
1132:            public void setPopupSize(final int i, final int i1) {
1133:                runMapping(new MapVoidAction("setPopupSize") {
1134:                    public void map() {
1135:                        ((JPopupMenu) getSource()).setPopupSize(i, i1);
1136:                    }
1137:                });
1138:            }
1139:
1140:            /**Maps <code>JPopupMenu.setPopupSize(Dimension)</code> through queue*/
1141:            public void setPopupSize(final Dimension dimension) {
1142:                runMapping(new MapVoidAction("setPopupSize") {
1143:                    public void map() {
1144:                        ((JPopupMenu) getSource()).setPopupSize(dimension);
1145:                    }
1146:                });
1147:            }
1148:
1149:            /**Maps <code>JPopupMenu.setSelected(Component)</code> through queue*/
1150:            public void setSelected(final Component component) {
1151:                runMapping(new MapVoidAction("setSelected") {
1152:                    public void map() {
1153:                        ((JPopupMenu) getSource()).setSelected(component);
1154:                    }
1155:                });
1156:            }
1157:
1158:            /**Maps <code>JPopupMenu.setSelectionModel(SingleSelectionModel)</code> through queue*/
1159:            public void setSelectionModel(
1160:                    final SingleSelectionModel singleSelectionModel) {
1161:                runMapping(new MapVoidAction("setSelectionModel") {
1162:                    public void map() {
1163:                        ((JPopupMenu) getSource())
1164:                                .setSelectionModel(singleSelectionModel);
1165:                    }
1166:                });
1167:            }
1168:
1169:            /**Maps <code>JPopupMenu.setUI(PopupMenuUI)</code> through queue*/
1170:            public void setUI(final PopupMenuUI popupMenuUI) {
1171:                runMapping(new MapVoidAction("setUI") {
1172:                    public void map() {
1173:                        ((JPopupMenu) getSource()).setUI(popupMenuUI);
1174:                    }
1175:                });
1176:            }
1177:
1178:            /**Maps <code>JPopupMenu.show(Component, int, int)</code> through queue*/
1179:            public void show(final Component component, final int i,
1180:                    final int i1) {
1181:                runMapping(new MapVoidAction("show") {
1182:                    public void map() {
1183:                        ((JPopupMenu) getSource()).show(component, i, i1);
1184:                    }
1185:                });
1186:            }
1187:
1188:            //End of mapping                                      //
1189:            ////////////////////////////////////////////////////////
1190:
1191:            /**
1192:             * Checks component type.
1193:             */
1194:            public static class JPopupMenuFinder extends Finder {
1195:                /**
1196:                 * Constructs JPopupMenuFinder.
1197:                 * @param sf other searching criteria.
1198:                 */
1199:                public JPopupMenuFinder(ComponentChooser sf) {
1200:                    super (JPopupMenu.class, sf);
1201:                }
1202:
1203:                /**
1204:                 * Constructs JPopupMenuFinder.
1205:                 */
1206:                public JPopupMenuFinder() {
1207:                    super (JPopupMenu.class);
1208:                }
1209:
1210:                public boolean checkComponent(Component comp) {
1211:                    return (comp.isShowing() && super .checkComponent(comp));
1212:                }
1213:            }
1214:
1215:            /**
1216:             * Allwos to find a window containing JPopupMenu.
1217:             */
1218:            public static class JPopupWindowFinder implements  ComponentChooser {
1219:                ComponentChooser subFinder;
1220:                ComponentChooser ppFinder;
1221:
1222:                /**
1223:                 * Constructs JPopupWindowFinder.
1224:                 * @param sf searching criteria for a JPopupMenu inside the window..
1225:                 */
1226:                public JPopupWindowFinder(ComponentChooser sf) {
1227:                    subFinder = new JPopupMenuFinder(sf);
1228:                    ppFinder = new ComponentChooser() {
1229:                        public boolean checkComponent(Component comp) {
1230:                            return (comp.isShowing() && comp.isVisible() && subFinder
1231:                                    .checkComponent(comp));
1232:                        }
1233:
1234:                        public String getDescription() {
1235:                            return (subFinder.getDescription());
1236:                        }
1237:                    };
1238:                }
1239:
1240:                /**
1241:                 * Constructs JPopupWindowFinder.
1242:                 */
1243:                public JPopupWindowFinder() {
1244:                    this (ComponentSearcher.getTrueChooser("Any JPopupWindow"));
1245:                }
1246:
1247:                public boolean checkComponent(Component comp) {
1248:                    if (comp.isShowing() && comp instanceof  Window) {
1249:                        ComponentSearcher cs = new ComponentSearcher(
1250:                                (Container) comp);
1251:                        cs.setOutput(JemmyProperties.getCurrentOutput()
1252:                                .createErrorOutput());
1253:                        return (cs.findComponent(ppFinder) != null);
1254:                    }
1255:                    return (false);
1256:                }
1257:
1258:                public String getDescription() {
1259:                    return (subFinder.getDescription());
1260:                }
1261:            }
1262:
1263:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.