KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > customizers > ejbmodule > EntityEjbCustomizer


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * EntityEjbCustomizer.java October 23, 2003, 2:06 PM
21  *
22  */

23
24 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.Collection JavaDoc;
28
29 //DEPLOYMENT API
30
import javax.enterprise.deploy.spi.DConfigBean JavaDoc;
31
32 //Swing
33
import javax.swing.event.TableModelListener JavaDoc;
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 /**
41  *
42  * @author Rajeshwar Patil
43  * @version %I%, %G%
44  */

45 public class EntityEjbCustomizer extends EjbCustomizer
46             implements TableModelListener JavaDoc {
47
48
49     private EntityEjb theBean;
50     private EntityEjbPanel enityEjbPanel;
51     private BeanPoolPanel beanPoolPanel;
52     private BeanCachePanel beanCachePanel;
53
54
55     /** Creates a new instance of EntityEjbCustomizer */
56     public EntityEjbCustomizer() {
57     }
58     
59     public void setObject(Object JavaDoc bean) {
60         super.setObject(bean);
61         
62         // Only do this if the bean is actually changing.
63
if(theBean != bean) {
64             if(bean instanceof EntityEjb) {
65                 theBean = (EntityEjb) bean;
66             }
67         }
68     }
69     
70
71     //get the bean specific panel
72
protected javax.swing.JPanel JavaDoc getBeanPanel(){
73         enityEjbPanel = new EntityEjbPanel(this);
74         return enityEjbPanel;
75     }
76
77
78     //initialize all the elements in the bean specific panel
79
protected void initializeBeanPanel(BaseEjb theBean){
80         if(!(theBean instanceof EntityEjb)){
81             assert(false);
82         }
83
84         EntityEjb entityEjb = (EntityEjb)theBean;
85         String JavaDoc isReadOnlyBean = entityEjb.getIsReadOnlyBean();
86         if(isReadOnlyBean != null){
87             enityEjbPanel.setIsreadOnlyBean(isReadOnlyBean);
88         }
89         String JavaDoc refPeriodInSecs = entityEjb.getRefreshPeriodInSeconds();
90         if(refPeriodInSecs != null){
91             enityEjbPanel.setRefreshPeriodInSeconds(refPeriodInSecs);
92         }
93         String JavaDoc 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")); //NOI18N
101
beanPoolPanel.getAccessibleContext().setAccessibleDescription(bundle.getString("BeanPool_Acsbl_Desc")); //NOI18N
102
tabbedPanel.insertTab(bundle.getString("LBL_BeanPool"), null, beanPoolPanel, null, 0); // NOI18N
103

104         beanCachePanel = new BeanCachePanel(this);
105         beanCachePanel.getAccessibleContext().setAccessibleName(bundle.getString("BeanCache_Acsbl_Name")); //NOI18N
106
beanCachePanel.getAccessibleContext().setAccessibleDescription(bundle.getString("BeanCache_Acsbl_Desc")); //NOI18N
107
tabbedPanel.addTab(bundle.getString("LBL_BeanCache"), // NOI18N
108
beanCachePanel);
109
110         //Select Bean Pool Panel
111
tabbedPanel.setSelectedIndex(tabbedPanel.indexOfTab(bundle.getString("LBL_BeanPool"))); //NOI18N
112
}
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 JavaDoc getErrors(){
130         ArrayList JavaDoc errors = null;
131         if(validationSupport == null) assert(false);
132         errors = (ArrayList JavaDoc)super.getErrors();
133
134         //Entity Ejb field Validations
135
String JavaDoc property = enityEjbPanel.getIsreadOnlyBean();
136         errors.addAll(validationSupport.validate(property,
137             "/sun-ejb-jar/enterprise-beans/ejb/is-read-only-bean", //NOI18N
138
bundle.getString("LBL_Is_Read_Only_Bean"))); //NOI18N
139

140         property = enityEjbPanel.getRefreshPeriodInSeconds();
141         errors.addAll(validationSupport.validate(property,
142             "/sun-ejb-jar/enterprise-beans/ejb/refresh-period-in-seconds", //NOI18N
143
bundle.getString("LBL_Refresh_Period_In_Seconds"))); //NOI18N
144

145         property = enityEjbPanel.getCommitOption();
146         errors.addAll(validationSupport.validate(property,
147             "/sun-ejb-jar/enterprise-beans/ejb/commit-option", //NOI18N
148
bundle.getString("LBL_Commit_Option"))); //NOI18N
149

150         return errors;
151     }
152
153
154     public void validateEntries(){
155         super.validateEntries();
156     }
157
158
159     public String JavaDoc getHelpId() {
160         return "AS_CFG_EntityEjb"; //NOI18N
161
}
162
163
164     //Entity Ejb update methods
165
void updateIsReadOnlyBean(String JavaDoc 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 JavaDoc exception){
174             }
175             notifyChange();
176         }
177     }
178
179
180     void updateRefreshPeriodInSeconds(String JavaDoc 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 JavaDoc exception){
189             }
190             notifyChange();
191         }
192     }
193
194
195     void updateSetCommitOption(String JavaDoc 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 JavaDoc exception){
204             }
205             notifyChange();
206         }
207     }
208 }
209
Popular Tags