jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java
changeset 15333 56b81ef28fb4
parent 14656 6d8446e5b460
child 18133 41b4b144eaff
equal deleted inserted replaced
15332:aa02ac4b20b7 15333:56b81ef28fb4
  1876                     visRect.height = tree.getRowHeight() *
  1876                     visRect.height = tree.getRowHeight() *
  1877                             tree.getVisibleRowCount();
  1877                             tree.getVisibleRowCount();
  1878                 } else {
  1878                 } else {
  1879                     visRect.x -= i.left;
  1879                     visRect.x -= i.left;
  1880                     visRect.y -= i.top;
  1880                     visRect.y -= i.top;
       
  1881                 }
       
  1882                 // we should consider a non-visible area above
       
  1883                 Component component = SwingUtilities.getUnwrappedParent(tree);
       
  1884                 if (component instanceof JViewport) {
       
  1885                     component = component.getParent();
       
  1886                     if (component instanceof JScrollPane) {
       
  1887                         JScrollPane pane = (JScrollPane) component;
       
  1888                         JScrollBar bar = pane.getHorizontalScrollBar();
       
  1889                         if ((bar != null) && bar.isVisible()) {
       
  1890                             int height = bar.getHeight();
       
  1891                             visRect.y -= height;
       
  1892                             visRect.height += height;
       
  1893                         }
       
  1894                     }
  1881                 }
  1895                 }
  1882                 preferredSize.width = treeState.getPreferredWidth(visRect);
  1896                 preferredSize.width = treeState.getPreferredWidth(visRect);
  1883             }
  1897             }
  1884             else {
  1898             else {
  1885                 preferredSize.width = treeState.getPreferredWidth(null);
  1899                 preferredSize.width = treeState.getPreferredWidth(null);
  4502                     tree.scrollRectToVisible(newRect);
  4516                     tree.scrollRectToVisible(newRect);
  4503                 }
  4517                 }
  4504             }
  4518             }
  4505         }
  4519         }
  4506 
  4520 
  4507         private void home(JTree tree, BasicTreeUI ui, int direction,
  4521         private void home(JTree tree, final BasicTreeUI ui, int direction,
  4508                           boolean addToSelection, boolean changeSelection) {
  4522                           boolean addToSelection, boolean changeSelection) {
  4509 
  4523 
  4510             // disable moving of lead unless in discontiguous mode
  4524             // disable moving of lead unless in discontiguous mode
  4511             if (!addToSelection && !changeSelection &&
  4525             if (!addToSelection && !changeSelection &&
  4512                     tree.getSelectionModel().getSelectionMode() !=
  4526                     tree.getSelectionModel().getSelectionMode() !=
  4513                         TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION) {
  4527                         TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION) {
  4514                 changeSelection = true;
  4528                 changeSelection = true;
  4515             }
  4529             }
  4516 
  4530 
  4517             int rowCount = ui.getRowCount(tree);
  4531             final int rowCount = ui.getRowCount(tree);
  4518 
  4532 
  4519             if (rowCount > 0) {
  4533             if (rowCount > 0) {
  4520                 if(direction == -1) {
  4534                 if(direction == -1) {
  4521                     ui.ensureRowsAreVisible(0, 0);
  4535                     ui.ensureRowsAreVisible(0, 0);
  4522                     if (addToSelection) {
  4536                     if (addToSelection) {
  4564                     }
  4578                     }
  4565                     else {
  4579                     else {
  4566                         ui.setLeadSelectionPath(ui.getPathForRow(tree,
  4580                         ui.setLeadSelectionPath(ui.getPathForRow(tree,
  4567                                                           rowCount - 1), true);
  4581                                                           rowCount - 1), true);
  4568                     }
  4582                     }
       
  4583                     if (ui.isLargeModel()){
       
  4584                         SwingUtilities.invokeLater(new Runnable() {
       
  4585                             public void run() {
       
  4586                                 ui.ensureRowsAreVisible(rowCount - 1, rowCount - 1);
       
  4587                             }
       
  4588                         });
       
  4589                     }
  4569                 }
  4590                 }
  4570             }
  4591             }
  4571         }
  4592         }
  4572     }
  4593     }
  4573 } // End of class BasicTreeUI
  4594 } // End of class BasicTreeUI