1 21 package org.jacorb.imr.util; 22 23 import javax.swing.table.*; 24 import org.jacorb.imr.*; 25 import javax.swing.event.*; 26 35 36 public class ImRServerTableModel extends AbstractTableModel { 37 private ImRModel m_model; 38 private static final String [] m_columns = new String [] {"Name", "Host", "Command", "active", "holding"}; 39 40 private ServerInfo[] m_servers; 41 42 47 public ImRServerTableModel(ImRModel model){ 48 m_model = model; 49 } 50 51 58 public void setServers(ServerInfo[] servers){ 59 m_servers = servers; 60 fireTableChanged(new TableModelEvent(this)); 61 } 62 63 68 public void serverRefreshed(int index){ 69 fireTableRowsUpdated(index, index); 70 } 71 72 77 public int getRowCount(){ 78 return m_servers.length; 79 } 80 81 86 public int getColumnCount(){ 87 return m_columns.length; 88 } 89 90 96 public String getColumnName(int column){ 97 return m_columns[column]; 98 } 99 100 106 public Class getColumnClass(int index){ 107 if (index == 0 || index == 1 || index == 2) 108 return String .class; 109 110 else if (index == 3 || index == 4) 111 return Boolean .class; 112 113 else 114 return Object .class; 115 } 116 117 124 public Object getValueAt(int row, int column){ 125 if (column == 0) 126 return m_servers[row].name; 127 128 else if (column == 1) 129 return m_servers[row].host; 130 131 else if (column == 2) 132 return m_servers[row].command; 133 134 else if (column == 3) 135 return new Boolean (m_servers[row].active); 136 137 else if (column == 4) 138 return new Boolean (m_servers[row].holding); 139 140 return new Object (); 141 } 142 143 151 public boolean isCellEditable(int row, int column){ 152 if (column >= 1) 153 return true; 154 else 155 return false; 156 } 157 158 165 public void setValueAt(Object value, int row, int column){ 166 m_model.updateServer(row, m_columns[column], value); 167 } 168 } 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | Popular Tags |