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 *
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.
24 */
25
26 package sun.tools.jconsole.inspector;
27
28 import javax.swing.JTable;
29 import javax.swing.JScrollPane;
30 import javax.swing.JButton;
31
32 import java.awt.event.MouseListener;
33 import java.awt.Component;
34 import java.awt.Container;
35
36 import sun.tools.jconsole.MBeansTab;
37 import sun.tools.jconsole.Resources;
38
39 public class XDataViewer {
40
41 public static final int OPEN = 1;
42 public static final int ARRAY = 2;
43 public static final int NUMERIC = 3;
44 public static final int NOT_SUPPORTED = 4;
45
46 private MBeansTab tab;
47 public XDataViewer(MBeansTab tab) {
48 this.tab = tab;
49 }
50
51 public static void registerForMouseEvent(Component comp,
52 MouseListener mouseListener) {
53 if(comp instanceof JScrollPane) {
54 JScrollPane pane = (JScrollPane) comp;
55 comp = pane.getViewport().getView();
56 }
57 if(comp instanceof Container) {
83 if((ret = XPlottingViewer.isViewableValue(value)))
84 return ret;
85
86 return ret;
87 }
88
89 public static int getViewerType(Object data) {
90 if(XArrayDataViewer.isViewableValue(data))
91 return ARRAY;
92 if(XOpenTypeViewer.isViewableValue(data))
93 return OPEN;
94 if(XPlottingViewer.isViewableValue(data))
95 return NUMERIC;
96
97 return NOT_SUPPORTED;
98 }
99
100 public static String getActionLabel(int type) {
101 if(type == ARRAY ||
102 type == OPEN)
103 return Resources.getText("visualize");
104 if(type == NUMERIC)
105 return Resources.getText("plot");
106 return Resources.getText("expand");
107 }
108
109 public Component createOperationViewer(Object value,
110 XMBean mbean) {
111 if(value instanceof Number) return null;
112 if(value instanceof Component) return (Component) value;
113 return createAttributeViewer(value, mbean, null, null);
114 }
115
116 public static Component createNotificationViewer(Object value) {
117 Component comp = null;
118
119 if(value instanceof Number) return null;
120
121 if((comp = XArrayDataViewer.loadArray(value)) != null)
122 return comp;
123
124 if((comp = XOpenTypeViewer.loadOpenType(value)) != null)
125 return comp;
126
|
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 *
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.
24 */
25
26 package sun.tools.jconsole.inspector;
27
28 import javax.swing.JTable;
29 import javax.swing.JScrollPane;
30 import javax.swing.JButton;
31
32 import java.awt.event.MouseListener;
33 import java.awt.Component;
34 import java.awt.Container;
35
36 import sun.tools.jconsole.MBeansTab;
37 import sun.tools.jconsole.resources.Messages;
38
39 public class XDataViewer {
40
41 public static final int OPEN = 1;
42 public static final int ARRAY = 2;
43 public static final int NUMERIC = 3;
44 public static final int NOT_SUPPORTED = 4;
45
46 private MBeansTab tab;
47 public XDataViewer(MBeansTab tab) {
48 this.tab = tab;
49 }
50
51 public static void registerForMouseEvent(Component comp,
52 MouseListener mouseListener) {
53 if(comp instanceof JScrollPane) {
54 JScrollPane pane = (JScrollPane) comp;
55 comp = pane.getViewport().getView();
56 }
57 if(comp instanceof Container) {
83 if((ret = XPlottingViewer.isViewableValue(value)))
84 return ret;
85
86 return ret;
87 }
88
89 public static int getViewerType(Object data) {
90 if(XArrayDataViewer.isViewableValue(data))
91 return ARRAY;
92 if(XOpenTypeViewer.isViewableValue(data))
93 return OPEN;
94 if(XPlottingViewer.isViewableValue(data))
95 return NUMERIC;
96
97 return NOT_SUPPORTED;
98 }
99
100 public static String getActionLabel(int type) {
101 if(type == ARRAY ||
102 type == OPEN)
103 return Messages.VISUALIZE;
104 if(type == NUMERIC)
105 return Messages.PLOT;
106 return Messages.EXPAND;
107 }
108
109 public Component createOperationViewer(Object value,
110 XMBean mbean) {
111 if(value instanceof Number) return null;
112 if(value instanceof Component) return (Component) value;
113 return createAttributeViewer(value, mbean, null, null);
114 }
115
116 public static Component createNotificationViewer(Object value) {
117 Component comp = null;
118
119 if(value instanceof Number) return null;
120
121 if((comp = XArrayDataViewer.loadArray(value)) != null)
122 return comp;
123
124 if((comp = XOpenTypeViewer.loadOpenType(value)) != null)
125 return comp;
126
|