1 19 23 24 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule; 25 26 import java.util.ResourceBundle ; 27 28 import org.netbeans.modules.j2ee.sun.dd.api.ejb.ActivationConfigProperty; 29 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.BeanTableModel; 30 import org.netbeans.modules.j2ee.sun.share.configbean.MDEjb; 31 import org.netbeans.modules.j2ee.sun.share.configbean.StorageBeanFactory; 32 33 38 public class ActivationCfgPropertyModel extends BeanTableModel { 39 40 41 42 43 public ActivationCfgPropertyModel(){ 44 super(); 45 } 46 47 48 static final ResourceBundle bundle = 49 ResourceBundle.getBundle( 50 "org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule.Bundle"); 52 private static final String [] columnNames = { 53 bundle.getString("LBL_Activation_Config_Property_Name"), bundle.getString("LBL_Activation_Config_Property_Value") }; 56 57 58 protected String [] getColumnNames() { 59 return columnNames; 60 } 61 62 63 public Object getValueAt(int row, int column){ 64 Object retValue = null; 65 ActivationConfigProperty param = 66 (ActivationConfigProperty)getChildren().get(row); 67 if(param != null){ 68 if (column == 0){ 69 retValue = param.getActivationConfigPropertyName(); 70 } else { 71 retValue = param.getActivationConfigPropertyValue(); 72 } 73 } 74 return retValue; 75 } 76 77 78 public Object addRow(Object [] values){ 80 StorageBeanFactory storageFactory = ((MDEjb) getParent()).getConfig().getStorageFactory(); 81 ActivationConfigProperty param = storageFactory.createActivationConfigProperty(); 82 param.setActivationConfigPropertyName((String )values[0]); 83 param.setActivationConfigPropertyValue((String )values[1]); 84 ((MDEjb)getParent()).addActivationConfigProperty(param); 85 getChildren().add(param); 86 fireTableRowsInserted(getRowCount() - 1, getRowCount() - 1); 87 return param; 88 } 89 90 91 public void editRow(int row, Object [] values){ 92 ActivationConfigProperty param = 93 (ActivationConfigProperty)getChildren().get(row); 94 if(param != null){ 95 param.setActivationConfigPropertyName((String )values[0]); 96 param.setActivationConfigPropertyValue((String )values[1]); 97 } 98 } 99 100 101 public void removeRow(int row){ 102 ((MDEjb)getParent()).removeActivationConfigProperty( 103 (ActivationConfigProperty)getChildren().get(row)); 104 getChildren().remove(row); 105 fireTableRowsDeleted(row, row); 106 } 107 108 109 public Object [] getValues(int row){ 110 Object [] values = new Object [2]; 111 ActivationConfigProperty property = 112 (ActivationConfigProperty)getChildren().get(row); 113 if(property != null){ 114 values[0] = (Object )property.getActivationConfigPropertyName(); 115 values[1] = (Object )property.getActivationConfigPropertyValue(); 116 } 117 return values; 118 } 119 120 121 public boolean alreadyExists(Object [] values){ 123 boolean exists = false; 124 125 if(values != null){ 126 String name = (String )values[0]; 127 if(name != null){ 128 int count = getRowCount(); 129 ActivationConfigProperty property; 130 for(int i=0; i<count; i++){ 131 property = (ActivationConfigProperty)getChildren().get(i); 132 if(property != null){ 133 if(name.equals( 134 property.getActivationConfigPropertyName())){ 135 exists = true; 136 break; 137 } 138 } 139 } 140 } 141 } 142 return exists; 143 } 144 } 145 | Popular Tags |