Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
c356b304
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看板
提交
c356b304
编写于
8月 10, 2008
作者:
T
tbell
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
34494f81
54c1d936
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
808 addition
and
247 deletion
+808
-247
make/netbeans/jconsole/build.properties
make/netbeans/jconsole/build.properties
+1
-0
make/netbeans/jconsole/build.xml
make/netbeans/jconsole/build.xml
+7
-6
src/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java
.../com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java
+1
-1
src/share/classes/javax/management/openmbean/CompositeDataSupport.java
...sses/javax/management/openmbean/CompositeDataSupport.java
+16
-2
src/share/classes/javax/management/openmbean/TabularDataSupport.java
...lasses/javax/management/openmbean/TabularDataSupport.java
+16
-4
src/share/classes/sun/tools/jconsole/inspector/TableSorter.java
...are/classes/sun/tools/jconsole/inspector/TableSorter.java
+73
-45
src/share/classes/sun/tools/jconsole/inspector/XMBeanAttributes.java
...lasses/sun/tools/jconsole/inspector/XMBeanAttributes.java
+314
-135
src/share/classes/sun/tools/jconsole/inspector/XPlotter.java
src/share/classes/sun/tools/jconsole/inspector/XPlotter.java
+1
-0
src/share/classes/sun/tools/jconsole/inspector/XSheet.java
src/share/classes/sun/tools/jconsole/inspector/XSheet.java
+58
-36
src/share/classes/sun/tools/jconsole/inspector/XTable.java
src/share/classes/sun/tools/jconsole/inspector/XTable.java
+22
-7
src/share/classes/sun/tools/jconsole/inspector/XTextFieldEditor.java
...lasses/sun/tools/jconsole/inspector/XTextFieldEditor.java
+20
-11
test/javax/management/openmbean/CompositeDataStringTest.java
test/javax/management/openmbean/CompositeDataStringTest.java
+89
-0
test/javax/management/openmbean/TabularDataOrderTest.java
test/javax/management/openmbean/TabularDataOrderTest.java
+190
-0
未找到文件。
make/netbeans/jconsole/build.properties
浏览文件 @
c356b304
...
...
@@ -44,3 +44,4 @@ build.jdk.version = 1.7.0
build.release
=
${build.jdk.version}-opensource
build.number
=
b00
jconsole.version
=
${build.release}-${user.name}-${build.number}
jconsole.args
=
-debug
make/netbeans/jconsole/build.xml
浏览文件 @
c356b304
...
...
@@ -30,9 +30,9 @@
-->
<project
name=
"jconsole"
default=
"build"
basedir=
"."
>
<import
file=
"../common/shared.xml"
/>
<target
name=
"-pre-compile"
>
<copy
file=
"${root}/src/share/classes/sun/tools/jconsole/Version-template.java"
...
...
@@ -42,7 +42,7 @@
token=
"@@jconsole_version@@"
value=
"${jconsole.version}"
/>
</target>
<target
name=
"-post-compile"
>
<mkdir
dir=
"${dist.dir}/lib"
/>
<jar
destfile=
"${dist.dir}/lib/jconsole.jar"
...
...
@@ -55,18 +55,19 @@
</fileset>
</jar>
</target>
<target
name=
"run"
depends=
"-init,build"
>
<property
name=
"jvm.args"
value=
""
/>
<java
classname=
"sun.tools.jconsole.JConsole"
fork=
"true"
classpath=
"${classes.dir}:${bootstrap.jdk}/lib/tools.jar"
>
<jvmarg
line=
"${jvm.args}"
/>
<arg
line=
"${jconsole.args}"
/>
</java>
</target>
<target
name=
"clean"
depends=
"-init,shared.clean"
>
<delete
file=
"${dist.dir}/lib/jconsole.jar"
/>
</target>
</project>
src/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java
浏览文件 @
c356b304
...
...
@@ -825,7 +825,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory {
final
TabularData
table
=
(
TabularData
)
openValue
;
final
Collection
<
CompositeData
>
rows
=
cast
(
table
.
values
());
final
Map
<
Object
,
Object
>
valueMap
=
sortedMap
?
newSortedMap
()
:
newMap
();
sortedMap
?
newSortedMap
()
:
new
InsertionOrder
Map
();
for
(
CompositeData
row
:
rows
)
{
final
Object
key
=
keyMapping
.
fromOpenValue
(
row
.
get
(
"key"
));
...
...
src/share/classes/javax/management/openmbean/CompositeDataSupport.java
浏览文件 @
c356b304
...
...
@@ -355,6 +355,7 @@ public class CompositeDataSupport
* @return <code>true</code> if the specified object is equal to this
* <code>CompositeDataSupport</code> instance.
*/
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
...
...
@@ -419,6 +420,7 @@ public class CompositeDataSupport
*
* @return the hash code value for this <code>CompositeDataSupport</code> instance
*/
@Override
public
int
hashCode
()
{
int
hashcode
=
compositeType
.
hashCode
();
...
...
@@ -457,16 +459,28 @@ public class CompositeDataSupport
*
* @return a string representation of this <code>CompositeDataSupport</code> instance
*/
@Override
public
String
toString
()
{
return
new
StringBuilder
()
.
append
(
this
.
getClass
().
getName
())
.
append
(
"(compositeType="
)
.
append
(
compositeType
.
toString
())
.
append
(
",contents="
)
.
append
(
content
s
.
to
String
())
.
append
(
contentString
())
.
append
(
")"
)
.
toString
();
}
private
String
contentString
()
{
StringBuilder
sb
=
new
StringBuilder
(
"{"
);
String
sep
=
""
;
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
contents
.
entrySet
())
{
sb
.
append
(
sep
).
append
(
entry
.
getKey
()).
append
(
"="
);
String
s
=
Arrays
.
deepToString
(
new
Object
[]
{
entry
.
getValue
()});
sb
.
append
(
s
.
substring
(
1
,
s
.
length
()
-
1
));
sep
=
", "
;
}
sb
.
append
(
"}"
);
return
sb
.
toString
();
}
}
src/share/classes/javax/management/openmbean/TabularDataSupport.java
浏览文件 @
c356b304
...
...
@@ -29,15 +29,18 @@ package javax.management.openmbean;
// java import
//
import
com.sun.jmx.mbeanserver.GetPropertyAction
;
import
java.io.IOException
;
import
java.io.ObjectInputStream
;
import
java.io.Serializable
;
import
java.security.AccessController
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -79,12 +82,13 @@ public class TabularDataSupport
/**
* @serial This tabular data instance's contents: a {@link HashMap}
*/
// field cannot be final because of clone method
private
Map
<
Object
,
CompositeData
>
dataMap
;
/**
* @serial This tabular data instance's tabular type
*/
private
TabularType
tabularType
;
private
final
TabularType
tabularType
;
/**
* The array of item names that define the index used for rows (convenience field)
...
...
@@ -109,7 +113,7 @@ public class TabularDataSupport
*/
public
TabularDataSupport
(
TabularType
tabularType
)
{
this
(
tabularType
,
1
01
,
0.75f
);
this
(
tabularType
,
1
6
,
0.75f
);
}
/**
...
...
@@ -141,10 +145,18 @@ public class TabularDataSupport
List
<
String
>
tmpNames
=
tabularType
.
getIndexNames
();
this
.
indexNamesArray
=
tmpNames
.
toArray
(
new
String
[
tmpNames
.
size
()]);
// Since LinkedHashMap was introduced in SE 1.4, it's conceivable even
// if very unlikely that we might be the server of a 1.3 client. In
// that case you'll need to set this property. See CR 6334663.
String
useHashMapProp
=
AccessController
.
doPrivileged
(
new
GetPropertyAction
(
"jmx.tabular.data.hash.map"
));
boolean
useHashMap
=
"true"
.
equalsIgnoreCase
(
useHashMapProp
);
// Construct the empty contents HashMap
//
this
.
dataMap
=
new
HashMap
<
Object
,
CompositeData
>(
initialCapacity
,
loadFactor
);
this
.
dataMap
=
useHashMap
?
new
HashMap
<
Object
,
CompositeData
>(
initialCapacity
,
loadFactor
)
:
new
LinkedHashMap
<
Object
,
CompositeData
>(
initialCapacity
,
loadFactor
);
}
...
...
src/share/classes/sun/tools/jconsole/inspector/TableSorter.java
浏览文件 @
c356b304
...
...
@@ -25,71 +25,78 @@
package
sun.tools.jconsole.inspector
;
import
java.util.*
;
import
java.awt.event.*
;
import
javax.swing.table.*
;
import
javax.swing.event.*
;
// Imports for picking up mouse events from the JTable.
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
import
java.awt.event.InputEvent
;
import
java.awt.event.MouseListener
;
import
java.util.Vector
;
import
javax.swing.JTable
;
import
javax.swing.event.TableModelEvent
;
import
javax.swing.event.TableModelListener
;
import
javax.swing.table.DefaultTableModel
;
import
javax.swing.table.JTableHeader
;
import
javax.swing.table.TableColumnModel
;
import
sun.tools.jconsole.JConsole
;
@SuppressWarnings
(
"serial"
)
public
class
TableSorter
extends
DefaultTableModel
implements
MouseListener
{
private
boolean
ascending
=
true
;
private
TableColumnModel
columnModel
;
private
JTable
tableView
;
private
Vector
<
TableModelListener
>
l
istenerList
;
private
Vector
<
TableModelListener
>
evtL
istenerList
;
private
int
sortColumn
=
0
;
private
int
[]
invertedIndex
;
public
TableSorter
()
{
super
();
l
istenerList
=
new
Vector
<
TableModelListener
>();
evtL
istenerList
=
new
Vector
<
TableModelListener
>();
}
public
TableSorter
(
Object
[]
columnNames
,
int
numRows
)
{
super
(
columnNames
,
numRows
);
l
istenerList
=
new
Vector
<
TableModelListener
>();
evtL
istenerList
=
new
Vector
<
TableModelListener
>();
}
@Override
public
void
newDataAvailable
(
TableModelEvent
e
)
{
super
.
newDataAvailable
(
e
);
invertedIndex
=
new
int
[
getRowCount
()];
for
(
int
i
=
0
;
i
<
invertedIndex
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
invertedIndex
.
length
;
i
++)
{
invertedIndex
[
i
]
=
i
;
}
sort
(
this
.
sortColumn
);
sort
(
this
.
sortColumn
,
this
.
ascending
);
}
@Override
public
void
addTableModelListener
(
TableModelListener
l
)
{
l
istenerList
.
add
(
l
);
evtL
istenerList
.
add
(
l
);
super
.
addTableModelListener
(
l
);
}
@Override
public
void
removeTableModelListener
(
TableModelListener
l
)
{
l
istenerList
.
remove
(
l
);
evtL
istenerList
.
remove
(
l
);
super
.
removeTableModelListener
(
l
);
}
private
void
removeListeners
()
{
for
(
TableModelListener
tnl
:
l
istenerList
)
for
(
TableModelListener
tnl
:
evtL
istenerList
)
super
.
removeTableModelListener
(
tnl
);
}
private
void
restoreListeners
()
{
for
(
TableModelListener
tnl
:
l
istenerList
)
for
(
TableModelListener
tnl
:
evtL
istenerList
)
super
.
addTableModelListener
(
tnl
);
}
@SuppressWarnings
(
"unchecked"
)
public
int
compare
(
Object
o1
,
Object
o2
)
{
private
int
compare
(
Object
o1
,
Object
o2
)
{
// take care of the case where both o1 & o2 are null. Needed to keep
// the method symetric. Without this quickSort gives surprising results.
if
(
o1
==
o2
)
return
0
;
if
(
o1
==
null
)
return
1
;
if
(
o2
==
null
)
...
...
@@ -104,18 +111,40 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
}
}
public
void
sort
(
int
column
)
{
private
void
sort
(
int
column
,
boolean
isAscending
)
{
final
XMBeanAttributes
attrs
=
(
tableView
instanceof
XMBeanAttributes
)
?(
XMBeanAttributes
)
tableView
:
null
;
// We cannot sort rows when a cell is being
// edited - so we're going to cancel cell editing here if needed.
// This might happen when the user is editing a row, and clicks on
// another row without validating. In that case there are two events
// that compete: one is the validation of the value that was previously
// edited, the other is the mouse click that opens the new editor.
//
// When we reach here the previous value is already validated, and the
// old editor is closed, but the new editor might have opened.
// It's this new editor that wil be cancelled here, if needed.
//
if
(
attrs
!=
null
&&
attrs
.
isEditing
())
attrs
.
cancelCellEditing
();
// remove registered listeners
removeListeners
();
// do the sort
//n2sort(column);
quickSort
(
0
,
getRowCount
()-
1
,
column
);
if
(
JConsole
.
isDebug
())
{
System
.
err
.
println
(
"sorting table against column="
+
column
+
" ascending="
+
isAscending
);
}
quickSort
(
0
,
getRowCount
()-
1
,
column
,
isAscending
);
// restore registered listeners
restoreListeners
();
this
.
sortColumn
=
column
;
// update row heights in XMBeanAttributes (required by expandable cells)
if
(
tableView
instanceof
XMBeanAttributes
)
{
XMBeanAttributes
attrs
=
(
XMBeanAttributes
)
tableView
;
if
(
attrs
!=
null
)
{
for
(
int
i
=
0
;
i
<
getRowCount
();
i
++)
{
Vector
data
=
(
Vector
)
dataVector
.
elementAt
(
i
);
attrs
.
updateRowHeight
(
data
.
elementAt
(
1
),
i
);
...
...
@@ -123,21 +152,21 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
}
}
private
synchronized
boolean
compareS
(
Object
s1
,
Object
s2
)
{
if
(
a
scending
)
private
boolean
compareS
(
Object
s1
,
Object
s2
,
boolean
isAscending
)
{
if
(
isA
scending
)
return
(
compare
(
s1
,
s2
)
>
0
);
else
return
(
compare
(
s1
,
s2
)
<
0
);
}
private
synchronized
boolean
compareG
(
Object
s1
,
Object
s2
)
{
if
(
a
scending
)
private
boolean
compareG
(
Object
s1
,
Object
s2
,
boolean
isAscending
)
{
if
(
isA
scending
)
return
(
compare
(
s1
,
s2
)
<
0
);
else
return
(
compare
(
s1
,
s2
)
>
0
);
}
private
synchronized
void
quickSort
(
int
lo0
,
int
hi0
,
int
key
)
{
private
void
quickSort
(
int
lo0
,
int
hi0
,
int
key
,
boolean
isAscending
)
{
int
lo
=
lo0
;
int
hi
=
hi0
;
Object
mid
;
...
...
@@ -153,14 +182,14 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
* from the left Index.
*/
while
(
(
lo
<
hi0
)
&&
(
compareS
(
mid
,
getValueAt
(
lo
,
key
))
))
(
compareS
(
mid
,
getValueAt
(
lo
,
key
)
,
isAscending
)
))
++
lo
;
/* find an element that is smaller than or equal to
* the partition element starting from the right Index.
*/
while
(
(
hi
>
lo0
)
&&
(
compareG
(
mid
,
getValueAt
(
hi
,
key
))
))
(
compareG
(
mid
,
getValueAt
(
hi
,
key
)
,
isAscending
)
))
--
hi
;
// if the indexes have not crossed, swap
...
...
@@ -177,27 +206,17 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
* must now sort the left partition.
*/
if
(
lo0
<
hi
)
quickSort
(
lo0
,
hi
,
key
);
quickSort
(
lo0
,
hi
,
key
,
isAscending
);
/* If the left index has not reached the right
* side of array
* must now sort the right partition.
*/
if
(
lo
<=
hi0
)
quickSort
(
lo
,
hi0
,
key
);
quickSort
(
lo
,
hi0
,
key
,
isAscending
);
}
}
public
void
n2sort
(
int
column
)
{
for
(
int
i
=
0
;
i
<
getRowCount
();
i
++)
{
for
(
int
j
=
i
+
1
;
j
<
getRowCount
();
j
++)
{
if
(
compare
(
getValueAt
(
i
,
column
),
getValueAt
(
j
,
column
))
==
-
1
)
{
swap
(
i
,
j
,
column
);
}
}
}
}
private
Vector
getRow
(
int
row
)
{
return
(
Vector
)
dataVector
.
elementAt
(
row
);
}
...
...
@@ -207,7 +226,7 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
dataVector
.
setElementAt
(
data
,
row
);
}
p
ublic
void
swap
(
int
i
,
int
j
,
int
column
)
{
p
rivate
void
swap
(
int
i
,
int
j
,
int
column
)
{
Vector
data
=
getRow
(
i
);
setRow
(
getRow
(
j
),
i
);
setRow
(
data
,
j
);
...
...
@@ -223,11 +242,12 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
public
void
sortByColumn
(
int
column
,
boolean
ascending
)
{
this
.
ascending
=
ascending
;
sort
(
column
);
this
.
sortColumn
=
column
;
sort
(
column
,
ascending
);
}
public
int
[]
getInvertedIndex
(
)
{
return
invertedIndex
;
public
int
getIndexOfRow
(
int
row
)
{
return
invertedIndex
[
row
]
;
}
// Add a mouse listener to the Table to trigger a table sort
...
...
@@ -243,6 +263,14 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
int
viewColumn
=
columnModel
.
getColumnIndexAtX
(
e
.
getX
());
int
column
=
tableView
.
convertColumnIndexToModel
(
viewColumn
);
if
(
e
.
getClickCount
()
==
1
&&
column
!=
-
1
)
{
if
(
tableView
instanceof
XTable
)
{
XTable
attrs
=
(
XTable
)
tableView
;
// inform the table view that the rows are going to be sorted
// against the values in a given column. This gives the
// chance to the table view to close its editor - if needed.
//
attrs
.
sortRequested
(
column
);
}
tableView
.
invalidate
();
sortByColumn
(
column
);
tableView
.
validate
();
...
...
src/share/classes/sun/tools/jconsole/inspector/XMBeanAttributes.java
浏览文件 @
c356b304
此差异已折叠。
点击以展开。
src/share/classes/sun/tools/jconsole/inspector/XPlotter.java
浏览文件 @
c356b304
...
...
@@ -37,6 +37,7 @@ public class XPlotter extends Plotter {
super
(
unit
);
this
.
table
=
table
;
}
@Override
public
void
addValues
(
long
time
,
long
...
values
)
{
super
.
addValues
(
time
,
values
);
table
.
repaint
();
...
...
src/share/classes/sun/tools/jconsole/inspector/XSheet.java
浏览文件 @
c356b304
...
...
@@ -25,18 +25,39 @@
package
sun.tools.jconsole.inspector
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.io.*
;
import
javax.management.*
;
import
javax.swing.*
;
import
javax.swing.border.*
;
import
javax.swing.tree.*
;
import
java.awt.BorderLayout
;
import
java.awt.Color
;
import
java.awt.Component
;
import
java.awt.Dimension
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.io.IOException
;
import
javax.management.IntrospectionException
;
import
javax.management.NotificationListener
;
import
javax.management.MBeanInfo
;
import
javax.management.InstanceNotFoundException
;
import
javax.management.ReflectionException
;
import
javax.management.MBeanAttributeInfo
;
import
javax.management.MBeanOperationInfo
;
import
javax.management.MBeanNotificationInfo
;
import
javax.management.Notification
;
import
javax.swing.BorderFactory
;
import
javax.swing.JButton
;
import
javax.swing.JOptionPane
;
import
javax.swing.JPanel
;
import
javax.swing.JScrollPane
;
import
javax.swing.JTextArea
;
import
javax.swing.SwingWorker
;
import
javax.swing.border.LineBorder
;
import
javax.swing.tree.DefaultMutableTreeNode
;
import
javax.swing.tree.DefaultTreeModel
;
import
sun.tools.jconsole.*
;
import
sun.tools.jconsole.inspector.XNodeInfo.Type
;
import
static
sun
.
tools
.
jconsole
.
Resources
.*;
import
static
sun
.
tools
.
jconsole
.
Utilities
.*;
@SuppressWarnings
(
"serial"
)
public
class
XSheet
extends
JPanel
...
...
@@ -344,34 +365,41 @@ public class XSheet extends JPanel
return
;
}
mbean
=
(
XMBean
)
uo
.
getData
();
SwingWorker
<
Void
,
Void
>
sw
=
new
SwingWorker
<
Void
,
Void
>()
{
final
XMBean
xmb
=
mbean
;
SwingWorker
<
MBeanInfo
,
Void
>
sw
=
new
SwingWorker
<
MBeanInfo
,
Void
>()
{
@Override
public
Void
doInBackground
()
throws
InstanceNotFoundException
,
public
MBeanInfo
doInBackground
()
throws
InstanceNotFoundException
,
IntrospectionException
,
ReflectionException
,
IOException
{
mbeanAttributes
.
loadAttributes
(
mbean
,
mbean
.
getMBeanInfo
()
);
return
null
;
MBeanInfo
mbi
=
xmb
.
getMBeanInfo
(
);
return
mbi
;
}
@Override
protected
void
done
()
{
try
{
get
();
if
(!
isSelectedNode
(
node
,
currentNode
))
{
return
;
MBeanInfo
mbi
=
get
();
if
(
mbi
!=
null
&&
mbi
.
getAttributes
()
!=
null
&&
mbi
.
getAttributes
().
length
>
0
)
{
mbeanAttributes
.
loadAttributes
(
xmb
,
mbi
);
if
(!
isSelectedNode
(
node
,
currentNode
))
{
return
;
}
invalidate
();
mainPanel
.
removeAll
();
JPanel
borderPanel
=
new
JPanel
(
new
BorderLayout
());
borderPanel
.
setBorder
(
BorderFactory
.
createTitledBorder
(
Resources
.
getText
(
"Attribute values"
)));
borderPanel
.
add
(
new
JScrollPane
(
mbeanAttributes
));
mainPanel
.
add
(
borderPanel
,
BorderLayout
.
CENTER
);
// add the refresh button to the south panel
southPanel
.
removeAll
();
southPanel
.
add
(
refreshButton
,
BorderLayout
.
SOUTH
);
southPanel
.
setVisible
(
true
);
refreshButton
.
setEnabled
(
true
);
validate
();
repaint
();
}
invalidate
();
mainPanel
.
removeAll
();
JPanel
borderPanel
=
new
JPanel
(
new
BorderLayout
());
borderPanel
.
setBorder
(
BorderFactory
.
createTitledBorder
(
Resources
.
getText
(
"Attribute values"
)));
borderPanel
.
add
(
new
JScrollPane
(
mbeanAttributes
));
mainPanel
.
add
(
borderPanel
,
BorderLayout
.
CENTER
);
// add the refresh button to the south panel
southPanel
.
removeAll
();
southPanel
.
add
(
refreshButton
,
BorderLayout
.
SOUTH
);
southPanel
.
setVisible
(
true
);
refreshButton
.
setEnabled
(
true
);
validate
();
repaint
();
}
catch
(
Exception
e
)
{
Throwable
t
=
Utils
.
getActualException
(
e
);
if
(
JConsole
.
isDebug
())
{
...
...
@@ -704,13 +732,7 @@ public class XSheet extends JPanel
JButton
button
=
(
JButton
)
e
.
getSource
();
// Refresh button
if
(
button
==
refreshButton
)
{
new
SwingWorker
<
Void
,
Void
>()
{
@Override
public
Void
doInBackground
()
{
refreshAttributes
();
return
null
;
}
}.
execute
();
refreshAttributes
();
return
;
}
// Clear button
...
...
src/share/classes/sun/tools/jconsole/inspector/XTable.java
浏览文件 @
c356b304
...
...
@@ -25,10 +25,13 @@
package
sun.tools.jconsole.inspector
;
import
javax.swing.*
;
import
javax.swing.table.*
;
import
java.awt.*
;
import
java.io.*
;
import
java.awt.Color
;
import
java.awt.Component
;
import
java.awt.Font
;
import
javax.swing.JTable
;
import
javax.swing.table.DefaultTableCellRenderer
;
import
javax.swing.table.DefaultTableModel
;
import
javax.swing.table.TableCellRenderer
;
public
abstract
class
XTable
extends
JTable
{
static
final
int
NAME_COLUMN
=
0
;
...
...
@@ -38,8 +41,9 @@ public abstract class XTable extends JTable {
public
XTable
()
{
super
();
TableSorter
sorter
;
setModel
(
sorter
=
new
TableSorter
());
@SuppressWarnings
(
"serial"
)
final
TableSorter
sorter
=
new
TableSorter
();
setModel
(
sorter
);
sorter
.
addMouseListenerToHeaderInTable
(
this
);
setRowSelectionAllowed
(
false
);
setColumnSelectionAllowed
(
false
);
...
...
@@ -54,6 +58,14 @@ public abstract class XTable extends JTable {
return
editableColor
;
}
/**
* Called by TableSorter if a mouse event requests to sort the rows.
* @param column the column against which the rows are sorted
*/
void
sortRequested
(
int
column
)
{
// This is a hook for subclasses
}
/**
* This returns the select index as the table was at initialization
*/
...
...
@@ -67,7 +79,7 @@ public abstract class XTable extends JTable {
public
int
convertRowToIndex
(
int
row
)
{
if
(
row
==
-
1
)
return
row
;
if
(
getModel
()
instanceof
TableSorter
)
{
return
((
(
TableSorter
)
getModel
()).
getInvertedIndex
()[
row
]
);
return
((
TableSorter
)
getModel
()).
getIndexOfRow
(
row
);
}
else
{
return
row
;
}
...
...
@@ -97,6 +109,7 @@ public abstract class XTable extends JTable {
//JTable re-implementation
//attribute can be editable even if unavailable
@Override
public
boolean
isCellEditable
(
int
row
,
int
col
)
{
return
((
isTableEditable
()
&&
isColumnEditable
(
col
)
&&
isWritable
(
row
)
...
...
@@ -118,6 +131,7 @@ public abstract class XTable extends JTable {
* This method sets read write rows to be blue, and other rows to be their
* default rendered colour.
*/
@Override
public
TableCellRenderer
getCellRenderer
(
int
row
,
int
column
)
{
DefaultTableCellRenderer
tcr
=
(
DefaultTableCellRenderer
)
super
.
getCellRenderer
(
row
,
column
);
...
...
@@ -146,6 +160,7 @@ public abstract class XTable extends JTable {
return
tcr
;
}
@Override
public
Component
prepareRenderer
(
TableCellRenderer
renderer
,
int
row
,
int
column
)
{
Component
comp
=
super
.
prepareRenderer
(
renderer
,
row
,
column
);
...
...
src/share/classes/sun/tools/jconsole/inspector/XTextFieldEditor.java
浏览文件 @
c356b304
...
...
@@ -26,22 +26,30 @@
package
sun.tools.jconsole.inspector
;
import
java.awt.Component
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.FocusAdapter
;
import
java.awt.event.FocusEvent
;
import
java.awt.event.FocusListener
;
import
java.util.EventObject
;
import
java.awt.event.*
;
import
java.awt.dnd.DragSourceDropEvent
;
import
javax.swing.*
;
import
javax.swing.event.*
;
import
javax.swing.table.*
;
import
javax.swing.JMenuItem
;
import
javax.swing.JTable
;
import
javax.swing.JTextField
;
import
javax.swing.event.CellEditorListener
;
import
javax.swing.event.ChangeEvent
;
import
javax.swing.event.EventListenerList
;
import
javax.swing.table.TableCellEditor
;
@SuppressWarnings
(
"serial"
)
public
class
XTextFieldEditor
extends
XTextField
implements
TableCellEditor
{
protected
EventListenerList
l
istenerList
=
new
EventListenerList
();
protected
EventListenerList
evtL
istenerList
=
new
EventListenerList
();
protected
ChangeEvent
changeEvent
=
new
ChangeEvent
(
this
);
private
FocusListener
editorFocusListener
=
new
FocusAdapter
()
{
@Override
public
void
focusLost
(
FocusEvent
e
)
{
fireEditingStopped
();
// fireEditingStopped();
// must not call fireEditingStopped() here!
}
};
...
...
@@ -51,6 +59,7 @@ public class XTextFieldEditor extends XTextField implements TableCellEditor {
}
//edition stopped ou JMenuItem selection & JTextField selection
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
super
.
actionPerformed
(
e
);
if
((
e
.
getSource
()
instanceof
JMenuItem
)
||
...
...
@@ -67,16 +76,16 @@ public class XTextFieldEditor extends XTextField implements TableCellEditor {
//TableCellEditor implementation
public
void
addCellEditorListener
(
CellEditorListener
listener
)
{
l
istenerList
.
add
(
CellEditorListener
.
class
,
listener
);
evtL
istenerList
.
add
(
CellEditorListener
.
class
,
listener
);
}
public
void
removeCellEditorListener
(
CellEditorListener
listener
)
{
l
istenerList
.
remove
(
CellEditorListener
.
class
,
listener
);
evtL
istenerList
.
remove
(
CellEditorListener
.
class
,
listener
);
}
protected
void
fireEditingStopped
()
{
CellEditorListener
listener
;
Object
[]
listeners
=
l
istenerList
.
getListenerList
();
Object
[]
listeners
=
evtL
istenerList
.
getListenerList
();
for
(
int
i
=
0
;
i
<
listeners
.
length
;
i
++)
{
if
(
listeners
[
i
]
==
CellEditorListener
.
class
)
{
listener
=
(
CellEditorListener
)
listeners
[
i
+
1
];
...
...
@@ -87,7 +96,7 @@ public class XTextFieldEditor extends XTextField implements TableCellEditor {
protected
void
fireEditingCanceled
()
{
CellEditorListener
listener
;
Object
[]
listeners
=
l
istenerList
.
getListenerList
();
Object
[]
listeners
=
evtL
istenerList
.
getListenerList
();
for
(
int
i
=
0
;
i
<
listeners
.
length
;
i
++)
{
if
(
listeners
[
i
]
==
CellEditorListener
.
class
)
{
listener
=
(
CellEditorListener
)
listeners
[
i
+
1
];
...
...
test/javax/management/openmbean/CompositeDataStringTest.java
0 → 100644
浏览文件 @
c356b304
/*
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
import
javax.management.openmbean.CompositeType
;
import
javax.management.openmbean.OpenType
;
import
javax.management.openmbean.SimpleType
;
/*
* @test
* @bug 6610174
* @summary Test that CompositeDataSupport.toString() represents arrays correctly
* @author Eamonn McManus
*/
import
javax.management.openmbean.ArrayType
;
import
javax.management.openmbean.CompositeData
;
import
javax.management.openmbean.CompositeDataSupport
;
public
class
CompositeDataStringTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
CompositeType
basicCT
=
new
CompositeType
(
"basicCT"
,
"basic CompositeType"
,
new
String
[]
{
"name"
,
"value"
},
new
String
[]
{
"name"
,
"value"
},
new
OpenType
<?>[]
{
SimpleType
.
STRING
,
SimpleType
.
INTEGER
});
CompositeType
ct
=
new
CompositeType
(
"noddy"
,
"descr"
,
new
String
[]
{
"strings"
,
"ints"
,
"cds"
},
new
String
[]
{
"string array"
,
"int array"
,
"composite data array"
},
new
OpenType
<?>[]
{
ArrayType
.
getArrayType
(
SimpleType
.
STRING
),
ArrayType
.
getPrimitiveArrayType
(
int
[].
class
),
ArrayType
.
getArrayType
(
basicCT
)
});
CompositeData
basicCD1
=
new
CompositeDataSupport
(
basicCT
,
new
String
[]
{
"name"
,
"value"
},
new
Object
[]
{
"ceathar"
,
4
});
CompositeData
basicCD2
=
new
CompositeDataSupport
(
basicCT
,
new
String
[]
{
"name"
,
"value"
},
new
Object
[]
{
"naoi"
,
9
});
CompositeData
cd
=
new
CompositeDataSupport
(
ct
,
new
String
[]
{
"strings"
,
"ints"
,
"cds"
},
new
Object
[]
{
new
String
[]
{
"fred"
,
"jim"
,
"sheila"
},
new
int
[]
{
2
,
3
,
5
,
7
},
new
CompositeData
[]
{
basicCD1
,
basicCD2
}
});
String
s
=
cd
.
toString
();
System
.
out
.
println
(
"CompositeDataSupport.toString(): "
+
s
);
String
[]
expected
=
{
"fred, jim, sheila"
,
"2, 3, 5, 7"
,
"ceathar"
,
"naoi"
,
};
boolean
ok
=
true
;
for
(
String
expect
:
expected
)
{
if
(
s
.
contains
(
expect
))
System
.
out
.
println
(
"OK: string contains <"
+
expect
+
">"
);
else
{
ok
=
false
;
System
.
out
.
println
(
"NOT OK: string does not contain <"
+
expect
+
">"
);
}
}
if
(
ok
)
System
.
out
.
println
(
"TEST PASSED"
);
else
throw
new
Exception
(
"TEST FAILED: string did not contain expected substrings"
);
}
}
test/javax/management/openmbean/TabularDataOrderTest.java
0 → 100644
浏览文件 @
c356b304
/*
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6334663
* @summary Test that TabularDataSupport preserves the order elements were added
* @author Eamonn McManus
*/
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Modifier
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.management.JMX
;
import
javax.management.MBeanServer
;
import
javax.management.MBeanServerFactory
;
import
javax.management.ObjectName
;
import
javax.management.openmbean.CompositeData
;
import
javax.management.openmbean.CompositeDataSupport
;
import
javax.management.openmbean.CompositeType
;
import
javax.management.openmbean.OpenDataException
;
import
javax.management.openmbean.OpenType
;
import
javax.management.openmbean.SimpleType
;
import
javax.management.openmbean.TabularData
;
import
javax.management.openmbean.TabularDataSupport
;
import
javax.management.openmbean.TabularType
;
public
class
TabularDataOrderTest
{
private
static
String
failure
;
private
static
final
String
COMPAT_PROP_NAME
=
"jmx.tabular.data.hash.map"
;
private
static
final
String
[]
intNames
=
{
"unus"
,
"duo"
,
"tres"
,
"quatuor"
,
"quinque"
,
"sex"
,
"septem"
,
"octo"
,
"novem"
,
"decim"
,
};
private
static
final
Map
<
String
,
Integer
>
stringToValue
=
new
LinkedHashMap
<
String
,
Integer
>();
static
{
for
(
int
i
=
0
;
i
<
intNames
.
length
;
i
++)
stringToValue
.
put
(
intNames
[
i
],
i
+
1
);
}
public
static
interface
TestMXBean
{
public
Map
<
String
,
Integer
>
getMap
();
}
public
static
class
TestImpl
implements
TestMXBean
{
public
Map
<
String
,
Integer
>
getMap
()
{
return
stringToValue
;
}
}
private
static
final
CompositeType
ct
;
private
static
final
TabularType
tt
;
static
{
try
{
ct
=
new
CompositeType
(
"a.b.c"
,
"name and int"
,
new
String
[]
{
"name"
,
"int"
},
new
String
[]
{
"name of integer"
,
"value of integer"
},
new
OpenType
<?>[]
{
SimpleType
.
STRING
,
SimpleType
.
INTEGER
});
tt
=
new
TabularType
(
"d.e.f"
,
"name and int indexed by name"
,
ct
,
new
String
[]
{
"name"
});
}
catch
(
OpenDataException
e
)
{
throw
new
AssertionError
(
e
);
}
}
private
static
TabularData
makeTable
()
throws
OpenDataException
{
TabularData
td
=
new
TabularDataSupport
(
tt
);
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
stringToValue
.
entrySet
())
{
CompositeData
cd
=
new
CompositeDataSupport
(
ct
,
new
String
[]
{
"name"
,
"int"
},
new
Object
[]
{
entry
.
getKey
(),
entry
.
getValue
()});
td
.
put
(
cd
);
}
return
td
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
out
.
println
(
"Testing standard behaviour"
);
TabularData
td
=
makeTable
();
System
.
out
.
println
(
td
);
// Test that a default TabularData has the order keys were added in
int
last
=
0
;
boolean
ordered
=
true
;
for
(
Object
x
:
td
.
values
())
{
CompositeData
cd
=
(
CompositeData
)
x
;
String
name
=
(
String
)
cd
.
get
(
"name"
);
int
value
=
(
Integer
)
cd
.
get
(
"int"
);
System
.
out
.
println
(
name
+
" = "
+
value
);
if
(
last
+
1
!=
value
)
ordered
=
false
;
last
=
value
;
}
if
(!
ordered
)
fail
(
"Order not preserved"
);
// Now test the undocumented property that causes HashMap to be used
// instead of LinkedHashMap, in case serializing to a 1.3 client.
// We serialize and deserialize in case the implementation handles
// this at serialization time. Then we look at object fields; that's
// not guaranteed to work but at worst it will fail spuriously and
// we'll have to update the test.
System
.
out
.
println
(
"Testing compatible behaviour"
);
System
.
setProperty
(
COMPAT_PROP_NAME
,
"true"
);
td
=
makeTable
();
System
.
out
.
println
(
td
);
ByteArrayOutputStream
bout
=
new
ByteArrayOutputStream
();
ObjectOutputStream
oout
=
new
ObjectOutputStream
(
bout
);
oout
.
writeObject
(
td
);
oout
.
close
();
byte
[]
bytes
=
bout
.
toByteArray
();
ByteArrayInputStream
bin
=
new
ByteArrayInputStream
(
bytes
);
ObjectInputStream
oin
=
new
ObjectInputStream
(
bin
);
td
=
(
TabularData
)
oin
.
readObject
();
boolean
found
=
false
;
for
(
Field
f
:
td
.
getClass
().
getDeclaredFields
())
{
if
(
Modifier
.
isStatic
(
f
.
getModifiers
()))
continue
;
f
.
setAccessible
(
true
);
Object
x
=
f
.
get
(
td
);
if
(
x
!=
null
&&
x
.
getClass
()
==
HashMap
.
class
)
{
found
=
true
;
System
.
out
.
println
(
x
.
getClass
().
getName
()
+
" TabularDataSupport."
+
f
.
getName
()
+
" = "
+
x
);
break
;
}
}
if
(!
found
)
{
fail
(
"TabularDataSupport does not contain HashMap though "
+
COMPAT_PROP_NAME
+
"=true"
);
}
System
.
clearProperty
(
COMPAT_PROP_NAME
);
System
.
out
.
println
(
"Testing MXBean behaviour"
);
MBeanServer
mbs
=
MBeanServerFactory
.
newMBeanServer
();
ObjectName
name
=
new
ObjectName
(
"a:b=c"
);
mbs
.
registerMBean
(
new
TestImpl
(),
name
);
TestMXBean
proxy
=
JMX
.
newMXBeanProxy
(
mbs
,
name
,
TestMXBean
.
class
);
Map
<
String
,
Integer
>
map
=
proxy
.
getMap
();
List
<
String
>
origNames
=
new
ArrayList
<
String
>(
stringToValue
.
keySet
());
List
<
String
>
proxyNames
=
new
ArrayList
<
String
>(
map
.
keySet
());
if
(!
origNames
.
equals
(
proxyNames
))
fail
(
"Order mangled after passage through MXBean: "
+
proxyNames
);
if
(
failure
==
null
)
System
.
out
.
println
(
"TEST PASSED"
);
else
throw
new
Exception
(
"TEST FAILED: "
+
failure
);
}
private
static
void
fail
(
String
why
)
{
System
.
out
.
println
(
"FAILED: "
+
why
);
failure
=
why
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录