ComponentOperator.java revision 13978:1993af50385d
1/* 2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23package org.netbeans.jemmy.operators; 24 25import java.awt.AWTEvent; 26import java.awt.Color; 27import java.awt.Component; 28import java.awt.ComponentOrientation; 29import java.awt.Container; 30import java.awt.Cursor; 31import java.awt.Dimension; 32import java.awt.Font; 33import java.awt.FontMetrics; 34import java.awt.Graphics; 35import java.awt.Image; 36import java.awt.MenuComponent; 37import java.awt.Point; 38import java.awt.PopupMenu; 39import java.awt.Rectangle; 40import java.awt.Toolkit; 41import java.awt.Window; 42import java.awt.dnd.DropTarget; 43import java.awt.event.ComponentListener; 44import java.awt.event.FocusListener; 45import java.awt.event.InputMethodListener; 46import java.awt.event.KeyListener; 47import java.awt.event.MouseListener; 48import java.awt.event.MouseMotionListener; 49import java.awt.im.InputContext; 50import java.awt.im.InputMethodRequests; 51import java.awt.image.ColorModel; 52import java.awt.image.ImageObserver; 53import java.awt.image.ImageProducer; 54import java.beans.PropertyChangeListener; 55import java.io.PrintStream; 56import java.io.PrintWriter; 57import java.util.Hashtable; 58import java.util.Locale; 59 60import org.netbeans.jemmy.CharBindingMap; 61import org.netbeans.jemmy.ComponentChooser; 62import org.netbeans.jemmy.ComponentSearcher; 63import org.netbeans.jemmy.EventDispatcher; 64import org.netbeans.jemmy.JemmyException; 65import org.netbeans.jemmy.JemmyProperties; 66import org.netbeans.jemmy.Outputable; 67import org.netbeans.jemmy.QueueTool; 68import org.netbeans.jemmy.TestOut; 69import org.netbeans.jemmy.TimeoutExpiredException; 70import org.netbeans.jemmy.Timeoutable; 71import org.netbeans.jemmy.Timeouts; 72import org.netbeans.jemmy.Waitable; 73import org.netbeans.jemmy.Waiter; 74import org.netbeans.jemmy.drivers.DriverManager; 75import org.netbeans.jemmy.drivers.FocusDriver; 76import org.netbeans.jemmy.drivers.KeyDriver; 77import org.netbeans.jemmy.drivers.MouseDriver; 78 79/** 80 * Root class for all component operators. 81 * 82 * Provides basic methods to operate with mouse and keyboard.<BR> 83 * <BR> 84 * Almost all input methods can throw JemmyInputException or its subclass.<BR> 85 * 86 * ComponentOperator and its subclasses has a lot of methods which name and 87 * parameters just like consistent component has. In this case operator class 88 * just invokes consistent component method through AWT Event Queue 89 * (invokeAndWait method). 90 * 91 * <BR><BR>Timeouts used: <BR> 92 * ComponentOperator.PushKeyTimeout - time between key pressing and releasing 93 * <BR> 94 * ComponentOperator.MouseClickTimeout - time between mouse pressing and 95 * releasing <BR> 96 * ComponentOperator.WaitComponentTimeout - time to wait component displayed 97 * <BR> 98 * ComponentOperator.WaitComponentEnabledTimeout - time to wait component 99 * enabled <BR> 100 * ComponentOperator.BeforeDragTimeout - time to sleep before grag'n'drop 101 * operations <BR> 102 * ComponentOperator.AfterDragTimeout - time to sleep after grag'n'drop 103 * operations <BR> 104 * ComponentOperator.WaitFocusTimeout - time to wait component focus <BR> 105 * ComponentOperator.WaitStateTimeout- time to wait component to be in some 106 * state. Typically used from methods like 107 * {@code Operator.wait"something happened"(*)}<br>. 108 * 109 * @see org.netbeans.jemmy.Timeouts 110 * 111 * @author Alexandre Iline (alexandre.iline@oracle.com) 112 */ 113public class ComponentOperator extends Operator 114 implements Timeoutable, Outputable { 115 116 /** 117 * Identifier for a name property. 118 * 119 * @see #getDump 120 */ 121 public static final String NAME_DPROP = "Name:"; 122 123 /** 124 * Identifier for a visible property. 125 * 126 * @see #getDump 127 */ 128 public static final String IS_VISIBLE_DPROP = "Visible"; 129 130 /** 131 * Identifier for a showing property. 132 * 133 * @see #getDump 134 */ 135 public static final String IS_SHOWING_DPROP = "Showing"; 136 137 /** 138 * Identifier for a x coordinate property. 139 * 140 * @see #getDump 141 */ 142 public static final String X_DPROP = "X"; 143 144 /** 145 * Identifier for a y coordinate property. 146 * 147 * @see #getDump 148 */ 149 public static final String Y_DPROP = "Y"; 150 151 /** 152 * Identifier for a width property. 153 * 154 * @see #getDump 155 */ 156 public static final String WIDTH_DPROP = "Width"; 157 158 /** 159 * Identifier for a height property. 160 * 161 * @see #getDump 162 */ 163 public static final String HEIGHT_DPROP = "Height"; 164 165 private static final long PUSH_KEY_TIMEOUT = 0; 166 private static final long MOUSE_CLICK_TIMEOUT = 0; 167 private static final long BEFORE_DRAG_TIMEOUT = 0; 168 private static final long AFTER_DRAG_TIMEOUT = 0; 169 private static final long WAIT_COMPONENT_TIMEOUT = 60000; 170 private static final long WAIT_COMPONENT_ENABLED_TIMEOUT = 60000; 171 private static final long WAIT_FOCUS_TIMEOUT = 60000; 172 private static final long WAIT_STATE_TIMEOUT = 60000; 173 174 private final Component source; 175 private volatile Timeouts timeouts; // used in invokeSmoothly in clickMouse 176 private volatile TestOut output; // used in QueueTool.Locker 177 private volatile EventDispatcher dispatcher; // used in JInternalFrameByTitleFinder.checkComponent 178 private KeyDriver kDriver; 179 private MouseDriver mDriver; 180 private FocusDriver fDriver; 181 182 /** 183 * Constructor. 184 * 185 * @param comp a component 186 */ 187 public ComponentOperator(Component comp) { 188 super(); 189 source = comp; 190 kDriver = DriverManager.getKeyDriver(getClass()); 191 mDriver = DriverManager.getMouseDriver(getClass()); 192 fDriver = DriverManager.getFocusDriver(getClass()); 193 setEventDispatcher(new EventDispatcher(comp)); 194 } 195 196 /** 197 * Constructs a ComponentOperator object. 198 * 199 * @param cont container 200 * @param chooser a component chooser specifying searching criteria. 201 * @param index an index between appropriate ones. 202 */ 203 public ComponentOperator(ContainerOperator<?> cont, ComponentChooser chooser, int index) { 204 this(waitComponent((Container) cont.getSource(), 205 chooser, 206 index, cont.getTimeouts(), cont.getOutput())); 207 copyEnvironment(cont); 208 } 209 210 /** 211 * Constructs a ComponentOperator object. 212 * 213 * @param cont container 214 * @param chooser a component chooser specifying searching criteria. 215 */ 216 public ComponentOperator(ContainerOperator<?> cont, ComponentChooser chooser) { 217 this(cont, chooser, 0); 218 } 219 220 /** 221 * Constructor. Waits for a component in a container to show. The component 222 * is iis the {@code index+1}'th {@code java.awt.Component} that 223 * shows and that lies below the container in the display containment 224 * hierarchy. Uses cont's timeout and output for waiting and to init 225 * operator. 226 * 227 * @param cont Operator for a java.awt.Container. 228 * @param index an index between appropriate ones. 229 * @throws TimeoutExpiredException 230 */ 231 public ComponentOperator(ContainerOperator<?> cont, int index) { 232 this(cont, ComponentSearcher.getTrueChooser("Any component"), index); 233 } 234 235 /** 236 * Constructor. Waits for a component in a container to show. The component 237 * is is the first {@code java.awt.Component} that shows and that lies 238 * below the container in the display containment hierarchy. Uses cont's 239 * timeout and output for waiting and to init operator. 240 * 241 * @param cont Operator for a java.awt.Container. 242 * @throws TimeoutExpiredException 243 */ 244 public ComponentOperator(ContainerOperator<?> cont) { 245 this(cont, 0); 246 } 247 248 /** 249 * Searches Component in container. 250 * 251 * @param cont Container to search component in. 252 * @param chooser org.netbeans.jemmy.ComponentChooser implementation. 253 * @param index Ordinal component index. 254 * @return Component instance or null if component was not found. 255 */ 256 public static Component findComponent(Container cont, ComponentChooser chooser, int index) { 257 return findComponent(cont, chooser, index, false); 258 } 259 260 /** 261 * Searches Component in container. 262 * 263 * @param cont Container to search component in. 264 * @param chooser org.netbeans.jemmy.ComponentChooser implementation. 265 * @return Component instance or null if component was not found. 266 */ 267 public static Component findComponent(Container cont, ComponentChooser chooser) { 268 return findComponent(cont, chooser, 0); 269 } 270 271 /** 272 * Waits Component in container. 273 * 274 * @param cont Container to search component in. 275 * @param chooser org.netbeans.jemmy.ComponentChooser implementation. 276 * @param index Ordinal component index. 277 * @return Component instance or null if component was not found. 278 * @throws TimeoutExpiredException 279 */ 280 public static Component waitComponent(Container cont, ComponentChooser chooser, int index) { 281 return (waitComponent(cont, chooser, index, 282 JemmyProperties.getCurrentTimeouts(), 283 JemmyProperties.getCurrentOutput())); 284 } 285 286 /** 287 * Waits Component in container. 288 * 289 * @param cont Container to search component in. 290 * @param chooser org.netbeans.jemmy.ComponentChooser implementation. 291 * @return Component instance or null if component was not found. 292 * @throws TimeoutExpiredException 293 */ 294 public static Component waitComponent(Container cont, ComponentChooser chooser) { 295 return waitComponent(cont, chooser, 0); 296 } 297 298 /** 299 * A method to be used from subclasses. Uses {@code contOper}'s 300 * timeouts and output during the waiting. 301 * 302 * @param contOper Container to search component in. 303 * @param chooser org.netbeans.jemmy.ComponentChooser implementation. 304 * @param index Ordinal component index. 305 * @return Component instance or null if component was not found. 306 * @throws TimeoutExpiredException 307 */ 308 protected static Component waitComponent(ContainerOperator<?> contOper, 309 ComponentChooser chooser, int index) { 310 return (waitComponent((Container) contOper.getSource(), 311 chooser, index, 312 contOper.getTimeouts(), 313 contOper.getOutput())); 314 } 315 316 /** 317 * A method to be used from subclasses. Uses timeouts and output passed as 318 * parameters during the waiting. 319 * 320 * @param cont Container to search component in. 321 * @param chooser org.netbeans.jemmy.ComponentChooser implementation. 322 * @param index Ordinal component index. 323 * @param timeouts timeouts to be used during the waiting. 324 * @param output an output to be used during the waiting. 325 * @return Component instance or null if component was not found. 326 * @throws TimeoutExpiredException 327 */ 328 protected static Component waitComponent(final Container cont, 329 final ComponentChooser chooser, 330 final int index, 331 Timeouts timeouts, final TestOut output) { 332 try { 333 Waiter<Component, Void> waiter = new Waiter<>(new Waitable<Component, Void>() { 334 @Override 335 public Component actionProduced(Void obj) { 336 return findComponent(cont, new VisibleComponentFinder(chooser), index, 337 output.createErrorOutput()); 338 } 339 340 @Override 341 public String getDescription() { 342 return "Wait " + chooser.getDescription() + " loaded"; 343 } 344 345 @Override 346 public String toString() { 347 return "ComponentOperator.waitComponent.Waitable{description = " + getDescription() + '}'; 348 } 349 }); 350 waiter.setTimeoutsToCloneOf(timeouts, "ComponentOperator.WaitComponentTimeout"); 351 waiter.setOutput(output); 352 return waiter.waitAction(null); 353 } catch (InterruptedException e) { 354 return null; 355 } 356 } 357 358 /** 359 * Searches Components in container. 360 * 361 * @param cont Container to search components in. 362 * @param chooser org.netbeans.jemmy.ComponentChooser implementation. 363 * @return Component array or empty array if component was not found. 364 */ 365 public static Component[] findComponents(Container cont, ComponentChooser chooser) { 366 ComponentSearcher searcher = new ComponentSearcher(cont); 367 return searcher.findComponents(new VisibleComponentFinder(chooser)); 368 } 369 370 private static Component findComponent(Container cont, ComponentChooser chooser, int index, TestOut output) { 371 ComponentSearcher searcher = new ComponentSearcher(cont); 372 searcher.setOutput(output); 373 return searcher.findComponent(new VisibleComponentFinder(chooser), index); 374 } 375 376 private static Component findComponent(Container cont, ComponentChooser chooser, int index, boolean supressOutout) { 377 return findComponent(cont, chooser, index, JemmyProperties.getCurrentOutput().createErrorOutput()); 378 } 379 380 static { 381 Timeouts.initDefault("ComponentOperator.PushKeyTimeout", PUSH_KEY_TIMEOUT); 382 Timeouts.initDefault("ComponentOperator.MouseClickTimeout", MOUSE_CLICK_TIMEOUT); 383 Timeouts.initDefault("ComponentOperator.BeforeDragTimeout", BEFORE_DRAG_TIMEOUT); 384 Timeouts.initDefault("ComponentOperator.AfterDragTimeout", AFTER_DRAG_TIMEOUT); 385 Timeouts.initDefault("ComponentOperator.WaitComponentTimeout", WAIT_COMPONENT_TIMEOUT); 386 Timeouts.initDefault("ComponentOperator.WaitComponentEnabledTimeout", WAIT_COMPONENT_ENABLED_TIMEOUT); 387 Timeouts.initDefault("ComponentOperator.WaitStateTimeout", WAIT_STATE_TIMEOUT); 388 Timeouts.initDefault("ComponentOperator.WaitFocusTimeout", WAIT_FOCUS_TIMEOUT); 389 } 390 391 /** 392 * Returns component. 393 */ 394 @Override 395 public Component getSource() { 396 return source; 397 } 398 399 /** 400 * Returns org.netbeans.jemmy.EventDispatcher instance which is used to 401 * dispatch events. 402 * 403 * @return the dispatcher. 404 * @see org.netbeans.jemmy.EventDispatcher 405 */ 406 public EventDispatcher getEventDispatcher() { 407 return dispatcher; 408 } 409 410 //////////////////////////////////////////////////////// 411 //Environment // 412 //////////////////////////////////////////////////////// 413 @Override 414 public void setOutput(TestOut out) { 415 super.setOutput(out); 416 this.output = out; 417 if (dispatcher != null) { 418 dispatcher.setOutput(output.createErrorOutput()); 419 } 420 } 421 422 @Override 423 public TestOut getOutput() { 424 return output; 425 } 426 427 @Override 428 public void setTimeouts(Timeouts timeouts) { 429 super.setTimeouts(timeouts); 430 this.timeouts = timeouts; 431 if (dispatcher != null) { 432 dispatcher.setTimeouts(getTimeouts()); 433 } 434 } 435 436 @Override 437 public Timeouts getTimeouts() { 438 return timeouts; 439 } 440 441 @Override 442 public void copyEnvironment(Operator anotherOperator) { 443 super.copyEnvironment(anotherOperator); 444 kDriver = (KeyDriver) DriverManager. 445 getDriver(DriverManager.KEY_DRIVER_ID, 446 getClass(), 447 anotherOperator.getProperties()); 448 mDriver = (MouseDriver) DriverManager. 449 getDriver(DriverManager.MOUSE_DRIVER_ID, 450 getClass(), 451 anotherOperator.getProperties()); 452 fDriver = (FocusDriver) DriverManager. 453 getDriver(DriverManager.FOCUS_DRIVER_ID, 454 getClass(), 455 anotherOperator.getProperties()); 456 } 457 458 //////////////////////////////////////////////////////// 459 //Mouse operations 460 //////////////////////////////////////////////////////// 461 /** 462 * Makes mouse click. 463 * 464 * @param x Horizontal click coordinate 465 * @param y Vertical click coordinate 466 * @param clickCount Click count 467 * @param mouseButton Mouse button (InputEvent.BUTTON1/2/3_MASK value) 468 * @param modifiers Modifiers (combination of InputEvent.*_MASK values) 469 * @param forPopup signals that click is intended to call popup. 470 */ 471 public void clickMouse(final int x, final int y, final int clickCount, final int mouseButton, 472 final int modifiers, final boolean forPopup) { 473 getQueueTool().invokeSmoothly(new QueueTool.QueueAction<Void>("Path selecting") { 474 @Override 475 public Void launch() { 476 mDriver.clickMouse(ComponentOperator.this, x, y, clickCount, mouseButton, modifiers, 477 timeouts.create("ComponentOperator.MouseClickTimeout")); 478 return null; 479 } 480 }); 481 } 482 483 /** 484 * Makes mouse click. 485 * 486 * @param x Horizontal click coordinate 487 * @param y Vertical click coordinate 488 * @param clickCount Click count 489 * @param mouseButton Mouse button (InputEvent.BUTTON1/2/3_MASK value) 490 * @param modifiers Modifiers (combination of InputEvent.*_MASK values) 491 * @see #clickMouse(int, int, int, int, int, boolean) 492 */ 493 public void clickMouse(int x, int y, int clickCount, int mouseButton, int modifiers) { 494 clickMouse(x, y, clickCount, mouseButton, modifiers, false); 495 } 496 497 /** 498 * Makes mouse click with 0 modifiers. 499 * 500 * @param x Horizontal click coordinate 501 * @param y Vertical click coordinate 502 * @param clickCount Click count 503 * @param mouseButton Mouse button (InputEvent.BUTTON1/2/3_MASK value) 504 * @see #clickMouse(int, int, int, int, int) 505 */ 506 public void clickMouse(int x, int y, int clickCount, int mouseButton) { 507 clickMouse(x, y, clickCount, mouseButton, 0); 508 } 509 510 /** 511 * Makes mouse click by default mouse button with 0 modifiers. 512 * 513 * @param x Horizontal click coordinate 514 * @param y Vertical click coordinate 515 * @param clickCount Click count 516 * @see #clickMouse(int, int, int, int) 517 * @see #getDefaultMouseButton() 518 */ 519 public void clickMouse(int x, int y, int clickCount) { 520 clickMouse(x, y, clickCount, getDefaultMouseButton()); 521 } 522 523 /** 524 * Press mouse. 525 * 526 * @param x Horizontal click coordinate 527 * @param y Vertical click coordinate 528 */ 529 public void pressMouse(int x, int y) { 530 mDriver.pressMouse(this, x, y, getDefaultMouseButton(), 0); 531 } 532 533 /** 534 * Releases mouse. 535 * 536 * @param x Horizontal click coordinate 537 * @param y Vertical click coordinate 538 */ 539 public void releaseMouse(int x, int y) { 540 mDriver.releaseMouse(this, x, y, getDefaultMouseButton(), 0); 541 } 542 543 /** 544 * Move mouse over the component. 545 * 546 * @param x Horisontal destination coordinate. 547 * @param y Vertical destination coordinate. 548 */ 549 public void moveMouse(int x, int y) { 550 mDriver.moveMouse(this, x, y); 551 } 552 553 /** 554 * Drag mouse over the component. 555 * 556 * @param x Horisontal destination coordinate. 557 * @param y Vertical destination coordinate. 558 * @param mouseButton Mouse button 559 * @param modifiers Modifiers 560 */ 561 public void dragMouse(int x, int y, int mouseButton, int modifiers) { 562 mDriver.dragMouse(this, x, y, getDefaultMouseButton(), 0); 563 } 564 565 /** 566 * Drag mouse over the component with 0 modifiers. 567 * 568 * @param x Horisontal destination coordinate. 569 * @param y Vertical destination coordinate. 570 * @param mouseButton Mouse button 571 * @see #dragMouse(int, int, int, int) 572 */ 573 public void dragMouse(int x, int y, int mouseButton) { 574 dragMouse(x, y, mouseButton, 0); 575 } 576 577 /** 578 * Drag mouse over the component with 0 modifiers and default mose button 579 * pressed. 580 * 581 * @param x Horisontal destination coordinate. 582 * @param y Vertical destination coordinate. 583 * @see #dragMouse(int, int, int) 584 * @see #getDefaultMouseButton() 585 */ 586 public void dragMouse(int x, int y) { 587 dragMouse(x, y, getDefaultMouseButton()); 588 } 589 590 /** 591 * Makes drag'n'drop operation. 592 * 593 * @param start_x Start horizontal coordinate 594 * @param start_y Start vertical coordinate 595 * @param end_x End horizontal coordinate 596 * @param end_y End vertical coordinate 597 * @param mouseButton Mouse button 598 * @param modifiers Modifiers 599 */ 600 public void dragNDrop(int start_x, int start_y, int end_x, int end_y, int mouseButton, int modifiers) { 601 mDriver.dragNDrop(this, start_x, start_y, end_x, end_y, mouseButton, modifiers, 602 timeouts.create("ComponentOperator.BeforeDragTimeout"), 603 timeouts.create("ComponentOperator.AfterDragTimeout")); 604 } 605 606 /** 607 * Makes drag'n'drop operation with 0 modifiers. 608 * 609 * @param start_x Start horizontal coordinate 610 * @param start_y Start vertical coordinate 611 * @param end_x End horizontal coordinate 612 * @param end_y End vertical coordinate 613 * @param mouseButton Mouse button 614 * @see #dragNDrop(int, int, int, int, int, int) 615 */ 616 public void dragNDrop(int start_x, int start_y, int end_x, int end_y, int mouseButton) { 617 dragNDrop(start_x, start_y, end_x, end_y, mouseButton, 0); 618 } 619 620 /** 621 * Makes drag'n'drop operation by default mouse buttons with 0 modifiers. 622 * 623 * @param start_x Start horizontal coordinate 624 * @param start_y Start vertical coordinate 625 * @param end_x End horizontal coordinate 626 * @param end_y End vertical coordinate 627 * @see #dragNDrop(int, int, int, int, int) 628 * @see #getDefaultMouseButton() 629 */ 630 public void dragNDrop(int start_x, int start_y, int end_x, int end_y) { 631 dragNDrop(start_x, start_y, end_x, end_y, getDefaultMouseButton(), 0); 632 } 633 634 /** 635 * Clicks for popup. 636 * 637 * @param x Horizontal click coordinate. 638 * @param y Vertical click coordinate. 639 * @param mouseButton Mouse button. 640 * @see #clickMouse(int, int, int, int, int, boolean) 641 */ 642 public void clickForPopup(int x, int y, int mouseButton) { 643 makeComponentVisible(); 644 clickMouse(x, y, 1, mouseButton, 0, true); 645 } 646 647 /** 648 * Clicks for popup by popup mouse button. 649 * 650 * @param x Horizontal click coordinate. 651 * @param y Vertical click coordinate. 652 * @see #clickForPopup(int, int, int) 653 * @see #getPopupMouseButton() 654 */ 655 public void clickForPopup(int x, int y) { 656 clickForPopup(x, y, getPopupMouseButton()); 657 } 658 659 /** 660 * Makes mouse click on the component center with 0 modifiers. 661 * 662 * @param clickCount Click count 663 * @param mouseButton Mouse button (InputEvent.BUTTON1/2/3_MASK value) 664 * @see #clickMouse(int, int, int, int) 665 */ 666 public void clickMouse(final int clickCount, final int mouseButton) { 667 getQueueTool().invokeSmoothly(new QueueTool.QueueAction<Void>("Clicking the mouse button") { 668 @Override 669 public Void launch() { 670 clickMouse(getCenterXForClick(), getCenterYForClick(), clickCount, mouseButton); 671 return null; 672 } 673 }); 674 } 675 676 /** 677 * Makes mouse click on the component center by default mouse button with 0 678 * modifiers. 679 * 680 * @param clickCount Click count 681 * @see #clickMouse(int, int) 682 * @see #getDefaultMouseButton() 683 */ 684 public void clickMouse(int clickCount) { 685 clickMouse(clickCount, getDefaultMouseButton()); 686 } 687 688 /** 689 * Makes siple mouse click on the component center by default mouse button 690 * with 0 modifiers. 691 * 692 * @see #clickMouse(int) 693 * @see #getDefaultMouseButton() 694 */ 695 public void clickMouse() { 696 clickMouse(1); 697 } 698 699 /** 700 * Move mouse inside the component. 701 */ 702 public void enterMouse() { 703 mDriver.enterMouse(this); 704 } 705 706 /** 707 * Move mouse outside the component. 708 */ 709 public void exitMouse() { 710 mDriver.exitMouse(this); 711 } 712 713 /** 714 * Press mouse. 715 */ 716 public void pressMouse() { 717 getQueueTool().invokeSmoothly(new QueueTool.QueueAction<Void>("Pressing the mouse button") { 718 @Override 719 public Void launch() { 720 pressMouse(getCenterXForClick(), getCenterYForClick()); 721 return null; 722 } 723 }); 724 } 725 726 /** 727 * Releases mouse. 728 */ 729 public void releaseMouse() { 730 getQueueTool().invokeSmoothly(new QueueTool.QueueAction<Void>("Releasing the mouse button") { 731 @Override 732 public Void launch() { 733 releaseMouse(getCenterXForClick(), getCenterYForClick()); 734 return null; 735 } 736 }); 737 } 738 739 /** 740 * Clicks for popup at the component center. 741 * 742 * @param mouseButton Mouse button. 743 * @see #clickForPopup(int, int) 744 */ 745 public void clickForPopup(int mouseButton) { 746 clickForPopup(getCenterXForClick(), getCenterYForClick(), mouseButton); 747 } 748 749 /** 750 * Clicks for popup by popup mouse button at the component center. 751 * 752 * @see #clickForPopup(int) 753 * @see #getPopupMouseButton() 754 */ 755 public void clickForPopup() { 756 clickForPopup(getPopupMouseButton()); 757 } 758 759 //////////////////////////////////////////////////////// 760 //Keyboard operations 761 //////////////////////////////////////////////////////// 762 /** 763 * Press key. 764 * 765 * @param keyCode Key code (KeyEvent.VK_* value) 766 * @param modifiers Modifiers (combination of InputEvent.*_MASK fields) 767 */ 768 public void pressKey(int keyCode, int modifiers) { 769 kDriver.pressKey(this, keyCode, modifiers); 770 } 771 772 /** 773 * Press key with no modifiers. 774 * 775 * @param keyCode Key code (KeyEvent.VK_* value) 776 */ 777 public void pressKey(int keyCode) { 778 pressKey(keyCode, 0); 779 } 780 781 /** 782 * Typed key. 783 * 784 * @param keyChar Char to be typed. 785 * @param modifiers Modifiers (combination of InputEvent.*_MASK fields) 786 */ 787 public void typedKey(char keyChar, int modifiers) { 788 kDriver.typedKey(this, getCharBindingMap().getCharKey(keyChar), keyChar, modifiers); 789 } 790 791 /** 792 * Releases key. 793 * 794 * @param keyCode Key code (KeyEvent.VK_* value) 795 * @param modifiers Modifiers (combination of InputEvent.*_MASK fields) 796 */ 797 public void releaseKey(int keyCode, int modifiers) { 798 kDriver.releaseKey(this, keyCode, modifiers); 799 } 800 801 /** 802 * Releases key with no modifiers. 803 * 804 * @param keyCode Key code (KeyEvent.VK_* value) 805 */ 806 public void releaseKey(int keyCode) { 807 releaseKey(keyCode, 0); 808 } 809 810 /** 811 * Pushs key. 812 * 813 * @param keyCode Key code (KeyEvent.VK_* value) 814 * @param modifiers Modifiers (combination of InputEvent.*_MASK fields) 815 */ 816 public void pushKey(int keyCode, int modifiers) { 817 kDriver.pushKey(this, keyCode, modifiers, timeouts.create("ComponentOperator.PushKeyTimeout")); 818 } 819 820 /** 821 * Pushs key. 822 * 823 * @param keyCode Key code (KeyEvent.VK_* value) 824 */ 825 public void pushKey(int keyCode) { 826 pushKey(keyCode, 0); 827 } 828 829 /** 830 * Types one char. 831 * 832 * @param keyCode Key code (KeyEvent.VK_* value) 833 * @param keyChar Char to be typed. 834 * @param modifiers Modifiers (combination of InputEvent.*_MASK fields) 835 */ 836 public void typeKey(int keyCode, char keyChar, int modifiers) { 837 kDriver.typeKey(this, keyCode, keyChar, modifiers, timeouts.create("ComponentOperator.PushKeyTimeout")); 838 } 839 840 /** 841 * Types one char. Uses map defined by setCharBindingMap(CharBindingMap) 842 * method to find a key should be pressed. 843 * 844 * @param keyChar Char to be typed. 845 * @param modifiers Modifiers (combination of InputEvent.*_MASK fields) 846 * @see org.netbeans.jemmy.CharBindingMap 847 * @see #setCharBindingMap(CharBindingMap) 848 * @see #typeKey(int, char, int) 849 */ 850 public void typeKey(char keyChar, int modifiers) { 851 typeKey(getCharKey(keyChar), keyChar, modifiers | getCharModifiers(keyChar)); 852 } 853 854 /** 855 * Types one char. Uses map defined by setCharBindingMap(CharBindingMap) 856 * method to find a key and modifiers should be pressed. 857 * 858 * @param keyChar Char to be typed. 859 * @see #setCharBindingMap(CharBindingMap) 860 * @see #typeKey(char, int) 861 */ 862 public void typeKey(char keyChar) { 863 typeKey(keyChar, 0); 864 } 865 866 //////////////////////////////////////////////////////// 867 //Util 868 //////////////////////////////////////////////////////// 869 /** 870 * Activates component's window. 871 * 872 * @deprecated Use makeComponentVisible() instead. 873 * @see #makeComponentVisible() 874 */ 875 @Deprecated 876 public void activateWindow() { 877 getVisualizer().makeVisible(this); 878 } 879 880 /** 881 * Prepares component for user input. Uses visualizer defined by 882 * setVisualiser() method. 883 */ 884 public void makeComponentVisible() { 885 getVisualizer().makeVisible(this); 886 /* 887 final ComponentOperator compOper = (ComponentOperator)this; 888 runMapping(new MapVoidAction("add") { 889 public void map() { 890 getVisualizer().makeVisible(compOper); 891 } 892 }); 893 */ 894 } 895 896 /** 897 * Gives input focus to the component. 898 */ 899 public void getFocus() { 900 fDriver.giveFocus(this); 901 } 902 903 /** 904 * Return the center x coordinate. 905 * 906 * @return the center x coordinate. 907 */ 908 public int getCenterX() { 909 return getWidth() / 2; 910 } 911 912 /** 913 * Return the center y coordinate. 914 * 915 * @return the center y coordinate. 916 */ 917 public int getCenterY() { 918 return getHeight() / 2; 919 } 920 921 /** 922 * Return the x coordinate which should be used for mouse operations by 923 * default. 924 * 925 * @return the center x coordinate of the visible component part. 926 */ 927 public int getCenterXForClick() { 928 return getCenterX(); 929 } 930 931 /** 932 * Return the y coordinate which should be used for mouse operations by 933 * default. 934 * 935 * @return the center y coordinate of the visible component part. 936 */ 937 public int getCenterYForClick() { 938 return getCenterY(); 939 } 940 941 /** 942 * Waits for the component to be enabled. 943 * 944 * @throws TimeoutExpiredException 945 * @throws InterruptedException 946 */ 947 public void waitComponentEnabled() throws InterruptedException { 948 Waiter<Component, Component> waiter = new Waiter<>(new Waitable<Component, Component>() { 949 @Override 950 public Component actionProduced(Component obj) { 951 if (obj.isEnabled()) { 952 return obj; 953 } else { 954 return null; 955 } 956 } 957 958 @Override 959 public String getDescription() { 960 return ("Component enabled: " 961 + getSource().getClass().toString()); 962 } 963 964 @Override 965 public String toString() { 966 return "ComponentOperator.waitComponentEnabled.Waitable{description = " + getDescription() + '}'; 967 } 968 }); 969 waiter.setOutput(output); 970 waiter.setTimeoutsToCloneOf(timeouts, "ComponentOperator.WaitComponentEnabledTimeout"); 971 waiter.waitAction(getSource()); 972 } 973 974 /** 975 * Waits for the component to be enabled. per request: 37831 976 * 977 * @throws TimeoutExpiredException 978 */ 979 public void wtComponentEnabled() { 980 try { 981 waitComponentEnabled(); 982 } catch (InterruptedException e) { 983 throw (new JemmyException("Interrupted!", e)); 984 } 985 } 986 987 /** 988 * Returns an array of containers for this component. 989 * 990 * @return an array of containers 991 */ 992 public Container[] getContainers() { 993 int counter = 0; 994 Container cont = getSource().getParent(); 995 if (cont == null) { 996 return new Container[0]; 997 } 998 do { 999 counter++; 1000 } while ((cont = cont.getParent()) != null); 1001 Container[] res = new Container[counter]; 1002 cont = getSource().getParent(); 1003 counter = 0; 1004 do { 1005 counter++; 1006 res[counter - 1] = cont; 1007 } while ((cont = cont.getParent()) != null); 1008 return res; 1009 } 1010 1011 /** 1012 * Searches a container. 1013 * 1014 * @param chooser a chooser specifying the searching criteria. 1015 * @return a containers specified by searching criteria. 1016 */ 1017 public Container getContainer(ComponentChooser chooser) { 1018 int counter = 0; 1019 Container cont = getSource().getParent(); 1020 if (cont == null) { 1021 return null; 1022 } 1023 do { 1024 if (chooser.checkComponent(cont)) { 1025 return cont; 1026 } 1027 counter++; 1028 } while ((cont = cont.getParent()) != null); 1029 return null; 1030 } 1031 1032 /** 1033 * Searches the window under component. 1034 * 1035 * @return the component window. 1036 */ 1037 public Window getWindow() { 1038 if (getSource() instanceof Window) { 1039 return (Window) getSource(); 1040 } 1041 Window window = (Window) getContainer(new ComponentChooser() { 1042 @Override 1043 public boolean checkComponent(Component comp) { 1044 return comp instanceof Window; 1045 } 1046 1047 @Override 1048 public String getDescription() { 1049 return ""; 1050 } 1051 1052 @Override 1053 public String toString() { 1054 return "ComponentOperator.getWindow.ComponentChooser{description = " + getDescription() + '}'; 1055 } 1056 }); 1057 if (window == null && getSource() instanceof Window) { 1058 return (Window) getSource(); 1059 } else { 1060 return window; 1061 } 1062 } 1063 1064 /** 1065 * Waits for this Component has the keyboard focus. 1066 * 1067 * @throws TimeoutExpiredException 1068 */ 1069 public void waitHasFocus() { 1070 Waiter<String, Void> focusWaiter = new Waiter<>(new Waitable<String, Void>() { 1071 @Override 1072 public String actionProduced(Void obj) { 1073 return hasFocus() ? "" : null; 1074 } 1075 1076 @Override 1077 public String getDescription() { 1078 return "Wait component has focus"; 1079 } 1080 1081 @Override 1082 public String toString() { 1083 return "ComponentOperator.waitHasFocus.Waitable{description = " + getDescription() + '}'; 1084 } 1085 }); 1086 focusWaiter.setTimeoutsToCloneOf(timeouts, "ComponentOperator.WaitFocusTimeout"); 1087 focusWaiter.setOutput(output.createErrorOutput()); 1088 try { 1089 focusWaiter.waitAction(null); 1090 } catch (InterruptedException e) { 1091 output.printStackTrace(e); 1092 } 1093 } 1094 1095 /** 1096 * Waits for the component to be visible or unvisible. 1097 * 1098 * @param visibility required visiblity. 1099 * @throws TimeoutExpiredException 1100 */ 1101 public void waitComponentVisible(final boolean visibility) { 1102 waitState(new ComponentChooser() { 1103 @Override 1104 public boolean checkComponent(Component comp) { 1105 return isVisible() == visibility; 1106 } 1107 1108 @Override 1109 public String getDescription() { 1110 return "Component is " + (visibility ? "" : " not ") + "visible"; 1111 } 1112 1113 @Override 1114 public String toString() { 1115 return "ComponentOperator.waitComponentVisible.ComponentChooser{description = " + getDescription() + '}'; 1116 } 1117 }); 1118 } 1119 1120 public void waitComponentShowing(final boolean visibility) { 1121 waitState(new ComponentChooser() { 1122 @Override 1123 public boolean checkComponent(Component comp) { 1124 return isShowing() == visibility; 1125 } 1126 1127 @Override 1128 public String getDescription() { 1129 return "Component is " + (visibility ? "" : " not ") + "showing"; 1130 } 1131 1132 @Override 1133 public String toString() { 1134 return "ComponentOperator.waitComponentShowing.ComponentChooser{description = " + getDescription() + '}'; 1135 } 1136 }); 1137 } 1138 1139 /** 1140 * Returns information about component. 1141 */ 1142 @Override 1143 public Hashtable<String, Object> getDump() { 1144 Hashtable<String, Object> result = super.getDump(); 1145 if (getSource().getName() != null) { 1146 result.put(NAME_DPROP, getSource().getName()); 1147 } 1148 result.put(IS_VISIBLE_DPROP, getSource().isVisible() ? "true" : "false"); 1149 result.put(IS_SHOWING_DPROP, getSource().isShowing() ? "true" : "false"); 1150 result.put(X_DPROP, Integer.toString(getSource().getX())); 1151 result.put(Y_DPROP, Integer.toString(getSource().getY())); 1152 result.put(WIDTH_DPROP, Integer.toString(getSource().getWidth())); 1153 result.put(HEIGHT_DPROP, Integer.toString(getSource().getHeight())); 1154 return result; 1155 } 1156 1157 //////////////////////////////////////////////////////// 1158 //Mapping // 1159 /** 1160 * Maps {@code Component.add(PopupMenu)} through queue 1161 */ 1162 public void add(final PopupMenu popupMenu) { 1163 runMapping(new MapVoidAction("add") { 1164 @Override 1165 public void map() { 1166 getSource().add(popupMenu); 1167 } 1168 }); 1169 } 1170 1171 /** 1172 * Maps {@code Component.addComponentListener(ComponentListener)} 1173 * through queue 1174 */ 1175 public void addComponentListener(final ComponentListener componentListener) { 1176 runMapping(new MapVoidAction("addComponentListener") { 1177 @Override 1178 public void map() { 1179 getSource().addComponentListener(componentListener); 1180 } 1181 }); 1182 } 1183 1184 /** 1185 * Maps {@code Component.addFocusListener(FocusListener)} through queue 1186 */ 1187 public void addFocusListener(final FocusListener focusListener) { 1188 runMapping(new MapVoidAction("addFocusListener") { 1189 @Override 1190 public void map() { 1191 getSource().addFocusListener(focusListener); 1192 } 1193 }); 1194 } 1195 1196 /** 1197 * Maps {@code Component.addInputMethodListener(InputMethodListener)} 1198 * through queue 1199 */ 1200 public void addInputMethodListener(final InputMethodListener inputMethodListener) { 1201 runMapping(new MapVoidAction("addInputMethodListener") { 1202 @Override 1203 public void map() { 1204 getSource().addInputMethodListener(inputMethodListener); 1205 } 1206 }); 1207 } 1208 1209 /** 1210 * Maps {@code Component.addKeyListener(KeyListener)} through queue 1211 */ 1212 public void addKeyListener(final KeyListener keyListener) { 1213 runMapping(new MapVoidAction("addKeyListener") { 1214 @Override 1215 public void map() { 1216 getSource().addKeyListener(keyListener); 1217 } 1218 }); 1219 } 1220 1221 /** 1222 * Maps {@code Component.addMouseListener(MouseListener)} through queue 1223 */ 1224 public void addMouseListener(final MouseListener mouseListener) { 1225 runMapping(new MapVoidAction("addMouseListener") { 1226 @Override 1227 public void map() { 1228 getSource().addMouseListener(mouseListener); 1229 } 1230 }); 1231 } 1232 1233 /** 1234 * Maps {@code Component.addMouseMotionListener(MouseMotionListener)} 1235 * through queue 1236 */ 1237 public void addMouseMotionListener(final MouseMotionListener mouseMotionListener) { 1238 runMapping(new MapVoidAction("addMouseMotionListener") { 1239 @Override 1240 public void map() { 1241 getSource().addMouseMotionListener(mouseMotionListener); 1242 } 1243 }); 1244 } 1245 1246 /** 1247 * Maps {@code Component.addNotify()} through queue 1248 */ 1249 public void addNotify() { 1250 runMapping(new MapVoidAction("addNotify") { 1251 @Override 1252 public void map() { 1253 getSource().addNotify(); 1254 } 1255 }); 1256 } 1257 1258 /** 1259 * Maps 1260 * {@code Component.addPropertyChangeListener(PropertyChangeListener)} 1261 * through queue 1262 */ 1263 public void addPropertyChangeListener(final PropertyChangeListener propertyChangeListener) { 1264 runMapping(new MapVoidAction("addPropertyChangeListener") { 1265 @Override 1266 public void map() { 1267 getSource().addPropertyChangeListener(propertyChangeListener); 1268 } 1269 }); 1270 } 1271 1272 /** 1273 * Maps 1274 * {@code Component.addPropertyChangeListener(String, PropertyChangeListener)} 1275 * through queue 1276 */ 1277 public void addPropertyChangeListener(final String string, final PropertyChangeListener propertyChangeListener) { 1278 runMapping(new MapVoidAction("addPropertyChangeListener") { 1279 @Override 1280 public void map() { 1281 getSource().addPropertyChangeListener(string, propertyChangeListener); 1282 } 1283 }); 1284 } 1285 1286 /** 1287 * Maps {@code Component.checkImage(Image, int, int, ImageObserver)} 1288 * through queue 1289 */ 1290 public int checkImage(final Image image, final int i, final int i1, final ImageObserver imageObserver) { 1291 return (runMapping(new MapIntegerAction("checkImage") { 1292 @Override 1293 public int map() { 1294 return getSource().checkImage(image, i, i1, imageObserver); 1295 } 1296 })); 1297 } 1298 1299 /** 1300 * Maps {@code Component.checkImage(Image, ImageObserver)} through queue 1301 */ 1302 public int checkImage(final Image image, final ImageObserver imageObserver) { 1303 return (runMapping(new MapIntegerAction("checkImage") { 1304 @Override 1305 public int map() { 1306 return getSource().checkImage(image, imageObserver); 1307 } 1308 })); 1309 } 1310 1311 /** 1312 * Maps {@code Component.contains(int, int)} through queue 1313 */ 1314 public boolean contains(final int i, final int i1) { 1315 return (runMapping(new MapBooleanAction("contains") { 1316 @Override 1317 public boolean map() { 1318 return getSource().contains(i, i1); 1319 } 1320 })); 1321 } 1322 1323 /** 1324 * Maps {@code Component.contains(Point)} through queue 1325 */ 1326 public boolean contains(final Point point) { 1327 return (runMapping(new MapBooleanAction("contains") { 1328 @Override 1329 public boolean map() { 1330 return getSource().contains(point); 1331 } 1332 })); 1333 } 1334 1335 /** 1336 * Maps {@code Component.createImage(int, int)} through queue 1337 */ 1338 public Image createImage(final int i, final int i1) { 1339 return (runMapping(new MapAction<Image>("createImage") { 1340 @Override 1341 public Image map() { 1342 return getSource().createImage(i, i1); 1343 } 1344 })); 1345 } 1346 1347 /** 1348 * Maps {@code Component.createImage(ImageProducer)} through queue 1349 */ 1350 public Image createImage(final ImageProducer imageProducer) { 1351 return (runMapping(new MapAction<Image>("createImage") { 1352 @Override 1353 public Image map() { 1354 return getSource().createImage(imageProducer); 1355 } 1356 })); 1357 } 1358 1359 /** 1360 * Maps {@code Component.dispatchEvent(AWTEvent)} through queue 1361 */ 1362 public void dispatchEvent(final AWTEvent aWTEvent) { 1363 runMapping(new MapVoidAction("dispatchEvent") { 1364 @Override 1365 public void map() { 1366 getSource().dispatchEvent(aWTEvent); 1367 } 1368 }); 1369 } 1370 1371 /** 1372 * Maps {@code Component.doLayout()} through queue 1373 */ 1374 public void doLayout() { 1375 runMapping(new MapVoidAction("doLayout") { 1376 @Override 1377 public void map() { 1378 getSource().doLayout(); 1379 } 1380 }); 1381 } 1382 1383 /** 1384 * Maps {@code Component.enableInputMethods(boolean)} through queue 1385 */ 1386 public void enableInputMethods(final boolean b) { 1387 runMapping(new MapVoidAction("enableInputMethods") { 1388 @Override 1389 public void map() { 1390 getSource().enableInputMethods(b); 1391 } 1392 }); 1393 } 1394 1395 /** 1396 * Maps {@code Component.getAlignmentX()} through queue 1397 */ 1398 public float getAlignmentX() { 1399 return (runMapping(new MapFloatAction("getAlignmentX") { 1400 @Override 1401 public float map() { 1402 return getSource().getAlignmentX(); 1403 } 1404 })); 1405 } 1406 1407 /** 1408 * Maps {@code Component.getAlignmentY()} through queue 1409 */ 1410 public float getAlignmentY() { 1411 return (runMapping(new MapFloatAction("getAlignmentY") { 1412 @Override 1413 public float map() { 1414 return getSource().getAlignmentY(); 1415 } 1416 })); 1417 } 1418 1419 /** 1420 * Maps {@code Component.getBackground()} through queue 1421 */ 1422 public Color getBackground() { 1423 return (runMapping(new MapAction<Color>("getBackground") { 1424 @Override 1425 public Color map() { 1426 return getSource().getBackground(); 1427 } 1428 })); 1429 } 1430 1431 /** 1432 * Maps {@code Component.getBounds()} through queue 1433 */ 1434 public Rectangle getBounds() { 1435 return (runMapping(new MapAction<Rectangle>("getBounds") { 1436 @Override 1437 public Rectangle map() { 1438 return getSource().getBounds(); 1439 } 1440 })); 1441 } 1442 1443 /** 1444 * Maps {@code Component.getBounds(Rectangle)} through queue 1445 */ 1446 public Rectangle getBounds(final Rectangle rectangle) { 1447 return (runMapping(new MapAction<Rectangle>("getBounds") { 1448 @Override 1449 public Rectangle map() { 1450 return getSource().getBounds(rectangle); 1451 } 1452 })); 1453 } 1454 1455 /** 1456 * Maps {@code Component.getColorModel()} through queue 1457 */ 1458 public ColorModel getColorModel() { 1459 return (runMapping(new MapAction<ColorModel>("getColorModel") { 1460 @Override 1461 public ColorModel map() { 1462 return getSource().getColorModel(); 1463 } 1464 })); 1465 } 1466 1467 /** 1468 * Maps {@code Component.getComponentAt(int, int)} through queue 1469 */ 1470 public Component getComponentAt(final int i, final int i1) { 1471 return (runMapping(new MapAction<Component>("getComponentAt") { 1472 @Override 1473 public Component map() { 1474 return getSource().getComponentAt(i, i1); 1475 } 1476 })); 1477 } 1478 1479 /** 1480 * Maps {@code Component.getComponentAt(Point)} through queue 1481 */ 1482 public Component getComponentAt(final Point point) { 1483 return (runMapping(new MapAction<Component>("getComponentAt") { 1484 @Override 1485 public Component map() { 1486 return getSource().getComponentAt(point); 1487 } 1488 })); 1489 } 1490 1491 /** 1492 * Maps {@code Component.getComponentOrientation()} through queue 1493 */ 1494 public ComponentOrientation getComponentOrientation() { 1495 return (runMapping(new MapAction<ComponentOrientation>("getComponentOrientation") { 1496 @Override 1497 public ComponentOrientation map() { 1498 return getSource().getComponentOrientation(); 1499 } 1500 })); 1501 } 1502 1503 /** 1504 * Maps {@code Component.getCursor()} through queue 1505 */ 1506 public Cursor getCursor() { 1507 return (runMapping(new MapAction<Cursor>("getCursor") { 1508 @Override 1509 public Cursor map() { 1510 return getSource().getCursor(); 1511 } 1512 })); 1513 } 1514 1515 /** 1516 * Maps {@code Component.getDropTarget()} through queue 1517 */ 1518 public DropTarget getDropTarget() { 1519 return (runMapping(new MapAction<DropTarget>("getDropTarget") { 1520 @Override 1521 public DropTarget map() { 1522 return getSource().getDropTarget(); 1523 } 1524 })); 1525 } 1526 1527 /** 1528 * Maps {@code Component.getFont()} through queue 1529 */ 1530 public Font getFont() { 1531 return (runMapping(new MapAction<Font>("getFont") { 1532 @Override 1533 public Font map() { 1534 return getSource().getFont(); 1535 } 1536 })); 1537 } 1538 1539 /** 1540 * Maps {@code Component.getFontMetrics(Font)} through queue 1541 */ 1542 public FontMetrics getFontMetrics(final Font font) { 1543 return (runMapping(new MapAction<FontMetrics>("getFontMetrics") { 1544 @Override 1545 public FontMetrics map() { 1546 return getSource().getFontMetrics(font); 1547 } 1548 })); 1549 } 1550 1551 /** 1552 * Maps {@code Component.getForeground()} through queue 1553 */ 1554 public Color getForeground() { 1555 return (runMapping(new MapAction<Color>("getForeground") { 1556 @Override 1557 public Color map() { 1558 return getSource().getForeground(); 1559 } 1560 })); 1561 } 1562 1563 /** 1564 * Maps {@code Component.getGraphics()} through queue 1565 */ 1566 public Graphics getGraphics() { 1567 return (runMapping(new MapAction<Graphics>("getGraphics") { 1568 @Override 1569 public Graphics map() { 1570 return getSource().getGraphics(); 1571 } 1572 })); 1573 } 1574 1575 /** 1576 * Maps {@code Component.getHeight()} through queue 1577 */ 1578 public int getHeight() { 1579 return (runMapping(new MapIntegerAction("getHeight") { 1580 @Override 1581 public int map() { 1582 return getSource().getHeight(); 1583 } 1584 })); 1585 } 1586 1587 /** 1588 * Maps {@code Component.getInputContext()} through queue 1589 */ 1590 public InputContext getInputContext() { 1591 return (runMapping(new MapAction<InputContext>("getInputContext") { 1592 @Override 1593 public InputContext map() { 1594 return getSource().getInputContext(); 1595 } 1596 })); 1597 } 1598 1599 /** 1600 * Maps {@code Component.getInputMethodRequests()} through queue 1601 */ 1602 public InputMethodRequests getInputMethodRequests() { 1603 return (runMapping(new MapAction<InputMethodRequests>("getInputMethodRequests") { 1604 @Override 1605 public InputMethodRequests map() { 1606 return getSource().getInputMethodRequests(); 1607 } 1608 })); 1609 } 1610 1611 /** 1612 * Maps {@code Component.getLocale()} through queue 1613 */ 1614 public Locale getLocale() { 1615 return (runMapping(new MapAction<Locale>("getLocale") { 1616 @Override 1617 public Locale map() { 1618 return getSource().getLocale(); 1619 } 1620 })); 1621 } 1622 1623 /** 1624 * Maps {@code Component.getLocation()} through queue 1625 */ 1626 public Point getLocation() { 1627 return (runMapping(new MapAction<Point>("getLocation") { 1628 @Override 1629 public Point map() { 1630 return getSource().getLocation(); 1631 } 1632 })); 1633 } 1634 1635 /** 1636 * Maps {@code Component.getLocation(Point)} through queue 1637 */ 1638 public Point getLocation(final Point point) { 1639 return (runMapping(new MapAction<Point>("getLocation") { 1640 @Override 1641 public Point map() { 1642 return getSource().getLocation(point); 1643 } 1644 })); 1645 } 1646 1647 /** 1648 * Maps {@code Component.getLocationOnScreen()} through queue 1649 */ 1650 public Point getLocationOnScreen() { 1651 return (runMapping(new MapAction<Point>("getLocationOnScreen") { 1652 @Override 1653 public Point map() { 1654 return getSource().getLocationOnScreen(); 1655 } 1656 })); 1657 } 1658 1659 /** 1660 * Maps {@code Component.getMaximumSize()} through queue 1661 */ 1662 public Dimension getMaximumSize() { 1663 return (runMapping(new MapAction<Dimension>("getMaximumSize") { 1664 @Override 1665 public Dimension map() { 1666 return getSource().getMaximumSize(); 1667 } 1668 })); 1669 } 1670 1671 /** 1672 * Maps {@code Component.getMinimumSize()} through queue 1673 */ 1674 public Dimension getMinimumSize() { 1675 return (runMapping(new MapAction<Dimension>("getMinimumSize") { 1676 @Override 1677 public Dimension map() { 1678 return getSource().getMinimumSize(); 1679 } 1680 })); 1681 } 1682 1683 /** 1684 * Maps {@code Component.getName()} through queue 1685 */ 1686 public String getName() { 1687 return (runMapping(new MapAction<String>("getName") { 1688 @Override 1689 public String map() { 1690 return getSource().getName(); 1691 } 1692 })); 1693 } 1694 1695 /** 1696 * Maps {@code Component.getParent()} through queue 1697 */ 1698 public Container getParent() { 1699 return (runMapping(new MapAction<Container>("getParent") { 1700 @Override 1701 public Container map() { 1702 return getSource().getParent(); 1703 } 1704 })); 1705 } 1706 1707 /** 1708 * Maps {@code Component.getPreferredSize()} through queue 1709 */ 1710 public Dimension getPreferredSize() { 1711 return (runMapping(new MapAction<Dimension>("getPreferredSize") { 1712 @Override 1713 public Dimension map() { 1714 return getSource().getPreferredSize(); 1715 } 1716 })); 1717 } 1718 1719 /** 1720 * Maps {@code Component.getSize()} through queue 1721 */ 1722 public Dimension getSize() { 1723 return (runMapping(new MapAction<Dimension>("getSize") { 1724 @Override 1725 public Dimension map() { 1726 return getSource().getSize(); 1727 } 1728 })); 1729 } 1730 1731 /** 1732 * Maps {@code Component.getSize(Dimension)} through queue 1733 */ 1734 public Dimension getSize(final Dimension dimension) { 1735 return (runMapping(new MapAction<Dimension>("getSize") { 1736 @Override 1737 public Dimension map() { 1738 return getSource().getSize(dimension); 1739 } 1740 })); 1741 } 1742 1743 /** 1744 * Maps {@code Component.getToolkit()} through queue 1745 */ 1746 public Toolkit getToolkit() { 1747 return (runMapping(new MapAction<Toolkit>("getToolkit") { 1748 @Override 1749 public Toolkit map() { 1750 return getSource().getToolkit(); 1751 } 1752 })); 1753 } 1754 1755 /** 1756 * Maps {@code Component.getTreeLock()} through queue 1757 */ 1758 public Object getTreeLock() { 1759 return (runMapping(new MapAction<Object>("getTreeLock") { 1760 @Override 1761 public Object map() { 1762 return getSource().getTreeLock(); 1763 } 1764 })); 1765 } 1766 1767 /** 1768 * Maps {@code Component.getWidth()} through queue 1769 */ 1770 public int getWidth() { 1771 return (runMapping(new MapIntegerAction("getWidth") { 1772 @Override 1773 public int map() { 1774 return getSource().getWidth(); 1775 } 1776 })); 1777 } 1778 1779 /** 1780 * Maps {@code Component.getX()} through queue 1781 */ 1782 public int getX() { 1783 return (runMapping(new MapIntegerAction("getX") { 1784 @Override 1785 public int map() { 1786 return getSource().getX(); 1787 } 1788 })); 1789 } 1790 1791 /** 1792 * Maps {@code Component.getY()} through queue 1793 */ 1794 public int getY() { 1795 return (runMapping(new MapIntegerAction("getY") { 1796 @Override 1797 public int map() { 1798 return getSource().getY(); 1799 } 1800 })); 1801 } 1802 1803 /** 1804 * Maps {@code Component.hasFocus()} through queue 1805 */ 1806 public boolean hasFocus() { 1807 return (runMapping(new MapBooleanAction("hasFocus") { 1808 @Override 1809 public boolean map() { 1810 return getSource().hasFocus(); 1811 } 1812 })); 1813 } 1814 1815 /** 1816 * Maps {@code Component.imageUpdate(Image, int, int, int, int, int)} 1817 * through queue 1818 */ 1819 public boolean imageUpdate(final Image image, final int i, final int i1, final int i2, final int i3, final int i4) { 1820 return (runMapping(new MapBooleanAction("imageUpdate") { 1821 @Override 1822 public boolean map() { 1823 return getSource().imageUpdate(image, i, i1, i2, i3, i4); 1824 } 1825 })); 1826 } 1827 1828 /** 1829 * Maps {@code Component.invalidate()} through queue 1830 */ 1831 public void invalidate() { 1832 runMapping(new MapVoidAction("invalidate") { 1833 @Override 1834 public void map() { 1835 getSource().invalidate(); 1836 } 1837 }); 1838 } 1839 1840 /** 1841 * Maps {@code Component.isDisplayable()} through queue 1842 */ 1843 public boolean isDisplayable() { 1844 return (runMapping(new MapBooleanAction("isDisplayable") { 1845 @Override 1846 public boolean map() { 1847 return getSource().isDisplayable(); 1848 } 1849 })); 1850 } 1851 1852 /** 1853 * Maps {@code Component.isDoubleBuffered()} through queue 1854 */ 1855 public boolean isDoubleBuffered() { 1856 return (runMapping(new MapBooleanAction("isDoubleBuffered") { 1857 @Override 1858 public boolean map() { 1859 return getSource().isDoubleBuffered(); 1860 } 1861 })); 1862 } 1863 1864 /** 1865 * Maps {@code Component.isEnabled()} through queue 1866 */ 1867 public boolean isEnabled() { 1868 return (runMapping(new MapBooleanAction("isEnabled") { 1869 @Override 1870 public boolean map() { 1871 return getSource().isEnabled(); 1872 } 1873 })); 1874 } 1875 1876 /** 1877 * Maps {@code Component.isFocusTraversable()} through queue 1878 */ 1879 @Deprecated 1880 public boolean isFocusTraversable() { 1881 return (runMapping(new MapBooleanAction("isFocusTraversable") { 1882 @Override 1883 public boolean map() { 1884 return getSource().isFocusTraversable(); 1885 } 1886 })); 1887 } 1888 1889 /** 1890 * Maps {@code Component.isLightweight()} through queue 1891 */ 1892 public boolean isLightweight() { 1893 return (runMapping(new MapBooleanAction("isLightweight") { 1894 @Override 1895 public boolean map() { 1896 return getSource().isLightweight(); 1897 } 1898 })); 1899 } 1900 1901 /** 1902 * Maps {@code Component.isOpaque()} through queue 1903 */ 1904 public boolean isOpaque() { 1905 return (runMapping(new MapBooleanAction("isOpaque") { 1906 @Override 1907 public boolean map() { 1908 return getSource().isOpaque(); 1909 } 1910 })); 1911 } 1912 1913 /** 1914 * Maps {@code Component.isShowing()} through queue 1915 */ 1916 public boolean isShowing() { 1917 return (runMapping(new MapBooleanAction("isShowing") { 1918 @Override 1919 public boolean map() { 1920 return getSource().isShowing(); 1921 } 1922 })); 1923 } 1924 1925 /** 1926 * Maps {@code Component.isValid()} through queue 1927 */ 1928 public boolean isValid() { 1929 return (runMapping(new MapBooleanAction("isValid") { 1930 @Override 1931 public boolean map() { 1932 return getSource().isValid(); 1933 } 1934 })); 1935 } 1936 1937 /** 1938 * Maps {@code Component.isVisible()} through queue 1939 */ 1940 public boolean isVisible() { 1941 return (runMapping(new MapBooleanAction("isVisible") { 1942 @Override 1943 public boolean map() { 1944 return getSource().isVisible(); 1945 } 1946 })); 1947 } 1948 1949 /** 1950 * Maps {@code Component.list()} through queue 1951 */ 1952 public void list() { 1953 runMapping(new MapVoidAction("list") { 1954 @Override 1955 public void map() { 1956 getSource().list(); 1957 } 1958 }); 1959 } 1960 1961 /** 1962 * Maps {@code Component.list(PrintStream)} through queue 1963 */ 1964 public void list(final PrintStream printStream) { 1965 runMapping(new MapVoidAction("list") { 1966 @Override 1967 public void map() { 1968 getSource().list(printStream); 1969 } 1970 }); 1971 } 1972 1973 /** 1974 * Maps {@code Component.list(PrintStream, int)} through queue 1975 */ 1976 public void list(final PrintStream printStream, final int i) { 1977 runMapping(new MapVoidAction("list") { 1978 @Override 1979 public void map() { 1980 getSource().list(printStream, i); 1981 } 1982 }); 1983 } 1984 1985 /** 1986 * Maps {@code Component.list(PrintWriter)} through queue 1987 */ 1988 public void list(final PrintWriter printWriter) { 1989 runMapping(new MapVoidAction("list") { 1990 @Override 1991 public void map() { 1992 getSource().list(printWriter); 1993 } 1994 }); 1995 } 1996 1997 /** 1998 * Maps {@code Component.list(PrintWriter, int)} through queue 1999 */ 2000 public void list(final PrintWriter printWriter, final int i) { 2001 runMapping(new MapVoidAction("list") { 2002 @Override 2003 public void map() { 2004 getSource().list(printWriter, i); 2005 } 2006 }); 2007 } 2008 2009 /** 2010 * Maps {@code Component.paint(Graphics)} through queue 2011 */ 2012 public void paint(final Graphics graphics) { 2013 runMapping(new MapVoidAction("paint") { 2014 @Override 2015 public void map() { 2016 getSource().paint(graphics); 2017 } 2018 }); 2019 } 2020 2021 /** 2022 * Maps {@code Component.paintAll(Graphics)} through queue 2023 */ 2024 public void paintAll(final Graphics graphics) { 2025 runMapping(new MapVoidAction("paintAll") { 2026 @Override 2027 public void map() { 2028 getSource().paintAll(graphics); 2029 } 2030 }); 2031 } 2032 2033 /** 2034 * Maps {@code Component.prepareImage(Image, int, int, ImageObserver)} 2035 * through queue 2036 */ 2037 public boolean prepareImage(final Image image, final int i, final int i1, final ImageObserver imageObserver) { 2038 return (runMapping(new MapBooleanAction("prepareImage") { 2039 @Override 2040 public boolean map() { 2041 return getSource().prepareImage(image, i, i1, imageObserver); 2042 } 2043 })); 2044 } 2045 2046 /** 2047 * Maps {@code Component.prepareImage(Image, ImageObserver)} through queue 2048 */ 2049 public boolean prepareImage(final Image image, final ImageObserver imageObserver) { 2050 return (runMapping(new MapBooleanAction("prepareImage") { 2051 @Override 2052 public boolean map() { 2053 return getSource().prepareImage(image, imageObserver); 2054 } 2055 })); 2056 } 2057 2058 /** 2059 * Maps {@code Component.print(Graphics)} through queue 2060 */ 2061 public void print(final Graphics graphics) { 2062 runMapping(new MapVoidAction("print") { 2063 @Override 2064 public void map() { 2065 getSource().print(graphics); 2066 } 2067 }); 2068 } 2069 2070 /** 2071 * Maps {@code Component.printAll(Graphics)} through queue 2072 */ 2073 public void printAll(final Graphics graphics) { 2074 runMapping(new MapVoidAction("printAll") { 2075 @Override 2076 public void map() { 2077 getSource().printAll(graphics); 2078 } 2079 }); 2080 } 2081 2082 /** 2083 * Maps {@code Component.remove(MenuComponent)} through queue 2084 */ 2085 public void remove(final MenuComponent menuComponent) { 2086 runMapping(new MapVoidAction("remove") { 2087 @Override 2088 public void map() { 2089 getSource().remove(menuComponent); 2090 } 2091 }); 2092 } 2093 2094 /** 2095 * Maps {@code Component.removeComponentListener(ComponentListener)} 2096 * through queue 2097 */ 2098 public void removeComponentListener(final ComponentListener componentListener) { 2099 runMapping(new MapVoidAction("removeComponentListener") { 2100 @Override 2101 public void map() { 2102 getSource().removeComponentListener(componentListener); 2103 } 2104 }); 2105 } 2106 2107 /** 2108 * Maps {@code Component.removeFocusListener(FocusListener)} through queue 2109 */ 2110 public void removeFocusListener(final FocusListener focusListener) { 2111 runMapping(new MapVoidAction("removeFocusListener") { 2112 @Override 2113 public void map() { 2114 getSource().removeFocusListener(focusListener); 2115 } 2116 }); 2117 } 2118 2119 /** 2120 * Maps 2121 * {@code Component.removeInputMethodListener(InputMethodListener)} 2122 * through queue 2123 */ 2124 public void removeInputMethodListener(final InputMethodListener inputMethodListener) { 2125 runMapping(new MapVoidAction("removeInputMethodListener") { 2126 @Override 2127 public void map() { 2128 getSource().removeInputMethodListener(inputMethodListener); 2129 } 2130 }); 2131 } 2132 2133 /** 2134 * Maps {@code Component.removeKeyListener(KeyListener)} through queue 2135 */ 2136 public void removeKeyListener(final KeyListener keyListener) { 2137 runMapping(new MapVoidAction("removeKeyListener") { 2138 @Override 2139 public void map() { 2140 getSource().removeKeyListener(keyListener); 2141 } 2142 }); 2143 } 2144 2145 /** 2146 * Maps {@code Component.removeMouseListener(MouseListener)} through queue 2147 */ 2148 public void removeMouseListener(final MouseListener mouseListener) { 2149 runMapping(new MapVoidAction("removeMouseListener") { 2150 @Override 2151 public void map() { 2152 getSource().removeMouseListener(mouseListener); 2153 } 2154 }); 2155 } 2156 2157 /** 2158 * Maps 2159 * {@code Component.removeMouseMotionListener(MouseMotionListener)} 2160 * through queue 2161 */ 2162 public void removeMouseMotionListener(final MouseMotionListener mouseMotionListener) { 2163 runMapping(new MapVoidAction("removeMouseMotionListener") { 2164 @Override 2165 public void map() { 2166 getSource().removeMouseMotionListener(mouseMotionListener); 2167 } 2168 }); 2169 } 2170 2171 /** 2172 * Maps {@code Component.removeNotify()} through queue 2173 */ 2174 public void removeNotify() { 2175 runMapping(new MapVoidAction("removeNotify") { 2176 @Override 2177 public void map() { 2178 getSource().removeNotify(); 2179 } 2180 }); 2181 } 2182 2183 /** 2184 * Maps 2185 * {@code Component.removePropertyChangeListener(PropertyChangeListener)} 2186 * through queue 2187 */ 2188 public void removePropertyChangeListener(final PropertyChangeListener propertyChangeListener) { 2189 runMapping(new MapVoidAction("removePropertyChangeListener") { 2190 @Override 2191 public void map() { 2192 getSource().removePropertyChangeListener(propertyChangeListener); 2193 } 2194 }); 2195 } 2196 2197 /** 2198 * Maps 2199 * {@code Component.removePropertyChangeListener(String, PropertyChangeListener)} 2200 * through queue 2201 */ 2202 public void removePropertyChangeListener(final String string, final PropertyChangeListener propertyChangeListener) { 2203 runMapping(new MapVoidAction("removePropertyChangeListener") { 2204 @Override 2205 public void map() { 2206 getSource().removePropertyChangeListener(string, propertyChangeListener); 2207 } 2208 }); 2209 } 2210 2211 /** 2212 * Maps {@code Component.repaint()} through queue 2213 */ 2214 public void repaint() { 2215 runMapping(new MapVoidAction("repaint") { 2216 @Override 2217 public void map() { 2218 getSource().repaint(); 2219 } 2220 }); 2221 } 2222 2223 /** 2224 * Maps {@code Component.repaint(int, int, int, int)} through queue 2225 */ 2226 public void repaint(final int i, final int i1, final int i2, final int i3) { 2227 runMapping(new MapVoidAction("repaint") { 2228 @Override 2229 public void map() { 2230 getSource().repaint(i, i1, i2, i3); 2231 } 2232 }); 2233 } 2234 2235 /** 2236 * Maps {@code Component.repaint(long)} through queue 2237 */ 2238 public void repaint(final long l) { 2239 runMapping(new MapVoidAction("repaint") { 2240 @Override 2241 public void map() { 2242 getSource().repaint(l); 2243 } 2244 }); 2245 } 2246 2247 /** 2248 * Maps {@code Component.repaint(long, int, int, int, int)} through queue 2249 */ 2250 public void repaint(final long l, final int i, final int i1, final int i2, final int i3) { 2251 runMapping(new MapVoidAction("repaint") { 2252 @Override 2253 public void map() { 2254 getSource().repaint(l, i, i1, i2, i3); 2255 } 2256 }); 2257 } 2258 2259 /** 2260 * Maps {@code Component.requestFocus()} through queue 2261 */ 2262 public void requestFocus() { 2263 runMapping(new MapVoidAction("requestFocus") { 2264 @Override 2265 public void map() { 2266 getSource().requestFocus(); 2267 } 2268 }); 2269 } 2270 2271 /** 2272 * Maps {@code Component.setBackground(Color)} through queue 2273 */ 2274 public void setBackground(final Color color) { 2275 runMapping(new MapVoidAction("setBackground") { 2276 @Override 2277 public void map() { 2278 getSource().setBackground(color); 2279 } 2280 }); 2281 } 2282 2283 /** 2284 * Maps {@code Component.setBounds(int, int, int, int)} through queue 2285 */ 2286 public void setBounds(final int i, final int i1, final int i2, final int i3) { 2287 runMapping(new MapVoidAction("setBounds") { 2288 @Override 2289 public void map() { 2290 getSource().setBounds(i, i1, i2, i3); 2291 } 2292 }); 2293 } 2294 2295 /** 2296 * Maps {@code Component.setBounds(Rectangle)} through queue 2297 */ 2298 public void setBounds(final Rectangle rectangle) { 2299 runMapping(new MapVoidAction("setBounds") { 2300 @Override 2301 public void map() { 2302 getSource().setBounds(rectangle); 2303 } 2304 }); 2305 } 2306 2307 /** 2308 * Maps {@code Component.setComponentOrientation(ComponentOrientation)} 2309 * through queue 2310 */ 2311 public void setComponentOrientation(final ComponentOrientation componentOrientation) { 2312 runMapping(new MapVoidAction("setComponentOrientation") { 2313 @Override 2314 public void map() { 2315 getSource().setComponentOrientation(componentOrientation); 2316 } 2317 }); 2318 } 2319 2320 /** 2321 * Maps {@code Component.setCursor(Cursor)} through queue 2322 */ 2323 public void setCursor(final Cursor cursor) { 2324 runMapping(new MapVoidAction("setCursor") { 2325 @Override 2326 public void map() { 2327 getSource().setCursor(cursor); 2328 } 2329 }); 2330 } 2331 2332 /** 2333 * Maps {@code Component.setDropTarget(DropTarget)} through queue 2334 */ 2335 public void setDropTarget(final DropTarget dropTarget) { 2336 runMapping(new MapVoidAction("setDropTarget") { 2337 @Override 2338 public void map() { 2339 getSource().setDropTarget(dropTarget); 2340 } 2341 }); 2342 } 2343 2344 /** 2345 * Maps {@code Component.setEnabled(boolean)} through queue 2346 */ 2347 public void setEnabled(final boolean b) { 2348 runMapping(new MapVoidAction("setEnabled") { 2349 @Override 2350 public void map() { 2351 getSource().setEnabled(b); 2352 } 2353 }); 2354 } 2355 2356 /** 2357 * Maps {@code Component.setFont(Font)} through queue 2358 */ 2359 public void setFont(final Font font) { 2360 runMapping(new MapVoidAction("setFont") { 2361 @Override 2362 public void map() { 2363 getSource().setFont(font); 2364 } 2365 }); 2366 } 2367 2368 /** 2369 * Maps {@code Component.setForeground(Color)} through queue 2370 */ 2371 public void setForeground(final Color color) { 2372 runMapping(new MapVoidAction("setForeground") { 2373 @Override 2374 public void map() { 2375 getSource().setForeground(color); 2376 } 2377 }); 2378 } 2379 2380 /** 2381 * Maps {@code Component.setLocale(Locale)} through queue 2382 */ 2383 public void setLocale(final Locale locale) { 2384 runMapping(new MapVoidAction("setLocale") { 2385 @Override 2386 public void map() { 2387 getSource().setLocale(locale); 2388 } 2389 }); 2390 } 2391 2392 /** 2393 * Maps {@code Component.setLocation(int, int)} through queue 2394 */ 2395 public void setLocation(final int i, final int i1) { 2396 runMapping(new MapVoidAction("setLocation") { 2397 @Override 2398 public void map() { 2399 getSource().setLocation(i, i1); 2400 } 2401 }); 2402 } 2403 2404 /** 2405 * Maps {@code Component.setLocation(Point)} through queue 2406 */ 2407 public void setLocation(final Point point) { 2408 runMapping(new MapVoidAction("setLocation") { 2409 @Override 2410 public void map() { 2411 getSource().setLocation(point); 2412 } 2413 }); 2414 } 2415 2416 /** 2417 * Maps {@code Component.setName(String)} through queue 2418 */ 2419 public void setName(final String string) { 2420 runMapping(new MapVoidAction("setName") { 2421 @Override 2422 public void map() { 2423 getSource().setName(string); 2424 } 2425 }); 2426 } 2427 2428 /** 2429 * Maps {@code Component.setSize(int, int)} through queue 2430 */ 2431 public void setSize(final int i, final int i1) { 2432 runMapping(new MapVoidAction("setSize") { 2433 @Override 2434 public void map() { 2435 getSource().setSize(i, i1); 2436 } 2437 }); 2438 } 2439 2440 /** 2441 * Maps {@code Component.setSize(Dimension)} through queue 2442 */ 2443 public void setSize(final Dimension dimension) { 2444 runMapping(new MapVoidAction("setSize") { 2445 @Override 2446 public void map() { 2447 getSource().setSize(dimension); 2448 } 2449 }); 2450 } 2451 2452 /** 2453 * Maps {@code Component.setVisible(boolean)} through queue 2454 */ 2455 public void setVisible(final boolean b) { 2456 runMapping(new MapVoidAction("setVisible") { 2457 @Override 2458 public void map() { 2459 getSource().setVisible(b); 2460 } 2461 }); 2462 } 2463 2464 /** 2465 * Maps {@code Component.transferFocus()} through queue 2466 */ 2467 public void transferFocus() { 2468 runMapping(new MapVoidAction("transferFocus") { 2469 @Override 2470 public void map() { 2471 getSource().transferFocus(); 2472 } 2473 }); 2474 } 2475 2476 /** 2477 * Maps {@code Component.update(Graphics)} through queue 2478 */ 2479 public void update(final Graphics graphics) { 2480 runMapping(new MapVoidAction("update") { 2481 @Override 2482 public void map() { 2483 getSource().update(graphics); 2484 } 2485 }); 2486 } 2487 2488 /** 2489 * Maps {@code Component.validate()} through queue 2490 */ 2491 public void validate() { 2492 runMapping(new MapVoidAction("validate") { 2493 @Override 2494 public void map() { 2495 getSource().validate(); 2496 } 2497 }); 2498 } 2499 2500 //End of mapping // 2501 //////////////////////////////////////////////////////// 2502 private void setEventDispatcher(EventDispatcher dispatcher) { 2503 dispatcher.setOutput(getOutput().createErrorOutput()); 2504 dispatcher.setTimeouts(getTimeouts()); 2505 this.dispatcher = dispatcher; 2506 } 2507 2508 static class VisibleComponentFinder implements ComponentChooser { 2509 2510 ComponentChooser subFinder; 2511 2512 public VisibleComponentFinder(ComponentChooser sf) { 2513 subFinder = sf; 2514 } 2515 2516 @Override 2517 public boolean checkComponent(Component comp) { 2518 if (comp.isShowing()) { 2519 return subFinder.checkComponent(comp); 2520 } 2521 return false; 2522 } 2523 2524 @Override 2525 public String getDescription() { 2526 return subFinder.getDescription(); 2527 } 2528 2529 @Override 2530 public String toString() { 2531 return "VisibleComponentFinder{" + "subFinder=" + subFinder + '}'; 2532 } 2533 } 2534 2535} 2536