JSplitPaneOperator.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.Component; 26import java.awt.Container; 27import java.util.Hashtable; 28 29import javax.swing.JButton; 30import javax.swing.JSplitPane; 31import javax.swing.plaf.SplitPaneUI; 32import javax.swing.plaf.basic.BasicSplitPaneDivider; 33 34import org.netbeans.jemmy.Action; 35import org.netbeans.jemmy.ComponentChooser; 36import org.netbeans.jemmy.ComponentSearcher; 37import org.netbeans.jemmy.Outputable; 38import org.netbeans.jemmy.TestOut; 39import org.netbeans.jemmy.TimeoutExpiredException; 40import org.netbeans.jemmy.Timeoutable; 41import org.netbeans.jemmy.Timeouts; 42import org.netbeans.jemmy.drivers.DriverManager; 43import org.netbeans.jemmy.drivers.ScrollDriver; 44import org.netbeans.jemmy.drivers.scrolling.ScrollAdjuster; 45import org.netbeans.jemmy.util.EmptyVisualizer; 46 47/** 48 * <BR><BR>Timeouts used: <BR> 49 * JSplitPaneOperator.ScrollClickTimeout - time for simple scroll click <BR> 50 * JSplitPaneOperator.BetweenClickTimeout - time to sleep between scroll clicks 51 * <BR> 52 * JSplitPaneOperator.WholeScrollTimeout - time for the whole scrolling <BR> 53 * ComponentOperator.WaitComponentTimeout - time to wait component displayed 54 * <BR>. 55 * 56 * @see org.netbeans.jemmy.Timeouts 57 * 58 * @author Alexandre Iline (alexandre.iline@oracle.com) 59 * 60 * Class to operate with javax.swing.JSplitPane component 61 * 62 */ 63public class JSplitPaneOperator extends JComponentOperator 64 implements Timeoutable, Outputable { 65 66 /** 67 * Identifier for a "minimum" property. 68 * 69 * @see #getDump 70 */ 71 public static final String MINIMUM_DPROP = "Minimum"; 72 73 /** 74 * Identifier for a "maximum" property. 75 * 76 * @see #getDump 77 */ 78 public static final String MAXIMUM_DPROP = "Maximum"; 79 80 /** 81 * Identifier for a "value" property. 82 * 83 * @see #getDump 84 */ 85 public static final String VALUE_DPROP = "Value"; 86 87 /** 88 * Identifier for a "orientation" property. 89 * 90 * @see #getDump 91 */ 92 public static final String ORIENTATION_DPROP = "Orientation"; 93 94 /** 95 * Identifier for a "HORIZONTAL" value of "orientation" property. 96 * 97 * @see #getDump 98 */ 99 public static final String HORIZONTAL_ORIENTATION_DPROP_VALUE = "HORIZONTAL"; 100 101 /** 102 * Identifier for a "VERTICAL" value of "orientation" property. 103 * 104 * @see #getDump 105 */ 106 public static final String VERTICAL_ORIENTATION_DPROP_VALUE = "VERTICAL"; 107 108 /** 109 * Identifier for a "one touch expendable" property. 110 * 111 * @see #getDump 112 */ 113 public static final String IS_ONE_TOUCH_EXPANDABLE_DPROP = "One touch expandable"; 114 115 private final static long SCROLL_CLICK_TIMEOUT = 0; 116 private final static long BETWEEN_CLICK_TIMEOUT = 0; 117 private final static long WHOLE_SCROLL_TIMEOUT = 60000; 118 119 private Timeouts timeouts; 120 private TestOut output; 121 private ContainerOperator<?> divider; 122 private ScrollDriver driver; 123 124 /** 125 * Constructor. 126 * 127 * @param b JSplitPane component. 128 */ 129 public JSplitPaneOperator(JSplitPane b) { 130 super(b); 131 driver = DriverManager.getScrollDriver(getClass()); 132 } 133 134 /** 135 * Constructs a JSplitPaneOperator object. 136 * 137 * @param cont a container 138 * @param chooser a component chooser specifying searching criteria. 139 * @param index an index between appropriate ones. 140 */ 141 public JSplitPaneOperator(ContainerOperator<?> cont, ComponentChooser chooser, int index) { 142 this((JSplitPane) cont. 143 waitSubComponent(new JSplitPaneFinder(chooser), 144 index)); 145 copyEnvironment(cont); 146 } 147 148 /** 149 * Constructs a JSplitPaneOperator object. 150 * 151 * @param cont a container 152 * @param chooser a component chooser specifying searching criteria. 153 */ 154 public JSplitPaneOperator(ContainerOperator<?> cont, ComponentChooser chooser) { 155 this(cont, chooser, 0); 156 } 157 158 /** 159 * Constructor. Waits component in container first. Uses cont's timeout and 160 * output for waiting and to init operator. 161 * 162 * @param cont Operator pointing a container to search component in. 163 * @param index Ordinal component index. 164 * @throws TimeoutExpiredException 165 */ 166 public JSplitPaneOperator(ContainerOperator<?> cont, int index) { 167 this((JSplitPane) waitComponent(cont, 168 new JSplitPaneFinder(), 169 index)); 170 copyEnvironment(cont); 171 } 172 173 /** 174 * Constructor. Waits component in container first. Uses cont's timeout and 175 * output for waiting and to init operator. 176 * 177 * @param cont Operator pointing a container to search component in. 178 * @throws TimeoutExpiredException 179 */ 180 public JSplitPaneOperator(ContainerOperator<?> cont) { 181 this(cont, 0); 182 } 183 184 /** 185 * Searches JSplitPane in container. 186 * 187 * @param cont Container to search component in. 188 * @param chooser org.netbeans.jemmy.ComponentChooser implementation. 189 * @param index Ordinal component index. 190 * @return JSplitPane instance or null if component was not found. 191 */ 192 public static JSplitPane findJSplitPane(Container cont, ComponentChooser chooser, int index) { 193 return (JSplitPane) findComponent(cont, new JSplitPaneFinder(chooser), index); 194 } 195 196 /** 197 * Searches 0'th JSplitPane in container. 198 * 199 * @param cont Container to search component in. 200 * @param chooser org.netbeans.jemmy.ComponentChooser implementation. 201 * @return JSplitPane instance or null if component was not found. 202 */ 203 public static JSplitPane findJSplitPane(Container cont, ComponentChooser chooser) { 204 return findJSplitPane(cont, chooser, 0); 205 } 206 207 /** 208 * Searches JSplitPane in container. 209 * 210 * @param cont Container to search component in. 211 * @param index Ordinal component index. 212 * @return JSplitPane instance or null if component was not found. 213 */ 214 public static JSplitPane findJSplitPane(Container cont, int index) { 215 return findJSplitPane(cont, ComponentSearcher.getTrueChooser(Integer.toString(index) + "'th JSplitPane instance"), index); 216 } 217 218 /** 219 * Searches 0'th JSplitPane in container. 220 * 221 * @param cont Container to search component in. 222 * @return JSplitPane instance or null if component was not found. 223 */ 224 public static JSplitPane findJSplitPane(Container cont) { 225 return findJSplitPane(cont, 0); 226 } 227 228 /** 229 * Searches JSplitPane object which component lies on. 230 * 231 * @param comp Component to find JSplitPane under. 232 * @param chooser org.netbeans.jemmy.ComponentChooser implementation. 233 * @return JSplitPane instance or null if component was not found. 234 */ 235 public static JSplitPane findJSplitPaneUnder(Component comp, ComponentChooser chooser) { 236 return (JSplitPane) findContainerUnder(comp, new JSplitPaneFinder(chooser)); 237 } 238 239 /** 240 * Searches JSplitPane object which component lies on. 241 * 242 * @param comp Component to find JSplitPane under. 243 * @return JSplitPane instance or null if component was not found. 244 */ 245 public static JSplitPane findJSplitPaneUnder(Component comp) { 246 return findJSplitPaneUnder(comp, new JSplitPaneFinder()); 247 } 248 249 /** 250 * Waits JSplitPane in container. 251 * 252 * @param cont Container to search component in. 253 * @param chooser org.netbeans.jemmy.ComponentChooser implementation. 254 * @param index Ordinal component index. 255 * @return JSplitPane instance or null if component was not displayed. 256 * @throws TimeoutExpiredException 257 */ 258 public static JSplitPane waitJSplitPane(Container cont, ComponentChooser chooser, int index) { 259 return (JSplitPane) waitComponent(cont, new JSplitPaneFinder(chooser), index); 260 } 261 262 /** 263 * Waits 0'th JSplitPane in container. 264 * 265 * @param cont Container to search component in. 266 * @param chooser org.netbeans.jemmy.ComponentChooser implementation. 267 * @return JSplitPane instance or null if component was not displayed. 268 * @throws TimeoutExpiredException 269 */ 270 public static JSplitPane waitJSplitPane(Container cont, ComponentChooser chooser) { 271 return waitJSplitPane(cont, chooser, 0); 272 } 273 274 /** 275 * Waits JSplitPane in container. 276 * 277 * @param cont Container to search component in. 278 * @param index Ordinal component index. 279 * @return JSplitPane instance or null if component was not displayed. 280 * @throws TimeoutExpiredException 281 */ 282 public static JSplitPane waitJSplitPane(Container cont, int index) { 283 return waitJSplitPane(cont, ComponentSearcher.getTrueChooser(Integer.toString(index) + "'th JSplitPane instance"), index); 284 } 285 286 /** 287 * Waits 0'th JSplitPane in container. 288 * 289 * @param cont Container to search component in. 290 * @return JSplitPane instance or null if component was not displayed. 291 * @throws TimeoutExpiredException 292 */ 293 public static JSplitPane waitJSplitPane(Container cont) { 294 return waitJSplitPane(cont, 0); 295 } 296 297 static { 298 Timeouts.initDefault("JSplitPaneOperator.ScrollClickTimeout", SCROLL_CLICK_TIMEOUT); 299 Timeouts.initDefault("JSplitPaneOperator.BetweenClickTimeout", BETWEEN_CLICK_TIMEOUT); 300 Timeouts.initDefault("JSplitPaneOperator.WholeScrollTimeout", WHOLE_SCROLL_TIMEOUT); 301 } 302 303 @Override 304 public void setTimeouts(Timeouts timeouts) { 305 this.timeouts = timeouts; 306 Timeouts times = timeouts; 307 times.setTimeout("ComponentOperator.BeforeDragTimeout", 308 0); 309 times.setTimeout("ComponentOperator.AfterDragTimeout", 310 times.getTimeout("JSplitPaneOperator.ScrollClickTimeout")); 311 super.setTimeouts(times); 312 } 313 314 @Override 315 public Timeouts getTimeouts() { 316 return timeouts; 317 } 318 319 @Override 320 public void setOutput(TestOut out) { 321 output = out; 322 super.setOutput(output.createErrorOutput()); 323 } 324 325 @Override 326 public TestOut getOutput() { 327 return output; 328 } 329 330 @Override 331 public void copyEnvironment(Operator anotherOperator) { 332 super.copyEnvironment(anotherOperator); 333 driver 334 = (ScrollDriver) DriverManager. 335 getDriver(DriverManager.SCROLL_DRIVER_ID, 336 getClass(), 337 anotherOperator.getProperties()); 338 } 339 340 /** 341 * Searches divider inside split pane. 342 * 343 * @return an operator for the divider. 344 */ 345 public BasicSplitPaneDivider findDivider() { 346 return ((BasicSplitPaneDivider) waitSubComponent(new ComponentChooser() { 347 @Override 348 public boolean checkComponent(Component comp) { 349 return comp instanceof BasicSplitPaneDivider; 350 } 351 352 @Override 353 public String getDescription() { 354 return ""; 355 } 356 357 @Override 358 public String toString() { 359 return "JSplitPaneOperator.findDivider.ComponentChooser{description = " + getDescription() + '}'; 360 } 361 })); 362 } 363 364 /** 365 * Searches divider inside split pane. 366 * 367 * @return an operator for the divider. 368 */ 369 public ContainerOperator<?> getDivider() { 370 if (divider == null) { 371 divider = new ContainerOperator<>(findDivider()); 372 divider.copyEnvironment(this); 373 divider.setOutput(getOutput().createErrorOutput()); 374 } 375 return divider; 376 } 377 378 /** 379 * Scrolls to the position defined by a ScrollAdjuster implementation. 380 * 381 * @param adj defines scrolling direction, and so on. 382 * @throws TimeoutExpiredException 383 */ 384 public void scrollTo(final ScrollAdjuster adj) { 385 produceTimeRestricted(new Action<Void, Void>() { 386 @Override 387 public Void launch(Void obj) { 388 driver.scroll(JSplitPaneOperator.this, adj); 389 return null; 390 } 391 392 @Override 393 public String getDescription() { 394 return "Moving a divider"; 395 } 396 397 @Override 398 public String toString() { 399 return "JSplitPaneOperator.scrollTo.Action{description = " + getDescription() + '}'; 400 } 401 }, "JSplitPaneOperator.WholeScrollTimeout"); 402 } 403 404 /** 405 * Changes divider location. 406 * 407 * @param dividerLocation location to move divider to. 408 */ 409 public void moveDivider(int dividerLocation) { 410 output.printTrace("Move JSplitPane divider to " + Integer.toString(dividerLocation) 411 + " location. JSplitPane : \n" + toStringSource()); 412 output.printGolden("Move JSplitPane divider to " + Integer.toString(dividerLocation) 413 + " location"); 414 scrollTo(new ValueScrollAdjuster(dividerLocation)); 415 } 416 417 /** 418 * Changes divider location. 419 * 420 * @param proportionalLocation Proportional location. Should be great then 0 421 * and less then 1. 422 */ 423 public void moveDivider(double proportionalLocation) { 424 output.printTrace("Move JSplitPane divider to " + Double.toString(proportionalLocation) 425 + " proportional location. JSplitPane : \n" + toStringSource()); 426 output.printGolden("Move JSplitPane divider to " + Double.toString(proportionalLocation) 427 + " proportional location"); 428 scrollTo(new ValueScrollAdjuster(getMinimumDividerLocation() 429 + (int) (proportionalLocation 430 * (getMaximumDividerLocation() - getMinimumDividerLocation())))); 431 } 432 433 /** 434 * Moves the divider all the way to the left/top. 435 */ 436 public void moveToMinimum() { 437 output.printTrace("Scroll JSplitPane to minimum. JSplitPane : \n" + toStringSource()); 438 output.printGolden("Scroll JSplitPane to minimum."); 439 produceTimeRestricted(new Action<Void, Void>() { 440 @Override 441 public Void launch(Void obj) { 442 driver.scrollToMinimum(JSplitPaneOperator.this, getOrientation()); 443 return null; 444 } 445 446 @Override 447 public String getDescription() { 448 return "Scrolling"; 449 } 450 451 @Override 452 public String toString() { 453 return "JSplitPaneOperator.moveToMinimum.Action{description = " + getDescription() + '}'; 454 } 455 }, "JSplitPaneOperator.WholeScrollTimeout"); 456 } 457 458 /** 459 * Moves the divider all the way to the right/bottom. 460 */ 461 public void moveToMaximum() { 462 output.printTrace("Scroll JSplitPane to maximum. JSplitPane : \n" + toStringSource()); 463 output.printGolden("Scroll JSplitPane to maximum."); 464 produceTimeRestricted(new Action<Void, Void>() { 465 @Override 466 public Void launch(Void obj) { 467 driver.scrollToMaximum(JSplitPaneOperator.this, getOrientation()); 468 return null; 469 } 470 471 @Override 472 public String getDescription() { 473 return "Scrolling"; 474 } 475 476 @Override 477 public String toString() { 478 return "JSplitPaneOperator.moveToMaximum.Action{description = " + getDescription() + '}'; 479 } 480 }, "JSplitPaneOperator.WholeScrollTimeout"); 481 } 482 483 /** 484 * Pushes one time right(bottom) expand button. 485 * 486 * @throws TimeoutExpiredException 487 */ 488 public void expandRight() { 489 String mess = "Expand "; 490 if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT) { 491 mess = mess + "right"; 492 } else { 493 mess = mess + "bottom"; 494 } 495 output.printTrace(mess + " JSplitPane side. JSplitPane : \n" + toStringSource()); 496 output.printGolden(mess + " JSplitPane side."); 497 expandTo(0); 498 } 499 500 /** 501 * Pushes one time left(top) expand button. 502 * 503 * @throws TimeoutExpiredException 504 */ 505 public void expandLeft() { 506 String mess = "Expand "; 507 if (getOrientation() == JSplitPane.HORIZONTAL_SPLIT) { 508 mess = mess + "left"; 509 } else { 510 mess = mess + "top"; 511 } 512 output.printTrace(mess + " JSplitPane side. JSplitPane : \n" + toStringSource()); 513 output.printGolden(mess + " JSplitPane side."); 514 expandTo(1); 515 } 516 517 @Override 518 public Hashtable<String, Object> getDump() { 519 Hashtable<String, Object> result = super.getDump(); 520 result.put(MINIMUM_DPROP, Integer.toString(((JSplitPane) getSource()).getMinimumDividerLocation())); 521 result.put(MAXIMUM_DPROP, Integer.toString(((JSplitPane) getSource()).getMaximumDividerLocation())); 522 result.put(ORIENTATION_DPROP, (((JSplitPane) getSource()).getOrientation() == JSplitPane.HORIZONTAL_SPLIT) 523 ? HORIZONTAL_ORIENTATION_DPROP_VALUE 524 : VERTICAL_ORIENTATION_DPROP_VALUE); 525 result.put(VALUE_DPROP, Integer.toString(((JSplitPane) getSource()).getDividerLocation())); 526 result.put(IS_ONE_TOUCH_EXPANDABLE_DPROP, ((JSplitPane) getSource()).isOneTouchExpandable() ? "true" : "false"); 527 return result; 528 } 529 530 //////////////////////////////////////////////////////// 531 //Mapping // 532 /** 533 * Maps {@code JSplitPane.getBottomComponent()} through queue 534 */ 535 public Component getBottomComponent() { 536 return (runMapping(new MapAction<Component>("getBottomComponent") { 537 @Override 538 public Component map() { 539 return ((JSplitPane) getSource()).getBottomComponent(); 540 } 541 })); 542 } 543 544 /** 545 * Maps {@code JSplitPane.getDividerLocation()} through queue 546 */ 547 public int getDividerLocation() { 548 return (runMapping(new MapIntegerAction("getDividerLocation") { 549 @Override 550 public int map() { 551 return ((JSplitPane) getSource()).getDividerLocation(); 552 } 553 })); 554 } 555 556 /** 557 * Maps {@code JSplitPane.getDividerSize()} through queue 558 */ 559 public int getDividerSize() { 560 return (runMapping(new MapIntegerAction("getDividerSize") { 561 @Override 562 public int map() { 563 return ((JSplitPane) getSource()).getDividerSize(); 564 } 565 })); 566 } 567 568 /** 569 * Maps {@code JSplitPane.getLastDividerLocation()} through queue 570 */ 571 public int getLastDividerLocation() { 572 return (runMapping(new MapIntegerAction("getLastDividerLocation") { 573 @Override 574 public int map() { 575 return ((JSplitPane) getSource()).getLastDividerLocation(); 576 } 577 })); 578 } 579 580 /** 581 * Maps {@code JSplitPane.getLeftComponent()} through queue 582 */ 583 public Component getLeftComponent() { 584 return (runMapping(new MapAction<Component>("getLeftComponent") { 585 @Override 586 public Component map() { 587 return ((JSplitPane) getSource()).getLeftComponent(); 588 } 589 })); 590 } 591 592 /** 593 * Maps {@code JSplitPane.getMaximumDividerLocation()} through queue 594 */ 595 public int getMaximumDividerLocation() { 596 return (runMapping(new MapIntegerAction("getMaximumDividerLocation") { 597 @Override 598 public int map() { 599 return ((JSplitPane) getSource()).getMaximumDividerLocation(); 600 } 601 })); 602 } 603 604 /** 605 * Maps {@code JSplitPane.getMinimumDividerLocation()} through queue 606 */ 607 public int getMinimumDividerLocation() { 608 return (runMapping(new MapIntegerAction("getMinimumDividerLocation") { 609 @Override 610 public int map() { 611 return ((JSplitPane) getSource()).getMinimumDividerLocation(); 612 } 613 })); 614 } 615 616 /** 617 * Maps {@code JSplitPane.getOrientation()} through queue 618 */ 619 public int getOrientation() { 620 return (runMapping(new MapIntegerAction("getOrientation") { 621 @Override 622 public int map() { 623 return ((JSplitPane) getSource()).getOrientation(); 624 } 625 })); 626 } 627 628 /** 629 * Maps {@code JSplitPane.getRightComponent()} through queue 630 */ 631 public Component getRightComponent() { 632 return (runMapping(new MapAction<Component>("getRightComponent") { 633 @Override 634 public Component map() { 635 return ((JSplitPane) getSource()).getRightComponent(); 636 } 637 })); 638 } 639 640 /** 641 * Maps {@code JSplitPane.getTopComponent()} through queue 642 */ 643 public Component getTopComponent() { 644 return (runMapping(new MapAction<Component>("getTopComponent") { 645 @Override 646 public Component map() { 647 return ((JSplitPane) getSource()).getTopComponent(); 648 } 649 })); 650 } 651 652 /** 653 * Maps {@code JSplitPane.getUI()} through queue 654 */ 655 public SplitPaneUI getUI() { 656 return (runMapping(new MapAction<SplitPaneUI>("getUI") { 657 @Override 658 public SplitPaneUI map() { 659 return ((JSplitPane) getSource()).getUI(); 660 } 661 })); 662 } 663 664 /** 665 * Maps {@code JSplitPane.isContinuousLayout()} through queue 666 */ 667 public boolean isContinuousLayout() { 668 return (runMapping(new MapBooleanAction("isContinuousLayout") { 669 @Override 670 public boolean map() { 671 return ((JSplitPane) getSource()).isContinuousLayout(); 672 } 673 })); 674 } 675 676 /** 677 * Maps {@code JSplitPane.isOneTouchExpandable()} through queue 678 */ 679 public boolean isOneTouchExpandable() { 680 return (runMapping(new MapBooleanAction("isOneTouchExpandable") { 681 @Override 682 public boolean map() { 683 return ((JSplitPane) getSource()).isOneTouchExpandable(); 684 } 685 })); 686 } 687 688 /** 689 * Maps {@code JSplitPane.resetToPreferredSizes()} through queue 690 */ 691 public void resetToPreferredSizes() { 692 runMapping(new MapVoidAction("resetToPreferredSizes") { 693 @Override 694 public void map() { 695 ((JSplitPane) getSource()).resetToPreferredSizes(); 696 } 697 }); 698 } 699 700 /** 701 * Maps {@code JSplitPane.setBottomComponent(Component)} through queue 702 */ 703 public void setBottomComponent(final Component component) { 704 runMapping(new MapVoidAction("setBottomComponent") { 705 @Override 706 public void map() { 707 ((JSplitPane) getSource()).setBottomComponent(component); 708 } 709 }); 710 } 711 712 /** 713 * Maps {@code JSplitPane.setContinuousLayout(boolean)} through queue 714 */ 715 public void setContinuousLayout(final boolean b) { 716 runMapping(new MapVoidAction("setContinuousLayout") { 717 @Override 718 public void map() { 719 ((JSplitPane) getSource()).setContinuousLayout(b); 720 } 721 }); 722 } 723 724 /** 725 * Maps {@code JSplitPane.setDividerLocation(double)} through queue 726 */ 727 public void setDividerLocation(final double d) { 728 runMapping(new MapVoidAction("setDividerLocation") { 729 @Override 730 public void map() { 731 ((JSplitPane) getSource()).setDividerLocation(d); 732 } 733 }); 734 } 735 736 /** 737 * Maps {@code JSplitPane.setDividerLocation(int)} through queue 738 */ 739 public void setDividerLocation(final int i) { 740 runMapping(new MapVoidAction("setDividerLocation") { 741 @Override 742 public void map() { 743 ((JSplitPane) getSource()).setDividerLocation(i); 744 } 745 }); 746 } 747 748 /** 749 * Maps {@code JSplitPane.setDividerSize(int)} through queue 750 */ 751 public void setDividerSize(final int i) { 752 runMapping(new MapVoidAction("setDividerSize") { 753 @Override 754 public void map() { 755 ((JSplitPane) getSource()).setDividerSize(i); 756 } 757 }); 758 } 759 760 /** 761 * Maps {@code JSplitPane.setLastDividerLocation(int)} through queue 762 */ 763 public void setLastDividerLocation(final int i) { 764 runMapping(new MapVoidAction("setLastDividerLocation") { 765 @Override 766 public void map() { 767 ((JSplitPane) getSource()).setLastDividerLocation(i); 768 } 769 }); 770 } 771 772 /** 773 * Maps {@code JSplitPane.setLeftComponent(Component)} through queue 774 */ 775 public void setLeftComponent(final Component component) { 776 runMapping(new MapVoidAction("setLeftComponent") { 777 @Override 778 public void map() { 779 ((JSplitPane) getSource()).setLeftComponent(component); 780 } 781 }); 782 } 783 784 /** 785 * Maps {@code JSplitPane.setOneTouchExpandable(boolean)} through queue 786 */ 787 public void setOneTouchExpandable(final boolean b) { 788 runMapping(new MapVoidAction("setOneTouchExpandable") { 789 @Override 790 public void map() { 791 ((JSplitPane) getSource()).setOneTouchExpandable(b); 792 } 793 }); 794 } 795 796 /** 797 * Maps {@code JSplitPane.setOrientation(int)} through queue 798 */ 799 public void setOrientation(final int i) { 800 runMapping(new MapVoidAction("setOrientation") { 801 @Override 802 public void map() { 803 ((JSplitPane) getSource()).setOrientation(i); 804 } 805 }); 806 } 807 808 /** 809 * Maps {@code JSplitPane.setRightComponent(Component)} through queue 810 */ 811 public void setRightComponent(final Component component) { 812 runMapping(new MapVoidAction("setRightComponent") { 813 @Override 814 public void map() { 815 ((JSplitPane) getSource()).setRightComponent(component); 816 } 817 }); 818 } 819 820 /** 821 * Maps {@code JSplitPane.setTopComponent(Component)} through queue 822 */ 823 public void setTopComponent(final Component component) { 824 runMapping(new MapVoidAction("setTopComponent") { 825 @Override 826 public void map() { 827 ((JSplitPane) getSource()).setTopComponent(component); 828 } 829 }); 830 } 831 832 /** 833 * Maps {@code JSplitPane.setUI(SplitPaneUI)} through queue 834 */ 835 public void setUI(final SplitPaneUI splitPaneUI) { 836 runMapping(new MapVoidAction("setUI") { 837 @Override 838 public void map() { 839 ((JSplitPane) getSource()).setUI(splitPaneUI); 840 } 841 }); 842 } 843 844 //End of mapping // 845 //////////////////////////////////////////////////////// 846 private void expandTo(int index) { 847 makeComponentVisible(); 848 JButtonOperator bo 849 = new JButtonOperator((JButton) getDivider(). 850 waitSubComponent(new JButtonOperator.JButtonFinder(ComponentSearcher. 851 getTrueChooser("JButton")), 852 index)); 853 bo.copyEnvironment(getDivider()); 854 bo.setVisualizer(new EmptyVisualizer()); 855 bo.push(); 856 } 857 858 /** 859 * Checks component type. 860 */ 861 public static class JSplitPaneFinder extends Finder { 862 863 /** 864 * Constructs JSplitPaneFinder. 865 * 866 * @param sf other searching criteria. 867 */ 868 public JSplitPaneFinder(ComponentChooser sf) { 869 super(JSplitPane.class, sf); 870 } 871 872 /** 873 * Constructs JSplitPaneFinder. 874 */ 875 public JSplitPaneFinder() { 876 super(JSplitPane.class); 877 } 878 } 879 880 private class ValueScrollAdjuster implements ScrollAdjuster { 881 882 int value; 883 884 public ValueScrollAdjuster(int value) { 885 this.value = value; 886 } 887 888 @Override 889 public int getScrollDirection() { 890 if (getDividerLocation() == value) { 891 return ScrollAdjuster.DO_NOT_TOUCH_SCROLL_DIRECTION; 892 } else { 893 return ((getDividerLocation() < value) 894 ? ScrollAdjuster.INCREASE_SCROLL_DIRECTION 895 : ScrollAdjuster.DECREASE_SCROLL_DIRECTION); 896 } 897 } 898 899 @Override 900 public int getScrollOrientation() { 901 return getOrientation(); 902 } 903 904 @Override 905 public String getDescription() { 906 return "Scroll to " + Integer.toString(value) + " value"; 907 } 908 909 @Override 910 public String toString() { 911 return "ValueScrollAdjuster{" + "value=" + value + '}'; 912 } 913 } 914} 915