1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule; 26 27 import java.util.Map ; 28 import java.util.ResourceBundle ; 29 30 import org.netbeans.modules.j2ee.sun.dd.api.ejb.Method; 31 import org.netbeans.modules.j2ee.sun.dd.api.common.MethodParams; 32 import org.netbeans.modules.j2ee.sun.share.configbean.CmpEntityEjb; 33 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.MultiMethodTableModel; 34 import org.netbeans.modules.j2ee.sun.share.configbean.StorageBeanFactory; 35 36 40 public class FlushAtEndOfMethodModel extends MultiMethodTableModel{ 41 42 static final ResourceBundle bundle = 43 ResourceBundle.getBundle( 44 "org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule.Bundle"); 46 private CmpEntityEjb cmpEntityEjb; 47 48 private static final String [] columnNames = { 49 bundle.getString("LBL_Method"), bundle.getString("LBL_Flush"), bundle.getString("LBL_Description") }; 53 54 55 56 public FlushAtEndOfMethodModel(CmpEntityEjb cmpEntityEjb, Map selectionToMethodsMap, Map selectionToDDMethodsMap) { 57 super(selectionToMethodsMap, selectionToDDMethodsMap); 58 this.cmpEntityEjb = cmpEntityEjb; 59 } 60 61 62 public void setData(CmpEntityEjb cmpEntityEjb, Map selectionToMethodsMap, Map selectionToDDMethodsMap){ 63 this.cmpEntityEjb = cmpEntityEjb; 64 setData(selectionToMethodsMap, selectionToDDMethodsMap); 65 } 66 67 68 public FlushAtEndOfMethodModel() { 69 } 70 71 72 protected String [] getColumnNames(){ 73 return columnNames; 74 } 75 76 77 protected Class getColumnType(int column){ 78 if(column == 2){ 79 return String .class; 80 }else{ 81 assert(false); 83 } 84 return Object .class; 85 } 86 87 104 protected Object getValueAt(int column, Object object, int row){ 105 if(column == 0){ 106 DummyMethod method = (DummyMethod) object; 109 return "Method" + row; 110 } else { 111 assert(false); 114 return null; 115 } 116 } 117 118 119 protected Object getDDValueAt(int column, Object ddObject){ 120 if(column == 2){ 121 Method ddMethod = (Method) ddObject; 122 return ddMethod.getDescription( ); 123 } else { 124 assert(false); 126 return null; 127 } 128 } 129 130 131 protected void setDDValueAt(int column, Object ddObject, Object value){ 132 if(column == 2){ 133 Method ddMethod = (Method) ddObject; 134 ddMethod.setDescription((String )value); 135 } else { 136 assert(false); 138 } 139 } 140 141 142 protected Object getDDMethod(Object object, String selection){ 144 StorageBeanFactory storageFactory = cmpEntityEjb.getConfig().getStorageFactory(); 145 DummyMethod method = (DummyMethod)object; 150 Method ddMethod = storageFactory.createMethod(); 152 ddMethod.setMethodName(method.getName()); 154 ddMethod.setMethodIntf(selection); 155 ddMethod.setEjbName(cmpEntityEjb.getEjbName()); 156 157 String [] params = method.getParameterTypes(); 158 MethodParams ddParams = storageFactory.createMethodParams(); 160 for(int i=0; i<params.length; i++){ 161 ddParams.addMethodParam(params[i]); 162 } 163 164 ddMethod.setMethodParams(ddParams); 165 166 172 return ddMethod; 173 } 174 175 176 protected void addDDMethod(Object ddObject){ 177 Method ddMethod = (Method)ddObject; 178 cmpEntityEjb.addMethod(ddMethod); 180 } 181 182 183 protected void removeDDMethod(Object ddObject){ 184 Method ddMethod = (Method)ddObject; 185 cmpEntityEjb.removeMethod(ddMethod); 186 } 187 188 189 protected boolean areEqual(Object ddObject, Object object){ 192 Method ddMethod = (Method)ddObject; 194 DummyMethod method = (DummyMethod) object; 195 boolean returnValue = false; 196 197 198 String ddMethodName = ddMethod.getMethodName(); 199 String methodName = method.getName(); 201 if(ddMethodName.equals(methodName)){ 203 MethodParams methodParams = ddMethod.getMethodParams(); 205 String [] params = method.getParameterTypes(); 206 207 String ddParam; 208 String param; 209 for(int i=0; i<params.length; i++){ 210 param = params[i]; 211 ddParam = methodParams.getMethodParam(i); 212 if(!param.equals(ddParam)){ 215 return false; 216 } 217 } 218 return true; 219 } else { 220 return false; 221 } 222 } 223 224 225 private void printMethod(Method ddMethod){ 226 System.out.println("FlushAtEndOfMethodModel ddMethod:" + ddMethod); System.out.println("FlushAtEndOfMethodModel ddMethod:" + ddMethod.toString()); System.out.println("FlushAtEndOfMethodModel name :" + ddMethod.getMethodName() ); System.out.println("FlushAtEndOfMethodModel interface :" + ddMethod.getMethodIntf() ); System.out.println("FlushAtEndOfMethodModel ejb name :" + ddMethod.getEjbName() ); System.out.println("FlushAtEndOfMethodModel params :" + ddMethod.getMethodParams() ); } 233 } 234 | Popular Tags |