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.CheckpointAtEndOfMethod; 37 import org.netbeans.modules.j2ee.sun.dd.api.ejb.Method; 38 import org.netbeans.modules.j2ee.sun.share.configbean.StatefulEjb; 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 CheckpointAtEndOfMethodPanel extends MultiMethodTablePanel{ 50 51 private StatefulEjb statefulEjb; 52 private StatefulEjbCustomizer customizer; 53 private CheckpointAtEndOfMethodModel 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 CheckpointAtEndOfMethodPanel(StatefulEjb statefulEjb, StatefulEjbCustomizer customizer) { 66 this.statefulEjb = statefulEjb; 67 this.customizer = customizer; 68 } 69 70 71 protected MultiMethodTableModel getMultiMethodTableModel(){ 72 Map selectionToMethodsMap = getSelectionToMethodsMap(); 73 Map selectionToDDMethodsMap = getSelectionToDDMethodsMap(); 74 model = new CheckpointAtEndOfMethodModel(statefulEjb, selectionToMethodsMap, selectionToDDMethodsMap); 75 model.addTableModelListener((TableModelListener )customizer); 76 return model; 77 } 78 79 80 public void setData(StatefulEjb statefulEjb){ 81 this.statefulEjb = statefulEjb; 82 Map selectionToMethodsMap = getSelectionToMethodsMap(); 83 Map selectionToDDMethodsMap = getSelectionToDDMethodsMap(); 84 model.setData(statefulEjb, 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("Checkpoint_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("Method_Header_Tool_Tip"); } 156 if(col == 1){ 157 return bundle.getString("Checkpoint_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(statefulEjb != null){ 173 DDBean ddBean = statefulEjb.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(statefulEjb != null){ 213 CheckpointAtEndOfMethod checkpointAtEndOfMethod = statefulEjb.getCheckpointAtEndOfMethod(); 214 if(checkpointAtEndOfMethod != null){ 215 Method[] ddMethods = checkpointAtEndOfMethod.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(); 282 method.setName("FirstMethod"); 283 String [] params = {"int"}; 284 method.setParameterTypes(params); 285 methods.add(method); 286 287 DummyMethod method2 = new DummyMethod(); 288 method2.setName("SecondMethod"); 289 String [] params2 = {"int", "String"}; 290 method2.setParameterTypes(params2); 291 methods.add(method2); 292 return methods; 294 }else{ 295 ArrayList methods = new ArrayList (); 296 for(int j=0; j<20; j++){ 297 DummyMethod method = new DummyMethod(); 298 method.setName("FirstMethod"); 299 String [] params = {"String"}; 300 method.setParameterTypes(params); 301 methods.add(method); 302 } 303 return methods; 304 } 305 } 306 307 308 public void addTableModelListener(TableModelListener listner){ 309 model.addTableModelListener(listner); 310 } 311 } 312 | Popular Tags |