KickJava   Java API By Example, From Geeks To Geeks.

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


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  * MessageSecurityTableModel.java
21  *
22  * Created on April 24, 2006, 3:56 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.webservice;
29
30 import java.util.ArrayList JavaDoc;
31 import javax.swing.table.AbstractTableModel JavaDoc;
32 import org.netbeans.modules.j2ee.sun.dd.api.common.MessageSecurity;
33
34 /**
35  *
36  * @author Peter Williams
37  */

38 public class MessageSecurityTableModel extends AbstractTableModel JavaDoc {
39     
40 // private String [] columnNames = { "Operation / Java Method", "Request Protection", "Response Protection" };
41
private static final String JavaDoc [] columnNames = { "Operation", "Req Source", "Req Target", "Resp Source", "Resp Target" };
42     
43     /** Hashset of all the rows. Stores instances of MessageSecurity
44      */

45     private ArrayList JavaDoc rowData;
46     
47     public MessageSecurityTableModel(MessageSecurity [] ms) {
48         if(ms != null) {
49             rowData = new ArrayList JavaDoc(ms.length);
50             for(int i = 0; i < ms.length; i++) {
51                 rowData.add(ms[i]);
52             }
53         } else {
54             rowData = new ArrayList JavaDoc();
55         }
56     }
57     
58     public Object JavaDoc getValueAt(int rowIndex, int columnIndex) {
59         Object JavaDoc result = null;
60         if(rowIndex >= 0 && rowIndex < rowData.size()) {
61             MessageSecurity row = (MessageSecurity) rowData.get(rowIndex);
62             if(row != null) {
63                 result = getFieldByColumn(row, columnIndex);
64             }
65         }
66         return result;
67     }
68
69     public int getRowCount() {
70         return rowData.size();
71     }
72
73     public int getColumnCount() {
74         return columnNames.length;
75     }
76
77     public Class JavaDoc getColumnClass(int columnIndex) {
78         return String JavaDoc.class;
79     }
80
81     public String JavaDoc getColumnName(int column) {
82         assert column < 0 || column > columnNames.length;
83         return (column >= 0 && column < columnNames.length) ? columnNames[column] : "unknown";
84     }
85
86     public void setValueAt(Object JavaDoc aValue, int rowIndex, int columnIndex) {
87     }
88
89     public boolean isCellEditable(int rowIndex, int columnIndex) {
90         return (columnIndex > 0) ? true : false;
91     }
92
93     private String JavaDoc getFieldByColumn(MessageSecurity row, int columnIndex) {
94         assert columnIndex < 0 || columnIndex > columnNames.length;
95         switch(columnIndex) {
96             case 0:
97                 return row.getMessage(0).getOperationName();
98             case 1:
99                 return row.getRequestProtectionAuthSource();
100             case 2:
101                 return row.getRequestProtectionAuthRecipient();
102             case 3:
103                 return row.getResponseProtectionAuthSource();
104             case 4:
105                 return row.getResponseProtectionAuthRecipient();
106         }
107         return null;
108     }
109
110     private void setFieldByColumn(MessageSecurity row, int columnIndex, String JavaDoc field) {
111     }
112 }
113
Popular Tags