1 23 24 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 40 public class RoleMapElementTableModel extends javax.swing.table.AbstractTableModel { 41 42 RoleMapElement v = null; 43 44 private static java.util.ResourceBundle bundle = 45 java.util.ResourceBundle.getBundle("com.sun.enterprise.tools.common.properties.Bundle"); 47 48 public RoleMapElementTableModel(RoleMapElement rm) { 49 v = rm; 50 } 51 52 public java.lang.Object getValueAt(int param, int param1) { 53 Object retVal = null; 54 if (param1 != 3) 55 retVal = ""; if (param < v.getLength()) 57 retVal = v.getAttributeDetail(param, param1); return retVal; 59 } 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 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); if (v.getLength() < pre) { 81 Reporter.info("fireTableRowsDeleted"); fireTableRowsDeleted(row, row); 84 } 85 } 86 87 public String 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 (bundle.getString("COL_HEADER_ERR_ERR_ERR")); 97 } 98 99 public static void main(String args[]) { 100 RoleMapElement pe = new RoleMapElement(args); 101 javax.swing.JTable tab = new javax.swing.JTable (new RoleMapElementTableModel(pe)); 103 javax.swing.table.TableColumnModel tcm = tab.getColumnModel(); 104 javax.swing.table.TableColumn tc = tcm.getColumn(1); 105 PasswordRender pre2 = new PasswordRender(); 107 tc.setCellEditor(new javax.swing.DefaultCellEditor (new javax.swing.JPasswordField ())); 108 tc.setCellRenderer(pre2); 109 javax.swing.JScrollPane sp = new javax.swing.JScrollPane (tab); 110 javax.swing.JFrame f = new javax.swing.JFrame (); 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 { 117 private RoleMapElement myRM; 118 public CloseTestWindow(RoleMapElement rm) { 119 myRM = rm; 120 } 121 public void windowClosing(java.awt.event.WindowEvent e) { 122 System.out.println(myRM.dumpIt()); System.exit(0); 124 } 125 } 126 127 } 128 | Popular Tags |