jdk/src/share/classes/sun/tools/jconsole/inspector/XMBeanInfo.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 55 5ecee29e98d8
child 5506 202f599c92aa
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 55
diff changeset
     2
 * Copyright 2004-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.tools.jconsole.inspector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.BorderLayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.GridLayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.management.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.swing.border.TitledBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import javax.swing.table.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.tools.jconsole.Resources;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import static sun.tools.jconsole.Utilities.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
@SuppressWarnings("serial")
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
public class XMBeanInfo extends JPanel {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private static final Color lightYellow = new Color(255, 255, 128);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    private final int NAME_COLUMN = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    private final int VALUE_COLUMN = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private final String[] columnNames = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        Resources.getText("Name"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        Resources.getText("Value")
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private JTable infoTable = new JTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    private JTable descTable = new JTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private JPanel infoBorderPanel = new JPanel(new BorderLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private JPanel descBorderPanel = new JPanel(new BorderLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private static class ReadOnlyDefaultTableModel extends DefaultTableModel {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    58
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    59
        @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        public void setValueAt(Object value, int row, int col) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private static class TableRowDivider {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        private String tableRowDividerText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        public TableRowDivider(String tableRowDividerText) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
            this.tableRowDividerText = tableRowDividerText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    72
        @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            return tableRowDividerText;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private static MBeanInfoTableCellRenderer renderer =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            new MBeanInfoTableCellRenderer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private static class MBeanInfoTableCellRenderer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            extends DefaultTableCellRenderer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    83
        @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        public Component getTableCellRendererComponent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                JTable table, Object value, boolean isSelected,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                boolean hasFocus, int row, int column) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            Component comp = super.getTableCellRendererComponent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                    table, value, isSelected, hasFocus, row, column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            if (value instanceof TableRowDivider) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                JLabel label = new JLabel(value.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                label.setBackground(ensureContrast(lightYellow,
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    92
                        label.getForeground()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                label.setOpaque(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                return label;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            return comp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    private static TableCellEditor editor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            new MBeanInfoTableCellEditor(new JTextField());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    private static class MBeanInfoTableCellEditor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            extends Utils.ReadOnlyTableCellEditor {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   104
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        public MBeanInfoTableCellEditor(JTextField tf) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            super(tf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        }
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   108
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   109
        @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        public Component getTableCellEditorComponent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                JTable table, Object value, boolean isSelected,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                int row, int column) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            Component comp = super.getTableCellEditorComponent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                    table, value, isSelected, row, column);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            if (value instanceof TableRowDivider) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                JLabel label = new JLabel(value.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                label.setBackground(ensureContrast(lightYellow,
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   118
                        label.getForeground()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                label.setOpaque(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                return label;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            return comp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    public XMBeanInfo() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        // Use the grid layout to display the two tables
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        super(new GridLayout(2, 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        // MBean*Info table
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        infoTable.setModel(new ReadOnlyDefaultTableModel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        infoTable.setRowSelectionAllowed(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        infoTable.setColumnSelectionAllowed(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        infoTable.getTableHeader().setReorderingAllowed(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        ((DefaultTableModel) infoTable.getModel()).setColumnIdentifiers(columnNames);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        infoTable.getColumnModel().getColumn(NAME_COLUMN).setPreferredWidth(140);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        infoTable.getColumnModel().getColumn(NAME_COLUMN).setMaxWidth(140);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        infoTable.getColumnModel().getColumn(NAME_COLUMN).setCellRenderer(renderer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        infoTable.getColumnModel().getColumn(VALUE_COLUMN).setCellRenderer(renderer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        infoTable.getColumnModel().getColumn(NAME_COLUMN).setCellEditor(editor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        infoTable.getColumnModel().getColumn(VALUE_COLUMN).setCellEditor(editor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        infoTable.addKeyListener(new Utils.CopyKeyAdapter());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        infoTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        JScrollPane infoTableScrollPane = new JScrollPane(infoTable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        infoBorderPanel.setBorder(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                BorderFactory.createTitledBorder("MBeanInfoPlaceHolder"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        infoBorderPanel.add(infoTableScrollPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        // Descriptor table
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        descTable.setModel(new ReadOnlyDefaultTableModel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        descTable.setRowSelectionAllowed(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        descTable.setColumnSelectionAllowed(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        descTable.getTableHeader().setReorderingAllowed(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        ((DefaultTableModel) descTable.getModel()).setColumnIdentifiers(columnNames);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        descTable.getColumnModel().getColumn(NAME_COLUMN).setPreferredWidth(140);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        descTable.getColumnModel().getColumn(NAME_COLUMN).setMaxWidth(140);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        descTable.getColumnModel().getColumn(NAME_COLUMN).setCellRenderer(renderer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        descTable.getColumnModel().getColumn(VALUE_COLUMN).setCellRenderer(renderer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        descTable.getColumnModel().getColumn(NAME_COLUMN).setCellEditor(editor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        descTable.getColumnModel().getColumn(VALUE_COLUMN).setCellEditor(editor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        descTable.addKeyListener(new Utils.CopyKeyAdapter());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        descTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        JScrollPane descTableScrollPane = new JScrollPane(descTable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        descBorderPanel.setBorder(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                BorderFactory.createTitledBorder(Resources.getText("Descriptor")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        descBorderPanel.add(descTableScrollPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        // Add the two tables to the grid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        add(infoBorderPanel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        add(descBorderPanel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   174
    // Call on EDT
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    public void emptyInfoTable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        DefaultTableModel tableModel = (DefaultTableModel) infoTable.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        while (tableModel.getRowCount() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            tableModel.removeRow(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   182
    // Call on EDT
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    public void emptyDescTable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        DefaultTableModel tableModel = (DefaultTableModel) descTable.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        while (tableModel.getRowCount() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            tableModel.removeRow(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   190
    // Call on EDT
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    private void addDescriptor(Descriptor desc, String text) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        if (desc != null && desc.getFieldNames().length > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            DefaultTableModel tableModel = (DefaultTableModel) descTable.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            Object rowData[] = new Object[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            rowData[0] = new TableRowDivider(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            rowData[1] = new TableRowDivider("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            for (String fieldName : desc.getFieldNames()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                rowData[0] = fieldName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                Object fieldValue = desc.getFieldValue(fieldName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                if (fieldValue instanceof boolean[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                    rowData[1] = Arrays.toString((boolean[]) fieldValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                } else if (fieldValue instanceof byte[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                    rowData[1] = Arrays.toString((byte[]) fieldValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                } else if (fieldValue instanceof char[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                    rowData[1] = Arrays.toString((char[]) fieldValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                } else if (fieldValue instanceof double[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                    rowData[1] = Arrays.toString((double[]) fieldValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                } else if (fieldValue instanceof float[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                    rowData[1] = Arrays.toString((float[]) fieldValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                } else if (fieldValue instanceof int[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                    rowData[1] = Arrays.toString((int[]) fieldValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                } else if (fieldValue instanceof long[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                    rowData[1] = Arrays.toString((long[]) fieldValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                } else if (fieldValue instanceof short[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                    rowData[1] = Arrays.toString((short[]) fieldValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                } else if (fieldValue instanceof Object[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                    rowData[1] = Arrays.toString((Object[]) fieldValue);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                    rowData[1] = fieldValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            tableModel.newDataAvailable(new TableModelEvent(tableModel));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   228
    // Call on EDT
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    public void addMBeanInfo(XMBean mbean, MBeanInfo mbeanInfo) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        emptyInfoTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        emptyDescTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        ((TitledBorder) infoBorderPanel.getBorder()).setTitle(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                Resources.getText("MBeanInfo"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        String text = Resources.getText("Info") + ":";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        DefaultTableModel tableModel = (DefaultTableModel) infoTable.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        Object rowData[] = new Object[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        rowData[0] = new TableRowDivider(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        rowData[1] = new TableRowDivider("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        rowData[0] = Resources.getText("ObjectName");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        rowData[1] = mbean.getObjectName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        rowData[0] = Resources.getText("ClassName");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        rowData[1] = mbeanInfo.getClassName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        rowData[0] = Resources.getText("Description");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        rowData[1] = mbeanInfo.getDescription();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        addDescriptor(mbeanInfo.getDescriptor(), text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        // MBeanConstructorInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        int i = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        for (MBeanConstructorInfo mbci : mbeanInfo.getConstructors()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            addMBeanConstructorInfo(mbci,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                    Resources.getText("Constructor") + "-" + i + ":");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            // MBeanParameterInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            int j = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            for (MBeanParameterInfo mbpi : mbci.getSignature()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                addMBeanParameterInfo(mbpi,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                        Resources.getText("Parameter") + "-" + i + "-" + j + ":");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                j++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            i++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        tableModel.newDataAvailable(new TableModelEvent(tableModel));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   269
    // Call on EDT
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    public void addMBeanAttributeInfo(MBeanAttributeInfo mbai) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        emptyInfoTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        emptyDescTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        ((TitledBorder) infoBorderPanel.getBorder()).setTitle(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                Resources.getText("MBeanAttributeInfo"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        String text = Resources.getText("Attribute") + ":";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        DefaultTableModel tableModel = (DefaultTableModel) infoTable.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        Object rowData[] = new Object[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        rowData[0] = new TableRowDivider(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        rowData[1] = new TableRowDivider("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        rowData[0] = Resources.getText("Name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        rowData[1] = mbai.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        rowData[0] = Resources.getText("Description");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        rowData[1] = mbai.getDescription();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        rowData[0] = Resources.getText("Readable");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        rowData[1] = mbai.isReadable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        rowData[0] = Resources.getText("Writable");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        rowData[1] = mbai.isWritable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        rowData[0] = Resources.getText("Is");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        rowData[1] = mbai.isIs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        rowData[0] = Resources.getText("Type");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        rowData[1] = mbai.getType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        addDescriptor(mbai.getDescriptor(), text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        tableModel.newDataAvailable(new TableModelEvent(tableModel));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   303
    // Call on EDT
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    public void addMBeanOperationInfo(MBeanOperationInfo mboi) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        emptyInfoTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        emptyDescTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        ((TitledBorder) infoBorderPanel.getBorder()).setTitle(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                Resources.getText("MBeanOperationInfo"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        String text = Resources.getText("Operation") + ":";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        DefaultTableModel tableModel = (DefaultTableModel) infoTable.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        Object rowData[] = new Object[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        rowData[0] = new TableRowDivider(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        rowData[1] = new TableRowDivider("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        rowData[0] = Resources.getText("Name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        rowData[1] = mboi.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        rowData[0] = Resources.getText("Description");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        rowData[1] = mboi.getDescription();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        rowData[0] = Resources.getText("Impact");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        switch (mboi.getImpact()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            case MBeanOperationInfo.INFO:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                rowData[1] = Resources.getText("INFO");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            case MBeanOperationInfo.ACTION:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                rowData[1] = Resources.getText("ACTION");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            case MBeanOperationInfo.ACTION_INFO:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                rowData[1] = Resources.getText("ACTION_INFO");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            case MBeanOperationInfo.UNKNOWN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                rowData[1] = Resources.getText("UNKNOWN");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        rowData[0] = Resources.getText("ReturnType");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        rowData[1] = mboi.getReturnType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        addDescriptor(mboi.getDescriptor(), text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        // MBeanParameterInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        int i = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        for (MBeanParameterInfo mbpi : mboi.getSignature()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            addMBeanParameterInfo(mbpi,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                    Resources.getText("Parameter") + "-" + i++ + ":");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        tableModel.newDataAvailable(new TableModelEvent(tableModel));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   351
    // Call on EDT
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    public void addMBeanNotificationInfo(MBeanNotificationInfo mbni) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        emptyInfoTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        emptyDescTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        ((TitledBorder) infoBorderPanel.getBorder()).setTitle(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                Resources.getText("MBeanNotificationInfo"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        String text = Resources.getText("Notification") + ":";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        DefaultTableModel tableModel = (DefaultTableModel) infoTable.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        Object rowData[] = new Object[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        rowData[0] = new TableRowDivider(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        rowData[1] = new TableRowDivider("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        rowData[0] = Resources.getText("Name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        rowData[1] = mbni.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        rowData[0] = Resources.getText("Description");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        rowData[1] = mbni.getDescription();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        rowData[0] = Resources.getText("NotifTypes");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        rowData[1] = Arrays.toString(mbni.getNotifTypes());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        addDescriptor(mbni.getDescriptor(), text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        tableModel.newDataAvailable(new TableModelEvent(tableModel));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   376
    // Call on EDT
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    private void addMBeanConstructorInfo(MBeanConstructorInfo mbci, String text) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        DefaultTableModel tableModel = (DefaultTableModel) infoTable.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        Object rowData[] = new Object[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        rowData[0] = new TableRowDivider(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        rowData[1] = new TableRowDivider("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        rowData[0] = Resources.getText("Name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        rowData[1] = mbci.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        rowData[0] = Resources.getText("Description");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        rowData[1] = mbci.getDescription();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        addDescriptor(mbci.getDescriptor(), text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        tableModel.newDataAvailable(new TableModelEvent(tableModel));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   393
    // Call on EDT
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    private void addMBeanParameterInfo(MBeanParameterInfo mbpi, String text) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        DefaultTableModel tableModel = (DefaultTableModel) infoTable.getModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        Object rowData[] = new Object[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        rowData[0] = new TableRowDivider(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        rowData[1] = new TableRowDivider("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        rowData[0] = Resources.getText("Name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        rowData[1] = mbpi.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        rowData[0] = Resources.getText("Description");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        rowData[1] = mbpi.getDescription();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        rowData[0] = Resources.getText("Type");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        rowData[1] = mbpi.getType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        tableModel.addRow(rowData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        addDescriptor(mbpi.getDescriptor(), text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        tableModel.newDataAvailable(new TableModelEvent(tableModel));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
}