KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > dd > loaders > ui > WSEjbBndAttributesPanel


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 package org.netbeans.modules.j2ee.websphere6.dd.loaders.ui;
20
21 import org.netbeans.modules.j2ee.websphere6.dd.loaders.WSMultiViewDataObject;
22 import org.netbeans.modules.xml.multiview.*;
23 import org.netbeans.modules.xml.multiview.ui.*;
24 import org.netbeans.modules.xml.multiview.Error;
25 import org.netbeans.modules.j2ee.websphere6.dd.loaders.ejbbnd.*;
26 import org.netbeans.modules.j2ee.websphere6.dd.beans.WSEjbBnd;
27 import org.openide.util.NbBundle;
28 /**
29  *
30  * @author dlm198383
31  */

32 public class WSEjbBndAttributesPanel extends SectionInnerPanel implements java.awt.event.ItemListener JavaDoc{
33     /** Creates new form WSEjbExtAttributesPanel */
34     WSEjbBnd ejbbnd;
35     WSMultiViewDataObject dObj;
36     
37     private javax.swing.JTextField JavaDoc cmpConnectionFactoryNameField;
38     private javax.swing.JTextField JavaDoc cmpConnectionFactoryJndiNameField;
39     private javax.swing.JCheckBox JavaDoc cmpConnectionFactoryCheckBox;
40     private javax.swing.JComboBox JavaDoc cmpConnectionFactoryAuthType;
41     private final String JavaDoc FACTORY_NAME="Default CMP Connection Factory Name"; //NOI18N
42
private final String JavaDoc FACTORY_JNDI_NAME="Default CMP Connection Factory JNDI Name"; //NOI18N
43

44     
45     /** Creates new form WSEjbBndAttributesPanel */
46     public WSEjbBndAttributesPanel(SectionView view, WSMultiViewDataObject dObj,WSEjbBnd ejbbnd) {
47         super(view);
48         this.dObj=dObj;
49         this.ejbbnd=ejbbnd;
50         initComponents();
51         bindCmpConnectionFactoryComponents();
52         initCmpConnectionFactoryComponents();
53         
54         nameField.setText(ejbbnd.getXmiId());
55         hrefField.setText(ejbbnd.getEjbJarHref());
56         currentBackendIdField.setText(ejbbnd.getCurrentBackendId());
57         addModifier(nameField);
58         addModifier(hrefField);
59         addModifier(currentBackendIdField);
60     }
61     private void bindCmpConnectionFactoryComponents() {
62         CMPConnectionFactory panel=(CMPConnectionFactory)cmpConnectionFactoryPanel;
63         cmpConnectionFactoryNameField=panel.getNameField();
64         cmpConnectionFactoryJndiNameField=panel.getJndiNameField();
65         cmpConnectionFactoryCheckBox=panel.getFactoryCheckBox();
66         cmpConnectionFactoryAuthType=panel.getAuthTypeComboBox();
67         panel.setComponentsBackground(SectionVisualTheme.getSectionActiveBackgroundColor());
68         panel.setEnabledComponents();
69     }
70     
71     private void initCmpConnectionFactoryComponents(){
72         addModifier(cmpConnectionFactoryNameField);
73         addModifier(cmpConnectionFactoryJndiNameField);
74         addValidatee(cmpConnectionFactoryNameField);
75         addValidatee(cmpConnectionFactoryJndiNameField);
76         
77         boolean factoryEnabled=(ejbbnd.getCmpConnectionFactory()==null)?false:true;
78         cmpConnectionFactoryCheckBox.setSelected(factoryEnabled);
79         
80         if(factoryEnabled) {
81             
82             cmpConnectionFactoryNameField.setText(
83                     ejbbnd.getCmpConnectionFactoryXmiId());
84             
85             cmpConnectionFactoryJndiNameField.setText(
86                     ejbbnd.getCmpConnectionFactoryJndiName());
87             
88             cmpConnectionFactoryAuthType.setSelectedItem(
89                     ejbbnd.getCmpConnectionFactoryResAuth());
90             
91         }
92         cmpConnectionFactoryCheckBox.addItemListener(this);
93         cmpConnectionFactoryAuthType.addItemListener(this);
94         ((CMPConnectionFactory)cmpConnectionFactoryPanel).setEnabledComponents();
95     }
96     public void setValue(javax.swing.JComponent JavaDoc source,Object JavaDoc value) {
97         if (source==nameField) {
98             ejbbnd.setXmiId((String JavaDoc)value);
99         } else if (source==hrefField) {
100             ejbbnd.setEjbJarHref((String JavaDoc)value);
101         } else if (source==currentBackendIdField) {
102             ejbbnd.setCurrentBackendId((String JavaDoc)value);
103         } else if(source==cmpConnectionFactoryNameField) {
104             ejbbnd.setCmpConnectionFactoryXmiId((String JavaDoc)value);
105         } else if(source==cmpConnectionFactoryJndiNameField) {
106             ejbbnd.setCmpConnectionFactoryJndiName((String JavaDoc)value);
107         }
108         
109     }
110     public void linkButtonPressed(Object JavaDoc ddBean, String JavaDoc ddProperty) {
111     }
112     public void rollbackValue(javax.swing.text.JTextComponent JavaDoc source) {
113         if (nameField==source) {
114             nameField.setText(ejbbnd.getXmiId());
115         }
116         if (hrefField==source) {
117             hrefField.setText(ejbbnd.getEjbJarHref());
118         }
119         if (currentBackendIdField==source) {
120             currentBackendIdField.setText(ejbbnd.getCurrentBackendId());
121         }
122         if (cmpConnectionFactoryNameField==source) {
123             cmpConnectionFactoryNameField.setText(ejbbnd.getCmpConnectionFactoryXmiId());
124         }
125         if (cmpConnectionFactoryJndiNameField==source) {
126             cmpConnectionFactoryNameField.setText(ejbbnd.getCmpConnectionFactoryJndiName());
127         }
128     }
129     public javax.swing.JComponent JavaDoc getErrorComponent(String JavaDoc errorId) {
130         if ("Name".equals(errorId)) return nameField;
131         if ("Ejb-Jar ID".equals(errorId)) return hrefField;
132         if("Current Backend ID".equals(errorId)) return currentBackendIdField;
133         return null;
134     }
135     public void documentChanged(javax.swing.text.JTextComponent JavaDoc comp, String JavaDoc value) {
136         if (comp==nameField) {
137             String JavaDoc val = (String JavaDoc)value;
138             if (val.length()==0) {
139                 getSectionView()
140                 .getErrorPanel()
141                 .setError(new Error JavaDoc(Error.MISSING_VALUE_MESSAGE, "Name", comp));
142                 return;
143             }
144             getSectionView().getErrorPanel().clearError();
145         }
146         if (comp==hrefField) {
147             String JavaDoc val = (String JavaDoc)value;
148             if (val.length()==0) {
149                 getSectionView()
150                 .getErrorPanel()
151                 .setError(new Error JavaDoc(Error.MISSING_VALUE_MESSAGE, "Ejb-Jar ID", comp));
152                 return;
153             }
154             getSectionView().getErrorPanel().clearError();
155         }
156         if (comp==currentBackendIdField) {
157             String JavaDoc val = (String JavaDoc)value;
158             if (val.length()==0) {
159                 getSectionView()
160                 .getErrorPanel()
161                 .setError(new Error JavaDoc(Error.MISSING_VALUE_MESSAGE, "Current Backend ID", comp));
162                 return;
163             }
164             getSectionView().getErrorPanel().clearError();
165         }
166         if(comp==cmpConnectionFactoryNameField) {
167             String JavaDoc val = (String JavaDoc)value;
168             if (val.length()==0) {
169                 getSectionView().getErrorPanel().setError(new Error JavaDoc(Error.MISSING_VALUE_MESSAGE, FACTORY_NAME, comp));
170                 return;
171             }
172             getSectionView().getErrorPanel().clearError();
173         }
174         if(comp==cmpConnectionFactoryJndiNameField) {
175             String JavaDoc val = (String JavaDoc)value;
176             if (val.length()==0) {
177                 getSectionView().getErrorPanel().setError(new Error JavaDoc(Error.MISSING_VALUE_MESSAGE, FACTORY_JNDI_NAME, comp));
178                 return;
179             }
180             getSectionView().getErrorPanel().clearError();
181         }
182     }
183     private void changeCmpConnectionFactoryState() {
184         if(cmpConnectionFactoryCheckBox.isSelected()) {
185             ejbbnd.setCmpConnectionFactory("");
186             ejbbnd.setCmpConnectionFactoryXmiId(cmpConnectionFactoryNameField.getText());
187             ejbbnd.setCmpConnectionFactoryResAuth(
188                     cmpConnectionFactoryAuthType.getSelectedItem().toString());
189         } else {
190             ejbbnd.setCmpConnectionFactory(null);
191         }
192         ((CMPConnectionFactory)cmpConnectionFactoryPanel).setEnabledComponents();
193     }
194     public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
195         dObj.setChangedFromUI(true);
196         changeCmpConnectionFactoryState();
197         // TODO add your handling code here:
198
dObj.modelUpdatedFromUI();
199         //dObj.setChangedFromUI(true);
200
dObj.setChangedFromUI(false);
201     }
202     protected void startUIChange() {
203         dObj.setChangedFromUI(true);
204     }
205     protected void endUIChange() {
206         dObj.modelUpdatedFromUI();
207         dObj.setChangedFromUI(false);
208     }
209     /** This method is called from within the constructor to
210      * initialize the form.
211      * WARNING: Do NOT modify this code. The content of this method is
212      * always regenerated by the Form Editor.
213      */

214     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
215
private void initComponents() {
216         nameLabel = new javax.swing.JLabel JavaDoc();
217         nameField = new javax.swing.JTextField JavaDoc();
218         currentBackendIdLabel = new javax.swing.JLabel JavaDoc();
219         currentBackendIdField = new javax.swing.JTextField JavaDoc();
220         rootId = new javax.swing.JLabel JavaDoc();
221         hrefField = new javax.swing.JTextField JavaDoc();
222         cmpConnectionFactoryPanel = new CMPConnectionFactory();
223         ((CMPConnectionFactory)cmpConnectionFactoryPanel).getFactoryCheckBox().setText(NbBundle.getMessage(CMPConnectionFactory.class,"LBL_DefaultCMPConnectionFactory"));
224
225         nameLabel.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_Name"));
226
227         currentBackendIdLabel.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_CurrentBackendId"));
228
229         rootId.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/websphere6/dd/loaders/ui/Bundle").getString("LBL_EjbJarId"));
230
231         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
232         this.setLayout(layout);
233         layout.setHorizontalGroup(
234             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
235             .add(layout.createSequentialGroup()
236                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
237                     .add(layout.createSequentialGroup()
238                         .add(58, 58, 58)
239                         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
240                             .add(rootId)
241                             .add(nameLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 35, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
242                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
243                         .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
244                             .add(hrefField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE)
245                             .add(nameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE)))
246                     .add(layout.createSequentialGroup()
247                         .addContainerGap()
248                         .add(currentBackendIdLabel)
249                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
250                         .add(currentBackendIdField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE))
251                     .add(layout.createSequentialGroup()
252                         .addContainerGap()
253                         .add(cmpConnectionFactoryPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE)))
254                 .addContainerGap())
255         );
256         layout.setVerticalGroup(
257             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
258             .add(layout.createSequentialGroup()
259                 .addContainerGap()
260                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
261                     .add(nameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
262                     .add(nameLabel))
263                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
264                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
265                     .add(rootId, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 14, Short.MAX_VALUE)
266                     .add(hrefField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
267                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
268                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
269                     .add(currentBackendIdLabel)
270                     .add(currentBackendIdField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
271                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
272                 .add(cmpConnectionFactoryPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
273                 .addContainerGap())
274         );
275     }// </editor-fold>//GEN-END:initComponents
276

277     
278     // Variables declaration - do not modify//GEN-BEGIN:variables
279
private javax.swing.JPanel JavaDoc cmpConnectionFactoryPanel;
280     private javax.swing.JTextField JavaDoc currentBackendIdField;
281     private javax.swing.JLabel JavaDoc currentBackendIdLabel;
282     private javax.swing.JTextField JavaDoc hrefField;
283     private javax.swing.JTextField JavaDoc nameField;
284     private javax.swing.JLabel JavaDoc nameLabel;
285     private javax.swing.JLabel JavaDoc rootId;
286     // End of variables declaration//GEN-END:variables
287

288 }
289
Popular Tags