/[classpath]/classpath/javax/swing/JTree.java
ViewVC logotype

Diff of /classpath/javax/swing/JTree.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8.2.6 by gnu_andrew, Fri May 20 18:20:57 2005 UTC revision 1.8.2.7 by gnu_andrew, Sun Jun 5 19:36:38 2005 UTC
# Line 56  import javax.swing.event.TreeSelectionEv Line 56  import javax.swing.event.TreeSelectionEv
56  import javax.swing.event.TreeSelectionListener;  import javax.swing.event.TreeSelectionListener;
57  import javax.swing.event.TreeWillExpandListener;  import javax.swing.event.TreeWillExpandListener;
58  import javax.swing.plaf.TreeUI;  import javax.swing.plaf.TreeUI;
59    import javax.swing.text.Position;
60  import javax.swing.tree.DefaultMutableTreeNode;  import javax.swing.tree.DefaultMutableTreeNode;
61  import javax.swing.tree.DefaultTreeCellRenderer;  import javax.swing.tree.DefaultTreeCellRenderer;
62  import javax.swing.tree.DefaultTreeModel;  import javax.swing.tree.DefaultTreeModel;
# Line 1704  public class JTree extends JComponent Line 1705  public class JTree extends JComponent
1705        }        }
1706      return relevantPaths.elements();      return relevantPaths.elements();
1707    }    }
1708    
1709      /**
1710       * Returns the next table element (beginning from the row
1711       * <code>startingRow</code>
1712       * that starts with <code>prefix</code>. Searching is done in the direction
1713       * specified by <code>bias</code>.
1714       *
1715       * @param prefix the prefix to search for in the cell values
1716       * @param startingRow the index of the row where to start searching from
1717       * @param bias the search direction, either {@link Position.Bias.Forward}
1718       *     or {@link Position.Bias.Backward}
1719       *
1720       * @return the path to the found element or -1 if no such element has
1721       *     been found
1722       *
1723       * @throws IllegalArgumentException if prefix is <code>null</code> or
1724       *     startingRow is not valid
1725       *
1726       * @since 1.4
1727       */
1728      public TreePath getNextMatch(String prefix, int startingRow,
1729                                   Position.Bias bias)
1730      {
1731        if (prefix == null)
1732          throw new IllegalArgumentException("The argument 'prefix' must not be"
1733                                             + " null.");
1734        if (startingRow < 0)
1735          throw new IllegalArgumentException("The argument 'startingRow' must not"
1736                                             + " be less than zero.");
1737    
1738        int size = getRowCount();
1739        if (startingRow > size)
1740          throw new IllegalArgumentException("The argument 'startingRow' must not"
1741                                             + " be greater than the number of"
1742                                             + " elements in the TreeModel.");
1743    
1744        TreePath foundPath = null;
1745        if (bias == Position.Bias.Forward)
1746          {
1747            for (int i = startingRow; i < size; i++)
1748              {
1749                TreePath path = getPathForRow(i);
1750                Object o = path.getLastPathComponent();
1751                // FIXME: in the following call to convertValueToText the
1752                // last argument (hasFocus) should be done right.
1753                String item = convertValueToText(o, isRowSelected(i),
1754                                                 isExpanded(i),
1755                                                 treeModel.isLeaf(o), i, false);
1756                if (item.startsWith(prefix))
1757                  {
1758                    foundPath = path;
1759                    break;
1760                  }
1761              }
1762          }
1763        else
1764          {
1765            for (int i = startingRow; i >= 0; i--)
1766              {
1767                TreePath path = getPathForRow(i);
1768                Object o = path.getLastPathComponent();
1769                // FIXME: in the following call to convertValueToText the
1770                // last argument (hasFocus) should be done right.
1771                String item = convertValueToText(o, isRowSelected(i),
1772                                                 isExpanded(i),
1773                                                 treeModel.isLeaf(o), i, false);
1774                if (item.startsWith(prefix))
1775                  {
1776                    foundPath = path;
1777                    break;
1778                  }
1779              }
1780          }
1781        return foundPath;
1782      }
1783  }  }

Legend:
Removed from v.1.8.2.6  
changed lines
  Added in v.1.8.2.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26