KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > customizers > PrincipalTableModel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * PrincipalTableModel.java
21  *
22  * Created on April 14, 2006, 10:10 PM
23  *
24  * To change this template, choose Tools | Template Manager
25  * and open the template in the editor.
26  */

27
28 package org.netbeans.modules.j2ee.sun.share.configbean.customizers;
29
30 import java.util.Collections JavaDoc;
31 import java.util.List JavaDoc;
32
33 import javax.swing.table.AbstractTableModel JavaDoc;
34 import org.netbeans.modules.j2ee.sun.share.PrincipalNameMapping;
35
36 /**
37  *
38  * @author Peter Williams
39  */

40 public class PrincipalTableModel extends SecurityMappingTableModel {
41     
42     /** Principal table can have 1 column (AS 7.0, 8.1) or 2 columns (AS 9.0).
43      */

44     public PrincipalTableModel(List JavaDoc p, int columns) {
45         super(p, columns);
46         assert (columns >= 1 && columns <= 2);
47     }
48     
49     /** Model manipulation
50      */

51     public int addElement(PrincipalNameMapping entry) {
52         return super.addElement(entry);
53     }
54     
55     public int replaceElement(PrincipalNameMapping oldEntry, PrincipalNameMapping newEntry) {
56         return super.replaceElement(oldEntry, newEntry);
57     }
58     
59     public int removeElement(PrincipalNameMapping entry) {
60         return super.removeElement(entry);
61     }
62     
63     public boolean contains(PrincipalNameMapping entry) {
64         return super.contains(entry);
65     }
66     
67     public PrincipalNameMapping getElementAt(int rowIndex) {
68         return (PrincipalNameMapping) super.getRowElement(rowIndex);
69     }
70     
71     /** TableModel interface methods
72      */

73     public String JavaDoc getColumnName(int column) {
74         switch(column) {
75             case 0:
76                 return SecurityRoleMappingCustomizer.customizerBundle.getString("LBL_PrincipalName"); // NOI18N
77
case 1:
78                 return SecurityRoleMappingCustomizer.customizerBundle.getString("LBL_ClassName"); // NOI18N
79
}
80         return null;
81     }
82
83     /** SecurityMappingTableModel methods
84      */

85     protected Object JavaDoc getColumnValueFromRow(Object JavaDoc rowEntry, int columnIndex) {
86         Object JavaDoc result = null;
87         PrincipalNameMapping entry = (PrincipalNameMapping) rowEntry;
88         if(columnIndex == 0) {
89             result = entry.getPrincipalName();
90         } else {
91             result = entry.getClassName();
92         }
93         return result;
94     }
95 }
96
Popular Tags