jdk/test/sanity/client/lib/jemmy/src/org/netbeans/jemmy/operators/JTreeOperator.java
changeset 36744 a00905527ec2
equal deleted inserted replaced
36743:bdc3f1b79fb7 36744:a00905527ec2
       
     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  */
       
    23 package org.netbeans.jemmy.operators;
       
    24 
       
    25 import java.awt.Component;
       
    26 import java.awt.Container;
       
    27 import java.awt.Dimension;
       
    28 import java.awt.Point;
       
    29 import java.awt.Rectangle;
       
    30 import java.util.Enumeration;
       
    31 import java.util.Hashtable;
       
    32 
       
    33 import javax.swing.JPopupMenu;
       
    34 import javax.swing.JScrollPane;
       
    35 import javax.swing.JTree;
       
    36 import javax.swing.event.TreeExpansionListener;
       
    37 import javax.swing.event.TreeSelectionListener;
       
    38 import javax.swing.event.TreeWillExpandListener;
       
    39 import javax.swing.plaf.TreeUI;
       
    40 import javax.swing.tree.ExpandVetoException;
       
    41 import javax.swing.tree.TreeCellEditor;
       
    42 import javax.swing.tree.TreeCellRenderer;
       
    43 import javax.swing.tree.TreeModel;
       
    44 import javax.swing.tree.TreePath;
       
    45 import javax.swing.tree.TreeSelectionModel;
       
    46 
       
    47 import org.netbeans.jemmy.ComponentChooser;
       
    48 import org.netbeans.jemmy.ComponentSearcher;
       
    49 import org.netbeans.jemmy.JemmyException;
       
    50 import org.netbeans.jemmy.JemmyInputException;
       
    51 import org.netbeans.jemmy.Outputable;
       
    52 import org.netbeans.jemmy.QueueTool;
       
    53 import org.netbeans.jemmy.TestOut;
       
    54 import org.netbeans.jemmy.TimeoutExpiredException;
       
    55 import org.netbeans.jemmy.Timeoutable;
       
    56 import org.netbeans.jemmy.Timeouts;
       
    57 import org.netbeans.jemmy.Waitable;
       
    58 import org.netbeans.jemmy.Waiter;
       
    59 import org.netbeans.jemmy.drivers.DriverManager;
       
    60 import org.netbeans.jemmy.drivers.TreeDriver;
       
    61 import org.netbeans.jemmy.util.EmptyVisualizer;
       
    62 
       
    63 /**
       
    64  * <BR><BR>Timeouts used: <BR>
       
    65  * JTreeOperator.WaitNodeExpandedTimeout - time to wait node expanded <BR>
       
    66  * JTreeOperator.WaitNodeCollapsedTimeout - time to wait node collapsed <BR>
       
    67  * JTreeOperator.WaitAfterNodeExpandedTimeout - time to to sleep after node
       
    68  * expanded <BR>
       
    69  * JTreeOperator.WaitNextNodeTimeout - time to wait next node displayed <BR>
       
    70  * JTreeOperator.WaitNodeVisibleTimeout - time to wait node visible <BR>
       
    71  * JTreeOperator.BeforeEditTimeout - time to sleep before edit click <BR>
       
    72  * JTreeOperator.WaitEditingTimeout - time to wait node editing <BR>
       
    73  * ComponentOperator.WaitComponentTimeout - time to wait component displayed
       
    74  * <BR>
       
    75  * ComponentOperator.WaitStateTimeout - time to wait for path to be expanded,
       
    76  * collapsed, selected, time to wait for a text in a row <BR>
       
    77  * WindowWaiter.WaitWindowTimeout - time to wait popup window displayed <BR>
       
    78  * JScrollBarOperator.WholeScrollTimeout - time for the whole scrolling <BR>.
       
    79  *
       
    80  * @see org.netbeans.jemmy.Timeouts
       
    81  *
       
    82  * @author Alexandre Iline (alexandre.iline@oracle.com)
       
    83  *
       
    84  */
       
    85 public class JTreeOperator extends JComponentOperator
       
    86         implements Timeoutable, Outputable {
       
    87 
       
    88     /**
       
    89      * Identifier for a "root" property.
       
    90      *
       
    91      * @see #getDump
       
    92      */
       
    93     public static final String ROOT_DPROP = "Root";
       
    94 
       
    95     /**
       
    96      * Identifier for a "node" properties.
       
    97      *
       
    98      * @see #getDump
       
    99      */
       
   100     public static final String NODE_PREFIX_DPROP = "Node";
       
   101 
       
   102     /**
       
   103      * Identifier for a "first selected" property.
       
   104      *
       
   105      * @see #getDump
       
   106      */
       
   107     public static final String SELECTION_FIRST_DPROP = "First selected";
       
   108 
       
   109     /**
       
   110      * Identifier for a "last selected" property.
       
   111      *
       
   112      * @see #getDump
       
   113      */
       
   114     public static final String SELECTION_LAST_DPROP = "Last selected";
       
   115 
       
   116     private final static long WAIT_NODE_EXPANDED_TIMEOUT = 60000;
       
   117     private final static long WAIT_NODE_COLLAPSED_TIMEOUT = 60000;
       
   118     private final static long WAIT_AFTER_NODE_EXPANDED_TIMEOUT = 0;
       
   119     private final static long WAIT_NEXT_NODE_TIMEOUT = 60000;
       
   120     private final static long WAIT_NODE_VISIBLE_TIMEOUT = 60000;
       
   121     private final static long BEFORE_EDIT_TIMEOUT = 1000;
       
   122     private final static long WAIT_EDITING_TIMEOUT = 60000;
       
   123 
       
   124     private TestOut output;
       
   125     private Timeouts timeouts;
       
   126     private TreeDriver driver;
       
   127 
       
   128     /**
       
   129      * Constructor.
       
   130      *
       
   131      * @param b a component
       
   132      */
       
   133     public JTreeOperator(JTree b) {
       
   134         super(b);
       
   135         driver = DriverManager.getTreeDriver(getClass());
       
   136     }
       
   137 
       
   138     /**
       
   139      * Constructs a JTreeOperator object.
       
   140      *
       
   141      * @param cont a container
       
   142      * @param chooser a component chooser specifying searching criteria.
       
   143      * @param index an index between appropriate ones.
       
   144      */
       
   145     public JTreeOperator(ContainerOperator<?> cont, ComponentChooser chooser, int index) {
       
   146         this((JTree) cont.
       
   147                 waitSubComponent(new JTreeFinder(chooser),
       
   148                         index));
       
   149         copyEnvironment(cont);
       
   150     }
       
   151 
       
   152     /**
       
   153      * Constructs a JTreeOperator object.
       
   154      *
       
   155      * @param cont a container
       
   156      * @param chooser a component chooser specifying searching criteria.
       
   157      */
       
   158     public JTreeOperator(ContainerOperator<?> cont, ComponentChooser chooser) {
       
   159         this(cont, chooser, 0);
       
   160     }
       
   161 
       
   162     /**
       
   163      * Constructor. Waits component in container first. Uses cont's timeout and
       
   164      * output for waiting and to init operator.
       
   165      *
       
   166      * @param cont a container
       
   167      * @param text Text of a row which is currently selected.
       
   168      * @param row a row index to check text in. If equals to -1, selected row is
       
   169      * checked.
       
   170      * @param index Ordinal component index.
       
   171      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
   172      * @throws TimeoutExpiredException
       
   173      */
       
   174     public JTreeOperator(ContainerOperator<?> cont, String text, int row, int index) {
       
   175         this((JTree) waitComponent(cont,
       
   176                 new JTreeByItemFinder(text, row,
       
   177                         cont.getComparator()),
       
   178                 index));
       
   179         copyEnvironment(cont);
       
   180     }
       
   181 
       
   182     /**
       
   183      * Constructor. Waits component in container first. Uses cont's timeout and
       
   184      * output for waiting and to init operator.
       
   185      *
       
   186      * @param cont a container
       
   187      * @param text Text of a row which is currently selected.
       
   188      * @param index Ordinal component index.
       
   189      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
   190      * @throws TimeoutExpiredException
       
   191      */
       
   192     public JTreeOperator(ContainerOperator<?> cont, String text, int index) {
       
   193         this(cont, text, -1, index);
       
   194     }
       
   195 
       
   196     /**
       
   197      * Constructor. Waits component in container first. Uses cont's timeout and
       
   198      * output for waiting and to init operator.
       
   199      *
       
   200      * @param cont a container
       
   201      * @param text Text of a row which is currently selected.
       
   202      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
   203      * @throws TimeoutExpiredException
       
   204      */
       
   205     public JTreeOperator(ContainerOperator<?> cont, String text) {
       
   206         this(cont, text, 0);
       
   207     }
       
   208 
       
   209     /**
       
   210      * Constructor. Waits component in container first. Uses cont's timeout and
       
   211      * output for waiting and to init operator.
       
   212      *
       
   213      * @param cont a container
       
   214      * @param index Ordinal component index.
       
   215      * @throws TimeoutExpiredException
       
   216      */
       
   217     public JTreeOperator(ContainerOperator<?> cont, int index) {
       
   218         this((JTree) waitComponent(cont,
       
   219                 new JTreeFinder(),
       
   220                 index));
       
   221         copyEnvironment(cont);
       
   222     }
       
   223 
       
   224     /**
       
   225      * Constructor. Waits component in container first. Uses cont's timeout and
       
   226      * output for waiting and to init operator.
       
   227      *
       
   228      * @param cont a container
       
   229      * @throws TimeoutExpiredException
       
   230      */
       
   231     public JTreeOperator(ContainerOperator<?> cont) {
       
   232         this(cont, 0);
       
   233     }
       
   234 
       
   235     /**
       
   236      * Searches JTree in container.
       
   237      *
       
   238      * @param cont Container to search component in.
       
   239      * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
       
   240      * @param index Ordinal component index.
       
   241      * @return JTree instance or null if component was not found.
       
   242      */
       
   243     public static JTree findJTree(Container cont, ComponentChooser chooser, int index) {
       
   244         return (JTree) findComponent(cont, new JTreeFinder(chooser), index);
       
   245     }
       
   246 
       
   247     /**
       
   248      * Searches 0'th JTree in container.
       
   249      *
       
   250      * @param cont Container to search component in.
       
   251      * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
       
   252      * @return JTree instance or null if component was not found.
       
   253      */
       
   254     public static JTree findJTree(Container cont, ComponentChooser chooser) {
       
   255         return findJTree(cont, chooser, 0);
       
   256     }
       
   257 
       
   258     /**
       
   259      * Searches JTree by item.
       
   260      *
       
   261      * @param cont Container to search component in.
       
   262      * @param text Item text. If null, contents is not checked.
       
   263      * @param ce Compare text exactly.
       
   264      * @param ccs Compare text case sensitively.
       
   265      * @param rowIndex Index of row to compare text. If -1, selected row is
       
   266      * checked.
       
   267      * @param index Ordinal component index.
       
   268      * @return JTree instance or null if component was not found.
       
   269      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
   270      */
       
   271     public static JTree findJTree(Container cont, String text, boolean ce, boolean ccs, int rowIndex, int index) {
       
   272         return findJTree(cont, new JTreeByItemFinder(text, rowIndex, new DefaultStringComparator(ce, ccs)), index);
       
   273     }
       
   274 
       
   275     /**
       
   276      * Searches JTree by item.
       
   277      *
       
   278      * @param cont Container to search component in.
       
   279      * @param text Item text. If null, contents is not checked.
       
   280      * @param ce Compare text exactly.
       
   281      * @param ccs Compare text case sensitively.
       
   282      * @param rowIndex Index of row to compare text. If -1, selected row is
       
   283      * checked.
       
   284      * @return JTree instance or null if component was not found.
       
   285      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
   286      */
       
   287     public static JTree findJTree(Container cont, String text, boolean ce, boolean ccs, int rowIndex) {
       
   288         return findJTree(cont, text, ce, ccs, rowIndex, 0);
       
   289     }
       
   290 
       
   291     /**
       
   292      * Waits JTree in container.
       
   293      *
       
   294      * @param cont Container to search component in.
       
   295      * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
       
   296      * @param index Ordinal component index.
       
   297      * @return JTree instance or null if component was not found.
       
   298      * @throws TimeoutExpiredException
       
   299      */
       
   300     public static JTree waitJTree(Container cont, ComponentChooser chooser, int index) {
       
   301         return (JTree) waitComponent(cont, new JTreeFinder(chooser), index);
       
   302     }
       
   303 
       
   304     /**
       
   305      * Waits 0'th JTree in container.
       
   306      *
       
   307      * @param cont Container to search component in.
       
   308      * @param chooser org.netbeans.jemmy.ComponentChooser implementation.
       
   309      * @return JTree instance or null if component was not found.
       
   310      * @throws TimeoutExpiredException
       
   311      */
       
   312     public static JTree waitJTree(Container cont, ComponentChooser chooser) {
       
   313         return waitJTree(cont, chooser, 0);
       
   314     }
       
   315 
       
   316     /**
       
   317      * Waits JTree by item.
       
   318      *
       
   319      * @param cont Container to search component in.
       
   320      * @param text Item text. If null, contents is not checked.
       
   321      * @param ce Compare text exactly.
       
   322      * @param ccs Compare text case sensitively.
       
   323      * @param rowIndex Index of row to compare text. If -1, selected row is
       
   324      * checked.
       
   325      * @param index Ordinal component index.
       
   326      * @return JTree instance or null if component was not found.
       
   327      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
   328      * @throws TimeoutExpiredException
       
   329      */
       
   330     public static JTree waitJTree(Container cont, String text, boolean ce, boolean ccs, int rowIndex, int index) {
       
   331         return waitJTree(cont, new JTreeByItemFinder(text, rowIndex, new DefaultStringComparator(ce, ccs)), index);
       
   332     }
       
   333 
       
   334     /**
       
   335      * Waits JTree by item.
       
   336      *
       
   337      * @param cont Container to search component in.
       
   338      * @param text Item text. If null, contents is not checked.
       
   339      * @param ce Compare text exactly.
       
   340      * @param ccs Compare text case sensitively.
       
   341      * @param rowIndex Index of row to compare text. If -1, selected row is
       
   342      * checked.
       
   343      * @return JTree instance or null if component was not found.
       
   344      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
   345      * @throws TimeoutExpiredException
       
   346      */
       
   347     public static JTree waitJTree(Container cont, String text, boolean ce, boolean ccs, int rowIndex) {
       
   348         return waitJTree(cont, text, ce, ccs, rowIndex, 0);
       
   349     }
       
   350 
       
   351     static {
       
   352         Timeouts.initDefault("JTreeOperator.WaitNodeExpandedTimeout", WAIT_NODE_EXPANDED_TIMEOUT);
       
   353         Timeouts.initDefault("JTreeOperator.WaitNodeCollapsedTimeout", WAIT_NODE_COLLAPSED_TIMEOUT);
       
   354         Timeouts.initDefault("JTreeOperator.WaitAfterNodeExpandedTimeout", WAIT_AFTER_NODE_EXPANDED_TIMEOUT);
       
   355         Timeouts.initDefault("JTreeOperator.WaitNextNodeTimeout", WAIT_NEXT_NODE_TIMEOUT);
       
   356         Timeouts.initDefault("JTreeOperator.WaitNodeVisibleTimeout", WAIT_NODE_VISIBLE_TIMEOUT);
       
   357         Timeouts.initDefault("JTreeOperator.BeforeEditTimeout", BEFORE_EDIT_TIMEOUT);
       
   358         Timeouts.initDefault("JTreeOperator.WaitEditingTimeout", WAIT_EDITING_TIMEOUT);
       
   359     }
       
   360 
       
   361     @Override
       
   362     public void setTimeouts(Timeouts times) {
       
   363         this.timeouts = times;
       
   364         super.setTimeouts(timeouts);
       
   365     }
       
   366 
       
   367     @Override
       
   368     public Timeouts getTimeouts() {
       
   369         return timeouts;
       
   370     }
       
   371 
       
   372     @Override
       
   373     public void setOutput(TestOut out) {
       
   374         output = out;
       
   375         super.setOutput(output.createErrorOutput());
       
   376     }
       
   377 
       
   378     @Override
       
   379     public TestOut getOutput() {
       
   380         return output;
       
   381     }
       
   382 
       
   383     @Override
       
   384     public void copyEnvironment(Operator anotherOperator) {
       
   385         super.copyEnvironment(anotherOperator);
       
   386         driver
       
   387                 = (TreeDriver) DriverManager.
       
   388                 getDriver(DriverManager.TREE_DRIVER_ID,
       
   389                         getClass(),
       
   390                         anotherOperator.getProperties());
       
   391     }
       
   392 
       
   393     /**
       
   394      * Expands path.
       
   395      *
       
   396      * @param path a path to be expanded.
       
   397      * @throws TimeoutExpiredException
       
   398      */
       
   399     public void doExpandPath(TreePath path) {
       
   400         if (path != null) {
       
   401             output.printLine("Expanding \"" + path.getPathComponent(path.getPathCount() - 1).toString()
       
   402                     + "\" node");
       
   403             output.printGolden("Expanding \"" + path.getPathComponent(path.getPathCount() - 1).toString()
       
   404                     + "\" node");
       
   405             driver.expandItem(this, getRowForPath(path));
       
   406             waitExpanded(path);
       
   407         } else {
       
   408             throw (new NoSuchPathException());
       
   409         }
       
   410     }
       
   411 
       
   412     /**
       
   413      * Expands path on row.
       
   414      *
       
   415      * @param row a row index to be expanded.
       
   416      * @throws TimeoutExpiredException
       
   417      */
       
   418     public void doExpandRow(int row) {
       
   419         output.printLine("Expanding " + Integer.toString(row)
       
   420                 + " row");
       
   421         output.printGolden("Expanding " + Integer.toString(row)
       
   422                 + " row");
       
   423         driver.expandItem(this, row);
       
   424         waitExpanded(row);
       
   425     }
       
   426 
       
   427     /**
       
   428      * Ensures that the node identified by path is currently viewable.
       
   429      *
       
   430      * @param path a path to be made visible.
       
   431      * @throws TimeoutExpiredException
       
   432      */
       
   433     public void doMakeVisible(TreePath path) {
       
   434         if (path != null) {
       
   435             output.printLine("Making \"" + path.toString() + "\" path visible");
       
   436             output.printGolden("Making path visible");
       
   437             makeVisible(path);
       
   438             waitVisible(path);
       
   439         } else {
       
   440             throw (new NoSuchPathException());
       
   441         }
       
   442     }
       
   443 
       
   444     /**
       
   445      * Returns number of child.
       
   446      *
       
   447      * @param node a node to count children of.
       
   448      * @return a number of children.
       
   449      */
       
   450     public int getChildCount(final Object node) {
       
   451         return runMapping(new MapIntegerAction("getChildCount") {
       
   452             @Override
       
   453             public int map() {
       
   454                 return ((JTree) getSource()).getModel().getChildCount(node);
       
   455             }
       
   456         });
       
   457     }
       
   458 
       
   459     /**
       
   460      * Returns node children.
       
   461      *
       
   462      * @param node a node to get children of.
       
   463      * @return an array of node children.
       
   464      */
       
   465     public Object[] getChildren(final Object node) {
       
   466         return (Object[]) runMapping(new MapAction<Object>("getChildren") {
       
   467             @Override
       
   468             public Object map() {
       
   469                 TreeModel md = ((JTree) getSource()).getModel();
       
   470                 Object[] result = new Object[md.getChildCount(node)];
       
   471                 for (int i = 0; i < md.getChildCount(node); i++) {
       
   472                     result[i] = md.getChild(node, i);
       
   473                 }
       
   474                 return result;
       
   475             }
       
   476         });
       
   477     }
       
   478 
       
   479     /**
       
   480      * Returns node child.
       
   481      *
       
   482      * @param node a node to get a child of.
       
   483      * @param index a child index.
       
   484      * @return a node child.
       
   485      */
       
   486     public Object getChild(final Object node, final int index) {
       
   487         return runMapping(new MapAction<Object>("getChild") {
       
   488             @Override
       
   489             public Object map() {
       
   490                 return ((JTree) getSource()).getModel().getChild(node, index);
       
   491             }
       
   492         });
       
   493     }
       
   494 
       
   495     /**
       
   496      * Returns number of child.
       
   497      *
       
   498      * @param path a path indicating a node to count children of.
       
   499      * @return a number of children.
       
   500      */
       
   501     public int getChildCount(TreePath path) {
       
   502         if (path != null) {
       
   503             return (getChildCount(path.
       
   504                     getLastPathComponent()));
       
   505         } else {
       
   506             throw (new NoSuchPathException());
       
   507         }
       
   508     }
       
   509 
       
   510     /**
       
   511      * Constructs new path from a path and index's subnode of it last node.
       
   512      *
       
   513      * @param path a path indicating a node to get a child of.
       
   514      * @param index a child node index.
       
   515      * @return a number of children.
       
   516      */
       
   517     public TreePath getChildPath(TreePath path, int index) {
       
   518         if (path != null) {
       
   519             return (path.
       
   520                     pathByAddingChild(getChild(path.
       
   521                             getLastPathComponent(), index)));
       
   522         } else {
       
   523             throw (new NoSuchPathException());
       
   524         }
       
   525     }
       
   526 
       
   527     /**
       
   528      * Constructs new paths from a path and all subnodes of it last node.
       
   529      *
       
   530      * @param path a path indicating a node to get children of.
       
   531      * @return a number of children.
       
   532      */
       
   533     public TreePath[] getChildPaths(TreePath path) {
       
   534         if (path != null) {
       
   535             Object[] children = getChildren(path.
       
   536                     getLastPathComponent());
       
   537             TreePath[] result = new TreePath[children.length];
       
   538             for (int i = 0; i < children.length; i++) {
       
   539                 result[i] = path.
       
   540                         pathByAddingChild(children[i]);
       
   541             }
       
   542             return result;
       
   543         } else {
       
   544             throw (new NoSuchPathException());
       
   545         }
       
   546     }
       
   547 
       
   548     /**
       
   549      * Returns the root of the tree.
       
   550      *
       
   551      * @return tree root.
       
   552      * @throws TimeoutExpiredException
       
   553      */
       
   554     public Object getRoot() {
       
   555         Waiter<Object, Void> rootWaiter = new Waiter<>(new Waitable<Object, Void>() {
       
   556             @Override
       
   557             public Object actionProduced(Void obj) {
       
   558                 Object root = getModel().getRoot();
       
   559                 if (root == null || root.toString().equals("null")) {
       
   560                     return null;
       
   561                 } else {
       
   562                     return root;
       
   563                 }
       
   564             }
       
   565 
       
   566             @Override
       
   567             public String getDescription() {
       
   568                 return "Wait root node";
       
   569             }
       
   570 
       
   571             @Override
       
   572             public String toString() {
       
   573                 return "JTreeOperator.getRoot.Waitable{description = " + getDescription() + '}';
       
   574             }
       
   575         });
       
   576         rootWaiter.setTimeoutsToCloneOf(timeouts, "JTreeOperator.WaitNodeVisibleTimeout");
       
   577         rootWaiter.setOutput(output.createErrorOutput());
       
   578         try {
       
   579             return rootWaiter.waitAction(null);
       
   580         } catch (InterruptedException e) {
       
   581             output.printStackTrace(e);
       
   582             return null;
       
   583         }
       
   584     }
       
   585 
       
   586     /**
       
   587      * Searches path in tree.
       
   588      *
       
   589      * @param chooser TreePathChooser implementation.
       
   590      * @return a path fitting the criteria.
       
   591      * @see TreePathChooser
       
   592      * @see #findPath
       
   593      * @throws TimeoutExpiredException
       
   594      */
       
   595     public TreePath findPath(TreePathChooser chooser) {
       
   596         output.printLine("Search for a tree path " + chooser.getDescription());
       
   597         output.printGolden("Search for a tree path");
       
   598         TreePath rootPath = new TreePath(getRoot());
       
   599         if (chooser.checkPath(rootPath, 0)) {
       
   600             return rootPath;
       
   601         }
       
   602         Waiter<Object[], Object[]> loadedWaiter = new Waiter<>(new Waitable<Object[], Object[]>() {
       
   603             // fields used in getDescription() method
       
   604             TreePath currentPath;
       
   605             String requestedPath;
       
   606 
       
   607             @Override
       
   608             public Object[] actionProduced(Object[] obj) {
       
   609                 TreePathChooser chsr = (TreePathChooser) obj[0];
       
   610                 requestedPath = chsr.getDescription();
       
   611                 TreePath path = (TreePath) obj[1];
       
   612                 currentPath = path;
       
   613                 Object[] result = new Object[2];
       
   614                 Object[] children = getChildren(path.getLastPathComponent());
       
   615                 for (int j = 0; j < children.length; j++) {
       
   616                     result[0] = path.pathByAddingChild(children[j]);
       
   617                     if (chsr.checkPath((TreePath) result[0], j)) {
       
   618                         result[1] = Boolean.TRUE;
       
   619                         return result;
       
   620                     }
       
   621                     if (chsr.hasAsParent((TreePath) result[0], j)) {
       
   622                         result[1] = Boolean.FALSE;
       
   623                         return result;
       
   624                     }
       
   625                 }
       
   626                 return null;
       
   627             }
       
   628 
       
   629             @Override
       
   630             public String getDescription() {
       
   631                 return "Wait next node loaded under parent " + currentPath + " when requested was " + requestedPath;
       
   632             }
       
   633 
       
   634             @Override
       
   635             public String toString() {
       
   636                 return "JTreeOperator.findPath.Waitable{description = " + getDescription() + '}';
       
   637             }
       
   638         });
       
   639         loadedWaiter.setTimeoutsToCloneOf(timeouts, "JTreeOperator.WaitNextNodeTimeout");
       
   640         loadedWaiter.setOutput(output.createErrorOutput());
       
   641         return findPathPrimitive(rootPath, chooser, loadedWaiter);
       
   642     }
       
   643 
       
   644     /**
       
   645      * Searches index'th row by row chooser.
       
   646      *
       
   647      * @param chooser a path searching criteria.
       
   648      * @param index a child index.
       
   649      * @return Row index or -1 if search was insuccessful.
       
   650      * @see JTreeOperator.TreeRowChooser
       
   651      */
       
   652     public int findRow(TreeRowChooser chooser, int index) {
       
   653         int count = 0;
       
   654         for (int i = 0; i < getRowCount(); i++) {
       
   655             if (chooser.checkRow(this, i)) {
       
   656                 if (count == index) {
       
   657                     return i;
       
   658                 } else {
       
   659                     count++;
       
   660                 }
       
   661             }
       
   662         }
       
   663         return -1;
       
   664     }
       
   665 
       
   666     /**
       
   667      * Searches a row by row chooser.
       
   668      *
       
   669      * @param chooser a path searching criteria.
       
   670      * @return Row index or -1 if search was insuccessful.
       
   671      * @see JTreeOperator.TreeRowChooser
       
   672      */
       
   673     public int findRow(TreeRowChooser chooser) {
       
   674         return findRow(chooser, 0);
       
   675     }
       
   676 
       
   677     /**
       
   678      * Searches index'th row by substring.
       
   679      *
       
   680      * @param item Substring.
       
   681      * @param comparator a string comparision algorithm
       
   682      * @param index an ordinal row index between ones matching the criteria
       
   683      * @return Row index or -1 if search was insuccessful.
       
   684      */
       
   685     public int findRow(String item, StringComparator comparator, int index) {
       
   686         return findRow(new BySubStringTreeRowChooser(item, comparator), index);
       
   687     }
       
   688 
       
   689     /**
       
   690      * Searches index'th row by substring.
       
   691      *
       
   692      * @param item Substring.
       
   693      * @param ce Compare exactly
       
   694      * @param cc Compare case sensitivelly.
       
   695      * @param index an ordinal row index between ones matching the criteria
       
   696      * @return Row index or -1 if search was insuccessful.
       
   697      * @deprecated Use findRow(String, int) or findRow(String, StringComparator,
       
   698      * int)
       
   699      */
       
   700     @Deprecated
       
   701     public int findRow(String item, boolean ce, boolean cc, int index) {
       
   702         return (findRow(item,
       
   703                 new DefaultStringComparator(ce, cc),
       
   704                 index));
       
   705     }
       
   706 
       
   707     /**
       
   708      * Searches index'th row by substring. Uses StringComparator assigned to
       
   709      * this object.
       
   710      *
       
   711      * @param item Substring.
       
   712      * @param index an ordinal row index between ones matching the criteria
       
   713      * @return Row index or -1 if search was insuccessful.
       
   714      */
       
   715     public int findRow(String item, int index) {
       
   716         return (findRow(item,
       
   717                 getComparator(),
       
   718                 index));
       
   719     }
       
   720 
       
   721     /**
       
   722      * Searches a row by substring.
       
   723      *
       
   724      * @param item Substring.
       
   725      * @param comparator a string comparision algorithm
       
   726      * @return Row index or -1 if search was insuccessful.
       
   727      */
       
   728     public int findRow(String item, StringComparator comparator) {
       
   729         return findRow(item, comparator, 0);
       
   730     }
       
   731 
       
   732     /**
       
   733      * Searches a row by substring.
       
   734      *
       
   735      * @param item Substring.
       
   736      * @param ce Compare exactly
       
   737      * @param cc Compare case sensitivelly.
       
   738      * @return Row index or -1 if search was insuccessful.
       
   739      * @deprecated Use findRow(String) or findRow(String, StringComparator)
       
   740      */
       
   741     @Deprecated
       
   742     public int findRow(String item, boolean ce, boolean cc) {
       
   743         return findRow(item, ce, cc, 0);
       
   744     }
       
   745 
       
   746     /**
       
   747      * Searches a row by substring. Uses StringComparator assigned to this
       
   748      * object.
       
   749      *
       
   750      * @param item Substring.
       
   751      * @return Row index or -1 if search was insuccessful.
       
   752      */
       
   753     public int findRow(String item) {
       
   754         return (findRow(item,
       
   755                 getComparator(),
       
   756                 0));
       
   757     }
       
   758 
       
   759     /**
       
   760      * Searches index'th row by rendered component.
       
   761      *
       
   762      * @param chooser Component checking object.
       
   763      * @param index an ordinal row index between ones matching the criteria
       
   764      * @return Row index or -1 if search was insuccessful.
       
   765      */
       
   766     public int findRow(ComponentChooser chooser, int index) {
       
   767         return findRow(new ByRenderedComponentTreeRowChooser(chooser), index);
       
   768     }
       
   769 
       
   770     /**
       
   771      * Searches a row by rendered component.
       
   772      *
       
   773      * @param chooser Component checking object.
       
   774      * @return Row index or -1 if search was insuccessful.
       
   775      */
       
   776     public int findRow(ComponentChooser chooser) {
       
   777         return findRow(chooser, 0);
       
   778     }
       
   779 
       
   780     /**
       
   781      * Searches path in tree. Can be used to find one of the nodes with the same
       
   782      * text. Example:<BR>
       
   783      * <pre>
       
   784      * root
       
   785      * +-+node
       
   786      * | +--subnode
       
   787      * +-+node
       
   788      * | +--subnode
       
   789      * | +--subnode
       
   790      * ...
       
   791      * String[] names = {"node", "subnode"};<BR>
       
   792      * int[] indexes = {1, 0};<BR>
       
   793      * </pre> TreePath path = findPath(names, indexes, true, true);<BR>
       
   794      * "path" will points to the second (from the top) "subnode" node.
       
   795      *
       
   796      * @param names Node texts array.
       
   797      * @param indexes Nodes indexes.
       
   798      * @param comparator a string comparision algorithm
       
   799      * @return a tree path matching the criteria
       
   800      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
   801      * @see #findPath
       
   802      * @throws TimeoutExpiredException
       
   803      */
       
   804     public TreePath findPath(String[] names, int[] indexes, StringComparator comparator) {
       
   805         return findPath(new StringArrayPathChooser(names, indexes, comparator));
       
   806     }
       
   807 
       
   808     /**
       
   809      * Searches path in tree. Can be used to find one of the nodes with the same
       
   810      * text. Example:<BR>
       
   811      * <pre>
       
   812      * root
       
   813      * +-+node
       
   814      * | +--subnode
       
   815      * +-+node
       
   816      * | +--subnode
       
   817      * | +--subnode
       
   818      * ...
       
   819      * String[] names = {"node", "subnode"};<BR>
       
   820      * int[] indexes = {1, 0};<BR>
       
   821      * </pre> TreePath path = findPath(names, indexes, true, true);<BR>
       
   822      * "path" will points to the second (from the top) "subnode" node.
       
   823      *
       
   824      * @param names Node texts array.
       
   825      * @param indexes Nodes indexes.
       
   826      * @param ce Compare exactly.
       
   827      * @param ccs Compare case sensitively.
       
   828      * @return a tree path matching the criteria
       
   829      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
   830      * @see #findPath
       
   831      * @throws TimeoutExpiredException
       
   832      * @deprecated Use findPath(String[], int[]) or findCellRow(String[], int[],
       
   833      * StringComparator)
       
   834      */
       
   835     @Deprecated
       
   836     public TreePath findPath(String[] names, int[] indexes, boolean ce, boolean ccs) {
       
   837         return findPath(names, indexes, new DefaultStringComparator(ce, ccs));
       
   838     }
       
   839 
       
   840     /**
       
   841      * Searches path in tree. Uses StringComparator assigned to this object.
       
   842      *
       
   843      * @param names Node texts array.
       
   844      * @param indexes Nodes indexes.
       
   845      * @return a tree path matching the criteria
       
   846      * @see #findPath
       
   847      * @throws TimeoutExpiredException
       
   848      */
       
   849     public TreePath findPath(String[] names, int[] indexes) {
       
   850         return findPath(names, indexes, getComparator());
       
   851     }
       
   852 
       
   853     /**
       
   854      * Searches path in tree.
       
   855      *
       
   856      * @param names Node texts array.
       
   857      * @param comparator a string comparision algorithm
       
   858      * @return a tree path matching the criteria
       
   859      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
   860      * @see #findPath
       
   861      * @throws TimeoutExpiredException
       
   862      */
       
   863     public TreePath findPath(String[] names, StringComparator comparator) {
       
   864         int[] indexes = new int[0];
       
   865         return findPath(names, indexes, comparator);
       
   866     }
       
   867 
       
   868     /**
       
   869      * Searches path in tree.
       
   870      *
       
   871      * @param names Node texts array.
       
   872      * @param ce Compare exactly.
       
   873      * @param ccs Compare case sensitively.
       
   874      * @return a tree path matching the criteria
       
   875      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
   876      * @see #findPath
       
   877      * @throws TimeoutExpiredException
       
   878      * @deprecated Use findPath(String[]) or findCellRow(String[],
       
   879      * StringComparator)
       
   880      */
       
   881     @Deprecated
       
   882     public TreePath findPath(String[] names, boolean ce, boolean ccs) {
       
   883         int[] indexes = new int[0];
       
   884         return findPath(names, indexes, ce, ccs);
       
   885     }
       
   886 
       
   887     /**
       
   888      * Searches path in tree. Uses StringComparator assigned to this object.
       
   889      *
       
   890      * @param names Node texts array.
       
   891      * @return a tree path matching the criteria
       
   892      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
   893      * @see #findPath
       
   894      * @throws TimeoutExpiredException
       
   895      */
       
   896     public TreePath findPath(String[] names) {
       
   897         int[] indexes = new int[0];
       
   898         return findPath(names, indexes, getComparator());
       
   899     }
       
   900 
       
   901     /**
       
   902      * Searches path in tree.
       
   903      *
       
   904      * @param path String representing tree path. Path components should be
       
   905      * devided by "delim" parameter.
       
   906      * @param indexes String representing indexes to search path components.
       
   907      * Indexes should be devided by "delim" parameter.
       
   908      * @param delim Path components delimiter.
       
   909      * @param comparator a string comparision algorithm
       
   910      * @return a tree path matching the criteria
       
   911      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
   912      * @see #findPath
       
   913      * @throws TimeoutExpiredException
       
   914      */
       
   915     public TreePath findPath(String path, String indexes, String delim, StringComparator comparator) {
       
   916         String[] indexStrings = parseString(indexes, delim);
       
   917         int[] indInts = new int[indexStrings.length];
       
   918         for (int i = 0; i < indexStrings.length; i++) {
       
   919             indInts[i] = Integer.parseInt(indexStrings[i]);
       
   920         }
       
   921         return findPath(parseString(path, delim), indInts, comparator);
       
   922     }
       
   923 
       
   924     /**
       
   925      * Searches path in tree.
       
   926      *
       
   927      * @param path String representing tree path. Path components should be
       
   928      * devided by "delim" parameter.
       
   929      * @param indexes String representing indexes to search path components.
       
   930      * Indexes should be devided by "delim" parameter.
       
   931      * @param delim Path components delimiter.
       
   932      * @param ce Compare exactly.
       
   933      * @param ccs Compare case sensitively.
       
   934      * @return a tree path matching the criteria
       
   935      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
   936      * @see #findPath
       
   937      * @throws TimeoutExpiredException
       
   938      * @deprecated Use findPath(String, String, String) or findCellRow(String,
       
   939      * String, String, StringComparator)
       
   940      */
       
   941     @Deprecated
       
   942     public TreePath findPath(String path, String indexes, String delim, boolean ce, boolean ccs) {
       
   943         return findPath(path, indexes, delim, new DefaultStringComparator(ce, ccs));
       
   944     }
       
   945 
       
   946     /**
       
   947      * Searches path in tree. Uses StringComparator assigned to this object.
       
   948      *
       
   949      * @param path String representing tree path. Path components should be
       
   950      * devided by "delim" parameter.
       
   951      * @param indexes String representing indexes to search path components.
       
   952      * Indexes should be devided by "delim" parameter.
       
   953      * @param delim Path components delimiter.
       
   954      * @return a tree path matching the criteria
       
   955      * @see #findPath
       
   956      * @throws TimeoutExpiredException
       
   957      */
       
   958     public TreePath findPath(String path, String indexes, String delim) {
       
   959         return findPath(path, indexes, delim, getComparator());
       
   960     }
       
   961 
       
   962     /**
       
   963      * Searches path in tree.
       
   964      *
       
   965      * @param path String representing tree path. Path components should be
       
   966      * devided by "delim" parameter.
       
   967      * @param delim Path components delimiter.
       
   968      * @param comparator a string comparision algorithm
       
   969      * @return a tree path matching the criteria
       
   970      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
   971      * @see #findPath
       
   972      * @throws TimeoutExpiredException
       
   973      */
       
   974     public TreePath findPath(String path, String delim, StringComparator comparator) {
       
   975         return findPath(parseString(path, delim), comparator);
       
   976     }
       
   977 
       
   978     /**
       
   979      * Searches path in tree.
       
   980      *
       
   981      * @param path String representing tree path.
       
   982      * @param comparator a string comparision algorithm
       
   983      * @return a tree path matching the criteria
       
   984      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
   985      * @see #findPath
       
   986      * @throws TimeoutExpiredException
       
   987      */
       
   988     public TreePath findPath(String path, StringComparator comparator) {
       
   989         return findPath(parseString(path), comparator);
       
   990     }
       
   991 
       
   992     /**
       
   993      * Searches path in tree.
       
   994      *
       
   995      * @param path String representing tree path. Path components should be
       
   996      * devided by "delim" parameter.
       
   997      * @param delim Path components delimiter.
       
   998      * @param ce Compare exactly.
       
   999      * @param ccs Compare case sensitively.
       
  1000      * @return a tree path matching the criteria
       
  1001      * @see ComponentOperator#isCaptionEqual(String, String, boolean, boolean)
       
  1002      * @see #findPath
       
  1003      * @throws TimeoutExpiredException
       
  1004      * @deprecated Use findPath(String, String) or findCellRow(String, String,
       
  1005      * StringComparator)
       
  1006      */
       
  1007     @Deprecated
       
  1008     public TreePath findPath(String path, String delim, boolean ce, boolean ccs) {
       
  1009         return findPath(parseString(path, delim), ce, ccs);
       
  1010     }
       
  1011 
       
  1012     /**
       
  1013      * Searches path in tree. Uses StringComparator assigned to this object.
       
  1014      *
       
  1015      * @param path String representing tree path. Path components should be
       
  1016      * devided by "delim" parameter.
       
  1017      * @param delim Path components delimiter.
       
  1018      * @return a tree path matching the criteria
       
  1019      * @see #findPath
       
  1020      * @throws TimeoutExpiredException
       
  1021      */
       
  1022     public TreePath findPath(String path, String delim) {
       
  1023         return findPath(parseString(path, delim));
       
  1024     }
       
  1025 
       
  1026     /**
       
  1027      * Searches path in tree. Uses StringComparator assigned to this object.
       
  1028      * Uses PathParser assigned to this object.
       
  1029      *
       
  1030      * @param path String representing tree path.
       
  1031      * @return a tree path matching the criteria
       
  1032      * @see #findPath
       
  1033      * @throws TimeoutExpiredException
       
  1034      */
       
  1035     public TreePath findPath(String path) {
       
  1036         return findPath(parseString(path));
       
  1037     }
       
  1038 
       
  1039     /**
       
  1040      * Ensures that the node identified by the specified path is collapsed and
       
  1041      * viewable.
       
  1042      *
       
  1043      * @param path a path to collapse.
       
  1044      * @throws TimeoutExpiredException
       
  1045      */
       
  1046     public void doCollapsePath(TreePath path) {
       
  1047         if (path != null) {
       
  1048             output.printLine("Collapsing \"" + path.toString() + "\" path");
       
  1049             output.printGolden("Collapsing path");
       
  1050             driver.collapseItem(this, getRowForPath(path));
       
  1051             if (getVerification()) {
       
  1052                 waitCollapsed(path);
       
  1053             }
       
  1054         } else {
       
  1055             throw (new NoSuchPathException());
       
  1056         }
       
  1057     }
       
  1058 
       
  1059     /**
       
  1060      * Ensures that the node in the specified row is collapsed.
       
  1061      *
       
  1062      * @param row a row index to collapse.
       
  1063      * @throws TimeoutExpiredException
       
  1064      */
       
  1065     public void doCollapseRow(int row) {
       
  1066         output.printLine("Collapsing \"" + Integer.toString(row) + "\" row");
       
  1067         output.printGolden("Collapsing path");
       
  1068         driver.collapseItem(this, row);
       
  1069         if (getVerification()) {
       
  1070             waitCollapsed(row);
       
  1071         }
       
  1072     }
       
  1073 
       
  1074     /**
       
  1075      * Selects the path.
       
  1076      *
       
  1077      * @param path a path to select.
       
  1078      */
       
  1079     public void selectPath(final TreePath path) {
       
  1080         if (path != null) {
       
  1081             output.printLine("Selecting \"" + path.toString() + "\" path");
       
  1082             output.printGolden("Selecting path");
       
  1083             scrollToPath(path);
       
  1084             getQueueTool().invokeSmoothly(new QueueTool.QueueAction<Void>("Path selecting") {
       
  1085                 @Override
       
  1086                 public Void launch() {
       
  1087                     driver.selectItem(JTreeOperator.this, getRowForPath(path));
       
  1088                     return null;
       
  1089                 }
       
  1090             });
       
  1091             if (getVerification()) {
       
  1092                 waitSelected(path);
       
  1093             }
       
  1094         } else {
       
  1095             throw (new NoSuchPathException());
       
  1096         }
       
  1097     }
       
  1098 
       
  1099     /**
       
  1100      * Selects the node in the specified row.
       
  1101      *
       
  1102      * @param row an index of row to select.
       
  1103      */
       
  1104     public void selectRow(int row) {
       
  1105         output.printLine("Collapsing \"" + Integer.toString(row) + "\" row");
       
  1106         output.printGolden("Collapsing path");
       
  1107         driver.selectItem(this, row);
       
  1108         if (getVerification()) {
       
  1109             waitSelected(row);
       
  1110         }
       
  1111     }
       
  1112 
       
  1113     /**
       
  1114      * Selects some pathes. If verification mode is on, checks that right paths
       
  1115      * have been selected.
       
  1116      *
       
  1117      * @param paths a paths to select.
       
  1118      */
       
  1119     public void selectPaths(TreePath[] paths) {
       
  1120         output.printLine("Selecting paths:");
       
  1121         int[] rows = new int[paths.length];
       
  1122         for (int i = 0; i < paths.length; i++) {
       
  1123             output.printLine("    " + paths[i].toString());
       
  1124             rows[i] = getRowForPath(paths[i]);
       
  1125         }
       
  1126         output.printGolden("Selecting paths");
       
  1127         driver.selectItems(this, rows);
       
  1128         if (getVerification()) {
       
  1129             waitSelected(paths);
       
  1130         }
       
  1131     }
       
  1132 
       
  1133     /**
       
  1134      * Retuns points which can be used to click on path.
       
  1135      *
       
  1136      * @param path a tree path to click on.
       
  1137      * @return a Point in component's coordinate system.
       
  1138      */
       
  1139     public Point getPointToClick(TreePath path) {
       
  1140         if (path != null) {
       
  1141             Rectangle rect = getPathBounds(path);
       
  1142             if (rect != null) {
       
  1143                 return (new Point((int) (rect.getX() + rect.getWidth() / 2),
       
  1144                         (int) (rect.getY() + rect.getHeight() / 2)));
       
  1145             } else {
       
  1146                 throw (new NoSuchPathException(path));
       
  1147             }
       
  1148         } else {
       
  1149             throw (new NoSuchPathException());
       
  1150         }
       
  1151     }
       
  1152 
       
  1153     /**
       
  1154      * Retuns points which can be used to click on path.
       
  1155      *
       
  1156      * @param row a row index to click on.
       
  1157      * @return a Point in component's coordinate system.
       
  1158      */
       
  1159     public Point getPointToClick(int row) {
       
  1160         Rectangle rect = getRowBounds(row);
       
  1161         if (rect != null) {
       
  1162             return (new Point((int) (rect.getX() + rect.getWidth() / 2),
       
  1163                     (int) (rect.getY() + rect.getHeight() / 2)));
       
  1164         } else {
       
  1165             throw (new NoSuchPathException(row));
       
  1166         }
       
  1167     }
       
  1168 
       
  1169     /**
       
  1170      * Clicks on the node.
       
  1171      *
       
  1172      * @param path a path to click on.
       
  1173      * @param clickCount a number of clicks
       
  1174      * @param mouseButton InputEvent.BUTTON1/2/3_MASK value
       
  1175      * @param modifiers Combination of InputEvent.*_MASK values
       
  1176      * @throws TimeoutExpiredException
       
  1177      */
       
  1178     public void clickOnPath(TreePath path, int clickCount, int mouseButton, int modifiers) {
       
  1179         if (path != null) {
       
  1180             output.printLine("Click on \"" + path.toString()
       
  1181                     + "\" path");
       
  1182             output.printGolden("Click on path");
       
  1183             makeComponentVisible();
       
  1184             if (path.getParentPath() != null) {
       
  1185                 expandPath(path.getParentPath());
       
  1186             }
       
  1187             makeVisible(path);
       
  1188             scrollToPath(path);
       
  1189             Point point = getPointToClick(path);
       
  1190             clickMouse((int) point.getX(), (int) point.getY(), clickCount, mouseButton, modifiers);
       
  1191         } else {
       
  1192             throw (new NoSuchPathException());
       
  1193         }
       
  1194     }
       
  1195 
       
  1196     /**
       
  1197      * Clicks on the node.
       
  1198      *
       
  1199      * @param path a path to click on.
       
  1200      * @param clickCount a number of clicks
       
  1201      * @param mouseButton InputEvent.BUTTON1/2/3_MASK value
       
  1202      * @throws TimeoutExpiredException
       
  1203      */
       
  1204     public void clickOnPath(TreePath path, int clickCount, int mouseButton) {
       
  1205         clickOnPath(path, clickCount, mouseButton, 0);
       
  1206     }
       
  1207 
       
  1208     /**
       
  1209      * Clicks on the node.
       
  1210      *
       
  1211      * @param path a path to click on.
       
  1212      * @param clickCount a number of clicks
       
  1213      * @throws TimeoutExpiredException
       
  1214      */
       
  1215     public void clickOnPath(TreePath path, int clickCount) {
       
  1216         clickOnPath(path, clickCount, getDefaultMouseButton());
       
  1217     }
       
  1218 
       
  1219     /**
       
  1220      * Clicks on the node.
       
  1221      *
       
  1222      * @param path a path to click on.
       
  1223      * @throws TimeoutExpiredException
       
  1224      */
       
  1225     public void clickOnPath(TreePath path) {
       
  1226         clickOnPath(path, 1);
       
  1227     }
       
  1228 
       
  1229     /**
       
  1230      * Calls popup on the specified pathes.
       
  1231      *
       
  1232      * @param paths an array of paths to select before invoking popup on one of
       
  1233      * them
       
  1234      * @param mouseButton a mouse button tused to call popup.
       
  1235      * @return an opened popup menu.
       
  1236      * @throws TimeoutExpiredException
       
  1237      */
       
  1238     public JPopupMenu callPopupOnPaths(TreePath[] paths, int mouseButton) {
       
  1239         if (paths.length == 1) {
       
  1240             output.printLine("Call popup on \"" + paths[0].toString()
       
  1241                     + "\" path");
       
  1242             output.printGolden("Call popup on path");
       
  1243         } else {
       
  1244             output.printLine("Call popup on some pathes:");
       
  1245             for (TreePath path : paths) {
       
  1246                 output.printLine("    " + path.toString());
       
  1247             }
       
  1248             output.printGolden("Call popup on paths");
       
  1249         }
       
  1250         makeComponentVisible();
       
  1251         for (TreePath path : paths) {
       
  1252             if (path.getParentPath() != null) {
       
  1253                 expandPath(path.getParentPath());
       
  1254             }
       
  1255         }
       
  1256         selectPaths(paths);
       
  1257         scrollToPath(paths[paths.length - 1]);
       
  1258         Point point = getPointToClick(paths[paths.length - 1]);
       
  1259         return (JPopupMenuOperator.callPopup(this,
       
  1260                 (int) point.getX(),
       
  1261                 (int) point.getY(),
       
  1262                 mouseButton));
       
  1263     }
       
  1264 
       
  1265     /**
       
  1266      * Calls popup on the specified pathes.
       
  1267      *
       
  1268      * @param paths an array of paths to select before invoking popup on one of
       
  1269      * them
       
  1270      * @return an opened popup menu.
       
  1271      * @throws TimeoutExpiredException
       
  1272      */
       
  1273     public JPopupMenu callPopupOnPaths(TreePath[] paths) {
       
  1274         return callPopupOnPaths(paths, getPopupMouseButton());
       
  1275     }
       
  1276 
       
  1277     /**
       
  1278      * Calls popup on the specified path.
       
  1279      *
       
  1280      * @param path a path to invoking popup on.
       
  1281      * @param mouseButton a mouse button tused to call popup.
       
  1282      * @return an opened popup menu.
       
  1283      * @throws TimeoutExpiredException
       
  1284      */
       
  1285     public JPopupMenu callPopupOnPath(TreePath path, int mouseButton) {
       
  1286         if (path != null) {
       
  1287             TreePath[] paths = {path};
       
  1288             return callPopupOnPaths(paths, mouseButton);
       
  1289         } else {
       
  1290             throw (new NoSuchPathException());
       
  1291         }
       
  1292     }
       
  1293 
       
  1294     /**
       
  1295      * Calls popup on the specified path.
       
  1296      *
       
  1297      * @param path a path to invoking popup on.
       
  1298      * @return an opened popup menu.
       
  1299      * @throws TimeoutExpiredException
       
  1300      */
       
  1301     public JPopupMenu callPopupOnPath(TreePath path) {
       
  1302         return callPopupOnPath(path, getPopupMouseButton());
       
  1303     }
       
  1304 
       
  1305     /**
       
  1306      * Scrolls to a path if the tree is on a JScrollPane component.
       
  1307      *
       
  1308      * @param path a tree path to scroll to.
       
  1309      */
       
  1310     public void scrollToPath(TreePath path) {
       
  1311         if (path != null) {
       
  1312             output.printTrace("Scroll JTree to path \"" + path.toString() + "\"\n    : "
       
  1313                     + toStringSource());
       
  1314             output.printGolden("Scroll JTree to path \"" + path.toString() + "\"");
       
  1315             makeComponentVisible();
       
  1316             //try to find JScrollPane under.
       
  1317             JScrollPane scroll = (JScrollPane) getContainer(new JScrollPaneOperator.JScrollPaneFinder(ComponentSearcher.
       
  1318                     getTrueChooser("JScrollPane")));
       
  1319             if (scroll == null) {
       
  1320                 return;
       
  1321             }
       
  1322             JScrollPaneOperator scroller = new JScrollPaneOperator(scroll);
       
  1323             scroller.copyEnvironment(this);
       
  1324             scroller.setVisualizer(new EmptyVisualizer());
       
  1325             Rectangle rect = getPathBounds(path);
       
  1326             if (rect != null) {
       
  1327                 scroller.scrollToComponentRectangle(getSource(),
       
  1328                         (int) rect.getX(),
       
  1329                         (int) rect.getY(),
       
  1330                         (int) rect.getWidth(),
       
  1331                         (int) rect.getHeight());
       
  1332             } else {
       
  1333                 throw (new NoSuchPathException(path));
       
  1334             }
       
  1335         } else {
       
  1336             throw (new NoSuchPathException());
       
  1337         }
       
  1338     }
       
  1339 
       
  1340     /**
       
  1341      * Scrolls to a row if the tree is on a JScrollPane component.
       
  1342      *
       
  1343      * @param row a row index to scroll to.
       
  1344      */
       
  1345     public void scrollToRow(int row) {
       
  1346         scrollToPath(getPathForRow(row));
       
  1347     }
       
  1348 
       
  1349     /**
       
  1350      * Turns path to the editing mode.
       
  1351      *
       
  1352      * @param path a tree path to click on.
       
  1353      * @throws TimeoutExpiredException
       
  1354      */
       
  1355     public void clickForEdit(TreePath path) {
       
  1356         driver.startEditing(this, getRowForPath(path),
       
  1357                 timeouts.create("JTreeOperator.WaitEditingTimeout"));
       
  1358     }
       
  1359 
       
  1360     /**
       
  1361      * Ask renderer for component to be displayed.
       
  1362      *
       
  1363      * @param path a path indicating the rendered node.
       
  1364      * @param isSelected True if the specified cell is selected.
       
  1365      * @param isExpanded True if the specified cell is expanded.
       
  1366      * @param cellHasFocus True if the specified cell has the focus.
       
  1367      * @return Component to be displayed.
       
  1368      */
       
  1369     public Component getRenderedComponent(TreePath path, boolean isSelected, boolean isExpanded, boolean cellHasFocus) {
       
  1370         if (path != null) {
       
  1371             return (getCellRenderer().
       
  1372                     getTreeCellRendererComponent((JTree) getSource(),
       
  1373                             path.getLastPathComponent(),
       
  1374                             isSelected,
       
  1375                             isExpanded,
       
  1376                             getModel().isLeaf(path.getLastPathComponent()),
       
  1377                             getRowForPath(path),
       
  1378                             cellHasFocus));
       
  1379         } else {
       
  1380             throw (new NoSuchPathException());
       
  1381         }
       
  1382     }
       
  1383 
       
  1384     /**
       
  1385      * Ask renderer for component to be displayed. Uses isPathSelected(TreePath)
       
  1386      * to determine whether path is selected. Uses isExpanded(TreePath) to
       
  1387      * determine whether path is expanded.
       
  1388      *
       
  1389      * @param path a path indicating the rendered node.
       
  1390      * @return Component to be displayed.
       
  1391      */
       
  1392     public Component getRenderedComponent(TreePath path) {
       
  1393         return (getRenderedComponent(path,
       
  1394                 isPathSelected(path),
       
  1395                 isExpanded(path),
       
  1396                 false));
       
  1397     }
       
  1398 
       
  1399     /**
       
  1400      * Changes text of last path component.
       
  1401      *
       
  1402      * @param path a path indicating the node to change value for.
       
  1403      * @param newNodeText a new node value
       
  1404      * @deprecated Use changePathObject(TreePath, Object) instead.
       
  1405      * @see #changePathObject(TreePath, Object)
       
  1406      * @throws TimeoutExpiredException
       
  1407      */
       
  1408     @Deprecated
       
  1409     public void changePathText(TreePath path, String newNodeText) {
       
  1410         changePathObject(path, newNodeText);
       
  1411     }
       
  1412 
       
  1413     /**
       
  1414      * Changes last path component using getCellEditor() editor.
       
  1415      *
       
  1416      * @param path a path indicating the node to change value for.
       
  1417      * @param newValue a new node value
       
  1418      * @throws TimeoutExpiredException
       
  1419      */
       
  1420     public void changePathObject(TreePath path, Object newValue) {
       
  1421         scrollToPath(path);
       
  1422         driver.editItem(this, getRowForPath(path), newValue,
       
  1423                 timeouts.create("JTreeOperator.WaitEditingTimeout"));
       
  1424     }
       
  1425 
       
  1426     /**
       
  1427      * Waits path to be expanded.
       
  1428      *
       
  1429      * @param path a path to wait expanded.
       
  1430      */
       
  1431     public void waitExpanded(final TreePath path) {
       
  1432         if (path != null) {
       
  1433             getOutput().printLine("Wait \"" + path.toString() + "\" path to be expanded in component \n    : "
       
  1434                     + toStringSource());
       
  1435             getOutput().printGolden("Wait \"" + path.toString() + "\" path to be expanded");
       
  1436             waitState(new ComponentChooser() {
       
  1437                 @Override
       
  1438                 public boolean checkComponent(Component comp) {
       
  1439                     return isExpanded(path);
       
  1440                 }
       
  1441 
       
  1442                 @Override
       
  1443                 public String getDescription() {
       
  1444                     return "Has \"" + path.toString() + "\" path expanded";
       
  1445                 }
       
  1446 
       
  1447                 @Override
       
  1448                 public String toString() {
       
  1449                     return "JTreeOperator.waitExpanded.ComponentChooser{description = " + getDescription() + '}';
       
  1450                 }
       
  1451             });
       
  1452         } else {
       
  1453             throw (new NoSuchPathException());
       
  1454         }
       
  1455     }
       
  1456 
       
  1457     /**
       
  1458      * Waits row to be expanded.
       
  1459      *
       
  1460      * @param row a row index to wait expanded.
       
  1461      */
       
  1462     public void waitExpanded(final int row) {
       
  1463         getOutput().printLine("Wait " + Integer.toString(row) + "'th row to be expanded in component \n    : "
       
  1464                 + toStringSource());
       
  1465         getOutput().printGolden("Wait " + Integer.toString(row) + "'th row to be expanded");
       
  1466         waitState(new ComponentChooser() {
       
  1467             @Override
       
  1468             public boolean checkComponent(Component comp) {
       
  1469                 return isExpanded(row);
       
  1470             }
       
  1471 
       
  1472             @Override
       
  1473             public String getDescription() {
       
  1474                 return "Has " + Integer.toString(row) + "'th row expanded";
       
  1475             }
       
  1476 
       
  1477             @Override
       
  1478             public String toString() {
       
  1479                 return "JTreeOperator.waitExpanded.ComponentChooser{description = " + getDescription() + '}';
       
  1480             }
       
  1481         });
       
  1482     }
       
  1483 
       
  1484     /**
       
  1485      * Waits path to be collapsed.
       
  1486      *
       
  1487      * @param path a path to wait collapsed.
       
  1488      */
       
  1489     public void waitCollapsed(final TreePath path) {
       
  1490         if (path != null) {
       
  1491             getOutput().printLine("Wait \"" + path.toString() + "\" path to be collapsed in component \n    : "
       
  1492                     + toStringSource());
       
  1493             getOutput().printGolden("Wait \"" + path.toString() + "\" path to be collapsed");
       
  1494             waitState(new ComponentChooser() {
       
  1495                 @Override
       
  1496                 public boolean checkComponent(Component comp) {
       
  1497                     return isCollapsed(path);
       
  1498                 }
       
  1499 
       
  1500                 @Override
       
  1501                 public String getDescription() {
       
  1502                     return "Has \"" + path.toString() + "\" path collapsed";
       
  1503                 }
       
  1504 
       
  1505                 @Override
       
  1506                 public String toString() {
       
  1507                     return "JTreeOperator.waitCollapsed.ComponentChooser{description = " + getDescription() + '}';
       
  1508                 }
       
  1509             });
       
  1510         } else {
       
  1511             throw (new NoSuchPathException());
       
  1512         }
       
  1513     }
       
  1514 
       
  1515     /**
       
  1516      * Waits row to be collapsed.
       
  1517      *
       
  1518      * @param row a row index to wait collapsed.
       
  1519      */
       
  1520     public void waitCollapsed(final int row) {
       
  1521         getOutput().printLine("Wait " + Integer.toString(row) + "'th row to be collapsed in component \n    : "
       
  1522                 + toStringSource());
       
  1523         getOutput().printGolden("Wait " + Integer.toString(row) + "'th row to be collapsed");
       
  1524         waitState(new ComponentChooser() {
       
  1525             @Override
       
  1526             public boolean checkComponent(Component comp) {
       
  1527                 return isCollapsed(row);
       
  1528             }
       
  1529 
       
  1530             @Override
       
  1531             public String getDescription() {
       
  1532                 return "Has " + Integer.toString(row) + "'th row collapsed";
       
  1533             }
       
  1534 
       
  1535             @Override
       
  1536             public String toString() {
       
  1537                 return "JTreeOperator.waitCollapsed.ComponentChooser{description = " + getDescription() + '}';
       
  1538             }
       
  1539         });
       
  1540     }
       
  1541 
       
  1542     /**
       
  1543      * Waits path to be visible.
       
  1544      *
       
  1545      * @param path a path to wait visible.
       
  1546      */
       
  1547     public void waitVisible(final TreePath path) {
       
  1548         if (path != null) {
       
  1549             getOutput().printLine("Wait \"" + path.toString() + "\" path to be visible in component \n    : "
       
  1550                     + toStringSource());
       
  1551             getOutput().printGolden("Wait \"" + path.toString() + "\" path to be visible");
       
  1552             waitState(new ComponentChooser() {
       
  1553                 @Override
       
  1554                 public boolean checkComponent(Component comp) {
       
  1555                     return isVisible(path);
       
  1556                 }
       
  1557 
       
  1558                 @Override
       
  1559                 public String getDescription() {
       
  1560                     return "Has \"" + path.toString() + "\" path visible";
       
  1561                 }
       
  1562 
       
  1563                 @Override
       
  1564                 public String toString() {
       
  1565                     return "JTreeOperator.waitVisible.ComponentChooser{description = " + getDescription() + '}';
       
  1566                 }
       
  1567             });
       
  1568         } else {
       
  1569             throw (new NoSuchPathException());
       
  1570         }
       
  1571     }
       
  1572 
       
  1573     /**
       
  1574      * Waits some paths to be selected.
       
  1575      *
       
  1576      * @param paths an array of paths to be selected.
       
  1577      */
       
  1578     public void waitSelected(final TreePath[] paths) {
       
  1579         getOutput().printLine("Wait right selection in component \n    : "
       
  1580                 + toStringSource());
       
  1581         getOutput().printGolden("Wait right selection");
       
  1582         waitState(new ComponentChooser() {
       
  1583             @Override
       
  1584             public boolean checkComponent(Component comp) {
       
  1585                 TreePath[] rpaths = getSelectionModel().getSelectionPaths();
       
  1586                 if (rpaths != null) {
       
  1587                     for (int i = 0; i < rpaths.length; i++) {
       
  1588                         if (!rpaths[i].equals(paths[i])) {
       
  1589                             return false;
       
  1590                         }
       
  1591                     }
       
  1592                     return true;
       
  1593                 } else {
       
  1594                     return false;
       
  1595                 }
       
  1596             }
       
  1597 
       
  1598             @Override
       
  1599             public String getDescription() {
       
  1600                 return "Has right selection";
       
  1601             }
       
  1602 
       
  1603             @Override
       
  1604             public String toString() {
       
  1605                 return "JTreeOperator.waitSelected.ComponentChooser{description = " + getDescription() + '}';
       
  1606             }
       
  1607         });
       
  1608     }
       
  1609 
       
  1610     /**
       
  1611      * Waits path to be selected.
       
  1612      *
       
  1613      * @param path a tree path to be selected.
       
  1614      */
       
  1615     public void waitSelected(final TreePath path) {
       
  1616         waitSelected(new TreePath[]{path});
       
  1617     }
       
  1618 
       
  1619     /**
       
  1620      * Waits rows to be selected.
       
  1621      *
       
  1622      * @param rows an indices of rows to be selected.
       
  1623      */
       
  1624     public void waitSelected(int[] rows) {
       
  1625         TreePath[] paths = new TreePath[rows.length];
       
  1626         for (int i = 0; i < rows.length; i++) {
       
  1627             paths[i] = getPathForRow(rows[i]);
       
  1628         }
       
  1629         waitSelected(paths);
       
  1630     }
       
  1631 
       
  1632     /**
       
  1633      * Waits row to be selected.
       
  1634      *
       
  1635      * @param row an index of a row to be selected.
       
  1636      */
       
  1637     public void waitSelected(int row) {
       
  1638         waitSelected(new int[]{row});
       
  1639     }
       
  1640 
       
  1641     /**
       
  1642      * Wat for text in certain row.
       
  1643      *
       
  1644      * @param rowText Text to be compared with row text be
       
  1645      * {@code getComparator()} comparator.
       
  1646      * @param row Row index. If -1, selected one is checked.
       
  1647      */
       
  1648     public void waitRow(String rowText, int row) {
       
  1649         getOutput().printLine("Wait \"" + rowText + "\" text in "
       
  1650                 + Integer.toString(row) + "'th line in component \n    : "
       
  1651                 + toStringSource());
       
  1652         getOutput().printGolden("Wait \"" + rowText + " \" text in "
       
  1653                 + Integer.toString(row) + "'th line");
       
  1654         waitState(new JTreeByItemFinder(rowText, row, getComparator()));
       
  1655     }
       
  1656 
       
  1657     public Object chooseSubnode(Object parent, String text, int index, StringComparator comparator) {
       
  1658         int count = -1;
       
  1659         Object node;
       
  1660         for (int i = 0; i < getChildCount(parent); i++) {
       
  1661             try {
       
  1662                 node = getChild(parent, i);
       
  1663             } catch (JemmyException e) {
       
  1664                 if (e.getInnerThrowable() instanceof IndexOutOfBoundsException) {
       
  1665                     // tree probably re-generated because we haven't found child with specified index
       
  1666                     return null;
       
  1667                 } else {
       
  1668                     throw e;
       
  1669                 }
       
  1670             }
       
  1671             if (comparator.equals(node.toString(),
       
  1672                     text)) {
       
  1673                 count++;
       
  1674                 if (count == index) {
       
  1675                     return node;
       
  1676                 }
       
  1677             }
       
  1678         }
       
  1679         return null;
       
  1680     }
       
  1681 
       
  1682     public Object chooseSubnode(Object parent, String text, StringComparator comparator) {
       
  1683         return chooseSubnode(parent, text, 0, comparator);
       
  1684     }
       
  1685 
       
  1686     public Object chooseSubnode(Object parent, String text, int index) {
       
  1687         return chooseSubnode(parent, text, index, getComparator());
       
  1688     }
       
  1689 
       
  1690     public Object chooseSubnode(Object parent, String text) {
       
  1691         return chooseSubnode(parent, text, 0, getComparator());
       
  1692     }
       
  1693 
       
  1694     /**
       
  1695      * Returns information about component.
       
  1696      */
       
  1697     @Override
       
  1698     public Hashtable<String, Object> getDump() {
       
  1699         Hashtable<String, Object> result = super.getDump();
       
  1700         Object root = ((JTree) getSource()).getModel().getRoot();
       
  1701         // only if root is not hidden
       
  1702         result.put(ROOT_DPROP, root.toString());
       
  1703         addChildrenToDump(result, NODE_PREFIX_DPROP, root, new TreePath(root));
       
  1704         int minSelection = ((JTree) getSource()).getMinSelectionRow();
       
  1705         if (minSelection >= 0) {
       
  1706             Object minObject = ((JTree) getSource()).
       
  1707                     getPathForRow(minSelection).
       
  1708                     getLastPathComponent();
       
  1709             result.put(SELECTION_FIRST_DPROP, minObject.toString());
       
  1710             int maxSelection = ((JTree) getSource()).getMaxSelectionRow();
       
  1711             if (maxSelection > minSelection) {
       
  1712                 Object maxObject = ((JTree) getSource()).
       
  1713                         getPathForRow(maxSelection).
       
  1714                         getLastPathComponent();
       
  1715                 result.put(SELECTION_LAST_DPROP, maxObject.toString());
       
  1716             }
       
  1717         }
       
  1718         return result;
       
  1719     }
       
  1720 
       
  1721     ////////////////////////////////////////////////////////
       
  1722     //Mapping                                             //
       
  1723     /**
       
  1724      * Maps {@code JTree.addSelectionInterval(int, int)} through queue
       
  1725      */
       
  1726     public void addSelectionInterval(final int i, final int i1) {
       
  1727         runMapping(new MapVoidAction("addSelectionInterval") {
       
  1728             @Override
       
  1729             public void map() {
       
  1730                 ((JTree) getSource()).addSelectionInterval(i, i1);
       
  1731             }
       
  1732         });
       
  1733     }
       
  1734 
       
  1735     /**
       
  1736      * Maps {@code JTree.addSelectionPath(TreePath)} through queue
       
  1737      */
       
  1738     public void addSelectionPath(final TreePath treePath) {
       
  1739         runMapping(new MapVoidAction("addSelectionPath") {
       
  1740             @Override
       
  1741             public void map() {
       
  1742                 ((JTree) getSource()).addSelectionPath(treePath);
       
  1743             }
       
  1744         });
       
  1745     }
       
  1746 
       
  1747     /**
       
  1748      * Maps {@code JTree.addSelectionPaths(TreePath[])} through queue
       
  1749      */
       
  1750     public void addSelectionPaths(final TreePath[] treePath) {
       
  1751         runMapping(new MapVoidAction("addSelectionPaths") {
       
  1752             @Override
       
  1753             public void map() {
       
  1754                 ((JTree) getSource()).addSelectionPaths(treePath);
       
  1755             }
       
  1756         });
       
  1757     }
       
  1758 
       
  1759     /**
       
  1760      * Maps {@code JTree.addSelectionRow(int)} through queue
       
  1761      */
       
  1762     public void addSelectionRow(final int i) {
       
  1763         runMapping(new MapVoidAction("addSelectionRow") {
       
  1764             @Override
       
  1765             public void map() {
       
  1766                 ((JTree) getSource()).addSelectionRow(i);
       
  1767             }
       
  1768         });
       
  1769     }
       
  1770 
       
  1771     /**
       
  1772      * Maps {@code JTree.addSelectionRows(int[])} through queue
       
  1773      */
       
  1774     public void addSelectionRows(final int[] i) {
       
  1775         runMapping(new MapVoidAction("addSelectionRows") {
       
  1776             @Override
       
  1777             public void map() {
       
  1778                 ((JTree) getSource()).addSelectionRows(i);
       
  1779             }
       
  1780         });
       
  1781     }
       
  1782 
       
  1783     /**
       
  1784      * Maps {@code JTree.addTreeExpansionListener(TreeExpansionListener)}
       
  1785      * through queue
       
  1786      */
       
  1787     public void addTreeExpansionListener(final TreeExpansionListener treeExpansionListener) {
       
  1788         runMapping(new MapVoidAction("addTreeExpansionListener") {
       
  1789             @Override
       
  1790             public void map() {
       
  1791                 ((JTree) getSource()).addTreeExpansionListener(treeExpansionListener);
       
  1792             }
       
  1793         });
       
  1794     }
       
  1795 
       
  1796     /**
       
  1797      * Maps {@code JTree.addTreeSelectionListener(TreeSelectionListener)}
       
  1798      * through queue
       
  1799      */
       
  1800     public void addTreeSelectionListener(final TreeSelectionListener treeSelectionListener) {
       
  1801         runMapping(new MapVoidAction("addTreeSelectionListener") {
       
  1802             @Override
       
  1803             public void map() {
       
  1804                 ((JTree) getSource()).addTreeSelectionListener(treeSelectionListener);
       
  1805             }
       
  1806         });
       
  1807     }
       
  1808 
       
  1809     /**
       
  1810      * Maps {@code JTree.addTreeWillExpandListener(TreeWillExpandListener)}
       
  1811      * through queue
       
  1812      */
       
  1813     public void addTreeWillExpandListener(final TreeWillExpandListener treeWillExpandListener) {
       
  1814         runMapping(new MapVoidAction("addTreeWillExpandListener") {
       
  1815             @Override
       
  1816             public void map() {
       
  1817                 ((JTree) getSource()).addTreeWillExpandListener(treeWillExpandListener);
       
  1818             }
       
  1819         });
       
  1820     }
       
  1821 
       
  1822     /**
       
  1823      * Maps {@code JTree.cancelEditing()} through queue
       
  1824      */
       
  1825     public void cancelEditing() {
       
  1826         runMapping(new MapVoidAction("cancelEditing") {
       
  1827             @Override
       
  1828             public void map() {
       
  1829                 ((JTree) getSource()).cancelEditing();
       
  1830             }
       
  1831         });
       
  1832     }
       
  1833 
       
  1834     /**
       
  1835      * Maps {@code JTree.clearSelection()} through queue
       
  1836      */
       
  1837     public void clearSelection() {
       
  1838         runMapping(new MapVoidAction("clearSelection") {
       
  1839             @Override
       
  1840             public void map() {
       
  1841                 ((JTree) getSource()).clearSelection();
       
  1842             }
       
  1843         });
       
  1844     }
       
  1845 
       
  1846     /**
       
  1847      * Maps {@code JTree.collapsePath(TreePath)} through queue
       
  1848      */
       
  1849     public void collapsePath(final TreePath treePath) {
       
  1850         runMapping(new MapVoidAction("collapsePath") {
       
  1851             @Override
       
  1852             public void map() {
       
  1853                 ((JTree) getSource()).collapsePath(treePath);
       
  1854             }
       
  1855         });
       
  1856     }
       
  1857 
       
  1858     /**
       
  1859      * Maps {@code JTree.collapseRow(int)} through queue
       
  1860      */
       
  1861     public void collapseRow(final int i) {
       
  1862         runMapping(new MapVoidAction("collapseRow") {
       
  1863             @Override
       
  1864             public void map() {
       
  1865                 ((JTree) getSource()).collapseRow(i);
       
  1866             }
       
  1867         });
       
  1868     }
       
  1869 
       
  1870     /**
       
  1871      * Maps
       
  1872      * {@code JTree.convertValueToText(Object, boolean, boolean, boolean, int, boolean)}
       
  1873      * through queue
       
  1874      */
       
  1875     public String convertValueToText(final Object object, final boolean b, final boolean b1, final boolean b2, final int i, final boolean b3) {
       
  1876         return (runMapping(new MapAction<String>("convertValueToText") {
       
  1877             @Override
       
  1878             public String map() {
       
  1879                 return ((JTree) getSource()).convertValueToText(object, b, b1, b2, i, b3);
       
  1880             }
       
  1881         }));
       
  1882     }
       
  1883 
       
  1884     /**
       
  1885      * Maps {@code JTree.expandPath(TreePath)} through queue
       
  1886      */
       
  1887     public void expandPath(final TreePath treePath) {
       
  1888         runMapping(new MapVoidAction("expandPath") {
       
  1889             @Override
       
  1890             public void map() {
       
  1891                 ((JTree) getSource()).expandPath(treePath);
       
  1892             }
       
  1893         });
       
  1894     }
       
  1895 
       
  1896     /**
       
  1897      * Maps {@code JTree.expandRow(int)} through queue
       
  1898      */
       
  1899     public void expandRow(final int i) {
       
  1900         runMapping(new MapVoidAction("expandRow") {
       
  1901             @Override
       
  1902             public void map() {
       
  1903                 ((JTree) getSource()).expandRow(i);
       
  1904             }
       
  1905         });
       
  1906     }
       
  1907 
       
  1908     /**
       
  1909      * Maps {@code JTree.fireTreeCollapsed(TreePath)} through queue
       
  1910      */
       
  1911     public void fireTreeCollapsed(final TreePath treePath) {
       
  1912         runMapping(new MapVoidAction("fireTreeCollapsed") {
       
  1913             @Override
       
  1914             public void map() {
       
  1915                 ((JTree) getSource()).fireTreeCollapsed(treePath);
       
  1916             }
       
  1917         });
       
  1918     }
       
  1919 
       
  1920     /**
       
  1921      * Maps {@code JTree.fireTreeExpanded(TreePath)} through queue
       
  1922      */
       
  1923     public void fireTreeExpanded(final TreePath treePath) {
       
  1924         runMapping(new MapVoidAction("fireTreeExpanded") {
       
  1925             @Override
       
  1926             public void map() {
       
  1927                 ((JTree) getSource()).fireTreeExpanded(treePath);
       
  1928             }
       
  1929         });
       
  1930     }
       
  1931 
       
  1932     /**
       
  1933      * Maps {@code JTree.fireTreeWillCollapse(TreePath)} through queue
       
  1934      */
       
  1935     public void fireTreeWillCollapse(final TreePath treePath) {
       
  1936         runMapping(new MapVoidAction("fireTreeWillCollapse") {
       
  1937             @Override
       
  1938             public void map() throws ExpandVetoException {
       
  1939                 ((JTree) getSource()).fireTreeWillCollapse(treePath);
       
  1940             }
       
  1941         });
       
  1942     }
       
  1943 
       
  1944     /**
       
  1945      * Maps {@code JTree.fireTreeWillExpand(TreePath)} through queue
       
  1946      */
       
  1947     public void fireTreeWillExpand(final TreePath treePath) {
       
  1948         runMapping(new MapVoidAction("fireTreeWillExpand") {
       
  1949             @Override
       
  1950             public void map() throws ExpandVetoException {
       
  1951                 ((JTree) getSource()).fireTreeWillExpand(treePath);
       
  1952             }
       
  1953         });
       
  1954     }
       
  1955 
       
  1956     /**
       
  1957      * Maps {@code JTree.getCellEditor()} through queue
       
  1958      */
       
  1959     public TreeCellEditor getCellEditor() {
       
  1960         return (runMapping(new MapAction<TreeCellEditor>("getCellEditor") {
       
  1961             @Override
       
  1962             public TreeCellEditor map() {
       
  1963                 return ((JTree) getSource()).getCellEditor();
       
  1964             }
       
  1965         }));
       
  1966     }
       
  1967 
       
  1968     /**
       
  1969      * Maps {@code JTree.getCellRenderer()} through queue
       
  1970      */
       
  1971     public TreeCellRenderer getCellRenderer() {
       
  1972         return (runMapping(new MapAction<TreeCellRenderer>("getCellRenderer") {
       
  1973             @Override
       
  1974             public TreeCellRenderer map() {
       
  1975                 return ((JTree) getSource()).getCellRenderer();
       
  1976             }
       
  1977         }));
       
  1978     }
       
  1979 
       
  1980     /**
       
  1981      * Maps {@code JTree.getClosestPathForLocation(int, int)} through queue
       
  1982      */
       
  1983     public TreePath getClosestPathForLocation(final int i, final int i1) {
       
  1984         return (runMapping(new MapAction<TreePath>("getClosestPathForLocation") {
       
  1985             @Override
       
  1986             public TreePath map() {
       
  1987                 return ((JTree) getSource()).getClosestPathForLocation(i, i1);
       
  1988             }
       
  1989         }));
       
  1990     }
       
  1991 
       
  1992     /**
       
  1993      * Maps {@code JTree.getClosestRowForLocation(int, int)} through queue
       
  1994      */
       
  1995     public int getClosestRowForLocation(final int i, final int i1) {
       
  1996         return (runMapping(new MapIntegerAction("getClosestRowForLocation") {
       
  1997             @Override
       
  1998             public int map() {
       
  1999                 return ((JTree) getSource()).getClosestRowForLocation(i, i1);
       
  2000             }
       
  2001         }));
       
  2002     }
       
  2003 
       
  2004     /**
       
  2005      * Maps {@code JTree.getEditingPath()} through queue
       
  2006      */
       
  2007     public TreePath getEditingPath() {
       
  2008         return (runMapping(new MapAction<TreePath>("getEditingPath") {
       
  2009             @Override
       
  2010             public TreePath map() {
       
  2011                 return ((JTree) getSource()).getEditingPath();
       
  2012             }
       
  2013         }));
       
  2014     }
       
  2015 
       
  2016     /**
       
  2017      * Maps {@code JTree.getExpandedDescendants(TreePath)} through queue
       
  2018      */
       
  2019     public Enumeration<TreePath> getExpandedDescendants(final TreePath treePath) {
       
  2020         return (runMapping(new MapAction<Enumeration<TreePath>>("getExpandedDescendants") {
       
  2021             @Override
       
  2022             public Enumeration<TreePath> map() {
       
  2023                 return ((JTree) getSource()).getExpandedDescendants(treePath);
       
  2024             }
       
  2025         }));
       
  2026     }
       
  2027 
       
  2028     /**
       
  2029      * Maps {@code JTree.getInvokesStopCellEditing()} through queue
       
  2030      */
       
  2031     public boolean getInvokesStopCellEditing() {
       
  2032         return (runMapping(new MapBooleanAction("getInvokesStopCellEditing") {
       
  2033             @Override
       
  2034             public boolean map() {
       
  2035                 return ((JTree) getSource()).getInvokesStopCellEditing();
       
  2036             }
       
  2037         }));
       
  2038     }
       
  2039 
       
  2040     /**
       
  2041      * Maps {@code JTree.getLastSelectedPathComponent()} through queue
       
  2042      */
       
  2043     public Object getLastSelectedPathComponent() {
       
  2044         return (runMapping(new MapAction<Object>("getLastSelectedPathComponent") {
       
  2045             @Override
       
  2046             public Object map() {
       
  2047                 return ((JTree) getSource()).getLastSelectedPathComponent();
       
  2048             }
       
  2049         }));
       
  2050     }
       
  2051 
       
  2052     /**
       
  2053      * Maps {@code JTree.getLeadSelectionPath()} through queue
       
  2054      */
       
  2055     public TreePath getLeadSelectionPath() {
       
  2056         return (runMapping(new MapAction<TreePath>("getLeadSelectionPath") {
       
  2057             @Override
       
  2058             public TreePath map() {
       
  2059                 return ((JTree) getSource()).getLeadSelectionPath();
       
  2060             }
       
  2061         }));
       
  2062     }
       
  2063 
       
  2064     /**
       
  2065      * Maps {@code JTree.getLeadSelectionRow()} through queue
       
  2066      */
       
  2067     public int getLeadSelectionRow() {
       
  2068         return (runMapping(new MapIntegerAction("getLeadSelectionRow") {
       
  2069             @Override
       
  2070             public int map() {
       
  2071                 return ((JTree) getSource()).getLeadSelectionRow();
       
  2072             }
       
  2073         }));
       
  2074     }
       
  2075 
       
  2076     /**
       
  2077      * Maps {@code JTree.getMaxSelectionRow()} through queue
       
  2078      */
       
  2079     public int getMaxSelectionRow() {
       
  2080         return (runMapping(new MapIntegerAction("getMaxSelectionRow") {
       
  2081             @Override
       
  2082             public int map() {
       
  2083                 return ((JTree) getSource()).getMaxSelectionRow();
       
  2084             }
       
  2085         }));
       
  2086     }
       
  2087 
       
  2088     /**
       
  2089      * Maps {@code JTree.getMinSelectionRow()} through queue
       
  2090      */
       
  2091     public int getMinSelectionRow() {
       
  2092         return (runMapping(new MapIntegerAction("getMinSelectionRow") {
       
  2093             @Override
       
  2094             public int map() {
       
  2095                 return ((JTree) getSource()).getMinSelectionRow();
       
  2096             }
       
  2097         }));
       
  2098     }
       
  2099 
       
  2100     /**
       
  2101      * Maps {@code JTree.getModel()} through queue
       
  2102      */
       
  2103     public TreeModel getModel() {
       
  2104         return (runMapping(new MapAction<TreeModel>("getModel") {
       
  2105             @Override
       
  2106             public TreeModel map() {
       
  2107                 return ((JTree) getSource()).getModel();
       
  2108             }
       
  2109         }));
       
  2110     }
       
  2111 
       
  2112     /**
       
  2113      * Maps {@code JTree.getPathBounds(TreePath)} through queue
       
  2114      */
       
  2115     public Rectangle getPathBounds(final TreePath treePath) {
       
  2116         return (runMapping(new MapAction<Rectangle>("getPathBounds") {
       
  2117             @Override
       
  2118             public Rectangle map() {
       
  2119                 return ((JTree) getSource()).getPathBounds(treePath);
       
  2120             }
       
  2121         }));
       
  2122     }
       
  2123 
       
  2124     /**
       
  2125      * Maps {@code JTree.getPathForLocation(int, int)} through queue
       
  2126      */
       
  2127     public TreePath getPathForLocation(final int i, final int i1) {
       
  2128         return (runMapping(new MapAction<TreePath>("getPathForLocation") {
       
  2129             @Override
       
  2130             public TreePath map() {
       
  2131                 return ((JTree) getSource()).getPathForLocation(i, i1);
       
  2132             }
       
  2133         }));
       
  2134     }
       
  2135 
       
  2136     /**
       
  2137      * Maps {@code JTree.getPathForRow(int)} through queue
       
  2138      */
       
  2139     public TreePath getPathForRow(final int i) {
       
  2140         return (runMapping(new MapAction<TreePath>("getPathForRow") {
       
  2141             @Override
       
  2142             public TreePath map() {
       
  2143                 return ((JTree) getSource()).getPathForRow(i);
       
  2144             }
       
  2145         }));
       
  2146     }
       
  2147 
       
  2148     /**
       
  2149      * Maps {@code JTree.getPreferredScrollableViewportSize()} through queue
       
  2150      */
       
  2151     public Dimension getPreferredScrollableViewportSize() {
       
  2152         return (runMapping(new MapAction<Dimension>("getPreferredScrollableViewportSize") {
       
  2153             @Override
       
  2154             public Dimension map() {
       
  2155                 return ((JTree) getSource()).getPreferredScrollableViewportSize();
       
  2156             }
       
  2157         }));
       
  2158     }
       
  2159 
       
  2160     /**
       
  2161      * Maps {@code JTree.getRowBounds(int)} through queue
       
  2162      */
       
  2163     public Rectangle getRowBounds(final int i) {
       
  2164         return (runMapping(new MapAction<Rectangle>("getRowBounds") {
       
  2165             @Override
       
  2166             public Rectangle map() {
       
  2167                 return ((JTree) getSource()).getRowBounds(i);
       
  2168             }
       
  2169         }));
       
  2170     }
       
  2171 
       
  2172     /**
       
  2173      * Maps {@code JTree.getRowCount()} through queue
       
  2174      */
       
  2175     public int getRowCount() {
       
  2176         return (runMapping(new MapIntegerAction("getRowCount") {
       
  2177             @Override
       
  2178             public int map() {
       
  2179                 return ((JTree) getSource()).getRowCount();
       
  2180             }
       
  2181         }));
       
  2182     }
       
  2183 
       
  2184     /**
       
  2185      * Maps {@code JTree.getRowForLocation(int, int)} through queue
       
  2186      */
       
  2187     public int getRowForLocation(final int i, final int i1) {
       
  2188         return (runMapping(new MapIntegerAction("getRowForLocation") {
       
  2189             @Override
       
  2190             public int map() {
       
  2191                 return ((JTree) getSource()).getRowForLocation(i, i1);
       
  2192             }
       
  2193         }));
       
  2194     }
       
  2195 
       
  2196     /**
       
  2197      * Maps {@code JTree.getRowForPath(TreePath)} through queue
       
  2198      */
       
  2199     public int getRowForPath(final TreePath treePath) {
       
  2200         return (runMapping(new MapIntegerAction("getRowForPath") {
       
  2201             @Override
       
  2202             public int map() {
       
  2203                 return ((JTree) getSource()).getRowForPath(treePath);
       
  2204             }
       
  2205         }));
       
  2206     }
       
  2207 
       
  2208     /**
       
  2209      * Maps {@code JTree.getRowHeight()} through queue
       
  2210      */
       
  2211     public int getRowHeight() {
       
  2212         return (runMapping(new MapIntegerAction("getRowHeight") {
       
  2213             @Override
       
  2214             public int map() {
       
  2215                 return ((JTree) getSource()).getRowHeight();
       
  2216             }
       
  2217         }));
       
  2218     }
       
  2219 
       
  2220     /**
       
  2221      * Maps {@code JTree.getScrollableBlockIncrement(Rectangle, int, int)}
       
  2222      * through queue
       
  2223      */
       
  2224     public int getScrollableBlockIncrement(final Rectangle rectangle, final int i, final int i1) {
       
  2225         return (runMapping(new MapIntegerAction("getScrollableBlockIncrement") {
       
  2226             @Override
       
  2227             public int map() {
       
  2228                 return ((JTree) getSource()).getScrollableBlockIncrement(rectangle, i, i1);
       
  2229             }
       
  2230         }));
       
  2231     }
       
  2232 
       
  2233     /**
       
  2234      * Maps {@code JTree.getScrollableTracksViewportHeight()} through queue
       
  2235      */
       
  2236     public boolean getScrollableTracksViewportHeight() {
       
  2237         return (runMapping(new MapBooleanAction("getScrollableTracksViewportHeight") {
       
  2238             @Override
       
  2239             public boolean map() {
       
  2240                 return ((JTree) getSource()).getScrollableTracksViewportHeight();
       
  2241             }
       
  2242         }));
       
  2243     }
       
  2244 
       
  2245     /**
       
  2246      * Maps {@code JTree.getScrollableTracksViewportWidth()} through queue
       
  2247      */
       
  2248     public boolean getScrollableTracksViewportWidth() {
       
  2249         return (runMapping(new MapBooleanAction("getScrollableTracksViewportWidth") {
       
  2250             @Override
       
  2251             public boolean map() {
       
  2252                 return ((JTree) getSource()).getScrollableTracksViewportWidth();
       
  2253             }
       
  2254         }));
       
  2255     }
       
  2256 
       
  2257     /**
       
  2258      * Maps {@code JTree.getScrollableUnitIncrement(Rectangle, int, int)}
       
  2259      * through queue
       
  2260      */
       
  2261     public int getScrollableUnitIncrement(final Rectangle rectangle, final int i, final int i1) {
       
  2262         return (runMapping(new MapIntegerAction("getScrollableUnitIncrement") {
       
  2263             @Override
       
  2264             public int map() {
       
  2265                 return ((JTree) getSource()).getScrollableUnitIncrement(rectangle, i, i1);
       
  2266             }
       
  2267         }));
       
  2268     }
       
  2269 
       
  2270     /**
       
  2271      * Maps {@code JTree.getScrollsOnExpand()} through queue
       
  2272      */
       
  2273     public boolean getScrollsOnExpand() {
       
  2274         return (runMapping(new MapBooleanAction("getScrollsOnExpand") {
       
  2275             @Override
       
  2276             public boolean map() {
       
  2277                 return ((JTree) getSource()).getScrollsOnExpand();
       
  2278             }
       
  2279         }));
       
  2280     }
       
  2281 
       
  2282     /**
       
  2283      * Maps {@code JTree.getSelectionCount()} through queue
       
  2284      */
       
  2285     public int getSelectionCount() {
       
  2286         return (runMapping(new MapIntegerAction("getSelectionCount") {
       
  2287             @Override
       
  2288             public int map() {
       
  2289                 return ((JTree) getSource()).getSelectionCount();
       
  2290             }
       
  2291         }));
       
  2292     }
       
  2293 
       
  2294     /**
       
  2295      * Maps {@code JTree.getSelectionModel()} through queue
       
  2296      */
       
  2297     public TreeSelectionModel getSelectionModel() {
       
  2298         return (runMapping(new MapAction<TreeSelectionModel>("getSelectionModel") {
       
  2299             @Override
       
  2300             public TreeSelectionModel map() {
       
  2301                 return ((JTree) getSource()).getSelectionModel();
       
  2302             }
       
  2303         }));
       
  2304     }
       
  2305 
       
  2306     /**
       
  2307      * Maps {@code JTree.getSelectionPath()} through queue
       
  2308      */
       
  2309     public TreePath getSelectionPath() {
       
  2310         return (runMapping(new MapAction<TreePath>("getSelectionPath") {
       
  2311             @Override
       
  2312             public TreePath map() {
       
  2313                 return ((JTree) getSource()).getSelectionPath();
       
  2314             }
       
  2315         }));
       
  2316     }
       
  2317 
       
  2318     /**
       
  2319      * Maps {@code JTree.getSelectionPaths()} through queue
       
  2320      */
       
  2321     public TreePath[] getSelectionPaths() {
       
  2322         return ((TreePath[]) runMapping(new MapAction<Object>("getSelectionPaths") {
       
  2323             @Override
       
  2324             public Object map() {
       
  2325                 return ((JTree) getSource()).getSelectionPaths();
       
  2326             }
       
  2327         }));
       
  2328     }
       
  2329 
       
  2330     /**
       
  2331      * Maps {@code JTree.getSelectionRows()} through queue
       
  2332      */
       
  2333     public int[] getSelectionRows() {
       
  2334         return ((int[]) runMapping(new MapAction<Object>("getSelectionRows") {
       
  2335             @Override
       
  2336             public Object map() {
       
  2337                 return ((JTree) getSource()).getSelectionRows();
       
  2338             }
       
  2339         }));
       
  2340     }
       
  2341 
       
  2342     /**
       
  2343      * Maps {@code JTree.getShowsRootHandles()} through queue
       
  2344      */
       
  2345     public boolean getShowsRootHandles() {
       
  2346         return (runMapping(new MapBooleanAction("getShowsRootHandles") {
       
  2347             @Override
       
  2348             public boolean map() {
       
  2349                 return ((JTree) getSource()).getShowsRootHandles();
       
  2350             }
       
  2351         }));
       
  2352     }
       
  2353 
       
  2354     /**
       
  2355      * Maps {@code JTree.getUI()} through queue
       
  2356      */
       
  2357     public TreeUI getUI() {
       
  2358         return (runMapping(new MapAction<TreeUI>("getUI") {
       
  2359             @Override
       
  2360             public TreeUI map() {
       
  2361                 return ((JTree) getSource()).getUI();
       
  2362             }
       
  2363         }));
       
  2364     }
       
  2365 
       
  2366     /**
       
  2367      * Maps {@code JTree.getVisibleRowCount()} through queue
       
  2368      */
       
  2369     public int getVisibleRowCount() {
       
  2370         return (runMapping(new MapIntegerAction("getVisibleRowCount") {
       
  2371             @Override
       
  2372             public int map() {
       
  2373                 return ((JTree) getSource()).getVisibleRowCount();
       
  2374             }
       
  2375         }));
       
  2376     }
       
  2377 
       
  2378     /**
       
  2379      * Maps {@code JTree.hasBeenExpanded(TreePath)} through queue
       
  2380      */
       
  2381     public boolean hasBeenExpanded(final TreePath treePath) {
       
  2382         return (runMapping(new MapBooleanAction("hasBeenExpanded") {
       
  2383             @Override
       
  2384             public boolean map() {
       
  2385                 return ((JTree) getSource()).hasBeenExpanded(treePath);
       
  2386             }
       
  2387         }));
       
  2388     }
       
  2389 
       
  2390     /**
       
  2391      * Maps {@code JTree.isCollapsed(int)} through queue
       
  2392      */
       
  2393     public boolean isCollapsed(final int i) {
       
  2394         return (runMapping(new MapBooleanAction("isCollapsed") {
       
  2395             @Override
       
  2396             public boolean map() {
       
  2397                 return ((JTree) getSource()).isCollapsed(i);
       
  2398             }
       
  2399         }));
       
  2400     }
       
  2401 
       
  2402     /**
       
  2403      * Maps {@code JTree.isCollapsed(TreePath)} through queue
       
  2404      */
       
  2405     public boolean isCollapsed(final TreePath treePath) {
       
  2406         return (runMapping(new MapBooleanAction("isCollapsed") {
       
  2407             @Override
       
  2408             public boolean map() {
       
  2409                 return ((JTree) getSource()).isCollapsed(treePath);
       
  2410             }
       
  2411         }));
       
  2412     }
       
  2413 
       
  2414     /**
       
  2415      * Maps {@code JTree.isEditable()} through queue
       
  2416      */
       
  2417     public boolean isEditable() {
       
  2418         return (runMapping(new MapBooleanAction("isEditable") {
       
  2419             @Override
       
  2420             public boolean map() {
       
  2421                 return ((JTree) getSource()).isEditable();
       
  2422             }
       
  2423         }));
       
  2424     }
       
  2425 
       
  2426     /**
       
  2427      * Maps {@code JTree.isEditing()} through queue
       
  2428      */
       
  2429     public boolean isEditing() {
       
  2430         return (runMapping(new MapBooleanAction("isEditing") {
       
  2431             @Override
       
  2432             public boolean map() {
       
  2433                 return ((JTree) getSource()).isEditing();
       
  2434             }
       
  2435         }));
       
  2436     }
       
  2437 
       
  2438     /**
       
  2439      * Maps {@code JTree.isExpanded(int)} through queue
       
  2440      */
       
  2441     public boolean isExpanded(final int i) {
       
  2442         return (runMapping(new MapBooleanAction("isExpanded") {
       
  2443             @Override
       
  2444             public boolean map() {
       
  2445                 return ((JTree) getSource()).isExpanded(i);
       
  2446             }
       
  2447         }));
       
  2448     }
       
  2449 
       
  2450     /**
       
  2451      * Maps {@code JTree.isExpanded(TreePath)} through queue
       
  2452      */
       
  2453     public boolean isExpanded(final TreePath treePath) {
       
  2454         return (runMapping(new MapBooleanAction("isExpanded") {
       
  2455             @Override
       
  2456             public boolean map() {
       
  2457                 return ((JTree) getSource()).isExpanded(treePath);
       
  2458             }
       
  2459         }));
       
  2460     }
       
  2461 
       
  2462     /**
       
  2463      * Maps {@code JTree.isFixedRowHeight()} through queue
       
  2464      */
       
  2465     public boolean isFixedRowHeight() {
       
  2466         return (runMapping(new MapBooleanAction("isFixedRowHeight") {
       
  2467             @Override
       
  2468             public boolean map() {
       
  2469                 return ((JTree) getSource()).isFixedRowHeight();
       
  2470             }
       
  2471         }));
       
  2472     }
       
  2473 
       
  2474     /**
       
  2475      * Maps {@code JTree.isLargeModel()} through queue
       
  2476      */
       
  2477     public boolean isLargeModel() {
       
  2478         return (runMapping(new MapBooleanAction("isLargeModel") {
       
  2479             @Override
       
  2480             public boolean map() {
       
  2481                 return ((JTree) getSource()).isLargeModel();
       
  2482             }
       
  2483         }));
       
  2484     }
       
  2485 
       
  2486     /**
       
  2487      * Maps {@code JTree.isPathEditable(TreePath)} through queue
       
  2488      */
       
  2489     public boolean isPathEditable(final TreePath treePath) {
       
  2490         return (runMapping(new MapBooleanAction("isPathEditable") {
       
  2491             @Override
       
  2492             public boolean map() {
       
  2493                 return ((JTree) getSource()).isPathEditable(treePath);
       
  2494             }
       
  2495         }));
       
  2496     }
       
  2497 
       
  2498     /**
       
  2499      * Maps {@code JTree.isPathSelected(TreePath)} through queue
       
  2500      */
       
  2501     public boolean isPathSelected(final TreePath treePath) {
       
  2502         return (runMapping(new MapBooleanAction("isPathSelected") {
       
  2503             @Override
       
  2504             public boolean map() {
       
  2505                 return ((JTree) getSource()).isPathSelected(treePath);
       
  2506             }
       
  2507         }));
       
  2508     }
       
  2509 
       
  2510     /**
       
  2511      * Maps {@code JTree.isRootVisible()} through queue
       
  2512      */
       
  2513     public boolean isRootVisible() {
       
  2514         return (runMapping(new MapBooleanAction("isRootVisible") {
       
  2515             @Override
       
  2516             public boolean map() {
       
  2517                 return ((JTree) getSource()).isRootVisible();
       
  2518             }
       
  2519         }));
       
  2520     }
       
  2521 
       
  2522     /**
       
  2523      * Maps {@code JTree.isRowSelected(int)} through queue
       
  2524      */
       
  2525     public boolean isRowSelected(final int i) {
       
  2526         return (runMapping(new MapBooleanAction("isRowSelected") {
       
  2527             @Override
       
  2528             public boolean map() {
       
  2529                 return ((JTree) getSource()).isRowSelected(i);
       
  2530             }
       
  2531         }));
       
  2532     }
       
  2533 
       
  2534     /**
       
  2535      * Maps {@code JTree.isSelectionEmpty()} through queue
       
  2536      */
       
  2537     public boolean isSelectionEmpty() {
       
  2538         return (runMapping(new MapBooleanAction("isSelectionEmpty") {
       
  2539             @Override
       
  2540             public boolean map() {
       
  2541                 return ((JTree) getSource()).isSelectionEmpty();
       
  2542             }
       
  2543         }));
       
  2544     }
       
  2545 
       
  2546     /**
       
  2547      * Maps {@code JTree.isVisible(TreePath)} through queue
       
  2548      */
       
  2549     public boolean isVisible(final TreePath treePath) {
       
  2550         return (runMapping(new MapBooleanAction("isVisible") {
       
  2551             @Override
       
  2552             public boolean map() {
       
  2553                 return ((JTree) getSource()).isVisible(treePath);
       
  2554             }
       
  2555         }));
       
  2556     }
       
  2557 
       
  2558     /**
       
  2559      * Maps {@code JTree.makeVisible(TreePath)} through queue
       
  2560      */
       
  2561     public void makeVisible(final TreePath treePath) {
       
  2562         runMapping(new MapVoidAction("makeVisible") {
       
  2563             @Override
       
  2564             public void map() {
       
  2565                 ((JTree) getSource()).makeVisible(treePath);
       
  2566             }
       
  2567         });
       
  2568     }
       
  2569 
       
  2570     /**
       
  2571      * Maps {@code JTree.removeSelectionInterval(int, int)} through queue
       
  2572      */
       
  2573     public void removeSelectionInterval(final int i, final int i1) {
       
  2574         runMapping(new MapVoidAction("removeSelectionInterval") {
       
  2575             @Override
       
  2576             public void map() {
       
  2577                 ((JTree) getSource()).removeSelectionInterval(i, i1);
       
  2578             }
       
  2579         });
       
  2580     }
       
  2581 
       
  2582     /**
       
  2583      * Maps {@code JTree.removeSelectionPath(TreePath)} through queue
       
  2584      */
       
  2585     public void removeSelectionPath(final TreePath treePath) {
       
  2586         runMapping(new MapVoidAction("removeSelectionPath") {
       
  2587             @Override
       
  2588             public void map() {
       
  2589                 ((JTree) getSource()).removeSelectionPath(treePath);
       
  2590             }
       
  2591         });
       
  2592     }
       
  2593 
       
  2594     /**
       
  2595      * Maps {@code JTree.removeSelectionPaths(TreePath[])} through queue
       
  2596      */
       
  2597     public void removeSelectionPaths(final TreePath[] treePath) {
       
  2598         runMapping(new MapVoidAction("removeSelectionPaths") {
       
  2599             @Override
       
  2600             public void map() {
       
  2601                 ((JTree) getSource()).removeSelectionPaths(treePath);
       
  2602             }
       
  2603         });
       
  2604     }
       
  2605 
       
  2606     /**
       
  2607      * Maps {@code JTree.removeSelectionRow(int)} through queue
       
  2608      */
       
  2609     public void removeSelectionRow(final int i) {
       
  2610         runMapping(new MapVoidAction("removeSelectionRow") {
       
  2611             @Override
       
  2612             public void map() {
       
  2613                 ((JTree) getSource()).removeSelectionRow(i);
       
  2614             }
       
  2615         });
       
  2616     }
       
  2617 
       
  2618     /**
       
  2619      * Maps {@code JTree.removeSelectionRows(int[])} through queue
       
  2620      */
       
  2621     public void removeSelectionRows(final int[] i) {
       
  2622         runMapping(new MapVoidAction("removeSelectionRows") {
       
  2623             @Override
       
  2624             public void map() {
       
  2625                 ((JTree) getSource()).removeSelectionRows(i);
       
  2626             }
       
  2627         });
       
  2628     }
       
  2629 
       
  2630     /**
       
  2631      * Maps
       
  2632      * {@code JTree.removeTreeExpansionListener(TreeExpansionListener)}
       
  2633      * through queue
       
  2634      */
       
  2635     public void removeTreeExpansionListener(final TreeExpansionListener treeExpansionListener) {
       
  2636         runMapping(new MapVoidAction("removeTreeExpansionListener") {
       
  2637             @Override
       
  2638             public void map() {
       
  2639                 ((JTree) getSource()).removeTreeExpansionListener(treeExpansionListener);
       
  2640             }
       
  2641         });
       
  2642     }
       
  2643 
       
  2644     /**
       
  2645      * Maps
       
  2646      * {@code JTree.removeTreeSelectionListener(TreeSelectionListener)}
       
  2647      * through queue
       
  2648      */
       
  2649     public void removeTreeSelectionListener(final TreeSelectionListener treeSelectionListener) {
       
  2650         runMapping(new MapVoidAction("removeTreeSelectionListener") {
       
  2651             @Override
       
  2652             public void map() {
       
  2653                 ((JTree) getSource()).removeTreeSelectionListener(treeSelectionListener);
       
  2654             }
       
  2655         });
       
  2656     }
       
  2657 
       
  2658     /**
       
  2659      * Maps
       
  2660      * {@code JTree.removeTreeWillExpandListener(TreeWillExpandListener)}
       
  2661      * through queue
       
  2662      */
       
  2663     public void removeTreeWillExpandListener(final TreeWillExpandListener treeWillExpandListener) {
       
  2664         runMapping(new MapVoidAction("removeTreeWillExpandListener") {
       
  2665             @Override
       
  2666             public void map() {
       
  2667                 ((JTree) getSource()).removeTreeWillExpandListener(treeWillExpandListener);
       
  2668             }
       
  2669         });
       
  2670     }
       
  2671 
       
  2672     /**
       
  2673      * Maps {@code JTree.scrollPathToVisible(TreePath)} through queue
       
  2674      */
       
  2675     public void scrollPathToVisible(final TreePath treePath) {
       
  2676         runMapping(new MapVoidAction("scrollPathToVisible") {
       
  2677             @Override
       
  2678             public void map() {
       
  2679                 ((JTree) getSource()).scrollPathToVisible(treePath);
       
  2680             }
       
  2681         });
       
  2682     }
       
  2683 
       
  2684     /**
       
  2685      * Maps {@code JTree.scrollRowToVisible(int)} through queue
       
  2686      */
       
  2687     public void scrollRowToVisible(final int i) {
       
  2688         runMapping(new MapVoidAction("scrollRowToVisible") {
       
  2689             @Override
       
  2690             public void map() {
       
  2691                 ((JTree) getSource()).scrollRowToVisible(i);
       
  2692             }
       
  2693         });
       
  2694     }
       
  2695 
       
  2696     /**
       
  2697      * Maps {@code JTree.setCellEditor(TreeCellEditor)} through queue
       
  2698      */
       
  2699     public void setCellEditor(final TreeCellEditor treeCellEditor) {
       
  2700         runMapping(new MapVoidAction("setCellEditor") {
       
  2701             @Override
       
  2702             public void map() {
       
  2703                 ((JTree) getSource()).setCellEditor(treeCellEditor);
       
  2704             }
       
  2705         });
       
  2706     }
       
  2707 
       
  2708     /**
       
  2709      * Maps {@code JTree.setCellRenderer(TreeCellRenderer)} through queue
       
  2710      */
       
  2711     public void setCellRenderer(final TreeCellRenderer treeCellRenderer) {
       
  2712         runMapping(new MapVoidAction("setCellRenderer") {
       
  2713             @Override
       
  2714             public void map() {
       
  2715                 ((JTree) getSource()).setCellRenderer(treeCellRenderer);
       
  2716             }
       
  2717         });
       
  2718     }
       
  2719 
       
  2720     /**
       
  2721      * Maps {@code JTree.setEditable(boolean)} through queue
       
  2722      */
       
  2723     public void setEditable(final boolean b) {
       
  2724         runMapping(new MapVoidAction("setEditable") {
       
  2725             @Override
       
  2726             public void map() {
       
  2727                 ((JTree) getSource()).setEditable(b);
       
  2728             }
       
  2729         });
       
  2730     }
       
  2731 
       
  2732     /**
       
  2733      * Maps {@code JTree.setInvokesStopCellEditing(boolean)} through queue
       
  2734      */
       
  2735     public void setInvokesStopCellEditing(final boolean b) {
       
  2736         runMapping(new MapVoidAction("setInvokesStopCellEditing") {
       
  2737             @Override
       
  2738             public void map() {
       
  2739                 ((JTree) getSource()).setInvokesStopCellEditing(b);
       
  2740             }
       
  2741         });
       
  2742     }
       
  2743 
       
  2744     /**
       
  2745      * Maps {@code JTree.setLargeModel(boolean)} through queue
       
  2746      */
       
  2747     public void setLargeModel(final boolean b) {
       
  2748         runMapping(new MapVoidAction("setLargeModel") {
       
  2749             @Override
       
  2750             public void map() {
       
  2751                 ((JTree) getSource()).setLargeModel(b);
       
  2752             }
       
  2753         });
       
  2754     }
       
  2755 
       
  2756     /**
       
  2757      * Maps {@code JTree.setModel(TreeModel)} through queue
       
  2758      */
       
  2759     public void setModel(final TreeModel treeModel) {
       
  2760         runMapping(new MapVoidAction("setModel") {
       
  2761             @Override
       
  2762             public void map() {
       
  2763                 ((JTree) getSource()).setModel(treeModel);
       
  2764             }
       
  2765         });
       
  2766     }
       
  2767 
       
  2768     /**
       
  2769      * Maps {@code JTree.setRootVisible(boolean)} through queue
       
  2770      */
       
  2771     public void setRootVisible(final boolean b) {
       
  2772         runMapping(new MapVoidAction("setRootVisible") {
       
  2773             @Override
       
  2774             public void map() {
       
  2775                 ((JTree) getSource()).setRootVisible(b);
       
  2776             }
       
  2777         });
       
  2778     }
       
  2779 
       
  2780     /**
       
  2781      * Maps {@code JTree.setRowHeight(int)} through queue
       
  2782      */
       
  2783     public void setRowHeight(final int i) {
       
  2784         runMapping(new MapVoidAction("setRowHeight") {
       
  2785             @Override
       
  2786             public void map() {
       
  2787                 ((JTree) getSource()).setRowHeight(i);
       
  2788             }
       
  2789         });
       
  2790     }
       
  2791 
       
  2792     /**
       
  2793      * Maps {@code JTree.setScrollsOnExpand(boolean)} through queue
       
  2794      */
       
  2795     public void setScrollsOnExpand(final boolean b) {
       
  2796         runMapping(new MapVoidAction("setScrollsOnExpand") {
       
  2797             @Override
       
  2798             public void map() {
       
  2799                 ((JTree) getSource()).setScrollsOnExpand(b);
       
  2800             }
       
  2801         });
       
  2802     }
       
  2803 
       
  2804     /**
       
  2805      * Maps {@code JTree.setSelectionInterval(int, int)} through queue
       
  2806      */
       
  2807     public void setSelectionInterval(final int i, final int i1) {
       
  2808         runMapping(new MapVoidAction("setSelectionInterval") {
       
  2809             @Override
       
  2810             public void map() {
       
  2811                 ((JTree) getSource()).setSelectionInterval(i, i1);
       
  2812             }
       
  2813         });
       
  2814     }
       
  2815 
       
  2816     /**
       
  2817      * Maps {@code JTree.setSelectionModel(TreeSelectionModel)} through queue
       
  2818      */
       
  2819     public void setSelectionModel(final TreeSelectionModel treeSelectionModel) {
       
  2820         runMapping(new MapVoidAction("setSelectionModel") {
       
  2821             @Override
       
  2822             public void map() {
       
  2823                 ((JTree) getSource()).setSelectionModel(treeSelectionModel);
       
  2824             }
       
  2825         });
       
  2826     }
       
  2827 
       
  2828     /**
       
  2829      * Maps {@code JTree.setSelectionPath(TreePath)} through queue
       
  2830      */
       
  2831     public void setSelectionPath(final TreePath treePath) {
       
  2832         runMapping(new MapVoidAction("setSelectionPath") {
       
  2833             @Override
       
  2834             public void map() {
       
  2835                 ((JTree) getSource()).setSelectionPath(treePath);
       
  2836             }
       
  2837         });
       
  2838     }
       
  2839 
       
  2840     /**
       
  2841      * Maps {@code JTree.setSelectionPaths(TreePath[])} through queue
       
  2842      */
       
  2843     public void setSelectionPaths(final TreePath[] treePath) {
       
  2844         runMapping(new MapVoidAction("setSelectionPaths") {
       
  2845             @Override
       
  2846             public void map() {
       
  2847                 ((JTree) getSource()).setSelectionPaths(treePath);
       
  2848             }
       
  2849         });
       
  2850     }
       
  2851 
       
  2852     /**
       
  2853      * Maps {@code JTree.setSelectionRow(int)} through queue
       
  2854      */
       
  2855     public void setSelectionRow(final int i) {
       
  2856         runMapping(new MapVoidAction("setSelectionRow") {
       
  2857             @Override
       
  2858             public void map() {
       
  2859                 ((JTree) getSource()).setSelectionRow(i);
       
  2860             }
       
  2861         });
       
  2862     }
       
  2863 
       
  2864     /**
       
  2865      * Maps {@code JTree.setSelectionRows(int[])} through queue
       
  2866      */
       
  2867     public void setSelectionRows(final int[] i) {
       
  2868         runMapping(new MapVoidAction("setSelectionRows") {
       
  2869             @Override
       
  2870             public void map() {
       
  2871                 ((JTree) getSource()).setSelectionRows(i);
       
  2872             }
       
  2873         });
       
  2874     }
       
  2875 
       
  2876     /**
       
  2877      * Maps {@code JTree.setShowsRootHandles(boolean)} through queue
       
  2878      */
       
  2879     public void setShowsRootHandles(final boolean b) {
       
  2880         runMapping(new MapVoidAction("setShowsRootHandles") {
       
  2881             @Override
       
  2882             public void map() {
       
  2883                 ((JTree) getSource()).setShowsRootHandles(b);
       
  2884             }
       
  2885         });
       
  2886     }
       
  2887 
       
  2888     /**
       
  2889      * Maps {@code JTree.setUI(TreeUI)} through queue
       
  2890      */
       
  2891     public void setUI(final TreeUI treeUI) {
       
  2892         runMapping(new MapVoidAction("setUI") {
       
  2893             @Override
       
  2894             public void map() {
       
  2895                 ((JTree) getSource()).setUI(treeUI);
       
  2896             }
       
  2897         });
       
  2898     }
       
  2899 
       
  2900     /**
       
  2901      * Maps {@code JTree.setVisibleRowCount(int)} through queue
       
  2902      */
       
  2903     public void setVisibleRowCount(final int i) {
       
  2904         runMapping(new MapVoidAction("setVisibleRowCount") {
       
  2905             @Override
       
  2906             public void map() {
       
  2907                 ((JTree) getSource()).setVisibleRowCount(i);
       
  2908             }
       
  2909         });
       
  2910     }
       
  2911 
       
  2912     /**
       
  2913      * Maps {@code JTree.startEditingAtPath(TreePath)} through queue
       
  2914      */
       
  2915     public void startEditingAtPath(final TreePath treePath) {
       
  2916         runMapping(new MapVoidAction("startEditingAtPath") {
       
  2917             @Override
       
  2918             public void map() {
       
  2919                 ((JTree) getSource()).startEditingAtPath(treePath);
       
  2920             }
       
  2921         });
       
  2922     }
       
  2923 
       
  2924     /**
       
  2925      * Maps {@code JTree.stopEditing()} through queue
       
  2926      */
       
  2927     public boolean stopEditing() {
       
  2928         return (runMapping(new MapBooleanAction("stopEditing") {
       
  2929             @Override
       
  2930             public boolean map() {
       
  2931                 return ((JTree) getSource()).stopEditing();
       
  2932             }
       
  2933         }));
       
  2934     }
       
  2935 
       
  2936     /**
       
  2937      * Maps {@code JTree.treeDidChange()} through queue
       
  2938      */
       
  2939     public void treeDidChange() {
       
  2940         runMapping(new MapVoidAction("treeDidChange") {
       
  2941             @Override
       
  2942             public void map() {
       
  2943                 ((JTree) getSource()).treeDidChange();
       
  2944             }
       
  2945         });
       
  2946     }
       
  2947 
       
  2948     //End of mapping                                      //
       
  2949     ////////////////////////////////////////////////////////
       
  2950     /**
       
  2951      * Iterface to choose tree row. Defines criteria to distinguish row.
       
  2952      */
       
  2953     public interface TreeRowChooser {
       
  2954 
       
  2955         /**
       
  2956          * Should be true if row is good.
       
  2957          *
       
  2958          * @param oper Operator used to search item.
       
  2959          * @param row Row be checked.
       
  2960          * @return true if the row fits the criteria
       
  2961          */
       
  2962         public boolean checkRow(JTreeOperator oper, int row);
       
  2963 
       
  2964         /**
       
  2965          * Row description.
       
  2966          *
       
  2967          * @return a criteria description.
       
  2968          */
       
  2969         public String getDescription();
       
  2970     }
       
  2971 
       
  2972     private TreePath findPathPrimitive(TreePath path, TreePathChooser chooser, Waiter<Object[], Object[]> loadedWaiter) {
       
  2973         if (!isExpanded(path)) {
       
  2974             if (!isPathSelected(path)) {
       
  2975                 clickOnPath(path);
       
  2976             }
       
  2977             expandPath(path);
       
  2978         }
       
  2979         Object[] waitParam = {chooser, path};
       
  2980         Object[] waitResult = null;
       
  2981         try {
       
  2982             waitResult = loadedWaiter.waitAction(waitParam);
       
  2983         } catch (InterruptedException e) {
       
  2984             output.printStackTrace(e);
       
  2985             return null;
       
  2986         }
       
  2987         TreePath nextPath = (TreePath) waitResult[0];
       
  2988         boolean found = (Boolean) waitResult[1];
       
  2989         if (found) {
       
  2990             return nextPath;
       
  2991         } else {
       
  2992             return findPathPrimitive(nextPath, chooser, loadedWaiter);
       
  2993         }
       
  2994     }
       
  2995 
       
  2996     private String[] addChildrenToDump(Hashtable<String, Object> table, String title, Object node, TreePath path) {
       
  2997         if (((JTree) getSource()).isExpanded(path)) {
       
  2998             Object[] subNodes = getChildren(node);
       
  2999             String[] names = addToDump(table, title, subNodes);
       
  3000             for (int i = 0; i < subNodes.length; i++) {
       
  3001                 addChildrenToDump(table, names[i], subNodes[i], path.pathByAddingChild(subNodes[i]));
       
  3002             }
       
  3003             return names;
       
  3004         } else {
       
  3005             return new String[0];
       
  3006         }
       
  3007     }
       
  3008 
       
  3009     private static String pathToString(String[] path) {
       
  3010         StringBuilder desc = new StringBuilder("[ ");
       
  3011         for (String aPath : path) {
       
  3012             desc.append(aPath).append(", ");
       
  3013         }
       
  3014         if (desc.length() > 2) {
       
  3015             desc.setLength(desc.length() - 2);
       
  3016         }
       
  3017         desc.append(" ]");
       
  3018         return desc.toString();
       
  3019     }
       
  3020 
       
  3021     /**
       
  3022      * Can be throught during item selecting if list does not have item
       
  3023      * requested.
       
  3024      */
       
  3025     public class NoSuchPathException extends JemmyInputException {
       
  3026 
       
  3027         private static final long serialVersionUID = 42L;
       
  3028 
       
  3029         /**
       
  3030          * Constructor.
       
  3031          */
       
  3032         public NoSuchPathException() {
       
  3033             super("Unknown/null/invalid tree path.", null);
       
  3034         }
       
  3035 
       
  3036         /**
       
  3037          * Constructor.
       
  3038          *
       
  3039          * @param path a nonexistent path.
       
  3040          */
       
  3041         public NoSuchPathException(String[] path) {
       
  3042             super("No such path as \"" + pathToString(path) + "\"", getSource());
       
  3043         }
       
  3044 
       
  3045         /**
       
  3046          * Constructor.
       
  3047          *
       
  3048          * @param index a nonexistent line index.
       
  3049          */
       
  3050         public NoSuchPathException(int index) {
       
  3051             super("Tree does not contain " + index + "'th line", getSource());
       
  3052         }
       
  3053 
       
  3054         /**
       
  3055          * Constructor.
       
  3056          *
       
  3057          * @param path a nonexistent path.
       
  3058          */
       
  3059         public NoSuchPathException(TreePath path) {
       
  3060             super("No such path as \"" + path.toString() + "\"", getSource());
       
  3061         }
       
  3062     }
       
  3063 
       
  3064     /**
       
  3065      * Specifies criteria for path searching.
       
  3066      */
       
  3067     public interface TreePathChooser {
       
  3068 
       
  3069         /**
       
  3070          * Checks if the path fits the criteria.
       
  3071          *
       
  3072          * @param path TreePath to check.
       
  3073          * @param indexInParent Index of the "path" in path's parent.
       
  3074          * @return true if the path fits the criteria
       
  3075          */
       
  3076         public boolean checkPath(TreePath path, int indexInParent);
       
  3077 
       
  3078         /**
       
  3079          * Checks if the path has another path as a parent.
       
  3080          *
       
  3081          * @param path TreePath to check.
       
  3082          * @param indexInParent Index of the "path" in path's parent.
       
  3083          * @return true if path looked for is a child/grandchild of a path
       
  3084          * passed as a parameter.
       
  3085          */
       
  3086         public boolean hasAsParent(TreePath path, int indexInParent);
       
  3087 
       
  3088         /**
       
  3089          * Returns the description.
       
  3090          *
       
  3091          * @return a description.
       
  3092          */
       
  3093         public String getDescription();
       
  3094     }
       
  3095 
       
  3096     /**
       
  3097      * Specifies searching criteria basing on nodes' text.
       
  3098      */
       
  3099     class StringArrayPathChooser implements TreePathChooser {
       
  3100 
       
  3101         String[] arr;
       
  3102         int[] indices;
       
  3103         StringComparator comparator;
       
  3104 
       
  3105         /**
       
  3106          * Constructs StringArrayPathChooser.
       
  3107          *
       
  3108          * @param arr a node text array. First element defines a text of a first
       
  3109          * node under a tree root, second element - a children of the first
       
  3110          * node, ...
       
  3111          * @param indices indexes of nodes in nodes' parents.
       
  3112          * @param comparator String comparision criteria.
       
  3113          */
       
  3114         StringArrayPathChooser(String[] arr, int[] indices, StringComparator comparator) {
       
  3115             this.arr = arr;
       
  3116             this.comparator = comparator;
       
  3117             this.indices = indices;
       
  3118         }
       
  3119 
       
  3120         @Override
       
  3121         public boolean checkPath(TreePath path, int indexInParent) {
       
  3122             return (path.getPathCount() - 1 == arr.length
       
  3123                     && hasAsParent(path, indexInParent));
       
  3124         }
       
  3125 
       
  3126         @Override
       
  3127         public boolean hasAsParent(TreePath path, int indexInParent) {
       
  3128             Object[] comps = path.getPath();
       
  3129             Object node;
       
  3130             for (int i = 1; i < comps.length; i++) {
       
  3131                 if (arr.length < path.getPathCount() - 1) {
       
  3132                     return false;
       
  3133                 }
       
  3134                 /*
       
  3135                 if(!comparator.equals(comps[i].toString(), arr[i - 1])) {
       
  3136                     return false;
       
  3137                 }
       
  3138                  */
       
  3139                 if (indices.length >= path.getPathCount() - 1) {
       
  3140                     node = chooseSubnode(comps[i - 1], arr[i - 1], indices[i - 1], comparator);
       
  3141                 } else {
       
  3142                     node = chooseSubnode(comps[i - 1], arr[i - 1], comparator);
       
  3143                 }
       
  3144                 if (node != comps[i]) {
       
  3145                     return false;
       
  3146                 }
       
  3147             }
       
  3148             return true;
       
  3149         }
       
  3150 
       
  3151         @Override
       
  3152         public String getDescription() {
       
  3153             return pathToString(arr);
       
  3154         }
       
  3155 
       
  3156         @Override
       
  3157         public String toString() {
       
  3158             return "StringArrayPathChooser{" + "arr=" + arr + ", indices=" + indices + ", comparator=" + comparator + '}';
       
  3159         }
       
  3160     }
       
  3161 
       
  3162     private static class BySubStringTreeRowChooser implements TreeRowChooser {
       
  3163 
       
  3164         String subString;
       
  3165         StringComparator comparator;
       
  3166 
       
  3167         public BySubStringTreeRowChooser(String subString, StringComparator comparator) {
       
  3168             this.subString = subString;
       
  3169             this.comparator = comparator;
       
  3170         }
       
  3171 
       
  3172         @Override
       
  3173         public boolean checkRow(JTreeOperator oper, int row) {
       
  3174             return (comparator.equals(oper.getPathForRow(row).getLastPathComponent().toString(),
       
  3175                     subString));
       
  3176         }
       
  3177 
       
  3178         @Override
       
  3179         public String getDescription() {
       
  3180             return "Row containing \"" + subString + "\" string";
       
  3181         }
       
  3182 
       
  3183         @Override
       
  3184         public String toString() {
       
  3185             return "BySubStringTreeRowChooser{" + "subString=" + subString + ", comparator=" + comparator + '}';
       
  3186         }
       
  3187     }
       
  3188 
       
  3189     private static class ByRenderedComponentTreeRowChooser implements TreeRowChooser {
       
  3190 
       
  3191         ComponentChooser chooser;
       
  3192 
       
  3193         public ByRenderedComponentTreeRowChooser(ComponentChooser chooser) {
       
  3194             this.chooser = chooser;
       
  3195         }
       
  3196 
       
  3197         @Override
       
  3198         public boolean checkRow(JTreeOperator oper, int row) {
       
  3199             return chooser.checkComponent(oper.getRenderedComponent(oper.getPathForRow(row)));
       
  3200         }
       
  3201 
       
  3202         @Override
       
  3203         public String getDescription() {
       
  3204             return chooser.getDescription();
       
  3205         }
       
  3206 
       
  3207         @Override
       
  3208         public String toString() {
       
  3209             return "ByRenderedComponentTreeRowChooser{" + "chooser=" + chooser + '}';
       
  3210         }
       
  3211     }
       
  3212 
       
  3213     /**
       
  3214      * Checks component type.
       
  3215      */
       
  3216     public static class JTreeFinder extends Finder {
       
  3217 
       
  3218         /**
       
  3219          * Constructs JTreeFinder.
       
  3220          *
       
  3221          * @param sf other searching criteria.
       
  3222          */
       
  3223         public JTreeFinder(ComponentChooser sf) {
       
  3224             super(JTree.class, sf);
       
  3225         }
       
  3226 
       
  3227         /**
       
  3228          * Constructs JTreeFinder.
       
  3229          */
       
  3230         public JTreeFinder() {
       
  3231             super(JTree.class);
       
  3232         }
       
  3233     }
       
  3234 
       
  3235     /**
       
  3236      * Allows to find component by node text.
       
  3237      */
       
  3238     public static class JTreeByItemFinder implements ComponentChooser {
       
  3239 
       
  3240         String label;
       
  3241         int rowIndex;
       
  3242         StringComparator comparator;
       
  3243 
       
  3244         /**
       
  3245          * Constructs JTreeByItemFinder.
       
  3246          *
       
  3247          * @param lb a text pattern
       
  3248          * @param ii row index to check. If equal to -1, selected row is
       
  3249          * checked.
       
  3250          * @param comparator specifies string comparision algorithm.
       
  3251          */
       
  3252         public JTreeByItemFinder(String lb, int ii, StringComparator comparator) {
       
  3253             label = lb;
       
  3254             rowIndex = ii;
       
  3255             this.comparator = comparator;
       
  3256         }
       
  3257 
       
  3258         /**
       
  3259          * Constructs JTreeByItemFinder.
       
  3260          *
       
  3261          * @param lb a text pattern
       
  3262          * @param ii row index to check. If equal to -1, selected row is
       
  3263          * checked.
       
  3264          */
       
  3265         public JTreeByItemFinder(String lb, int ii) {
       
  3266             this(lb, ii, Operator.getDefaultStringComparator());
       
  3267         }
       
  3268 
       
  3269         @Override
       
  3270         public boolean checkComponent(Component comp) {
       
  3271             if (comp instanceof JTree) {
       
  3272                 if (label == null) {
       
  3273                     return true;
       
  3274                 }
       
  3275                 if (((JTree) comp).getRowCount() > rowIndex) {
       
  3276                     int ii = rowIndex;
       
  3277                     if (ii == -1) {
       
  3278                         int[] rows = ((JTree) comp).getSelectionRows();
       
  3279                         if (rows != null && rows.length > 0) {
       
  3280                             ii = rows[0];
       
  3281                         } else {
       
  3282                             return false;
       
  3283                         }
       
  3284                     }
       
  3285                     TreePath path = ((JTree) comp).getPathForRow(ii);
       
  3286                     if (path != null) {
       
  3287                         return (comparator.equals(path.getPathComponent(path.getPathCount() - 1).toString(),
       
  3288                                 label));
       
  3289                     }
       
  3290                 }
       
  3291             }
       
  3292             return false;
       
  3293         }
       
  3294 
       
  3295         @Override
       
  3296         public String getDescription() {
       
  3297             return ("JTree with text \"" + label + "\" in "
       
  3298                     + rowIndex + "'th row");
       
  3299         }
       
  3300 
       
  3301         @Override
       
  3302         public String toString() {
       
  3303             return "JTreeByItemFinder{" + "label=" + label + ", rowIndex=" + rowIndex + ", comparator=" + comparator + '}';
       
  3304         }
       
  3305     }
       
  3306 }