Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
3e28ab1d
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看板
提交
3e28ab1d
编写于
8月 08, 2008
作者:
E
emcmanus
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
fbcf965a
4303a2c1
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
496 addition
and
240 deletion
+496
-240
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/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
未找到文件。
make/netbeans/jconsole/build.properties
浏览文件 @
3e28ab1d
...
@@ -44,3 +44,4 @@ build.jdk.version = 1.7.0
...
@@ -44,3 +44,4 @@ build.jdk.version = 1.7.0
build.release
=
${build.jdk.version}-opensource
build.release
=
${build.jdk.version}-opensource
build.number
=
b00
build.number
=
b00
jconsole.version
=
${build.release}-${user.name}-${build.number}
jconsole.version
=
${build.release}-${user.name}-${build.number}
jconsole.args
=
-debug
make/netbeans/jconsole/build.xml
浏览文件 @
3e28ab1d
...
@@ -30,9 +30,9 @@
...
@@ -30,9 +30,9 @@
-->
-->
<project
name=
"jconsole"
default=
"build"
basedir=
"."
>
<project
name=
"jconsole"
default=
"build"
basedir=
"."
>
<import
file=
"../common/shared.xml"
/>
<import
file=
"../common/shared.xml"
/>
<target
name=
"-pre-compile"
>
<target
name=
"-pre-compile"
>
<copy
<copy
file=
"${root}/src/share/classes/sun/tools/jconsole/Version-template.java"
file=
"${root}/src/share/classes/sun/tools/jconsole/Version-template.java"
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
token=
"@@jconsole_version@@"
token=
"@@jconsole_version@@"
value=
"${jconsole.version}"
/>
value=
"${jconsole.version}"
/>
</target>
</target>
<target
name=
"-post-compile"
>
<target
name=
"-post-compile"
>
<mkdir
dir=
"${dist.dir}/lib"
/>
<mkdir
dir=
"${dist.dir}/lib"
/>
<jar
destfile=
"${dist.dir}/lib/jconsole.jar"
<jar
destfile=
"${dist.dir}/lib/jconsole.jar"
...
@@ -55,18 +55,19 @@
...
@@ -55,18 +55,19 @@
</fileset>
</fileset>
</jar>
</jar>
</target>
</target>
<target
name=
"run"
depends=
"-init,build"
>
<target
name=
"run"
depends=
"-init,build"
>
<property
name=
"jvm.args"
value=
""
/>
<property
name=
"jvm.args"
value=
""
/>
<java
classname=
"sun.tools.jconsole.JConsole"
<java
classname=
"sun.tools.jconsole.JConsole"
fork=
"true"
fork=
"true"
classpath=
"${classes.dir}:${bootstrap.jdk}/lib/tools.jar"
>
classpath=
"${classes.dir}:${bootstrap.jdk}/lib/tools.jar"
>
<jvmarg
line=
"${jvm.args}"
/>
<jvmarg
line=
"${jvm.args}"
/>
<arg
line=
"${jconsole.args}"
/>
</java>
</java>
</target>
</target>
<target
name=
"clean"
depends=
"-init,shared.clean"
>
<target
name=
"clean"
depends=
"-init,shared.clean"
>
<delete
file=
"${dist.dir}/lib/jconsole.jar"
/>
<delete
file=
"${dist.dir}/lib/jconsole.jar"
/>
</target>
</target>
</project>
</project>
src/share/classes/sun/tools/jconsole/inspector/TableSorter.java
浏览文件 @
3e28ab1d
...
@@ -25,71 +25,78 @@
...
@@ -25,71 +25,78 @@
package
sun.tools.jconsole.inspector
;
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.
// Imports for picking up mouse events from the JTable.
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
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.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.JTableHeader
;
import
javax.swing.table.TableColumnModel
;
import
javax.swing.table.TableColumnModel
;
import
sun.tools.jconsole.JConsole
;
@SuppressWarnings
(
"serial"
)
@SuppressWarnings
(
"serial"
)
public
class
TableSorter
extends
DefaultTableModel
implements
MouseListener
{
public
class
TableSorter
extends
DefaultTableModel
implements
MouseListener
{
private
boolean
ascending
=
true
;
private
boolean
ascending
=
true
;
private
TableColumnModel
columnModel
;
private
TableColumnModel
columnModel
;
private
JTable
tableView
;
private
JTable
tableView
;
private
Vector
<
TableModelListener
>
l
istenerList
;
private
Vector
<
TableModelListener
>
evtL
istenerList
;
private
int
sortColumn
=
0
;
private
int
sortColumn
=
0
;
private
int
[]
invertedIndex
;
private
int
[]
invertedIndex
;
public
TableSorter
()
{
public
TableSorter
()
{
super
();
super
();
l
istenerList
=
new
Vector
<
TableModelListener
>();
evtL
istenerList
=
new
Vector
<
TableModelListener
>();
}
}
public
TableSorter
(
Object
[]
columnNames
,
int
numRows
)
{
public
TableSorter
(
Object
[]
columnNames
,
int
numRows
)
{
super
(
columnNames
,
numRows
);
super
(
columnNames
,
numRows
);
l
istenerList
=
new
Vector
<
TableModelListener
>();
evtL
istenerList
=
new
Vector
<
TableModelListener
>();
}
}
@Override
public
void
newDataAvailable
(
TableModelEvent
e
)
{
public
void
newDataAvailable
(
TableModelEvent
e
)
{
super
.
newDataAvailable
(
e
);
super
.
newDataAvailable
(
e
);
invertedIndex
=
new
int
[
getRowCount
()];
invertedIndex
=
new
int
[
getRowCount
()];
for
(
int
i
=
0
;
i
<
invertedIndex
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
invertedIndex
.
length
;
i
++)
{
invertedIndex
[
i
]
=
i
;
invertedIndex
[
i
]
=
i
;
}
}
sort
(
this
.
sortColumn
);
sort
(
this
.
sortColumn
,
this
.
ascending
);
}
}
@Override
public
void
addTableModelListener
(
TableModelListener
l
)
{
public
void
addTableModelListener
(
TableModelListener
l
)
{
l
istenerList
.
add
(
l
);
evtL
istenerList
.
add
(
l
);
super
.
addTableModelListener
(
l
);
super
.
addTableModelListener
(
l
);
}
}
@Override
public
void
removeTableModelListener
(
TableModelListener
l
)
{
public
void
removeTableModelListener
(
TableModelListener
l
)
{
l
istenerList
.
remove
(
l
);
evtL
istenerList
.
remove
(
l
);
super
.
removeTableModelListener
(
l
);
super
.
removeTableModelListener
(
l
);
}
}
private
void
removeListeners
()
{
private
void
removeListeners
()
{
for
(
TableModelListener
tnl
:
l
istenerList
)
for
(
TableModelListener
tnl
:
evtL
istenerList
)
super
.
removeTableModelListener
(
tnl
);
super
.
removeTableModelListener
(
tnl
);
}
}
private
void
restoreListeners
()
{
private
void
restoreListeners
()
{
for
(
TableModelListener
tnl
:
l
istenerList
)
for
(
TableModelListener
tnl
:
evtL
istenerList
)
super
.
addTableModelListener
(
tnl
);
super
.
addTableModelListener
(
tnl
);
}
}
@SuppressWarnings
(
"unchecked"
)
@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
)
if
(
o1
==
null
)
return
1
;
return
1
;
if
(
o2
==
null
)
if
(
o2
==
null
)
...
@@ -104,18 +111,40 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
...
@@ -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
// remove registered listeners
removeListeners
();
removeListeners
();
// do the sort
// 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
// restore registered listeners
restoreListeners
();
restoreListeners
();
this
.
sortColumn
=
column
;
// update row heights in XMBeanAttributes (required by expandable cells)
// update row heights in XMBeanAttributes (required by expandable cells)
if
(
tableView
instanceof
XMBeanAttributes
)
{
if
(
attrs
!=
null
)
{
XMBeanAttributes
attrs
=
(
XMBeanAttributes
)
tableView
;
for
(
int
i
=
0
;
i
<
getRowCount
();
i
++)
{
for
(
int
i
=
0
;
i
<
getRowCount
();
i
++)
{
Vector
data
=
(
Vector
)
dataVector
.
elementAt
(
i
);
Vector
data
=
(
Vector
)
dataVector
.
elementAt
(
i
);
attrs
.
updateRowHeight
(
data
.
elementAt
(
1
),
i
);
attrs
.
updateRowHeight
(
data
.
elementAt
(
1
),
i
);
...
@@ -123,21 +152,21 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
...
@@ -123,21 +152,21 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
}
}
}
}
private
synchronized
boolean
compareS
(
Object
s1
,
Object
s2
)
{
private
boolean
compareS
(
Object
s1
,
Object
s2
,
boolean
isAscending
)
{
if
(
a
scending
)
if
(
isA
scending
)
return
(
compare
(
s1
,
s2
)
>
0
);
return
(
compare
(
s1
,
s2
)
>
0
);
else
else
return
(
compare
(
s1
,
s2
)
<
0
);
return
(
compare
(
s1
,
s2
)
<
0
);
}
}
private
synchronized
boolean
compareG
(
Object
s1
,
Object
s2
)
{
private
boolean
compareG
(
Object
s1
,
Object
s2
,
boolean
isAscending
)
{
if
(
a
scending
)
if
(
isA
scending
)
return
(
compare
(
s1
,
s2
)
<
0
);
return
(
compare
(
s1
,
s2
)
<
0
);
else
else
return
(
compare
(
s1
,
s2
)
>
0
);
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
lo
=
lo0
;
int
hi
=
hi0
;
int
hi
=
hi0
;
Object
mid
;
Object
mid
;
...
@@ -153,14 +182,14 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
...
@@ -153,14 +182,14 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
* from the left Index.
* from the left Index.
*/
*/
while
(
(
lo
<
hi0
)
&&
while
(
(
lo
<
hi0
)
&&
(
compareS
(
mid
,
getValueAt
(
lo
,
key
))
))
(
compareS
(
mid
,
getValueAt
(
lo
,
key
)
,
isAscending
)
))
++
lo
;
++
lo
;
/* find an element that is smaller than or equal to
/* find an element that is smaller than or equal to
* the partition element starting from the right Index.
* the partition element starting from the right Index.
*/
*/
while
(
(
hi
>
lo0
)
&&
while
(
(
hi
>
lo0
)
&&
(
compareG
(
mid
,
getValueAt
(
hi
,
key
))
))
(
compareG
(
mid
,
getValueAt
(
hi
,
key
)
,
isAscending
)
))
--
hi
;
--
hi
;
// if the indexes have not crossed, swap
// if the indexes have not crossed, swap
...
@@ -177,27 +206,17 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
...
@@ -177,27 +206,17 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
* must now sort the left partition.
* must now sort the left partition.
*/
*/
if
(
lo0
<
hi
)
if
(
lo0
<
hi
)
quickSort
(
lo0
,
hi
,
key
);
quickSort
(
lo0
,
hi
,
key
,
isAscending
);
/* If the left index has not reached the right
/* If the left index has not reached the right
* side of array
* side of array
* must now sort the right partition.
* must now sort the right partition.
*/
*/
if
(
lo
<=
hi0
)
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
)
{
private
Vector
getRow
(
int
row
)
{
return
(
Vector
)
dataVector
.
elementAt
(
row
);
return
(
Vector
)
dataVector
.
elementAt
(
row
);
}
}
...
@@ -207,7 +226,7 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
...
@@ -207,7 +226,7 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
dataVector
.
setElementAt
(
data
,
row
);
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
);
Vector
data
=
getRow
(
i
);
setRow
(
getRow
(
j
),
i
);
setRow
(
getRow
(
j
),
i
);
setRow
(
data
,
j
);
setRow
(
data
,
j
);
...
@@ -223,11 +242,12 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
...
@@ -223,11 +242,12 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
public
void
sortByColumn
(
int
column
,
boolean
ascending
)
{
public
void
sortByColumn
(
int
column
,
boolean
ascending
)
{
this
.
ascending
=
ascending
;
this
.
ascending
=
ascending
;
sort
(
column
);
this
.
sortColumn
=
column
;
sort
(
column
,
ascending
);
}
}
public
int
[]
getInvertedIndex
(
)
{
public
int
getIndexOfRow
(
int
row
)
{
return
invertedIndex
;
return
invertedIndex
[
row
]
;
}
}
// Add a mouse listener to the Table to trigger a table sort
// Add a mouse listener to the Table to trigger a table sort
...
@@ -243,6 +263,14 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
...
@@ -243,6 +263,14 @@ public class TableSorter extends DefaultTableModel implements MouseListener {
int
viewColumn
=
columnModel
.
getColumnIndexAtX
(
e
.
getX
());
int
viewColumn
=
columnModel
.
getColumnIndexAtX
(
e
.
getX
());
int
column
=
tableView
.
convertColumnIndexToModel
(
viewColumn
);
int
column
=
tableView
.
convertColumnIndexToModel
(
viewColumn
);
if
(
e
.
getClickCount
()
==
1
&&
column
!=
-
1
)
{
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
();
tableView
.
invalidate
();
sortByColumn
(
column
);
sortByColumn
(
column
);
tableView
.
validate
();
tableView
.
validate
();
...
...
src/share/classes/sun/tools/jconsole/inspector/XMBeanAttributes.java
浏览文件 @
3e28ab1d
...
@@ -25,31 +25,49 @@
...
@@ -25,31 +25,49 @@
package
sun.tools.jconsole.inspector
;
package
sun.tools.jconsole.inspector
;
import
javax.swing.*
;
import
javax.swing.event.*
;
import
javax.swing.table.*
;
import
javax.swing.tree.*
;
import
java.awt.BorderLayout
;
import
java.awt.Color
;
import
java.awt.GridLayout
;
import
java.awt.FlowLayout
;
import
java.awt.Component
;
import
java.awt.Component
;
import
java.awt.EventQueue
;
import
java.awt.EventQueue
;
import
java.awt.event.*
;
import
java.awt.Insets
;
import
java.awt.Dimension
;
import
java.awt.Dimension
;
import
java.util.*
;
import
java.awt.event.MouseAdapter
;
import
java.io.*
;
import
java.awt.event.MouseEvent
;
import
java.io.IOException
;
import
java.lang.reflect.Array
;
import
java.lang.reflect.Array
;
import
javax.management.*
;
import
java.util.EventObject
;
import
java.util.HashMap
;
import
java.util.WeakHashMap
;
import
java.util.concurrent.ExecutionException
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
javax.management.JMException
;
import
javax.management.MBeanInfo
;
import
javax.management.MBeanAttributeInfo
;
import
javax.management.AttributeList
;
import
javax.management.Attribute
;
import
javax.management.openmbean.CompositeData
;
import
javax.management.openmbean.CompositeData
;
import
javax.management.openmbean.TabularData
;
import
javax.management.openmbean.TabularData
;
import
javax.swing.JComponent
;
import
javax.swing.JOptionPane
;
import
javax.swing.JTable
;
import
javax.swing.JTextField
;
import
javax.swing.SwingWorker
;
import
javax.swing.event.ChangeEvent
;
import
javax.swing.event.TableModelEvent
;
import
javax.swing.event.TableModelListener
;
import
javax.swing.table.DefaultTableCellRenderer
;
import
javax.swing.table.DefaultTableModel
;
import
javax.swing.table.TableCellEditor
;
import
javax.swing.table.TableCellRenderer
;
import
javax.swing.table.TableColumn
;
import
javax.swing.table.TableColumnModel
;
import
javax.swing.table.TableModel
;
import
sun.tools.jconsole.Resources
;
import
sun.tools.jconsole.Resources
;
import
sun.tools.jconsole.MBeansTab
;
import
sun.tools.jconsole.MBeansTab
;
import
sun.tools.jconsole.Plotter
;
import
sun.tools.jconsole.JConsole
;
import
sun.tools.jconsole.JConsole
;
import
sun.tools.jconsole.ProxyClient.SnapshotMBeanServerConnection
;
import
sun.tools.jconsole.ProxyClient.SnapshotMBeanServerConnection
;
...
@@ -61,12 +79,14 @@ import sun.tools.jconsole.ProxyClient.SnapshotMBeanServerConnection;
...
@@ -61,12 +79,14 @@ import sun.tools.jconsole.ProxyClient.SnapshotMBeanServerConnection;
COMPULSORY to not call the JMX world in synchronized blocks */
COMPULSORY to not call the JMX world in synchronized blocks */
@SuppressWarnings
(
"serial"
)
@SuppressWarnings
(
"serial"
)
public
class
XMBeanAttributes
extends
XTable
{
public
class
XMBeanAttributes
extends
XTable
{
final
Logger
LOGGER
=
Logger
.
getLogger
(
XMBeanAttributes
.
class
.
getPackage
().
getName
());
private
final
static
String
[]
columnNames
=
private
final
static
String
[]
columnNames
=
{
Resources
.
getText
(
"Name"
),
{
Resources
.
getText
(
"Name"
),
Resources
.
getText
(
"Value"
)};
Resources
.
getText
(
"Value"
)};
private
boolean
editable
=
true
;
private
XMBean
mbean
;
private
XMBean
mbean
;
private
MBeanInfo
mbeanInfo
;
private
MBeanInfo
mbeanInfo
;
private
MBeanAttributeInfo
[]
attributesInfo
;
private
MBeanAttributeInfo
[]
attributesInfo
;
...
@@ -75,9 +95,8 @@ public class XMBeanAttributes extends XTable {
...
@@ -75,9 +95,8 @@ public class XMBeanAttributes extends XTable {
private
HashMap
<
String
,
Object
>
viewableAttributes
;
private
HashMap
<
String
,
Object
>
viewableAttributes
;
private
WeakHashMap
<
XMBean
,
HashMap
<
String
,
ZoomedCell
>>
viewersCache
=
private
WeakHashMap
<
XMBean
,
HashMap
<
String
,
ZoomedCell
>>
viewersCache
=
new
WeakHashMap
<
XMBean
,
HashMap
<
String
,
ZoomedCell
>>();
new
WeakHashMap
<
XMBean
,
HashMap
<
String
,
ZoomedCell
>>();
private
TableModelListener
attributesListener
;
private
final
TableModelListener
attributesListener
;
private
MBeansTab
mbeansTab
;
private
MBeansTab
mbeansTab
;
private
XTable
table
;
private
TableCellEditor
valueCellEditor
=
new
ValueCellEditor
();
private
TableCellEditor
valueCellEditor
=
new
ValueCellEditor
();
private
int
rowMinHeight
=
-
1
;
private
int
rowMinHeight
=
-
1
;
private
AttributesMouseListener
mouseListener
=
new
AttributesMouseListener
();
private
AttributesMouseListener
mouseListener
=
new
AttributesMouseListener
();
...
@@ -89,8 +108,8 @@ public class XMBeanAttributes extends XTable {
...
@@ -89,8 +108,8 @@ public class XMBeanAttributes extends XTable {
super
();
super
();
this
.
mbeansTab
=
mbeansTab
;
this
.
mbeansTab
=
mbeansTab
;
((
DefaultTableModel
)
getModel
()).
setColumnIdentifiers
(
columnNames
);
((
DefaultTableModel
)
getModel
()).
setColumnIdentifiers
(
columnNames
);
getModel
().
addTableModelListener
(
attributesListener
=
attributesListener
=
new
AttributesListener
(
this
);
new
AttributesListener
(
this
)
);
getModel
().
addTableModelListener
(
attributesListener
);
getColumnModel
().
getColumn
(
NAME_COLUMN
).
setPreferredWidth
(
40
);
getColumnModel
().
getColumn
(
NAME_COLUMN
).
setPreferredWidth
(
40
);
addMouseListener
(
mouseListener
);
addMouseListener
(
mouseListener
);
...
@@ -99,6 +118,7 @@ public class XMBeanAttributes extends XTable {
...
@@ -99,6 +118,7 @@ public class XMBeanAttributes extends XTable {
addKeyListener
(
new
Utils
.
CopyKeyAdapter
());
addKeyListener
(
new
Utils
.
CopyKeyAdapter
());
}
}
@Override
public
synchronized
Component
prepareRenderer
(
TableCellRenderer
renderer
,
public
synchronized
Component
prepareRenderer
(
TableCellRenderer
renderer
,
int
row
,
int
column
)
{
int
row
,
int
column
)
{
//In case we have a repaint thread that is in the process of
//In case we have a repaint thread that is in the process of
...
@@ -124,6 +144,7 @@ public class XMBeanAttributes extends XTable {
...
@@ -124,6 +144,7 @@ public class XMBeanAttributes extends XTable {
setRowHeight
(
row
,
rowMinHeight
);
setRowHeight
(
row
,
rowMinHeight
);
}
}
@Override
public
synchronized
TableCellRenderer
getCellRenderer
(
int
row
,
public
synchronized
TableCellRenderer
getCellRenderer
(
int
row
,
int
column
)
{
int
column
)
{
//In case we have a repaint thread that is in the process of
//In case we have a repaint thread that is in the process of
...
@@ -169,26 +190,40 @@ public class XMBeanAttributes extends XTable {
...
@@ -169,26 +190,40 @@ public class XMBeanAttributes extends XTable {
}
}
public
void
cancelCellEditing
()
{
public
void
cancelCellEditing
()
{
TableCellEditor
editor
=
getCellEditor
();
if
(
LOGGER
.
isLoggable
(
Level
.
FINER
))
{
if
(
editor
!=
null
)
{
LOGGER
.
finer
(
"Cancel Editing Row: "
+
getEditingRow
());
editor
.
cancelCellEditing
();
}
final
TableCellEditor
tableCellEditor
=
getCellEditor
();
if
(
tableCellEditor
!=
null
)
{
tableCellEditor
.
cancelCellEditing
();
}
}
}
}
public
void
stopCellEditing
()
{
public
void
stopCellEditing
()
{
TableCellEditor
editor
=
getCellEditor
();
if
(
LOGGER
.
isLoggable
(
Level
.
FINER
))
{
if
(
editor
!=
null
)
{
LOGGER
.
finer
(
"Stop Editing Row: "
+
getEditingRow
());
editor
.
stopCellEditing
();
}
final
TableCellEditor
tableCellEditor
=
getCellEditor
();
if
(
tableCellEditor
!=
null
)
{
tableCellEditor
.
stopCellEditing
();
}
}
}
}
public
final
boolean
editCellAt
(
int
row
,
int
column
,
EventObject
e
)
{
@Override
public
final
boolean
editCellAt
(
final
int
row
,
final
int
column
,
EventObject
e
)
{
if
(
LOGGER
.
isLoggable
(
Level
.
FINER
))
{
LOGGER
.
finer
(
"editCellAt(row="
+
row
+
", col="
+
column
+
", e="
+
e
+
")"
);
}
if
(
JConsole
.
isDebug
())
{
System
.
err
.
println
(
"edit: "
+
getValueName
(
row
)+
"="
+
getValue
(
row
));
}
boolean
retVal
=
super
.
editCellAt
(
row
,
column
,
e
);
boolean
retVal
=
super
.
editCellAt
(
row
,
column
,
e
);
if
(
retVal
)
{
if
(
retVal
)
{
TableCellEditor
e
ditor
=
final
TableCellEditor
tableCellE
ditor
=
getColumnModel
().
getColumn
(
column
).
getCellEditor
();
getColumnModel
().
getColumn
(
column
).
getCellEditor
();
if
(
e
ditor
==
valueCellEditor
)
{
if
(
tableCellE
ditor
==
valueCellEditor
)
{
((
JComponent
)
e
ditor
).
requestFocus
();
((
JComponent
)
tableCellE
ditor
).
requestFocus
();
}
}
}
}
return
retVal
;
return
retVal
;
...
@@ -213,6 +248,10 @@ public class XMBeanAttributes extends XTable {
...
@@ -213,6 +248,10 @@ public class XMBeanAttributes extends XTable {
public
void
setValueAt
(
Object
value
,
int
row
,
int
column
)
{
public
void
setValueAt
(
Object
value
,
int
row
,
int
column
)
{
if
(!
isCellError
(
row
,
column
)
&&
isColumnEditable
(
column
)
&&
if
(!
isCellError
(
row
,
column
)
&&
isColumnEditable
(
column
)
&&
isWritable
(
row
)
&&
Utils
.
isEditableType
(
getClassName
(
row
)))
{
isWritable
(
row
)
&&
Utils
.
isEditableType
(
getClassName
(
row
)))
{
if
(
JConsole
.
isDebug
())
{
System
.
err
.
println
(
"validating [row="
+
row
+
", column="
+
column
+
"]: "
+
getValueName
(
row
)+
"="
+
value
);
}
super
.
setValueAt
(
value
,
row
,
column
);
super
.
setValueAt
(
value
,
row
,
column
);
}
}
}
}
...
@@ -256,12 +295,14 @@ public class XMBeanAttributes extends XTable {
...
@@ -256,12 +295,14 @@ public class XMBeanAttributes extends XTable {
}
}
}
}
public
Object
getValue
(
int
row
)
{
public
Object
getValue
(
int
row
)
{
return
((
DefaultTableModel
)
getModel
()).
getValueAt
(
row
,
VALUE_COLUMN
);
final
Object
val
=
((
DefaultTableModel
)
getModel
())
.
getValueAt
(
row
,
VALUE_COLUMN
);
return
val
;
}
}
//tool tip only for editable column
//tool tip only for editable column
@Override
public
String
getToolTip
(
int
row
,
int
column
)
{
public
String
getToolTip
(
int
row
,
int
column
)
{
if
(
isCellError
(
row
,
column
))
{
if
(
isCellError
(
row
,
column
))
{
return
(
String
)
unavailableAttributes
.
get
(
getValueName
(
row
));
return
(
String
)
unavailableAttributes
.
get
(
getValueName
(
row
));
...
@@ -302,6 +343,7 @@ public class XMBeanAttributes extends XTable {
...
@@ -302,6 +343,7 @@ public class XMBeanAttributes extends XTable {
* Override JTable method in order to make any call to this method
* Override JTable method in order to make any call to this method
* atomic with TableModel elements.
* atomic with TableModel elements.
*/
*/
@Override
public
synchronized
int
getRowCount
()
{
public
synchronized
int
getRowCount
()
{
return
super
.
getRowCount
();
return
super
.
getRowCount
();
}
}
...
@@ -332,24 +374,67 @@ public class XMBeanAttributes extends XTable {
...
@@ -332,24 +374,67 @@ public class XMBeanAttributes extends XTable {
return
isViewable
;
return
isViewable
;
}
}
public
void
loadAttributes
(
final
XMBean
mbean
,
MBeanInfo
mbeanInfo
)
{
// Call this in EDT
public
void
loadAttributes
(
final
XMBean
mbean
,
final
MBeanInfo
mbeanInfo
)
{
final
SwingWorker
<
Runnable
,
Void
>
load
=
new
SwingWorker
<
Runnable
,
Void
>()
{
@Override
protected
Runnable
doInBackground
()
throws
Exception
{
return
doLoadAttributes
(
mbean
,
mbeanInfo
);
}
@Override
protected
void
done
()
{
try
{
final
Runnable
updateUI
=
get
();
if
(
updateUI
!=
null
)
updateUI
.
run
();
}
catch
(
RuntimeException
x
)
{
throw
x
;
}
catch
(
ExecutionException
x
)
{
if
(
JConsole
.
isDebug
())
{
System
.
err
.
println
(
"Exception raised while loading attributes: "
+
x
.
getCause
());
x
.
printStackTrace
();
}
}
catch
(
InterruptedException
x
)
{
if
(
JConsole
.
isDebug
())
{
System
.
err
.
println
(
"Interrupted while loading attributes: "
+
x
);
x
.
printStackTrace
();
}
}
}
};
mbeansTab
.
workerAdd
(
load
);
}
// Don't call this in EDT, but execute returned Runnable inside
// EDT - typically in the done() method of a SwingWorker
// This method can return null.
private
Runnable
doLoadAttributes
(
final
XMBean
mbean
,
MBeanInfo
infoOrNull
)
throws
JMException
,
IOException
{
// To avoid deadlock with events coming from the JMX side,
// To avoid deadlock with events coming from the JMX side,
// we retrieve all JMX stuff in a non synchronized block.
// we retrieve all JMX stuff in a non synchronized block.
if
(
mbean
==
null
)
return
;
if
(
mbean
==
null
)
return
null
;
final
MBeanInfo
curMBeanInfo
=
final
MBeanAttributeInfo
[]
attributesInfo
=
mbeanInfo
.
getAttributes
();
(
infoOrNull
==
null
)?
mbean
.
getMBeanInfo
():
infoOrNull
;
final
HashMap
<
String
,
Object
>
attributes
=
new
HashMap
<
String
,
Object
>(
attributesInfo
.
length
);
final
MBeanAttributeInfo
[]
attrsInfo
=
curMBeanInfo
.
getAttributes
();
final
HashMap
<
String
,
Object
>
unavailableAttributes
=
final
HashMap
<
String
,
Object
>
attrs
=
new
HashMap
<
String
,
Object
>(
attributesInfo
.
length
);
new
HashMap
<
String
,
Object
>(
attrsInfo
.
length
);
final
HashMap
<
String
,
Object
>
viewableAttributes
=
final
HashMap
<
String
,
Object
>
unavailableAttrs
=
new
HashMap
<
String
,
Object
>(
attributesInfo
.
length
);
new
HashMap
<
String
,
Object
>(
attrsInfo
.
length
);
final
HashMap
<
String
,
Object
>
viewableAttrs
=
new
HashMap
<
String
,
Object
>(
attrsInfo
.
length
);
AttributeList
list
=
null
;
AttributeList
list
=
null
;
try
{
try
{
list
=
mbean
.
getAttributes
(
attr
ibute
sInfo
);
list
=
mbean
.
getAttributes
(
attrsInfo
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
if
(
JConsole
.
isDebug
())
{
if
(
JConsole
.
isDebug
())
{
System
.
err
.
println
(
"Error calling getAttributes() on MBean \""
+
System
.
err
.
println
(
"Error calling getAttributes() on MBean \""
+
mbean
.
getObjectName
()
+
"\". JConsole will "
+
mbean
.
getObjectName
()
+
"\". JConsole will "
+
...
@@ -359,18 +444,18 @@ public class XMBeanAttributes extends XTable {
...
@@ -359,18 +444,18 @@ public class XMBeanAttributes extends XTable {
}
}
list
=
new
AttributeList
();
list
=
new
AttributeList
();
//Can't load all attributes, do it one after each other.
//Can't load all attributes, do it one after each other.
for
(
int
i
=
0
;
i
<
attr
ibute
sInfo
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
attrsInfo
.
length
;
i
++)
{
String
name
=
null
;
String
name
=
null
;
try
{
try
{
name
=
attr
ibute
sInfo
[
i
].
getName
();
name
=
attrsInfo
[
i
].
getName
();
Object
value
=
Object
value
=
mbean
.
getMBeanServerConnection
().
getAttribute
(
mbean
.
getObjectName
(),
name
);
mbean
.
getMBeanServerConnection
().
getAttribute
(
mbean
.
getObjectName
(),
name
);
list
.
add
(
new
Attribute
(
name
,
value
));
list
.
add
(
new
Attribute
(
name
,
value
));
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
if
(
attributesInfo
[
i
].
isReadable
())
{
if
(
attrsInfo
[
i
].
isReadable
())
{
unavailableAttributes
.
put
(
name
,
unavailableAttrs
.
put
(
name
,
Utils
.
getActualException
(
ex
).
Utils
.
getActualException
(
ex
).
toString
());
toString
());
}
}
}
}
}
}
...
@@ -380,22 +465,22 @@ public class XMBeanAttributes extends XTable {
...
@@ -380,22 +465,22 @@ public class XMBeanAttributes extends XTable {
for
(
int
i
=
0
;
i
<
att_length
;
i
++)
{
for
(
int
i
=
0
;
i
<
att_length
;
i
++)
{
Attribute
attribute
=
(
Attribute
)
list
.
get
(
i
);
Attribute
attribute
=
(
Attribute
)
list
.
get
(
i
);
if
(
isViewable
(
attribute
))
{
if
(
isViewable
(
attribute
))
{
viewableAttr
ibute
s
.
put
(
attribute
.
getName
(),
viewableAttrs
.
put
(
attribute
.
getName
(),
attribute
.
getValue
());
attribute
.
getValue
());
}
}
else
else
attr
ibute
s
.
put
(
attribute
.
getName
(),
attribute
.
getValue
());
attrs
.
put
(
attribute
.
getName
(),
attribute
.
getValue
());
}
}
// if not all attributes are accessible,
// if not all attributes are accessible,
// check them one after the other.
// check them one after the other.
if
(
att_length
<
attr
ibute
sInfo
.
length
)
{
if
(
att_length
<
attrsInfo
.
length
)
{
for
(
int
i
=
0
;
i
<
attr
ibute
sInfo
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
attrsInfo
.
length
;
i
++)
{
MBeanAttributeInfo
attributeInfo
=
attr
ibute
sInfo
[
i
];
MBeanAttributeInfo
attributeInfo
=
attrsInfo
[
i
];
if
(!
attr
ibute
s
.
containsKey
(
attributeInfo
.
getName
())
&&
if
(!
attrs
.
containsKey
(
attributeInfo
.
getName
())
&&
!
viewableAttr
ibute
s
.
containsKey
(
attributeInfo
.
!
viewableAttrs
.
containsKey
(
attributeInfo
.
getName
())
&&
getName
())
&&
!
unavailableAttr
ibute
s
.
containsKey
(
attributeInfo
.
!
unavailableAttrs
.
containsKey
(
attributeInfo
.
getName
()))
{
getName
()))
{
if
(
attributeInfo
.
isReadable
())
{
if
(
attributeInfo
.
isReadable
())
{
// getAttributes didn't help resolving the
// getAttributes didn't help resolving the
...
@@ -408,16 +493,13 @@ public class XMBeanAttributes extends XTable {
...
@@ -408,16 +493,13 @@ public class XMBeanAttributes extends XTable {
mbean
.
getObjectName
(),
attributeInfo
.
getName
());
mbean
.
getObjectName
(),
attributeInfo
.
getName
());
//What happens if now it is ok?
//What happens if now it is ok?
// Be pragmatic, add it to readable...
// Be pragmatic, add it to readable...
attr
ibute
s
.
put
(
attributeInfo
.
getName
(),
attrs
.
put
(
attributeInfo
.
getName
(),
v
);
v
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
//Put the exception that will be displayed
//Put the exception that will be displayed
// in tooltip
// in tooltip
unavailableAttributes
.
put
(
attributeInfo
.
unavailableAttrs
.
put
(
attributeInfo
.
getName
(),
getName
(),
Utils
.
getActualException
(
e
).
toString
());
Utils
.
getActualException
(
e
)
.
toString
());
}
}
}
}
}
}
...
@@ -426,10 +508,10 @@ public class XMBeanAttributes extends XTable {
...
@@ -426,10 +508,10 @@ public class XMBeanAttributes extends XTable {
}
}
catch
(
Exception
e
)
{
catch
(
Exception
e
)
{
//sets all attributes unavailable except the writable ones
//sets all attributes unavailable except the writable ones
for
(
int
i
=
0
;
i
<
attr
ibute
sInfo
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
attrsInfo
.
length
;
i
++)
{
MBeanAttributeInfo
attributeInfo
=
attr
ibute
sInfo
[
i
];
MBeanAttributeInfo
attributeInfo
=
attrsInfo
[
i
];
if
(
attributeInfo
.
isReadable
())
{
if
(
attributeInfo
.
isReadable
())
{
unavailableAttr
ibute
s
.
put
(
attributeInfo
.
getName
(),
unavailableAttrs
.
put
(
attributeInfo
.
getName
(),
Utils
.
getActualException
(
e
).
Utils
.
getActualException
(
e
).
toString
());
toString
());
}
}
...
@@ -438,40 +520,36 @@ public class XMBeanAttributes extends XTable {
...
@@ -438,40 +520,36 @@ public class XMBeanAttributes extends XTable {
//end of retrieval
//end of retrieval
//one update at a time
//one update at a time
synchronized
(
this
)
{
return
new
Runnable
()
{
public
void
run
()
{
synchronized
(
XMBeanAttributes
.
this
)
{
XMBeanAttributes
.
this
.
mbean
=
mbean
;
XMBeanAttributes
.
this
.
mbeanInfo
=
curMBeanInfo
;
XMBeanAttributes
.
this
.
attributesInfo
=
attrsInfo
;
XMBeanAttributes
.
this
.
attributes
=
attrs
;
XMBeanAttributes
.
this
.
unavailableAttributes
=
unavailableAttrs
;
XMBeanAttributes
.
this
.
viewableAttributes
=
viewableAttrs
;
this
.
mbean
=
mbean
;
this
.
mbeanInfo
=
mbeanInfo
;
this
.
attributesInfo
=
attributesInfo
;
this
.
attributes
=
attributes
;
this
.
unavailableAttributes
=
unavailableAttributes
;
this
.
viewableAttributes
=
viewableAttributes
;
EventQueue
.
invokeLater
(
new
Runnable
()
{
public
void
run
()
{
DefaultTableModel
tableModel
=
DefaultTableModel
tableModel
=
(
DefaultTableModel
)
getModel
();
(
DefaultTableModel
)
getModel
();
// don't listen to these events
tableModel
.
removeTableModelListener
(
attributesListener
);
// add attribute information
// add attribute information
emptyTable
();
emptyTable
(
tableModel
);
addTableData
(
tableModel
,
addTableData
(
tableModel
,
mbean
,
mbean
,
attribute
sInfo
,
attr
sInfo
,
attribute
s
,
attr
s
,
unavailableAttribute
s
,
unavailableAttr
s
,
viewableAttribute
s
);
viewableAttr
s
);
// update the model with the new data
// update the model with the new data
tableModel
.
newDataAvailable
(
new
TableModelEvent
(
tableModel
));
tableModel
.
newDataAvailable
(
new
TableModelEvent
(
tableModel
));
// re-register for change events
// re-register for change events
tableModel
.
addTableModelListener
(
attributesListener
);
tableModel
.
addTableModelListener
(
attributesListener
);
}
}
}
);
}
}
}
;
}
}
void
collapse
(
String
attributeName
,
final
Component
c
)
{
void
collapse
(
String
attributeName
,
final
Component
c
)
{
...
@@ -534,22 +612,80 @@ public class XMBeanAttributes extends XTable {
...
@@ -534,22 +612,80 @@ public class XMBeanAttributes extends XTable {
return
cell
;
return
cell
;
}
}
public
void
refreshAttributes
()
{
// This is called by XSheet when the "refresh" button is pressed.
SnapshotMBeanServerConnection
mbsc
=
mbeansTab
.
getSnapshotMBeanServerConnection
();
// In this case we will commit any pending attribute values by
mbsc
.
flush
();
// calling 'stopCellEditing'.
stopCellEditing
();
//
loadAttributes
(
mbean
,
mbeanInfo
);
public
void
refreshAttributes
()
{
refreshAttributes
(
true
);
}
// refreshAttributes(false) is called by tableChanged().
// in this case we must not call stopCellEditing, because it's already
// been called - e.g.
// lostFocus/mousePressed -> stopCellEditing -> setValueAt -> tableChanged
// -> refreshAttributes(false)
//
// Can be called in EDT - as long as the implementation of
// mbeansTab.getCachedMBeanServerConnection() and mbsc.flush() doesn't
// change
//
private
void
refreshAttributes
(
final
boolean
stopCellEditing
)
{
SwingWorker
<
Void
,
Void
>
sw
=
new
SwingWorker
<
Void
,
Void
>()
{
@Override
protected
Void
doInBackground
()
throws
Exception
{
SnapshotMBeanServerConnection
mbsc
=
mbeansTab
.
getSnapshotMBeanServerConnection
();
mbsc
.
flush
();
return
null
;
}
@Override
protected
void
done
()
{
try
{
get
();
if
(
stopCellEditing
)
stopCellEditing
();
loadAttributes
(
mbean
,
mbeanInfo
);
}
catch
(
Exception
x
)
{
if
(
JConsole
.
isDebug
())
{
x
.
printStackTrace
();
}
}
}
};
mbeansTab
.
workerAdd
(
sw
);
}
}
// We need to call stop editing here - otherwise edits are lost
// when resizing the table.
//
@Override
public
void
columnMarginChanged
(
ChangeEvent
e
)
{
if
(
isEditing
())
stopCellEditing
();
super
.
columnMarginChanged
(
e
);
}
// We need to call stop editing here - otherwise the edited value
// is transferred to the wrong row...
//
@Override
void
sortRequested
(
int
column
)
{
if
(
isEditing
())
stopCellEditing
();
super
.
sortRequested
(
column
);
}
public
void
emptyTable
()
{
@Override
synchronized
(
this
)
{
public
synchronized
void
emptyTable
()
{
((
DefaultTableModel
)
getModel
()).
emptyTable
((
DefaultTableModel
)
getModel
());
removeTableModelListener
(
attributesListener
);
super
.
emptyTable
();
}
}
}
// Call this in synchronized block.
private
void
emptyTable
(
DefaultTableModel
model
)
{
model
.
removeTableModelListener
(
attributesListener
);
super
.
emptyTable
();
}
private
boolean
isViewable
(
Attribute
attribute
)
{
private
boolean
isViewable
(
Attribute
attribute
)
{
Object
data
=
attribute
.
getValue
();
Object
data
=
attribute
.
getValue
();
return
XDataViewer
.
isViewableValue
(
data
);
return
XDataViewer
.
isViewableValue
(
data
);
...
@@ -659,6 +795,7 @@ public class XMBeanAttributes extends XTable {
...
@@ -659,6 +795,7 @@ public class XMBeanAttributes extends XTable {
class
AttributesMouseListener
extends
MouseAdapter
{
class
AttributesMouseListener
extends
MouseAdapter
{
@Override
public
void
mousePressed
(
MouseEvent
e
)
{
public
void
mousePressed
(
MouseEvent
e
)
{
if
(
e
.
getButton
()
==
MouseEvent
.
BUTTON1
)
{
if
(
e
.
getButton
()
==
MouseEvent
.
BUTTON1
)
{
if
(
e
.
getClickCount
()
>=
2
)
{
if
(
e
.
getClickCount
()
>=
2
)
{
...
@@ -674,8 +811,10 @@ public class XMBeanAttributes extends XTable {
...
@@ -674,8 +811,10 @@ public class XMBeanAttributes extends XTable {
}
}
}
}
@SuppressWarnings
(
"serial"
)
class
ValueCellEditor
extends
XTextFieldEditor
{
class
ValueCellEditor
extends
XTextFieldEditor
{
// implements javax.swing.table.TableCellEditor
// implements javax.swing.table.TableCellEditor
@Override
public
Component
getTableCellEditorComponent
(
JTable
table
,
public
Component
getTableCellEditorComponent
(
JTable
table
,
Object
value
,
Object
value
,
boolean
isSelected
,
boolean
isSelected
,
...
@@ -727,6 +866,7 @@ public class XMBeanAttributes extends XTable {
...
@@ -727,6 +866,7 @@ public class XMBeanAttributes extends XTable {
}
}
}
}
@SuppressWarnings
(
"serial"
)
class
MaximizedCellRenderer
extends
DefaultTableCellRenderer
{
class
MaximizedCellRenderer
extends
DefaultTableCellRenderer
{
Component
comp
;
Component
comp
;
MaximizedCellRenderer
(
Component
comp
)
{
MaximizedCellRenderer
(
Component
comp
)
{
...
@@ -736,6 +876,7 @@ public class XMBeanAttributes extends XTable {
...
@@ -736,6 +876,7 @@ public class XMBeanAttributes extends XTable {
comp
.
setPreferredSize
(
new
Dimension
((
int
)
d
.
getWidth
(),
200
));
comp
.
setPreferredSize
(
new
Dimension
((
int
)
d
.
getWidth
(),
200
));
}
}
}
}
@Override
public
Component
getTableCellRendererComponent
(
JTable
table
,
public
Component
getTableCellRendererComponent
(
JTable
table
,
Object
value
,
Object
value
,
boolean
isSelected
,
boolean
isSelected
,
...
@@ -818,6 +959,7 @@ public class XMBeanAttributes extends XTable {
...
@@ -818,6 +959,7 @@ public class XMBeanAttributes extends XTable {
return
minHeight
;
return
minHeight
;
}
}
@Override
public
String
toString
()
{
public
String
toString
()
{
if
(
value
==
null
)
return
null
;
if
(
value
==
null
)
return
null
;
...
@@ -854,45 +996,82 @@ public class XMBeanAttributes extends XTable {
...
@@ -854,45 +996,82 @@ public class XMBeanAttributes extends XTable {
this
.
component
=
component
;
this
.
component
=
component
;
}
}
// Call this in EDT
public
void
tableChanged
(
final
TableModelEvent
e
)
{
public
void
tableChanged
(
final
TableModelEvent
e
)
{
final
TableModel
model
=
(
TableModel
)
e
.
getSource
();
// only post changes to the draggable column
// only post changes to the draggable column
if
(
isColumnEditable
(
e
.
getColumn
()))
{
if
(
isColumnEditable
(
e
.
getColumn
()))
{
mbeansTab
.
workerAdd
(
new
Runnable
()
{
final
TableModel
model
=
(
TableModel
)
e
.
getSource
();
public
void
run
()
{
Object
tableValue
=
model
.
getValueAt
(
e
.
getFirstRow
(),
try
{
e
.
getColumn
());
Object
tableValue
=
model
.
getValueAt
(
e
.
getFirstRow
(),
if
(
LOGGER
.
isLoggable
(
Level
.
FINER
))
{
e
.
getColumn
());
LOGGER
.
finer
(
"tableChanged: firstRow="
+
e
.
getFirstRow
()+
// if it's a String, try construct new value
", lastRow="
+
e
.
getLastRow
()+
", column="
+
e
.
getColumn
()+
// using the defined type.
", value="
+
tableValue
);
if
(
tableValue
instanceof
String
)
{
}
tableValue
=
// if it's a String, try construct new value
Utils
.
createObjectFromString
(
getClassName
(
e
.
getFirstRow
()),
// type
// using the defined type.
(
String
)
tableValue
);
// value
if
(
tableValue
instanceof
String
)
{
}
try
{
String
attributeName
=
tableValue
=
getValueName
(
e
.
getFirstRow
());
Utils
.
createObjectFromString
(
getClassName
(
e
.
getFirstRow
()),
// type
Attribute
attribute
=
(
String
)
tableValue
);
// value
new
Attribute
(
attributeName
,
tableValue
);
}
catch
(
Throwable
ex
)
{
mbean
.
setAttribute
(
attribute
);
popupAndLog
(
ex
,
"tableChanged"
,
}
"Problem setting attribute"
);
catch
(
Throwable
ex
)
{
}
if
(
JConsole
.
isDebug
())
{
}
ex
.
printStackTrace
();
final
String
attributeName
=
getValueName
(
e
.
getFirstRow
());
}
final
Attribute
attribute
=
ex
=
Utils
.
getActualException
(
ex
);
new
Attribute
(
attributeName
,
tableValue
);
setAttribute
(
attribute
,
"tableChanged"
);
String
message
=
(
ex
.
getMessage
()
!=
null
)
?
ex
.
getMessage
()
:
ex
.
toString
();
EventQueue
.
invokeLater
(
new
ThreadDialog
(
component
,
message
+
"\n"
,
Resources
.
getText
(
"Problem setting attribute"
),
JOptionPane
.
ERROR_MESSAGE
));
}
refreshAttributes
();
}
});
}
}
}
}
// Call this in EDT
private
void
setAttribute
(
final
Attribute
attribute
,
final
String
method
)
{
final
SwingWorker
<
Void
,
Void
>
setAttribute
=
new
SwingWorker
<
Void
,
Void
>()
{
@Override
protected
Void
doInBackground
()
throws
Exception
{
try
{
if
(
JConsole
.
isDebug
())
{
System
.
err
.
println
(
"setAttribute("
+
attribute
.
getName
()+
"="
+
attribute
.
getValue
()+
")"
);
}
mbean
.
setAttribute
(
attribute
);
}
catch
(
Throwable
ex
)
{
popupAndLog
(
ex
,
method
,
"Problem setting attribute"
);
}
return
null
;
}
@Override
protected
void
done
()
{
try
{
get
();
}
catch
(
Exception
x
)
{
if
(
JConsole
.
isDebug
())
x
.
printStackTrace
();
}
refreshAttributes
(
false
);
}
};
mbeansTab
.
workerAdd
(
setAttribute
);
}
// Call this outside EDT
private
void
popupAndLog
(
Throwable
ex
,
String
method
,
String
key
)
{
ex
=
Utils
.
getActualException
(
ex
);
if
(
JConsole
.
isDebug
())
ex
.
printStackTrace
();
String
message
=
(
ex
.
getMessage
()
!=
null
)
?
ex
.
getMessage
()
:
ex
.
toString
();
EventQueue
.
invokeLater
(
new
ThreadDialog
(
component
,
message
+
"\n"
,
Resources
.
getText
(
key
),
JOptionPane
.
ERROR_MESSAGE
));
}
}
}
}
}
src/share/classes/sun/tools/jconsole/inspector/XPlotter.java
浏览文件 @
3e28ab1d
...
@@ -37,6 +37,7 @@ public class XPlotter extends Plotter {
...
@@ -37,6 +37,7 @@ public class XPlotter extends Plotter {
super
(
unit
);
super
(
unit
);
this
.
table
=
table
;
this
.
table
=
table
;
}
}
@Override
public
void
addValues
(
long
time
,
long
...
values
)
{
public
void
addValues
(
long
time
,
long
...
values
)
{
super
.
addValues
(
time
,
values
);
super
.
addValues
(
time
,
values
);
table
.
repaint
();
table
.
repaint
();
...
...
src/share/classes/sun/tools/jconsole/inspector/XSheet.java
浏览文件 @
3e28ab1d
...
@@ -25,18 +25,39 @@
...
@@ -25,18 +25,39 @@
package
sun.tools.jconsole.inspector
;
package
sun.tools.jconsole.inspector
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.awt.BorderLayout
;
import
java.io.*
;
import
java.awt.Color
;
import
javax.management.*
;
import
java.awt.Component
;
import
javax.swing.*
;
import
java.awt.Dimension
;
import
javax.swing.border.*
;
import
java.awt.event.ActionEvent
;
import
javax.swing.tree.*
;
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.*
;
import
sun.tools.jconsole.inspector.XNodeInfo.Type
;
import
sun.tools.jconsole.inspector.XNodeInfo.Type
;
import
static
sun
.
tools
.
jconsole
.
Resources
.*;
import
static
sun
.
tools
.
jconsole
.
Resources
.*;
import
static
sun
.
tools
.
jconsole
.
Utilities
.*;
@SuppressWarnings
(
"serial"
)
@SuppressWarnings
(
"serial"
)
public
class
XSheet
extends
JPanel
public
class
XSheet
extends
JPanel
...
@@ -344,34 +365,41 @@ public class XSheet extends JPanel
...
@@ -344,34 +365,41 @@ public class XSheet extends JPanel
return
;
return
;
}
}
mbean
=
(
XMBean
)
uo
.
getData
();
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
@Override
public
Void
doInBackground
()
throws
InstanceNotFoundException
,
public
MBeanInfo
doInBackground
()
throws
InstanceNotFoundException
,
IntrospectionException
,
ReflectionException
,
IOException
{
IntrospectionException
,
ReflectionException
,
IOException
{
mbeanAttributes
.
loadAttributes
(
mbean
,
mbean
.
getMBeanInfo
()
);
MBeanInfo
mbi
=
xmb
.
getMBeanInfo
(
);
return
null
;
return
mbi
;
}
}
@Override
@Override
protected
void
done
()
{
protected
void
done
()
{
try
{
try
{
get
();
MBeanInfo
mbi
=
get
();
if
(!
isSelectedNode
(
node
,
currentNode
))
{
if
(
mbi
!=
null
&&
mbi
.
getAttributes
()
!=
null
&&
return
;
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
)
{
}
catch
(
Exception
e
)
{
Throwable
t
=
Utils
.
getActualException
(
e
);
Throwable
t
=
Utils
.
getActualException
(
e
);
if
(
JConsole
.
isDebug
())
{
if
(
JConsole
.
isDebug
())
{
...
@@ -704,13 +732,7 @@ public class XSheet extends JPanel
...
@@ -704,13 +732,7 @@ public class XSheet extends JPanel
JButton
button
=
(
JButton
)
e
.
getSource
();
JButton
button
=
(
JButton
)
e
.
getSource
();
// Refresh button
// Refresh button
if
(
button
==
refreshButton
)
{
if
(
button
==
refreshButton
)
{
new
SwingWorker
<
Void
,
Void
>()
{
refreshAttributes
();
@Override
public
Void
doInBackground
()
{
refreshAttributes
();
return
null
;
}
}.
execute
();
return
;
return
;
}
}
// Clear button
// Clear button
...
...
src/share/classes/sun/tools/jconsole/inspector/XTable.java
浏览文件 @
3e28ab1d
...
@@ -25,10 +25,13 @@
...
@@ -25,10 +25,13 @@
package
sun.tools.jconsole.inspector
;
package
sun.tools.jconsole.inspector
;
import
javax.swing.*
;
import
java.awt.Color
;
import
javax.swing.table.*
;
import
java.awt.Component
;
import
java.awt.*
;
import
java.awt.Font
;
import
java.io.*
;
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
{
public
abstract
class
XTable
extends
JTable
{
static
final
int
NAME_COLUMN
=
0
;
static
final
int
NAME_COLUMN
=
0
;
...
@@ -38,8 +41,9 @@ public abstract class XTable extends JTable {
...
@@ -38,8 +41,9 @@ public abstract class XTable extends JTable {
public
XTable
()
{
public
XTable
()
{
super
();
super
();
TableSorter
sorter
;
@SuppressWarnings
(
"serial"
)
setModel
(
sorter
=
new
TableSorter
());
final
TableSorter
sorter
=
new
TableSorter
();
setModel
(
sorter
);
sorter
.
addMouseListenerToHeaderInTable
(
this
);
sorter
.
addMouseListenerToHeaderInTable
(
this
);
setRowSelectionAllowed
(
false
);
setRowSelectionAllowed
(
false
);
setColumnSelectionAllowed
(
false
);
setColumnSelectionAllowed
(
false
);
...
@@ -54,6 +58,14 @@ public abstract class XTable extends JTable {
...
@@ -54,6 +58,14 @@ public abstract class XTable extends JTable {
return
editableColor
;
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
* This returns the select index as the table was at initialization
*/
*/
...
@@ -67,7 +79,7 @@ public abstract class XTable extends JTable {
...
@@ -67,7 +79,7 @@ public abstract class XTable extends JTable {
public
int
convertRowToIndex
(
int
row
)
{
public
int
convertRowToIndex
(
int
row
)
{
if
(
row
==
-
1
)
return
row
;
if
(
row
==
-
1
)
return
row
;
if
(
getModel
()
instanceof
TableSorter
)
{
if
(
getModel
()
instanceof
TableSorter
)
{
return
((
(
TableSorter
)
getModel
()).
getInvertedIndex
()[
row
]
);
return
((
TableSorter
)
getModel
()).
getIndexOfRow
(
row
);
}
else
{
}
else
{
return
row
;
return
row
;
}
}
...
@@ -97,6 +109,7 @@ public abstract class XTable extends JTable {
...
@@ -97,6 +109,7 @@ public abstract class XTable extends JTable {
//JTable re-implementation
//JTable re-implementation
//attribute can be editable even if unavailable
//attribute can be editable even if unavailable
@Override
public
boolean
isCellEditable
(
int
row
,
int
col
)
{
public
boolean
isCellEditable
(
int
row
,
int
col
)
{
return
((
isTableEditable
()
&&
isColumnEditable
(
col
)
return
((
isTableEditable
()
&&
isColumnEditable
(
col
)
&&
isWritable
(
row
)
&&
isWritable
(
row
)
...
@@ -118,6 +131,7 @@ public abstract class XTable extends JTable {
...
@@ -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
* This method sets read write rows to be blue, and other rows to be their
* default rendered colour.
* default rendered colour.
*/
*/
@Override
public
TableCellRenderer
getCellRenderer
(
int
row
,
int
column
)
{
public
TableCellRenderer
getCellRenderer
(
int
row
,
int
column
)
{
DefaultTableCellRenderer
tcr
=
DefaultTableCellRenderer
tcr
=
(
DefaultTableCellRenderer
)
super
.
getCellRenderer
(
row
,
column
);
(
DefaultTableCellRenderer
)
super
.
getCellRenderer
(
row
,
column
);
...
@@ -146,6 +160,7 @@ public abstract class XTable extends JTable {
...
@@ -146,6 +160,7 @@ public abstract class XTable extends JTable {
return
tcr
;
return
tcr
;
}
}
@Override
public
Component
prepareRenderer
(
TableCellRenderer
renderer
,
public
Component
prepareRenderer
(
TableCellRenderer
renderer
,
int
row
,
int
column
)
{
int
row
,
int
column
)
{
Component
comp
=
super
.
prepareRenderer
(
renderer
,
row
,
column
);
Component
comp
=
super
.
prepareRenderer
(
renderer
,
row
,
column
);
...
...
src/share/classes/sun/tools/jconsole/inspector/XTextFieldEditor.java
浏览文件 @
3e28ab1d
...
@@ -26,22 +26,30 @@
...
@@ -26,22 +26,30 @@
package
sun.tools.jconsole.inspector
;
package
sun.tools.jconsole.inspector
;
import
java.awt.Component
;
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.util.EventObject
;
import
java.awt.event.*
;
import
javax.swing.JMenuItem
;
import
java.awt.dnd.DragSourceDropEvent
;
import
javax.swing.JTable
;
import
javax.swing.*
;
import
javax.swing.JTextField
;
import
javax.swing.event.*
;
import
javax.swing.event.CellEditorListener
;
import
javax.swing.table.*
;
import
javax.swing.event.ChangeEvent
;
import
javax.swing.event.EventListenerList
;
import
javax.swing.table.TableCellEditor
;
@SuppressWarnings
(
"serial"
)
@SuppressWarnings
(
"serial"
)
public
class
XTextFieldEditor
extends
XTextField
implements
TableCellEditor
{
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
);
protected
ChangeEvent
changeEvent
=
new
ChangeEvent
(
this
);
private
FocusListener
editorFocusListener
=
new
FocusAdapter
()
{
private
FocusListener
editorFocusListener
=
new
FocusAdapter
()
{
@Override
public
void
focusLost
(
FocusEvent
e
)
{
public
void
focusLost
(
FocusEvent
e
)
{
fireEditingStopped
();
// fireEditingStopped();
// must not call fireEditingStopped() here!
}
}
};
};
...
@@ -51,6 +59,7 @@ public class XTextFieldEditor extends XTextField implements TableCellEditor {
...
@@ -51,6 +59,7 @@ public class XTextFieldEditor extends XTextField implements TableCellEditor {
}
}
//edition stopped ou JMenuItem selection & JTextField selection
//edition stopped ou JMenuItem selection & JTextField selection
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
public
void
actionPerformed
(
ActionEvent
e
)
{
super
.
actionPerformed
(
e
);
super
.
actionPerformed
(
e
);
if
((
e
.
getSource
()
instanceof
JMenuItem
)
||
if
((
e
.
getSource
()
instanceof
JMenuItem
)
||
...
@@ -67,16 +76,16 @@ public class XTextFieldEditor extends XTextField implements TableCellEditor {
...
@@ -67,16 +76,16 @@ public class XTextFieldEditor extends XTextField implements TableCellEditor {
//TableCellEditor implementation
//TableCellEditor implementation
public
void
addCellEditorListener
(
CellEditorListener
listener
)
{
public
void
addCellEditorListener
(
CellEditorListener
listener
)
{
l
istenerList
.
add
(
CellEditorListener
.
class
,
listener
);
evtL
istenerList
.
add
(
CellEditorListener
.
class
,
listener
);
}
}
public
void
removeCellEditorListener
(
CellEditorListener
listener
)
{
public
void
removeCellEditorListener
(
CellEditorListener
listener
)
{
l
istenerList
.
remove
(
CellEditorListener
.
class
,
listener
);
evtL
istenerList
.
remove
(
CellEditorListener
.
class
,
listener
);
}
}
protected
void
fireEditingStopped
()
{
protected
void
fireEditingStopped
()
{
CellEditorListener
listener
;
CellEditorListener
listener
;
Object
[]
listeners
=
l
istenerList
.
getListenerList
();
Object
[]
listeners
=
evtL
istenerList
.
getListenerList
();
for
(
int
i
=
0
;
i
<
listeners
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
listeners
.
length
;
i
++)
{
if
(
listeners
[
i
]
==
CellEditorListener
.
class
)
{
if
(
listeners
[
i
]
==
CellEditorListener
.
class
)
{
listener
=
(
CellEditorListener
)
listeners
[
i
+
1
];
listener
=
(
CellEditorListener
)
listeners
[
i
+
1
];
...
@@ -87,7 +96,7 @@ public class XTextFieldEditor extends XTextField implements TableCellEditor {
...
@@ -87,7 +96,7 @@ public class XTextFieldEditor extends XTextField implements TableCellEditor {
protected
void
fireEditingCanceled
()
{
protected
void
fireEditingCanceled
()
{
CellEditorListener
listener
;
CellEditorListener
listener
;
Object
[]
listeners
=
l
istenerList
.
getListenerList
();
Object
[]
listeners
=
evtL
istenerList
.
getListenerList
();
for
(
int
i
=
0
;
i
<
listeners
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
listeners
.
length
;
i
++)
{
if
(
listeners
[
i
]
==
CellEditorListener
.
class
)
{
if
(
listeners
[
i
]
==
CellEditorListener
.
class
)
{
listener
=
(
CellEditorListener
)
listeners
[
i
+
1
];
listener
=
(
CellEditorListener
)
listeners
[
i
+
1
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录