Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
f759e8bb
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f759e8bb
编写于
6月 17, 2013
作者:
M
malenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8013571: TreeModelEvent doesn't accept "null" for root as Javadoc specifies.
Reviewed-by: alexsch
上级
c0960284
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
106 addition
and
21 deletion
+106
-21
src/share/classes/javax/swing/JTree.java
src/share/classes/javax/swing/JTree.java
+3
-3
src/share/classes/javax/swing/event/TreeModelEvent.java
src/share/classes/javax/swing/event/TreeModelEvent.java
+2
-2
src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java
src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java
+4
-4
src/share/classes/javax/swing/tree/FixedHeightLayoutCache.java
...hare/classes/javax/swing/tree/FixedHeightLayoutCache.java
+6
-5
src/share/classes/javax/swing/tree/VariableHeightLayoutCache.java
...e/classes/javax/swing/tree/VariableHeightLayoutCache.java
+6
-5
src/share/classes/sun/swing/SwingUtilities2.java
src/share/classes/sun/swing/SwingUtilities2.java
+21
-2
test/javax/swing/JTree/8013571/Test8013571.java
test/javax/swing/JTree/8013571/Test8013571.java
+64
-0
未找到文件。
src/share/classes/javax/swing/JTree.java
浏览文件 @
f759e8bb
...
@@ -3751,7 +3751,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
...
@@ -3751,7 +3751,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
* the nodes identified by in <code>e</code>.
* the nodes identified by in <code>e</code>.
*/
*/
void
removeDescendantSelectedPaths
(
TreeModelEvent
e
)
{
void
removeDescendantSelectedPaths
(
TreeModelEvent
e
)
{
TreePath
pPath
=
e
.
getTreePath
(
);
TreePath
pPath
=
SwingUtilities2
.
getTreePath
(
e
,
getModel
()
);
Object
[]
oldChildren
=
e
.
getChildren
();
Object
[]
oldChildren
=
e
.
getChildren
();
TreeSelectionModel
sm
=
getSelectionModel
();
TreeSelectionModel
sm
=
getSelectionModel
();
...
@@ -3785,7 +3785,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
...
@@ -3785,7 +3785,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
// and update BasicTreeUIs treeStructureChanged method
// and update BasicTreeUIs treeStructureChanged method
// to update descendants in response to a treeStructureChanged
// to update descendants in response to a treeStructureChanged
// event, all the children of the event won't collapse!
// event, all the children of the event won't collapse!
TreePath
parent
=
e
.
getTreePath
(
);
TreePath
parent
=
SwingUtilities2
.
getTreePath
(
e
,
getModel
()
);
if
(
parent
==
null
)
if
(
parent
==
null
)
return
;
return
;
...
@@ -3822,7 +3822,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
...
@@ -3822,7 +3822,7 @@ public class JTree extends JComponent implements Scrollable, Accessible
if
(
e
==
null
)
if
(
e
==
null
)
return
;
return
;
TreePath
parent
=
e
.
getTreePath
(
);
TreePath
parent
=
SwingUtilities2
.
getTreePath
(
e
,
getModel
()
);
Object
[]
children
=
e
.
getChildren
();
Object
[]
children
=
e
.
getChildren
();
if
(
children
==
null
)
if
(
children
==
null
)
...
...
src/share/classes/javax/swing/event/TreeModelEvent.java
浏览文件 @
f759e8bb
...
@@ -128,7 +128,7 @@ public class TreeModelEvent extends EventObject {
...
@@ -128,7 +128,7 @@ public class TreeModelEvent extends EventObject {
public
TreeModelEvent
(
Object
source
,
Object
[]
path
,
int
[]
childIndices
,
public
TreeModelEvent
(
Object
source
,
Object
[]
path
,
int
[]
childIndices
,
Object
[]
children
)
Object
[]
children
)
{
{
this
(
source
,
new
TreePath
(
path
),
childIndices
,
children
);
this
(
source
,
(
path
==
null
)
?
null
:
new
TreePath
(
path
),
childIndices
,
children
);
}
}
/**
/**
...
@@ -183,7 +183,7 @@ public class TreeModelEvent extends EventObject {
...
@@ -183,7 +183,7 @@ public class TreeModelEvent extends EventObject {
*/
*/
public
TreeModelEvent
(
Object
source
,
Object
[]
path
)
public
TreeModelEvent
(
Object
source
,
Object
[]
path
)
{
{
this
(
source
,
new
TreePath
(
path
));
this
(
source
,
(
path
==
null
)
?
null
:
new
TreePath
(
path
));
}
}
/**
/**
...
...
src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java
浏览文件 @
f759e8bb
...
@@ -3827,7 +3827,7 @@ public class BasicTreeUI extends TreeUI
...
@@ -3827,7 +3827,7 @@ public class BasicTreeUI extends TreeUI
//
//
public
void
treeNodesChanged
(
TreeModelEvent
e
)
{
public
void
treeNodesChanged
(
TreeModelEvent
e
)
{
if
(
treeState
!=
null
&&
e
!=
null
)
{
if
(
treeState
!=
null
&&
e
!=
null
)
{
TreePath
parentPath
=
e
.
getTreePath
(
);
TreePath
parentPath
=
SwingUtilities2
.
getTreePath
(
e
,
getModel
()
);
int
[]
indices
=
e
.
getChildIndices
();
int
[]
indices
=
e
.
getChildIndices
();
if
(
indices
==
null
||
indices
.
length
==
0
)
{
if
(
indices
==
null
||
indices
.
length
==
0
)
{
// The root has changed
// The root has changed
...
@@ -3882,7 +3882,7 @@ public class BasicTreeUI extends TreeUI
...
@@ -3882,7 +3882,7 @@ public class BasicTreeUI extends TreeUI
updateLeadSelectionRow
();
updateLeadSelectionRow
();
TreePath
path
=
e
.
getTreePath
(
);
TreePath
path
=
SwingUtilities2
.
getTreePath
(
e
,
getModel
()
);
if
(
treeState
.
isExpanded
(
path
))
{
if
(
treeState
.
isExpanded
(
path
))
{
updateSize
();
updateSize
();
...
@@ -3907,7 +3907,7 @@ public class BasicTreeUI extends TreeUI
...
@@ -3907,7 +3907,7 @@ public class BasicTreeUI extends TreeUI
updateLeadSelectionRow
();
updateLeadSelectionRow
();
TreePath
path
=
e
.
getTreePath
(
);
TreePath
path
=
SwingUtilities2
.
getTreePath
(
e
,
getModel
()
);
if
(
treeState
.
isExpanded
(
path
)
||
if
(
treeState
.
isExpanded
(
path
)
||
treeModel
.
getChildCount
(
path
.
getLastPathComponent
())
==
0
)
treeModel
.
getChildCount
(
path
.
getLastPathComponent
())
==
0
)
...
@@ -3921,7 +3921,7 @@ public class BasicTreeUI extends TreeUI
...
@@ -3921,7 +3921,7 @@ public class BasicTreeUI extends TreeUI
updateLeadSelectionRow
();
updateLeadSelectionRow
();
TreePath
pPath
=
e
.
getTreePath
(
);
TreePath
pPath
=
SwingUtilities2
.
getTreePath
(
e
,
getModel
()
);
if
(
pPath
!=
null
)
{
if
(
pPath
!=
null
)
{
pPath
=
pPath
.
getParentPath
();
pPath
=
pPath
.
getParentPath
();
...
...
src/share/classes/javax/swing/tree/FixedHeightLayoutCache.java
浏览文件 @
f759e8bb
...
@@ -26,13 +26,14 @@
...
@@ -26,13 +26,14 @@
package
javax.swing.tree
;
package
javax.swing.tree
;
import
javax.swing.event.TreeModelEvent
;
import
javax.swing.event.TreeModelEvent
;
import
java.awt.Dimension
;
import
java.awt.Rectangle
;
import
java.awt.Rectangle
;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
java.util.Hashtable
;
import
java.util.Hashtable
;
import
java.util.NoSuchElementException
;
import
java.util.NoSuchElementException
;
import
java.util.Stack
;
import
java.util.Stack
;
import
sun.swing.SwingUtilities2
;
/**
/**
* NOTE: This will become more open in a future release.
* NOTE: This will become more open in a future release.
* <p>
* <p>
...
@@ -346,7 +347,7 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache {
...
@@ -346,7 +347,7 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache {
if
(
e
!=
null
)
{
if
(
e
!=
null
)
{
int
changedIndexs
[];
int
changedIndexs
[];
FHTreeStateNode
changedParent
=
getNodeForPath
FHTreeStateNode
changedParent
=
getNodeForPath
(
e
.
getTreePath
(
),
false
,
false
);
(
SwingUtilities2
.
getTreePath
(
e
,
getModel
()
),
false
,
false
);
int
maxCounter
;
int
maxCounter
;
changedIndexs
=
e
.
getChildIndices
();
changedIndexs
=
e
.
getChildIndices
();
...
@@ -390,7 +391,7 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache {
...
@@ -390,7 +391,7 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache {
if
(
e
!=
null
)
{
if
(
e
!=
null
)
{
int
changedIndexs
[];
int
changedIndexs
[];
FHTreeStateNode
changedParent
=
getNodeForPath
FHTreeStateNode
changedParent
=
getNodeForPath
(
e
.
getTreePath
(
),
false
,
false
);
(
SwingUtilities2
.
getTreePath
(
e
,
getModel
()
),
false
,
false
);
int
maxCounter
;
int
maxCounter
;
changedIndexs
=
e
.
getChildIndices
();
changedIndexs
=
e
.
getChildIndices
();
...
@@ -429,7 +430,7 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache {
...
@@ -429,7 +430,7 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache {
if
(
e
!=
null
)
{
if
(
e
!=
null
)
{
int
changedIndexs
[];
int
changedIndexs
[];
int
maxCounter
;
int
maxCounter
;
TreePath
parentPath
=
e
.
getTreePath
(
);
TreePath
parentPath
=
SwingUtilities2
.
getTreePath
(
e
,
getModel
()
);
FHTreeStateNode
changedParentNode
=
getNodeForPath
FHTreeStateNode
changedParentNode
=
getNodeForPath
(
parentPath
,
false
,
false
);
(
parentPath
,
false
,
false
);
...
@@ -475,7 +476,7 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache {
...
@@ -475,7 +476,7 @@ public class FixedHeightLayoutCache extends AbstractLayoutCache {
*/
*/
public
void
treeStructureChanged
(
TreeModelEvent
e
)
{
public
void
treeStructureChanged
(
TreeModelEvent
e
)
{
if
(
e
!=
null
)
{
if
(
e
!=
null
)
{
TreePath
changedPath
=
e
.
getTreePath
(
);
TreePath
changedPath
=
SwingUtilities2
.
getTreePath
(
e
,
getModel
()
);
FHTreeStateNode
changedNode
=
getNodeForPath
FHTreeStateNode
changedNode
=
getNodeForPath
(
changedPath
,
false
,
false
);
(
changedPath
,
false
,
false
);
...
...
src/share/classes/javax/swing/tree/VariableHeightLayoutCache.java
浏览文件 @
f759e8bb
...
@@ -26,7 +26,6 @@
...
@@ -26,7 +26,6 @@
package
javax.swing.tree
;
package
javax.swing.tree
;
import
javax.swing.event.TreeModelEvent
;
import
javax.swing.event.TreeModelEvent
;
import
java.awt.Dimension
;
import
java.awt.Rectangle
;
import
java.awt.Rectangle
;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
java.util.Hashtable
;
import
java.util.Hashtable
;
...
@@ -34,6 +33,8 @@ import java.util.NoSuchElementException;
...
@@ -34,6 +33,8 @@ import java.util.NoSuchElementException;
import
java.util.Stack
;
import
java.util.Stack
;
import
java.util.Vector
;
import
java.util.Vector
;
import
sun.swing.SwingUtilities2
;
/**
/**
* NOTE: This will become more open in a future release.
* NOTE: This will become more open in a future release.
* <p>
* <p>
...
@@ -413,7 +414,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache {
...
@@ -413,7 +414,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache {
TreeStateNode
changedNode
;
TreeStateNode
changedNode
;
changedIndexs
=
e
.
getChildIndices
();
changedIndexs
=
e
.
getChildIndices
();
changedNode
=
getNodeForPath
(
e
.
getTreePath
(
),
false
,
false
);
changedNode
=
getNodeForPath
(
SwingUtilities2
.
getTreePath
(
e
,
getModel
()
),
false
,
false
);
if
(
changedNode
!=
null
)
{
if
(
changedNode
!=
null
)
{
Object
changedValue
=
changedNode
.
getValue
();
Object
changedValue
=
changedNode
.
getValue
();
...
@@ -466,7 +467,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache {
...
@@ -466,7 +467,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache {
TreeStateNode
changedParentNode
;
TreeStateNode
changedParentNode
;
changedIndexs
=
e
.
getChildIndices
();
changedIndexs
=
e
.
getChildIndices
();
changedParentNode
=
getNodeForPath
(
e
.
getTreePath
(
),
false
,
false
);
changedParentNode
=
getNodeForPath
(
SwingUtilities2
.
getTreePath
(
e
,
getModel
()
),
false
,
false
);
/* Only need to update the children if the node has been
/* Only need to update the children if the node has been
expanded once. */
expanded once. */
// PENDING(scott): make sure childIndexs is sorted!
// PENDING(scott): make sure childIndexs is sorted!
...
@@ -540,7 +541,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache {
...
@@ -540,7 +541,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache {
TreeStateNode
changedParentNode
;
TreeStateNode
changedParentNode
;
changedIndexs
=
e
.
getChildIndices
();
changedIndexs
=
e
.
getChildIndices
();
changedParentNode
=
getNodeForPath
(
e
.
getTreePath
(
),
false
,
false
);
changedParentNode
=
getNodeForPath
(
SwingUtilities2
.
getTreePath
(
e
,
getModel
()
),
false
,
false
);
// PENDING(scott): make sure that changedIndexs are sorted in
// PENDING(scott): make sure that changedIndexs are sorted in
// ascending order.
// ascending order.
if
(
changedParentNode
!=
null
&&
changedIndexs
!=
null
&&
if
(
changedParentNode
!=
null
&&
changedIndexs
!=
null
&&
...
@@ -628,7 +629,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache {
...
@@ -628,7 +629,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache {
public
void
treeStructureChanged
(
TreeModelEvent
e
)
{
public
void
treeStructureChanged
(
TreeModelEvent
e
)
{
if
(
e
!=
null
)
if
(
e
!=
null
)
{
{
TreePath
changedPath
=
e
.
getTreePath
(
);
TreePath
changedPath
=
SwingUtilities2
.
getTreePath
(
e
,
getModel
()
);
TreeStateNode
changedNode
;
TreeStateNode
changedNode
;
changedNode
=
getNodeForPath
(
changedPath
,
false
,
false
);
changedNode
=
getNodeForPath
(
changedPath
,
false
,
false
);
...
...
src/share/classes/sun/swing/SwingUtilities2.java
浏览文件 @
f759e8bb
...
@@ -33,18 +33,19 @@ import java.awt.event.*;
...
@@ -33,18 +33,19 @@ import java.awt.event.*;
import
java.awt.font.*
;
import
java.awt.font.*
;
import
java.awt.geom.*
;
import
java.awt.geom.*
;
import
java.awt.print.PrinterGraphics
;
import
java.awt.print.PrinterGraphics
;
import
java.text.Bidi
;
import
java.text.AttributedCharacterIterator
;
import
java.text.AttributedCharacterIterator
;
import
java.text.AttributedString
;
import
java.text.AttributedString
;
import
javax.swing.*
;
import
javax.swing.*
;
import
javax.swing.
plaf.*
;
import
javax.swing.
event.TreeModelEvent
;
import
javax.swing.text.Highlighter
;
import
javax.swing.text.Highlighter
;
import
javax.swing.text.JTextComponent
;
import
javax.swing.text.JTextComponent
;
import
javax.swing.text.DefaultHighlighter
;
import
javax.swing.text.DefaultHighlighter
;
import
javax.swing.text.DefaultCaret
;
import
javax.swing.text.DefaultCaret
;
import
javax.swing.table.TableCellRenderer
;
import
javax.swing.table.TableCellRenderer
;
import
javax.swing.table.TableColumnModel
;
import
javax.swing.table.TableColumnModel
;
import
javax.swing.tree.TreeModel
;
import
javax.swing.tree.TreePath
;
import
sun.swing.PrintColorUIResource
;
import
sun.swing.PrintColorUIResource
;
import
sun.swing.ImageIconUIResource
;
import
sun.swing.ImageIconUIResource
;
...
@@ -1887,4 +1888,22 @@ public class SwingUtilities2 {
...
@@ -1887,4 +1888,22 @@ public class SwingUtilities2 {
}
}
return
InputEvent
.
ALT_MASK
;
return
InputEvent
.
ALT_MASK
;
}
}
/**
* Returns the {@link TreePath} that identifies the changed nodes.
*
* @param event changes in a tree model
* @param model corresponing tree model
* @return the path to the changed nodes
*/
public
static
TreePath
getTreePath
(
TreeModelEvent
event
,
TreeModel
model
)
{
TreePath
path
=
event
.
getTreePath
();
if
((
path
==
null
)
&&
(
model
!=
null
))
{
Object
root
=
model
.
getRoot
();
if
(
root
!=
null
)
{
path
=
new
TreePath
(
root
);
}
}
return
path
;
}
}
}
test/javax/swing/JTree/8013571/Test8013571.java
0 → 100644
浏览文件 @
f759e8bb
/*
* Copyright (c) 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
javax.swing.JTree
;
import
javax.swing.tree.DefaultMutableTreeNode
;
import
javax.swing.tree.DefaultTreeModel
;
/*
* @test
* @bug 8016545
* @summary Tests beans with public fields
* @author Sergey Malenkov
*/
public
class
Test8013571
extends
DefaultTreeModel
{
public
static
void
main
(
String
[]
args
)
{
DefaultMutableTreeNode
root
=
create
(
"root"
);
root
.
add
(
create
(
"colors"
,
"blue"
,
"violet"
,
"red"
,
"yellow"
));
root
.
add
(
create
(
"sports"
,
"basketball"
,
"soccer"
,
"football"
,
"hockey"
));
root
.
add
(
create
(
"food"
,
"hot dogs"
,
"pizza"
,
"ravioli"
,
"bananas"
));
Test8013571
model
=
new
Test8013571
(
root
);
JTree
tree
=
new
JTree
(
model
);
model
.
fireTreeChanged
(
tree
);
}
private
static
DefaultMutableTreeNode
create
(
String
name
,
String
...
values
)
{
DefaultMutableTreeNode
node
=
new
DefaultMutableTreeNode
(
name
);
for
(
String
value
:
values
)
{
node
.
add
(
create
(
value
));
}
return
node
;
}
private
Test8013571
(
DefaultMutableTreeNode
root
)
{
super
(
root
);
}
private
void
fireTreeChanged
(
Object
source
)
{
fireTreeNodesInserted
(
source
,
null
,
null
,
null
);
fireTreeNodesChanged
(
source
,
null
,
null
,
null
);
fireTreeNodesRemoved
(
source
,
null
,
null
,
null
);
fireTreeStructureChanged
(
source
,
null
,
null
,
null
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录