1 24 25 package org.objectweb.cjdbc.console.gui.model; 26 27 import javax.management.MBeanAttributeInfo ; 28 import javax.management.ObjectName ; 29 import javax.swing.table.AbstractTableModel ; 30 31 import org.objectweb.cjdbc.console.gui.constants.GuiConstants; 32 import org.objectweb.cjdbc.console.jmx.RmiJmxClient; 33 34 40 public class AttributeModel extends AbstractTableModel 41 { 42 private MBeanAttributeInfo [] info; 43 private RmiJmxClient client; 44 private ObjectName mbean; 45 46 54 public AttributeModel(MBeanAttributeInfo [] info, RmiJmxClient client, 55 ObjectName mbean) 56 { 57 this.info = info; 58 this.client = client; 59 this.mbean = mbean; 60 } 61 62 63 66 public int getColumnCount() 67 { 68 return 3; 69 } 70 71 74 public int getRowCount() 75 { 76 return info.length; 77 } 78 79 84 public MBeanAttributeInfo [] getInfo() 85 { 86 return info; 87 } 88 89 92 public Object getValueAt(int rowIndex, int columnIndex) 93 { 94 if ((rowIndex >= 0 && rowIndex < info.length) == false) 95 return null; 96 switch (columnIndex) 97 { 98 case 0 : 99 return info[rowIndex].getName(); 100 case 1 : 101 return GuiConstants.getParameterType(info[rowIndex].getType()); 102 case 2 : 103 try 104 { 105 return client.getAttributeValue(mbean, info[rowIndex].getName()); 106 } 107 catch (Exception e) 108 { 109 return "-----"; 110 } 111 default : 112 return null; 113 } 114 } 115 116 119 public boolean isCellEditable(int rowIndex, int columnIndex) 120 { 121 if ((rowIndex >= 0 && rowIndex < info.length) == false) 122 return false; 123 if (rowIndex != 2) 124 return false; 125 else 126 return info[rowIndex].isWritable(); 127 } 128 129 132 public String getColumnName(int column) 133 { 134 switch (column) 135 { 136 case 0 : 137 return "Name"; 138 case 1 : 139 return "Type"; 140 case 2 : 141 return "Value"; 142 default : 143 return null; 144 } 145 } 146 } | Popular Tags |