提交 bd49191e 编写于 作者: A asaha

Merge

/*
* 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 @@ public class JTree extends JComponent implements Scrollable, Accessible
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 @@ public class JTree extends JComponent implements Scrollable, Accessible
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 @@ public class JTree extends JComponent implements Scrollable, Accessible
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 @@ public class JTree extends JComponent implements Scrollable, Accessible
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 @@ public class JTree extends JComponent implements Scrollable, Accessible
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 @@ public class JTree extends JComponent implements Scrollable, Accessible
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 @@ public class JTree extends JComponent implements Scrollable, Accessible
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 @@ public class JTree extends JComponent implements Scrollable, Accessible
}
// 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 class JTree extends JComponent implements Scrollable, Accessible
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 @@ public class JTree extends JComponent implements Scrollable, Accessible
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 @@ public class JTree extends JComponent implements Scrollable, Accessible
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 @@ public class JTree extends JComponent implements Scrollable, Accessible
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 @@ public class JTree extends JComponent implements Scrollable, Accessible
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 @@ public class JTree extends JComponent implements Scrollable, Accessible
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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册