00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 package org.objectweb.cjdbc.console.gui.model;
00026
00027 import javax.management.MBeanAttributeInfo;
00028 import javax.management.ObjectName;
00029 import javax.swing.table.AbstractTableModel;
00030
00031 import org.objectweb.cjdbc.console.gui.constants.GuiConstants;
00032 import org.objectweb.cjdbc.console.jmx.RmiJmxClient;
00033
00034 public class AttributeModel extends AbstractTableModel
00035 {
00036 private MBeanAttributeInfo[] info;
00037 private RmiJmxClient client;
00038 private ObjectName mbean;
00039
00040
00041
00042
00043 public int getColumnCount()
00044 {
00045 return 3;
00046 }
00047
00048
00049
00050
00051 public int getRowCount()
00052 {
00053 return info.length;
00054 }
00055
00056
00057
00058
00059
00060
00061 public MBeanAttributeInfo[] getInfo()
00062 {
00063 return info;
00064 }
00065
00066
00067
00068
00069 public Object getValueAt(int rowIndex, int columnIndex)
00070 {
00071 if ((rowIndex >= 0 && rowIndex < info.length) == false)
00072 return null;
00073 switch (columnIndex)
00074 {
00075 case 0 :
00076 return info[rowIndex].getName();
00077 case 1 :
00078 return GuiConstants.getParameterType(info[rowIndex].getType());
00079 case 2 :
00080 try
00081 {
00082 return client.getAttributeValue(mbean, info[rowIndex].getName());
00083 }
00084 catch (Exception e)
00085 {
00086 return "-----";
00087 }
00088 default :
00089 return null;
00090 }
00091 }
00092
00093
00094
00095
00096 public boolean isCellEditable(int rowIndex, int columnIndex)
00097 {
00098 if ((rowIndex >= 0 && rowIndex < info.length) == false)
00099 return false;
00100 if (rowIndex != 2)
00101 return false;
00102 else
00103 return info[rowIndex].isWritable();
00104 }
00105
00106 public AttributeModel(MBeanAttributeInfo[] info, RmiJmxClient client,
00107 ObjectName mbean)
00108 {
00109 this.info = info;
00110 this.client = client;
00111 this.mbean = mbean;
00112 }
00113
00114
00115
00116
00117 public String getColumnName(int column)
00118 {
00119 switch (column)
00120 {
00121 case 0 :
00122 return "Name";
00123 case 1 :
00124 return "Type";
00125 case 2 :
00126 return "Value";
00127 default :
00128 return null;
00129 }
00130 }
00131 }