1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule; 26 27 import java.util.ArrayList ; 28 import java.util.Hashtable ; 29 import java.util.List ; 30 import java.util.Map ; 31 import java.util.ResourceBundle ; 32 33 import javax.enterprise.deploy.model.DDBean ; 34 import javax.swing.event.TableModelListener ; 35 36 import org.netbeans.modules.j2ee.sun.dd.api.ejb.FlushAtEndOfMethod; 37 import org.netbeans.modules.j2ee.sun.dd.api.ejb.Method; 38 import org.netbeans.modules.j2ee.sun.share.configbean.CmpEntityEjb; 39 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.MultiMethodTableModel; 40 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.MultiMethodTablePanel; 41 42 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule.DummyMethod; 43 44 45 49 public class FlushAtEndOfMethodPanel extends MultiMethodTablePanel{ 50 51 private CmpEntityEjb cmpEntityEjb; 52 private CmpEntityEjbCustomizer customizer; 53 private FlushAtEndOfMethodModel model; 54 55 public static final String HOME = "Home"; public static final String REMOTE = "Remote"; public static final String LOCAL = "Local"; public static final String LOCAL_HOME = "LocalHome"; 60 static final ResourceBundle bundle = 61 ResourceBundle.getBundle( 62 "org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule.Bundle"); 64 65 public FlushAtEndOfMethodPanel(CmpEntityEjb cmpEntityEjb, CmpEntityEjbCustomizer customizer) { 66 this.cmpEntityEjb = cmpEntityEjb; 67 this.customizer = customizer; 68 } 69 70 71 protected MultiMethodTableModel getMultiMethodTableModel(){ 72 Map selectionToMethodsMap = getSelectionToMethodsMap(); 73 Map selectionToDDMethodsMap = getSelectionToDDMethodsMap(); 74 model = new FlushAtEndOfMethodModel(cmpEntityEjb, selectionToMethodsMap, selectionToDDMethodsMap); 75 model.addTableModelListener((TableModelListener )customizer); 76 return model; 77 } 78 79 80 public void setData(CmpEntityEjb cmpEntityEjb){ 81 this.cmpEntityEjb = cmpEntityEjb; 82 Map selectionToMethodsMap = getSelectionToMethodsMap(); 83 Map selectionToDDMethodsMap = getSelectionToDDMethodsMap(); 84 model.setData(cmpEntityEjb, selectionToMethodsMap, selectionToDDMethodsMap); 85 setData(); 86 } 87 88 89 protected String getSelectionLabelText(){ 90 return bundle.getString("LBL_Interface_1"); } 92 93 94 protected String getSelectionLabelAcsblName(){ 95 return bundle.getString("Interface_Acsbl_Name"); } 97 98 99 protected String getSelectionLabelAcsblDesc(){ 100 return bundle.getString("Interface_Acsbl_Desc"); } 102 103 104 protected String getSelectionComboAcsblName(){ 105 return bundle.getString("Interface_Acsbl_Name"); } 107 108 109 protected String getSelectionComboAcsblDesc(){ 110 return bundle.getString("Interface_Acsbl_Desc"); } 112 113 114 protected String getTablePaneAcsblName(){ 115 return bundle.getString("Method_Acsbl_Name"); } 117 118 119 protected String getTablePaneAcsblDesc(){ 120 return bundle.getString("Flush_Method_Acsbl_Desc"); } 122 123 124 protected char getSelectionLabelMnemonic(){ 125 return bundle.getString("MNC_Interface").charAt(0); } 127 128 129 protected String getSelectionComboToolTip(){ 130 return bundle.getString("Interface_Tool_Tip"); } 132 133 134 protected String getTablePaneToolTip(){ 135 return bundle.getString("Method_Tool_Tip"); } 137 138 139 protected String getToolTip(int row, int col){ 140 if(col == 0){ 141 DummyMethod method = (DummyMethod) model.getMethods().get(row); 143 if(method != null){ 144 return method.getName(); } 147 } 148 return null; 149 } 150 151 152 protected String getToolTip(int col){ 153 if(col == 0){ 154 return bundle.getString("Flush_Method_Header_Tool_Tip"); } 156 if(col == 1){ 157 return bundle.getString("Flush_Header_Tool_Tip"); } 159 if(col == 2){ 160 return bundle.getString("Desc_Header_Tool_Tip"); } 162 return null; 163 } 164 165 166 private Map getSelectionToMethodsMap(){ 170 Hashtable selectionToMethodsMap = new Hashtable (); 172 if(cmpEntityEjb != null){ 173 DDBean ddBean = cmpEntityEjb.getDDBean(); 174 DDBean [] childBeans = ddBean.getChildBean("./home"); if(childBeans.length > 0){ 179 selectionToMethodsMap.put(HOME, getMethods(HOME)); 182 } 183 184 childBeans = ddBean.getChildBean("./remote"); if(childBeans.length > 0){ 186 selectionToMethodsMap.put(REMOTE, getMethods(REMOTE)); 189 } 190 191 childBeans = ddBean.getChildBean("./local-home"); if(childBeans.length > 0){ 193 selectionToMethodsMap.put(LOCAL_HOME, getMethods(LOCAL_HOME)); 195 } 196 197 childBeans = ddBean.getChildBean("./local"); if(childBeans.length > 0){ 199 selectionToMethodsMap.put(LOCAL, getMethods(LOCAL)); 201 } 202 203 } 204 return selectionToMethodsMap; 205 } 206 207 208 private Map getSelectionToDDMethodsMap(){ 211 Map selectionToDDMethodsMap = new Hashtable (); 212 if(cmpEntityEjb != null){ 213 FlushAtEndOfMethod flushAtEndOfMethod = cmpEntityEjb.getFlushAtEndOfMethod(); 214 if(flushAtEndOfMethod != null){ 215 Method[] ddMethods = flushAtEndOfMethod.getMethod(); 216 if(ddMethods != null){ 217 ArrayList homeMethods = null; 218 ArrayList remoteMethods = null; 219 ArrayList localMethods = null; 220 ArrayList localHomeMethods = null; 221 222 for(int i=0; i<ddMethods.length; i++){ 223 String interfaceType = ddMethods[i].getMethodIntf(); 224 if(HOME.equals(interfaceType)){ 225 if(homeMethods == null){ 226 homeMethods = new ArrayList (); 227 } 228 homeMethods.add(ddMethods[i]); 229 } 230 231 if(REMOTE.equals(interfaceType)){ 232 if(remoteMethods == null){ 233 remoteMethods = new ArrayList (); 234 } 235 remoteMethods.add(ddMethods[i]); 236 } 237 238 if(LOCAL_HOME.equals(interfaceType)){ 239 if(localHomeMethods == null){ 240 localHomeMethods = new ArrayList (); 241 } 242 localHomeMethods.add(ddMethods[i]); 243 } 244 245 if(LOCAL.equals(interfaceType)){ 246 if(localMethods == null){ 247 localMethods = new ArrayList (); 248 } 249 localMethods.add(ddMethods[i]); 250 } 251 } 252 253 if(homeMethods != null){ 254 selectionToDDMethodsMap.put(HOME, homeMethods); 255 } 256 if(remoteMethods != null){ 257 selectionToDDMethodsMap.put(REMOTE, remoteMethods); 258 } 259 if(localHomeMethods != null){ 260 selectionToDDMethodsMap.put(LOCAL_HOME, localHomeMethods); 261 } 262 if(localMethods != null){ 263 selectionToDDMethodsMap.put(LOCAL, localMethods); 264 } 265 } 266 } 267 } 268 return selectionToDDMethodsMap; 269 } 270 271 272 private List getMethods(String interfaceType){ 274 if(interfaceType.equals(LOCAL_HOME)){ 275 ArrayList methods = new ArrayList (); 280 DummyMethod method = new DummyMethod(); 281 method.setName("FirstMethod"); 282 String [] params = {"int"}; 283 method.setParameterTypes(params); 284 methods.add(method); 285 286 DummyMethod method2 = new DummyMethod(); 287 method2.setName("SecondMethod"); 288 String [] params2 = {"int", "String"}; 289 method2.setParameterTypes(params2); 290 methods.add(method2); 291 return methods; 292 }else{ 293 ArrayList methods = new ArrayList (); 294 DummyMethod method = new DummyMethod(); 295 method.setName("FirstMethod"); 296 String [] params = {"String"}; 297 method.setParameterTypes(params); 298 methods.add(method); 299 return methods; 300 } 301 } 302 303 public void addTableModelListener(TableModelListener listner){ 304 model.addTableModelListener(listner); 305 } 306 } 307 | Popular Tags |