001: /*
002: * JacORB - a free Java ORB
003: *
004: * Copyright (C) 1999-2004 Gerald Brose
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Library General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Library General Public License for more details.
015: *
016: * You should have received a copy of the GNU Library General Public
017: * License along with this library; if not, write to the Free
018: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
019: *
020: */
021: package org.jacorb.imr.util;
022:
023: import javax.swing.table.*;
024: import org.jacorb.imr.*;
025: import javax.swing.event.*;
026:
027: /**
028: * This is the model for the POA table. It does
029: * not write back data since the entries in the POA
030: * table are not editable.
031: *
032: * @author Nicolas Noffke
033: *
034: * $Log: ImRPOATableModel.java,v $
035: * Revision 1.8 2006/06/16 12:36:28 alphonse.bendt
036: * fixed some findbugs warnings
037: *
038: * Revision 1.7 2004/05/06 12:39:59 nicolas
039: * Updated Copyright notice to 2004
040: *
041: * Revision 1.6 2002/12/20 18:29:04 nicolas
042: * Updated Copyright year to 2003
043: *
044: * Revision 1.5 2002/07/01 07:54:16 nicolas
045: * updated or inserted Copyright notice
046: *
047: * Revision 1.4 2002/03/19 09:25:11 nicolas
048: * updated copyright to 2002
049: *
050: * Revision 1.3 2002/03/19 11:08:01 brose
051: * *** empty log message ***
052: *
053: * Revision 1.2 2002/03/17 18:44:01 brose
054: * *** empty log message ***
055: *
056: * Revision 1.4 1999/11/25 16:05:48 brose
057: * cosmetics
058: *
059: * Revision 1.3 1999/11/21 20:15:52 noffke
060: * GUI data is now updated periodically by a thread
061: *
062: * Revision 1.2 1999/11/14 17:15:40 noffke
063: * Cosmetics and commenting
064: *
065: *
066: */
067:
068: public class ImRPOATableModel extends AbstractTableModel {
069: private static final String[] m_columns = new String[] { "Name",
070: "Host", "Port", "active" };
071:
072: private POAInfo[] m_poas = null;
073:
074: /**
075: * Pass in the POAs the POA table should display.
076: * Notify the JTable of this event.
077: *
078: * @param poas an array containing the POAs to display.
079: */
080: public void setPOAs(POAInfo[] poas) {
081: if (m_poas != poas) {
082: m_poas = poas;
083: fireTableChanged(new TableModelEvent(this ));
084: }
085: }
086:
087: /**
088: * Get the number of rows.
089: *
090: * @return int the number of rows of this table.
091: */
092: public int getRowCount() {
093: if (m_poas == null)
094: return 0;
095: else
096: return m_poas.length;
097: }
098:
099: /**
100: * Get the number of columns.
101: *
102: * @return int the number of columns of this table.
103: */
104: public int getColumnCount() {
105: return m_columns.length;
106: }
107:
108: /**
109: * Get the name of a specific column.
110: *
111: * @param column the columns number.
112: * @return the columns name.
113: */
114: public String getColumnName(int column) {
115: return m_columns[column];
116: }
117:
118: /**
119: * Get the class of a specific column.
120: *
121: * @param index the columns index.
122: * @return the Class object for the column.
123: */
124: public Class getColumnClass(int index) {
125: if (index == 0 || index == 1)
126: return String.class;
127:
128: else if (index == 2)
129: return Integer.class;
130:
131: else if (index == 3)
132: return Boolean.class;
133:
134: else
135: return Object.class;
136: }
137:
138: /**
139: * Get the value of a specific table cell.
140: *
141: * @param row the cells row.
142: * @param column the cells column.
143: * @return Object the cells value.
144: */
145: public Object getValueAt(int row, int column) {
146: if (column == 0)
147: return m_poas[row].name;
148:
149: else if (column == 1)
150: return m_poas[row].host;
151:
152: else if (column == 2)
153: return new Integer(m_poas[row].port);
154:
155: else if (column == 3)
156: return Boolean.valueOf(m_poas[row].active);
157:
158: return new Object();
159: }
160:
161: /**
162: * Get the name of the server these POAs are associated with.
163: *
164: * @return a server name.
165: */
166: public String getServerName() {
167: if (m_poas == null || m_poas.length == 0)
168: return null;
169: else
170: //all POAs in one array have the same server
171: return m_poas[0].server;
172: }
173: } // ImRPOATableModel
|