1 19 20 package org.netbeans.modules.j2ee.ddloaders.web.multiview; 21 22 import org.netbeans.modules.j2ee.dd.api.common.CommonDDBean; 23 import org.netbeans.modules.j2ee.dd.api.common.EjbLocalRef; 24 import org.netbeans.modules.j2ee.dd.api.common.EjbRef; 25 import org.netbeans.modules.j2ee.dd.api.common.SecurityRole; 26 import org.netbeans.modules.j2ee.dd.api.web.WebApp; 27 import org.openide.util.NbBundle; 28 29 36 public class SecurityRoleTableModel extends DDBeanTableModel { 37 38 private static final String [] columnNames = { 39 NbBundle.getMessage(SecurityRoleTableModel.class, "TTL_SecurityRoleName"), 40 NbBundle.getMessage(SecurityRoleTableModel.class, "TTL_SecurityRoleDescription") 41 }; 42 43 protected String [] getColumnNames() { 44 return columnNames; 45 } 46 47 public void setValueAt(Object value, int row, int column) { 48 SecurityRole role = getSecurityRole(row); 49 50 if (column == 0) { 51 role.setRoleName((String ) value); 52 } else if (column == 1) { 53 role.setDescription((String ) value); 54 } 55 } 56 57 58 public Object getValueAt(int row, int column) { 59 SecurityRole role = getSecurityRole(row); 60 61 if (column == 0) { 62 return role.getRoleName(); 63 } else if (column == 1) { 64 return role.getDefaultDescription(); 65 } 66 67 return null; 68 } 69 70 public CommonDDBean addRow(Object [] values) { 71 try { 72 WebApp webApp = (WebApp)getParent(); 73 SecurityRole role = (SecurityRole) webApp.createBean("SecurityRole"); role.setRoleName((String ) values[0]); 75 role.setDescription((String ) values[1]); 76 77 int row = webApp.sizeSecurityRole(); 78 webApp.addSecurityRole(role); 79 getChildren().add(row, role); 80 fireTableRowsInserted(row, row); 81 82 return role; 83 } catch (ClassNotFoundException ex) { 84 } 85 86 return null; 87 } 88 89 public void editRow(int row, Object [] values) { 90 SecurityRole role = getSecurityRole(row); 92 role.setRoleName((String ) values[0]); 93 role.setDescription((String ) values[1]); 94 95 fireTableRowsUpdated(row,row); 96 } 97 98 public void removeRow(int row) { 99 WebApp webApp = (WebApp)getParent(); 100 SecurityRole role = getSecurityRole(row); 101 webApp.removeSecurityRole(role); 102 103 getChildren().remove(row); 104 fireTableRowsDeleted(row, row); 105 } 106 107 SecurityRole getSecurityRole(int row) { 108 return (SecurityRole) getChildren().get(row); 109 } 110 } 111 | Popular Tags |