1 19 27 28 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.webservice; 29 30 import java.util.ArrayList ; 31 import javax.swing.table.AbstractTableModel ; 32 import org.netbeans.modules.j2ee.sun.dd.api.common.MessageSecurity; 33 34 38 public class MessageSecurityTableModel extends AbstractTableModel { 39 40 private static final String [] columnNames = { "Operation", "Req Source", "Req Target", "Resp Source", "Resp Target" }; 42 43 45 private ArrayList rowData; 46 47 public MessageSecurityTableModel(MessageSecurity [] ms) { 48 if(ms != null) { 49 rowData = new ArrayList (ms.length); 50 for(int i = 0; i < ms.length; i++) { 51 rowData.add(ms[i]); 52 } 53 } else { 54 rowData = new ArrayList (); 55 } 56 } 57 58 public Object getValueAt(int rowIndex, int columnIndex) { 59 Object 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 getColumnClass(int columnIndex) { 78 return String .class; 79 } 80 81 public String 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 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 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 field) { 111 } 112 } 113 | Popular Tags |