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.MBeanOperationInfo;
00028 import javax.management.MBeanParameterInfo;
00029 import javax.swing.table.AbstractTableModel;
00030
00031 import org.objectweb.cjdbc.console.gui.constants.GuiConstants;
00032
00033 public class OperationModel extends AbstractTableModel
00034 {
00035 private MBeanOperationInfo[] info;
00036
00037
00038
00039
00040 public int getColumnCount()
00041 {
00042 return 2;
00043 }
00044
00045
00046
00047
00048
00049
00050 public MBeanOperationInfo[] getInfo()
00051 {
00052 return info;
00053 }
00054
00055
00056
00057
00058 public int getRowCount()
00059 {
00060 return info.length;
00061 }
00062
00063
00064
00065
00066 public boolean isCellEditable(int rowIndex, int columnIndex)
00067 {
00068 return false;
00069 }
00070
00071
00072
00073
00074 public Object getValueAt(int rowIndex, int columnIndex)
00075 {
00076 if ((rowIndex >= 0 && rowIndex < info.length) == false)
00077 return null;
00078 switch (columnIndex)
00079 {
00080 case 0 :
00081 StringBuffer name = new StringBuffer(info[rowIndex].getName());
00082 MBeanParameterInfo[] param = info[rowIndex].getSignature();
00083 name.append("(");
00084 for (int i = 0; i < param.length; i++)
00085 {
00086 if (i != 0)
00087 name.append(",");
00088 name.append(GuiConstants.getParameterType(param[i].getType()));
00089 }
00090 name.append(")");
00091 return name.toString();
00092 case 1 :
00093 return GuiConstants.getParameterType(info[rowIndex].getReturnType());
00094 default :
00095 return null;
00096 }
00097 }
00098
00099 public OperationModel(MBeanOperationInfo[] info)
00100 {
00101 this.info = info;
00102 }
00103
00104
00105
00106
00107 public String getColumnName(int column)
00108 {
00109 switch (column)
00110 {
00111 case 0 :
00112 return "Name";
00113 case 1 :
00114 return "Return";
00115 default :
00116 return null;
00117 }
00118 }
00119 }