KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > imr > util > ImRPOATableModel


1 /*
2  * JacORB - a free Java ORB
3  *
4  * Copyright (C) 1999-2004 Gerald Brose
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  */

21 package org.jacorb.imr.util;
22
23 import javax.swing.table.*;
24 import org.jacorb.imr.*;
25 import javax.swing.event.*;
26 /**
27  * This is the model for the POA table. It does
28  * not write back data since the entries in the POA
29  * table are not editable.
30  *
31  * @author Nicolas Noffke
32  *
33  * $Log: ImRPOATableModel.java,v $
34  * Revision 1.7 2004/05/06 12:39:59 nicolas
35  * Updated Copyright notice to 2004
36  *
37  * Revision 1.6 2002/12/20 18:29:04 nicolas
38  * Updated Copyright year to 2003
39  *
40  * Revision 1.5 2002/07/01 07:54:16 nicolas
41  * updated or inserted Copyright notice
42  *
43  * Revision 1.4 2002/03/19 09:25:11 nicolas
44  * updated copyright to 2002
45  *
46  * Revision 1.3 2002/03/19 11:08:01 brose
47  * *** empty log message ***
48  *
49  * Revision 1.2 2002/03/17 18:44:01 brose
50  * *** empty log message ***
51  *
52  * Revision 1.4 1999/11/25 16:05:48 brose
53  * cosmetics
54  *
55  * Revision 1.3 1999/11/21 20:15:52 noffke
56  * GUI data is now updated periodically by a thread
57  *
58  * Revision 1.2 1999/11/14 17:15:40 noffke
59  * Cosmetics and commenting
60  *
61  *
62  */

63
64 public class ImRPOATableModel extends AbstractTableModel {
65     private static final String JavaDoc[] m_columns = new String JavaDoc[] {"Name", "Host", "Port", "active"};
66
67     private POAInfo[] m_poas = null;
68
69     /**
70      * Pass in the POAs the POA table should display.
71      * Notify the JTable of this event.
72      *
73      * @param poas an array containing the POAs to display.
74      */

75     public void setPOAs(POAInfo[] poas){
76     if (m_poas != poas){
77         m_poas = poas;
78         fireTableChanged(new TableModelEvent(this));
79     }
80     }
81
82     /**
83      * Get the number of rows.
84      *
85      * @return int the number of rows of this table.
86      */

87     public int getRowCount(){
88     if (m_poas == null)
89         return 0;
90     else
91         return m_poas.length;
92     }
93
94     /**
95      * Get the number of columns.
96      *
97      * @return int the number of columns of this table.
98      */

99     public int getColumnCount(){
100     return m_columns.length;
101     }
102
103     /**
104      * Get the name of a specific column.
105      *
106      * @param column the columns number.
107      * @return the columns name.
108      */

109     public String JavaDoc getColumnName(int column){
110     return m_columns[column];
111     }
112
113     /**
114      * Get the class of a specific column.
115      *
116      * @param index the columns index.
117      * @return the Class object for the column.
118      */

119     public Class JavaDoc getColumnClass(int index){
120     if (index == 0 || index == 1)
121         return String JavaDoc.class;
122
123     else if (index == 2)
124         return Integer JavaDoc.class;
125
126     else if (index == 3)
127         return Boolean JavaDoc.class;
128
129     else
130         return Object JavaDoc.class;
131     }
132
133     /**
134      * Get the value of a specific table cell.
135      *
136      * @param row the cells row.
137      * @param column the cells column.
138      * @return Object the cells value.
139      */

140     public Object JavaDoc getValueAt(int row, int column){
141     if (column == 0)
142         return m_poas[row].name;
143
144     else if (column == 1)
145         return m_poas[row].host;
146
147     else if (column == 2)
148         return new Integer JavaDoc(m_poas[row].port);
149
150     else if (column == 3)
151         return new Boolean JavaDoc(m_poas[row].active);
152
153     return new Object JavaDoc();
154     }
155
156     /**
157      * Get the name of the server these POAs are associated with.
158      *
159      * @return a server name.
160      */

161     public String JavaDoc getServerName(){
162     if (m_poas == null || m_poas.length == 0)
163         return null;
164     else
165         //all POAs in one array have the same server
166
return m_poas[0].server;
167     }
168 } // ImRPOATableModel
169

170
171
172
173
174
175
176
177
178
179
180
181
182
183
Popular Tags