author | vlivanov |
Thu, 18 Jan 2018 02:25:18 +0300 | |
changeset 48596 | 860326263d1f |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
12851
diff
changeset
|
2 |
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
55
5ecee29e98d8
6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents:
2
diff
changeset
|
25 |
|
2 | 26 |
package sun.tools.jconsole.inspector; |
27 |
||
28 |
import java.awt.*; |
|
29 |
import javax.swing.*; |
|
30 |
import javax.management.*; |
|
31 |
||
32 |
@SuppressWarnings("serial") |
|
33 |
public class OperationEntry extends JPanel { |
|
34 |
private MBeanOperationInfo operation; |
|
35 |
private XTextField inputs[]; |
|
36 |
||
37 |
public OperationEntry (MBeanOperationInfo operation, |
|
38 |
boolean isCallable, |
|
39 |
JButton button, |
|
40 |
XOperations xoperations) { |
|
41 |
super(new BorderLayout()); |
|
42 |
this.operation = operation; |
|
43 |
setLayout(new FlowLayout(FlowLayout.LEFT)); |
|
44 |
setPanel(isCallable, button, xoperations); |
|
45 |
} |
|
46 |
||
12851
3334e1c781d0
7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents:
5506
diff
changeset
|
47 |
private void setPanel(boolean isCallable, |
2 | 48 |
JButton button, |
49 |
XOperations xoperations) { |
|
50 |
try { |
|
51 |
MBeanParameterInfo params[] = operation.getSignature(); |
|
52 |
add(new JLabel("(",JLabel.CENTER)); |
|
53 |
inputs = new XTextField[params.length]; |
|
54 |
for (int i = 0; i < params.length; i++) { |
|
55 |
if(params[i].getName() != null) { |
|
56 |
JLabel name = |
|
57 |
new JLabel(params[i].getName(), JLabel.CENTER); |
|
58 |
name.setToolTipText(params[i].getDescription()); |
|
59 |
add(name); |
|
60 |
} |
|
61 |
||
62 |
String defaultTextValue = |
|
63 |
Utils.getDefaultValue(params[i].getType()); |
|
64 |
int fieldWidth = defaultTextValue.length(); |
|
65 |
if (fieldWidth > 15) fieldWidth = 15; |
|
66 |
else |
|
67 |
if (fieldWidth < 10) fieldWidth = 10; |
|
68 |
||
69 |
add(inputs[i] = |
|
70 |
new XTextField(Utils.getReadableClassName(defaultTextValue), |
|
71 |
Utils.getClass(params[i].getType()), |
|
72 |
fieldWidth, |
|
73 |
isCallable, |
|
74 |
button, |
|
75 |
xoperations)); |
|
76 |
inputs[i].setHorizontalAlignment(SwingConstants.CENTER); |
|
77 |
||
78 |
if (i < params.length-1) |
|
79 |
add(new JLabel(",",JLabel.CENTER)); |
|
80 |
} |
|
81 |
add(new JLabel(")",JLabel.CENTER)); |
|
82 |
validate(); |
|
83 |
doLayout(); |
|
84 |
} |
|
85 |
catch (Exception e) { |
|
86 |
System.out.println("Error setting Operation panel :"+ |
|
87 |
e.getMessage()); |
|
88 |
} |
|
89 |
} |
|
90 |
||
91 |
public String[] getSignature() { |
|
92 |
MBeanParameterInfo params[] = operation.getSignature(); |
|
93 |
String result[] = new String[params.length]; |
|
94 |
for (int i = 0; i < params.length; i++) { |
|
95 |
result[i] = params[i].getType(); |
|
96 |
} |
|
97 |
return result; |
|
98 |
} |
|
99 |
||
100 |
public Object[] getParameters() throws Exception { |
|
101 |
MBeanParameterInfo params[] = operation.getSignature(); |
|
102 |
String signature[] = new String[params.length]; |
|
103 |
for (int i = 0; i < params.length; i++) |
|
104 |
signature[i] = params[i].getType(); |
|
105 |
return Utils.getParameters(inputs,signature); |
|
106 |
} |
|
107 |
||
108 |
public String getReturnType() { |
|
109 |
return operation.getReturnType(); |
|
110 |
} |
|
111 |
} |