KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > common > ui > GenericTableModel


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * GenericTableModel.java
26  *
27  * Created on February 20, 2001, 12:19 AM
28  */

29
30 package com.sun.enterprise.tools.common.ui;
31 import javax.swing.table.*;
32 import com.sun.enterprise.tools.common.util.diagnostics.Reporter;
33
34 /**
35  *
36  * @author bnevins
37  * @version
38  */

39 public class GenericTableModel extends AbstractTableModel
40 {
41     public GenericTableModel(GenericTableInfo info)
42     {
43         Reporter.assertIt(info); //NOI18N
44
tableInfo = info;
45         //load();
46
}
47     
48     //////////////////////////////////////////////////////////////
49

50     public String JavaDoc getColumnName(int c)
51     {
52         return tableInfo.getColumnName(c);
53     }
54     
55     //////////////////////////////////////////////////////////////
56

57     public Class JavaDoc getColumnClass(int c)
58     {
59         return String JavaDoc.class;
60     }
61     
62     //////////////////////////////////////////////////////////////
63

64     public int getColumnCount()
65     {
66         return tableInfo.getColumnCount();
67     }
68     
69     //////////////////////////////////////////////////////////////
70

71     public int getRowCount()
72     {
73         return tableInfo.getRowCount();
74     }
75     
76     //////////////////////////////////////////////////////////////
77

78     public Object JavaDoc getValueAt(int r, int c)
79     {
80         return tableInfo.getString(r, c);
81     }
82     
83     //////////////////////////////////////////////////////////////
84

85     public void setValueAt(Object JavaDoc obj, int r, int c)
86     {
87         Reporter.assertIt(obj instanceof String JavaDoc); //NOI18N
88
String JavaDoc s = (String JavaDoc)obj;
89         
90         tableInfo.setString(r, c, s);
91     }
92     
93     //////////////////////////////////////////////////////////////
94

95     public boolean isCellEditable(int r, int c)
96     {
97         boolean b = tableInfo.isColumnEditable(c);
98     /// System.out.println("isColEditable for Column " + c + " --- " + b); //NOI18N
99
//return tableInfo.isColumnEditable(c);
100
return b;
101     }
102     
103     //////////////////////////////////////////////////////////////
104

105     private GenericTableInfo tableInfo = null;
106 }
107
108
Popular Tags