KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > common > properties > PropertyElementsTableModel


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  * PropertyElementsTableModel.java
26  *
27  * Created on March 14, 2002, 1:08 PM
28  */

29
30 package com.sun.enterprise.tools.common.properties;
31
32 /**
33  *
34  * @author vkraemer
35  * @version
36  */

37 public class PropertyElementsTableModel extends javax.swing.table.AbstractTableModel JavaDoc {
38     
39     PropertyElements v = null;
40
41     private static java.util.ResourceBundle JavaDoc bundle =
42         java.util.ResourceBundle.getBundle("com.sun.enterprise.tools.common.properties.Bundle"); // NOI18N
43

44     /** Creates new PropertyElementsTableModel */
45     public PropertyElementsTableModel(PropertyElements v) {
46         this.v = v;
47     }
48     
49     public java.lang.Object JavaDoc getValueAt(int param, int param1) {
50         Object JavaDoc retVal = ""; // NOI18N
51
if (param < v.getLength())
52             retVal = v.getAttributeDetail(param, param1); //NOI18N
53
return retVal;
54         // return ra.getAttributeValue("PropertyElement", param, intToAttribute(param1)); //NOI18N
55
}
56     
57     public int getRowCount() {
58         return v.getLength() + 1;
59     }
60     
61     public int getColumnCount() {
62         return v.getWidth();
63     }
64     
65     
66     public boolean isCellEditable(int row, int col) {
67         return true;
68     }
69     
70     public void setValueAt(Object JavaDoc val, int row, int col) {
71         int pre = v.getLength();
72         v.setAttributeDetail(val, row, col); //NOI18N
73
if (v.getLength() < pre) {
74             // the length changed.. I may need to fire a
75
fireTableStructureChanged();
76         }
77     }
78     
79     public String JavaDoc getColumnName(int col) {
80         if (0 == col)
81             return bundle.getString("COL_HEADER_NAME");
82         if (1 == col)
83             return bundle.getString("COL_HEADER_VALUE");
84         throw new RuntimeException JavaDoc(bundle.getString("COL_HEADER_ERR_ERR_ERR"));
85     }
86     
87     public static void main(String JavaDoc args[]) {
88         PropertyElements pe = new PropertyElements(args);
89         //if (null == args || 0 == args.length) {
90
javax.swing.JTable JavaDoc tab = new javax.swing.JTable JavaDoc(new PropertyElementsTableModel(pe));
91         javax.swing.JScrollPane JavaDoc sp = new javax.swing.JScrollPane JavaDoc(tab);
92         javax.swing.JFrame JavaDoc f = new javax.swing.JFrame JavaDoc();
93         f.addWindowListener(new CloseTestWindow(pe));
94         f.getContentPane().add(sp);
95         f.show();
96     }
97     
98     static class CloseTestWindow extends java.awt.event.WindowAdapter JavaDoc {
99         private PropertyElements myPE;
100         public CloseTestWindow(PropertyElements pe) {
101             myPE = pe;
102         }
103         public void windowClosing(java.awt.event.WindowEvent JavaDoc e) {
104             System.out.println(myPE.dumpIt()); //NOI18N
105
System.exit(0);
106         }
107     }
108     
109
110 }
111
Popular Tags