src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java

Print this page
rev 6109 : Fix for bug #222081 reported to NetBeans - the page action should be ready for null return value from getPathBounds


4449                     if(newPath.equals(lead)) {
4450                         visRect.y = Math.max(0, visRect.y - visRect.height);
4451                         newPath = tree.getClosestPathForLocation(visRect.x,
4452                                                                  visRect.y);
4453                     }
4454                 }
4455                 else {
4456                     // down
4457                     visRect.y = Math.min(maxSize.height, visRect.y +
4458                                          visRect.height - 1);
4459                     newPath = tree.getClosestPathForLocation(visRect.x,
4460                                                              visRect.y);
4461                     if(newPath.equals(lead)) {
4462                         visRect.y = Math.min(maxSize.height, visRect.y +
4463                                              visRect.height - 1);
4464                         newPath = tree.getClosestPathForLocation(visRect.x,
4465                                                                  visRect.y);
4466                     }
4467                 }
4468                 Rectangle            newRect = ui.getPathBounds(tree, newPath);
4469 
4470                 newRect.x = visRect.x;
4471                 newRect.width = visRect.width;
4472                 if(direction == -1) {
4473                     newRect.height = visRect.height;
4474                 }
4475                 else {
4476                     newRect.y -= (visRect.height - newRect.height);
4477                     newRect.height = visRect.height;
4478                 }
4479 
4480                 if(addToSelection) {
4481                     ui.extendSelection(newPath);
4482                 }
4483                 else if(changeSelection) {
4484                     tree.setSelectionPath(newPath);
4485                 }
4486                 else {
4487                     ui.setLeadSelectionPath(newPath, true);
4488                 }
4489                 tree.scrollRectToVisible(newRect);

4490             }
4491         }
4492 
4493         private void home(JTree tree, BasicTreeUI ui, int direction,
4494                           boolean addToSelection, boolean changeSelection) {
4495 
4496             // disable moving of lead unless in discontiguous mode
4497             if (!addToSelection && !changeSelection &&
4498                     tree.getSelectionModel().getSelectionMode() !=
4499                         TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION) {
4500                 changeSelection = true;
4501             }
4502 
4503             int rowCount = ui.getRowCount(tree);
4504 
4505             if (rowCount > 0) {
4506                 if(direction == -1) {
4507                     ui.ensureRowsAreVisible(0, 0);
4508                     if (addToSelection) {
4509                         TreePath        aPath = ui.getAnchorSelectionPath();




4449                     if(newPath.equals(lead)) {
4450                         visRect.y = Math.max(0, visRect.y - visRect.height);
4451                         newPath = tree.getClosestPathForLocation(visRect.x,
4452                                                                  visRect.y);
4453                     }
4454                 }
4455                 else {
4456                     // down
4457                     visRect.y = Math.min(maxSize.height, visRect.y +
4458                                          visRect.height - 1);
4459                     newPath = tree.getClosestPathForLocation(visRect.x,
4460                                                              visRect.y);
4461                     if(newPath.equals(lead)) {
4462                         visRect.y = Math.min(maxSize.height, visRect.y +
4463                                              visRect.height - 1);
4464                         newPath = tree.getClosestPathForLocation(visRect.x,
4465                                                                  visRect.y);
4466                     }
4467                 }
4468                 Rectangle            newRect = ui.getPathBounds(tree, newPath);
4469                 if (newRect != null) {
4470                     newRect.x = visRect.x;
4471                     newRect.width = visRect.width;
4472                     if(direction == -1) {
4473                         newRect.height = visRect.height;
4474                     }
4475                     else {
4476                         newRect.y -= (visRect.height - newRect.height);
4477                         newRect.height = visRect.height;
4478                     }
4479 
4480                     if(addToSelection) {
4481                         ui.extendSelection(newPath);
4482                     }
4483                     else if(changeSelection) {
4484                         tree.setSelectionPath(newPath);
4485                     }
4486                     else {
4487                         ui.setLeadSelectionPath(newPath, true);
4488                     }
4489                     tree.scrollRectToVisible(newRect);
4490                 }
4491             }
4492         }
4493 
4494         private void home(JTree tree, BasicTreeUI ui, int direction,
4495                           boolean addToSelection, boolean changeSelection) {
4496 
4497             // disable moving of lead unless in discontiguous mode
4498             if (!addToSelection && !changeSelection &&
4499                     tree.getSelectionModel().getSelectionMode() !=
4500                         TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION) {
4501                 changeSelection = true;
4502             }
4503 
4504             int rowCount = ui.getRowCount(tree);
4505 
4506             if (rowCount > 0) {
4507                 if(direction == -1) {
4508                     ui.ensureRowsAreVisible(0, 0);
4509                     if (addToSelection) {
4510                         TreePath        aPath = ui.getAnchorSelectionPath();