KickJava   Java API By Example, From Geeks To Geeks.

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


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  * RoleMapElementTableModel.java
26  *
27  * Created on March 18, 2002, 3:14 PM
28  */

29
30 package com.sun.enterprise.tools.common.properties;
31
32 import java.util.*;
33 import com.sun.enterprise.tools.common.util.diagnostics.Reporter;
34
35 /**
36  *
37  * @author vkraemer
38  * @version
39  */

40 public class RoleMapElementTableModel extends javax.swing.table.AbstractTableModel JavaDoc{
41
42     RoleMapElement v = null;
43     
44     private static java.util.ResourceBundle JavaDoc bundle =
45         java.util.ResourceBundle.getBundle("com.sun.enterprise.tools.common.properties.Bundle"); //NOI18N
46

47     /** Creates new RoleMapElementTableModel */
48     public RoleMapElementTableModel(RoleMapElement rm) {
49         v = rm;
50     }
51
52     public java.lang.Object JavaDoc getValueAt(int param, int param1) {
53         Object JavaDoc retVal = null;
54         if (param1 != 3)
55             retVal = ""; // NOI18N
56
if (param < v.getLength())
57             retVal = v.getAttributeDetail(param, param1); //NOI18N
58
return retVal;
59         // return ra.getAttributeValue("PropertyElement", param, intToAttribute(param1)); //NOI18N
60
}
61     
62     public int getRowCount() {
63         return v.getLength() + 1;
64     }
65     
66     public int getColumnCount() {
67         return v.getWidth();
68     }
69     
70     
71     public boolean isCellEditable(int row, int col) {
72         return true;
73     }
74     
75     public void setValueAt(Object JavaDoc val, int row, int col) {
76         if (col == 3)
77             Reporter.info("val size = " + ((Vector)val).size() + " row = " + row + " column = " + col);
78         int pre = v.getLength();
79         v.setAttributeDetail(val, row, col); //NOI18N
80
if (v.getLength() < pre) {
81             Reporter.info("fireTableRowsDeleted"); //NOI18N
82
// fireTableStructureChanged();
83
fireTableRowsDeleted(row, row);
84         }
85     }
86     
87     public String JavaDoc getColumnName(int col) {
88         if (0 == col)
89             return bundle.getString("COL_HEADER_BE_USERNAME");
90         if (1 == col)
91             return bundle.getString("COL_HEADER_BE_PASSWORD");
92         if (2 == col)
93             return bundle.getString("COL_HEADER_BE_CREDENTIAL");
94         if (3 == col)
95             return bundle.getString("COL_HEADER_CONTAINER_USERNAMES");
96         throw new RuntimeException JavaDoc(bundle.getString("COL_HEADER_ERR_ERR_ERR"));
97     }
98     
99     public static void main(String JavaDoc args[]) {
100         RoleMapElement pe = new RoleMapElement(args);
101         //if (null == args || 0 == args.length) {
102
javax.swing.JTable JavaDoc tab = new javax.swing.JTable JavaDoc(new RoleMapElementTableModel(pe));
103         javax.swing.table.TableColumnModel JavaDoc tcm = tab.getColumnModel();
104         javax.swing.table.TableColumn JavaDoc tc = tcm.getColumn(1);
105         //PasswordRenderEdit pre1 = new PasswordRenderEdit();
106
PasswordRender pre2 = new PasswordRender();
107         tc.setCellEditor(new javax.swing.DefaultCellEditor JavaDoc(new javax.swing.JPasswordField JavaDoc()));
108         tc.setCellRenderer(pre2);
109         javax.swing.JScrollPane JavaDoc sp = new javax.swing.JScrollPane JavaDoc(tab);
110         javax.swing.JFrame JavaDoc f = new javax.swing.JFrame JavaDoc();
111         f.addWindowListener(new CloseTestWindow(pe));
112         f.getContentPane().add(sp);
113         f.show();
114     }
115     
116     static class CloseTestWindow extends java.awt.event.WindowAdapter JavaDoc {
117         private RoleMapElement myRM;
118         public CloseTestWindow(RoleMapElement rm) {
119             myRM = rm;
120         }
121         public void windowClosing(java.awt.event.WindowEvent JavaDoc e) {
122             System.out.println(myRM.dumpIt()); //NOI18N
123
System.exit(0);
124         }
125     }
126     
127 }
128
Popular Tags