1 19 23 24 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule; 25 26 import java.util.ArrayList ; 27 import java.util.Collection ; 28 29 import javax.enterprise.deploy.spi.DConfigBean ; 31 32 import javax.swing.event.TableModelListener ; 34 35 import org.netbeans.modules.j2ee.sun.dd.api.ejb.BeanCache; 36 import org.netbeans.modules.j2ee.sun.dd.api.ejb.BeanPool; 37 import org.netbeans.modules.j2ee.sun.share.configbean.BaseEjb; 38 import org.netbeans.modules.j2ee.sun.share.configbean.EntityEjb; 39 40 45 public class EntityEjbCustomizer extends EjbCustomizer 46 implements TableModelListener { 47 48 49 private EntityEjb theBean; 50 private EntityEjbPanel enityEjbPanel; 51 private BeanPoolPanel beanPoolPanel; 52 private BeanCachePanel beanCachePanel; 53 54 55 56 public EntityEjbCustomizer() { 57 } 58 59 public void setObject(Object bean) { 60 super.setObject(bean); 61 62 if(theBean != bean) { 64 if(bean instanceof EntityEjb) { 65 theBean = (EntityEjb) bean; 66 } 67 } 68 } 69 70 71 protected javax.swing.JPanel getBeanPanel(){ 73 enityEjbPanel = new EntityEjbPanel(this); 74 return enityEjbPanel; 75 } 76 77 78 protected void initializeBeanPanel(BaseEjb theBean){ 80 if(!(theBean instanceof EntityEjb)){ 81 assert(false); 82 } 83 84 EntityEjb entityEjb = (EntityEjb)theBean; 85 String isReadOnlyBean = entityEjb.getIsReadOnlyBean(); 86 if(isReadOnlyBean != null){ 87 enityEjbPanel.setIsreadOnlyBean(isReadOnlyBean); 88 } 89 String refPeriodInSecs = entityEjb.getRefreshPeriodInSeconds(); 90 if(refPeriodInSecs != null){ 91 enityEjbPanel.setRefreshPeriodInSeconds(refPeriodInSecs); 92 } 93 String commitOption = entityEjb.getCommitOption(); 94 enityEjbPanel.setCommitOption(commitOption); 95 }; 96 97 98 protected void addTabbedBeanPanels() { 99 beanPoolPanel = new BeanPoolPanel(this); 100 beanPoolPanel.getAccessibleContext().setAccessibleName(bundle.getString("BeanPool_Acsbl_Name")); beanPoolPanel.getAccessibleContext().setAccessibleDescription(bundle.getString("BeanPool_Acsbl_Desc")); tabbedPanel.insertTab(bundle.getString("LBL_BeanPool"), null, beanPoolPanel, null, 0); 104 beanCachePanel = new BeanCachePanel(this); 105 beanCachePanel.getAccessibleContext().setAccessibleName(bundle.getString("BeanCache_Acsbl_Name")); beanCachePanel.getAccessibleContext().setAccessibleDescription(bundle.getString("BeanCache_Acsbl_Desc")); tabbedPanel.addTab(bundle.getString("LBL_BeanCache"), beanCachePanel); 109 110 tabbedPanel.setSelectedIndex(tabbedPanel.indexOfTab(bundle.getString("LBL_BeanPool"))); } 113 114 115 protected void initializeTabbedBeanPanels(BaseEjb theBean) { 116 if(!(theBean instanceof EntityEjb)){ 117 assert(false); 118 } 119 120 EntityEjb entityEjb = (EntityEjb)theBean; 121 BeanPool beanPool = entityEjb.getBeanPool(); 122 beanPoolPanel.setValues(beanPool); 123 124 BeanCache beanCache = entityEjb.getBeanCache(); 125 beanCachePanel.setValues(beanCache); 126 } 127 128 129 public Collection getErrors(){ 130 ArrayList errors = null; 131 if(validationSupport == null) assert(false); 132 errors = (ArrayList )super.getErrors(); 133 134 String property = enityEjbPanel.getIsreadOnlyBean(); 136 errors.addAll(validationSupport.validate(property, 137 "/sun-ejb-jar/enterprise-beans/ejb/is-read-only-bean", bundle.getString("LBL_Is_Read_Only_Bean"))); 140 property = enityEjbPanel.getRefreshPeriodInSeconds(); 141 errors.addAll(validationSupport.validate(property, 142 "/sun-ejb-jar/enterprise-beans/ejb/refresh-period-in-seconds", bundle.getString("LBL_Refresh_Period_In_Seconds"))); 145 property = enityEjbPanel.getCommitOption(); 146 errors.addAll(validationSupport.validate(property, 147 "/sun-ejb-jar/enterprise-beans/ejb/commit-option", bundle.getString("LBL_Commit_Option"))); 150 return errors; 151 } 152 153 154 public void validateEntries(){ 155 super.validateEntries(); 156 } 157 158 159 public String getHelpId() { 160 return "AS_CFG_EntityEjb"; } 162 163 164 void updateIsReadOnlyBean(String isReadOnlyBean){ 166 if(theBean != null){ 167 try{ 168 if(EMPTY_STRING.equals(isReadOnlyBean)){ 169 theBean.setIsReadOnlyBean(null); 170 }else{ 171 theBean.setIsReadOnlyBean(isReadOnlyBean); 172 } 173 }catch(java.beans.PropertyVetoException exception){ 174 } 175 notifyChange(); 176 } 177 } 178 179 180 void updateRefreshPeriodInSeconds(String refPeriodInSecs){ 181 if(theBean != null){ 182 try{ 183 if(EMPTY_STRING.equals(refPeriodInSecs)){ 184 theBean.setRefreshPeriodInSeconds(null); 185 }else{ 186 theBean.setRefreshPeriodInSeconds(refPeriodInSecs); 187 } 188 }catch(java.beans.PropertyVetoException exception){ 189 } 190 notifyChange(); 191 } 192 } 193 194 195 void updateSetCommitOption(String commitOption){ 196 if(theBean != null){ 197 try{ 198 if(EMPTY_STRING.equals(commitOption)){ 199 theBean.setCommitOption(null); 200 }else{ 201 theBean.setCommitOption(commitOption); 202 } 203 }catch(java.beans.PropertyVetoException exception){ 204 } 205 notifyChange(); 206 } 207 } 208 } 209 | Popular Tags |