Mercurial > hg > release > icedtea8-forest-3.0 > jdk
changeset 10746:628cb66e781b
Merge
author | asaha |
---|---|
date | Tue, 17 Feb 2015 10:43:46 -0800 |
parents | bf30dfeaa3ac (current diff) a2b104bdd112 (diff) |
children | 019f2d939ddc |
files | |
diffstat | 1 files changed, 49 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/javax/swing/JTree.java Tue Feb 17 20:05:15 2015 +0300 +++ b/src/share/classes/javax/swing/JTree.java Tue Feb 17 10:43:46 2015 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -872,9 +872,10 @@ if(treeModelListener != null) treeModel.addTreeModelListener(treeModelListener); // Mark the root as expanded, if it isn't a leaf. - if(treeModel.getRoot() != null && - !treeModel.isLeaf(treeModel.getRoot())) { - expandedState.put(new TreePath(treeModel.getRoot()), + Object treeRoot = treeModel.getRoot(); + if(treeRoot != null && + !treeModel.isLeaf(treeRoot)) { + expandedState.put(new TreePath(treeRoot), Boolean.TRUE); } } @@ -3223,6 +3224,9 @@ int count = indexs.length; Object parent = model.getRoot(); + if (parent == null) + return null; + TreePath parentPath = new TreePath(parent); for(int counter = 0; counter < count; counter++) { @@ -3798,8 +3802,9 @@ if (parent.getPathCount() == 1) { // New root, remove everything! clearToggledPaths(); - if(treeModel.getRoot() != null && - !treeModel.isLeaf(treeModel.getRoot())) { + Object treeRoot = treeModel.getRoot(); + if(treeRoot != null && + !treeModel.isLeaf(treeRoot)) { // Mark the root as expanded, if it isn't a leaf. expandedState.put(parent, Boolean.TRUE); } @@ -4283,7 +4288,11 @@ if (model == null) { return null; } - TreePath path = new TreePath(model.getRoot()); + Object treeRoot = model.getRoot(); + if (treeRoot == null) + return null; + + TreePath path = new TreePath(treeRoot); if (JTree.this.isVisible(path)) { TreeCellRenderer r = JTree.this.getCellRenderer(); TreeUI ui = JTree.this.getUI(); @@ -4296,8 +4305,8 @@ boolean expanded = JTree.this.isExpanded(path); return r.getTreeCellRendererComponent(JTree.this, - model.getRoot(), selected, expanded, - model.isLeaf(model.getRoot()), row, hasFocus); + treeRoot, selected, expanded, + model.isLeaf(treeRoot), row, hasFocus); } } return null; @@ -4350,8 +4359,11 @@ return 1; // the root node } + Object treeRoot = model.getRoot(); + if (treeRoot == null) + return 0; // return the root's first set of children count - return model.getChildCount(model.getRoot()); + return model.getChildCount(treeRoot); } /** @@ -4365,9 +4377,17 @@ if (model == null) { return null; } + + Object treeRoot = model.getRoot(); + if (treeRoot == null) { + return null; + } + if (isRootVisible()) { if (i == 0) { // return the root node Accessible - Object[] objPath = { model.getRoot() }; + Object[] objPath = { treeRoot }; + if (objPath[0] == null) + return null; TreePath path = new TreePath(objPath); return new AccessibleJTreeNode(JTree.this, path, JTree.this); } else { @@ -4376,12 +4396,14 @@ } // return Accessible for one of root's child nodes - int count = model.getChildCount(model.getRoot()); + int count = model.getChildCount(treeRoot); if (i < 0 || i >= count) { return null; } - Object obj = model.getChild(model.getRoot(), i); - Object[] objPath = { model.getRoot(), obj }; + Object obj = model.getChild(treeRoot, i); + if (obj == null) + return null; + Object[] objPath = { treeRoot, obj }; TreePath path = new TreePath(objPath); return new AccessibleJTreeNode(JTree.this, path, JTree.this); } @@ -4420,6 +4442,9 @@ public int getAccessibleSelectionCount() { Object[] rootPath = new Object[1]; rootPath[0] = treeModel.getRoot(); + if (rootPath[0] == null) + return 0; + TreePath childPath = new TreePath(rootPath); if (JTree.this.isPathSelected(childPath)) { return 1; @@ -4442,6 +4467,8 @@ if (i == 0) { Object[] rootPath = new Object[1]; rootPath[0] = treeModel.getRoot(); + if (rootPath[0] == null) + return null; TreePath childPath = new TreePath(rootPath); if (JTree.this.isPathSelected(childPath)) { return new AccessibleJTreeNode(JTree.this, childPath, JTree.this); @@ -4461,6 +4488,8 @@ if (i == 0) { Object[] rootPath = new Object[1]; rootPath[0] = treeModel.getRoot(); + if (rootPath[0] == null) + return false; TreePath childPath = new TreePath(rootPath); return JTree.this.isPathSelected(childPath); } else { @@ -4482,6 +4511,8 @@ if (model != null) { if (i == 0) { Object[] objPath = {model.getRoot()}; + if (objPath[0] == null) + return; TreePath path = new TreePath(objPath); JTree.this.addSelectionPath(path); } @@ -4500,6 +4531,8 @@ if (model != null) { if (i == 0) { Object[] objPath = {model.getRoot()}; + if (objPath[0] == null) + return; TreePath path = new TreePath(objPath); JTree.this.removeSelectionPath(path); } @@ -4525,6 +4558,8 @@ TreeModel model = JTree.this.getModel(); if (model != null) { Object[] objPath = {model.getRoot()}; + if (objPath[0] == null) + return; TreePath path = new TreePath(objPath); JTree.this.addSelectionPath(path); }