KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > customizers > other > WebAppRefCustomizer


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  * WebAppRefCustomizer.java
21  *
22  * Created on September 4, 2003, 5:28 PM
23  */

24 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.other;
25
26 import java.beans.Customizer JavaDoc;
27 import java.beans.PropertyVetoException JavaDoc;
28 import java.util.ResourceBundle JavaDoc;
29
30 import javax.swing.JPanel JavaDoc;
31
32 import org.netbeans.modules.j2ee.sun.share.configbean.WebAppRef;
33 import org.netbeans.modules.j2ee.sun.share.configbean.ErrorMessageDB;
34 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.CustomizerErrorPanel;
35 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.CustomizerTitlePanel;
36 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.BaseCustomizer;
37
38
39 /**
40  *
41  * @author Peter Williams
42  */

43 public class WebAppRefCustomizer extends BaseCustomizer {
44     
45     /** Resource bundle */
46     private static final ResourceBundle JavaDoc bundle = ResourceBundle.getBundle(
47         "org.netbeans.modules.j2ee.sun.share.configbean.customizers.other.Bundle"); // NOI18N
48

49     private WebAppRef theBean;
50
51     /** Creates new form WebAppRefCustomizer */
52     public WebAppRefCustomizer() {
53         initComponents();
54         initUserComponents();
55     }
56
57     public WebAppRef getBean() {
58         return theBean;
59     }
60     
61     /** This method is called from within the constructor to
62      * initialize the form.
63      * WARNING: Do NOT modify this code. The content of this method is
64      * always regenerated by the Form Editor.
65      */

66     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
67
private void initComponents() {
68         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
69
70         jPnlGeneral = new javax.swing.JPanel JavaDoc();
71         jLblWebUri = new javax.swing.JLabel JavaDoc();
72         jTxtWebUri = new javax.swing.JTextField JavaDoc();
73         jLblContextRoot = new javax.swing.JLabel JavaDoc();
74         jTxtContextRoot = new javax.swing.JTextField JavaDoc();
75         jBtnDefault = new javax.swing.JButton JavaDoc();
76         jPnlPlaceHolder = new javax.swing.JPanel JavaDoc();
77
78         setLayout(new java.awt.GridBagLayout JavaDoc());
79
80         jPnlGeneral.setLayout(new java.awt.GridBagLayout JavaDoc());
81
82         jLblWebUri.setDisplayedMnemonic(bundle.getString("MNC_WebUri").charAt(0));
83         jLblWebUri.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
84         jLblWebUri.setLabelFor(jTxtWebUri);
85         jLblWebUri.setText(bundle.getString("LBL_WebURI_1"));
86         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
87         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
88         jPnlGeneral.add(jLblWebUri, gridBagConstraints);
89         jLblWebUri.getAccessibleContext().setAccessibleName(bundle.getString("WebURI_Acsbl_Name"));
90         jLblWebUri.getAccessibleContext().setAccessibleDescription(bundle.getString("WebURI_Acsbl_Desc"));
91
92         jTxtWebUri.setEditable(false);
93         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
94         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
95         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
96         gridBagConstraints.ipady = 2;
97         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 0, 0);
98         jPnlGeneral.add(jTxtWebUri, gridBagConstraints);
99         jTxtWebUri.getAccessibleContext().setAccessibleName(bundle.getString("WebURI_Acsbl_Name"));
100         jTxtWebUri.getAccessibleContext().setAccessibleDescription(bundle.getString("WebURI_Acsbl_Desc"));
101
102         jLblContextRoot.setDisplayedMnemonic(bundle.getString("MNC_ContextRoot").charAt(0));
103         jLblContextRoot.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
104         jLblContextRoot.setLabelFor(jTxtContextRoot);
105         jLblContextRoot.setText(bundle.getString("LBL_ContextRoot_1"));
106         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
107         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
108         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 0);
109         jPnlGeneral.add(jLblContextRoot, gridBagConstraints);
110         jLblContextRoot.getAccessibleContext().setAccessibleName(bundle.getString("ContextRoot_Acsbl_Name"));
111         jLblContextRoot.getAccessibleContext().setAccessibleDescription(bundle.getString("ContextRoot_Acsbl_Desc"));
112
113         jTxtContextRoot.addKeyListener(new java.awt.event.KeyAdapter JavaDoc() {
114             public void keyReleased(java.awt.event.KeyEvent JavaDoc evt) {
115                 jTxtContextRootKeyReleased(evt);
116             }
117         });
118
119         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
120         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
121         gridBagConstraints.ipady = 2;
122         gridBagConstraints.weightx = 1.0;
123         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 0);
124         jPnlGeneral.add(jTxtContextRoot, gridBagConstraints);
125         jTxtContextRoot.getAccessibleContext().setAccessibleName(bundle.getString("ContextRoot_Acsbl_Name"));
126         jTxtContextRoot.getAccessibleContext().setAccessibleDescription(bundle.getString("ContextRoot_Acsbl_Desc"));
127
128         jBtnDefault.setMnemonic(bundle.getString("MNC_Default_ContextRoot").charAt(0));
129         jBtnDefault.setText(bundle.getString("LBL_ResetToDefault"));
130         jBtnDefault.addActionListener(new java.awt.event.ActionListener JavaDoc() {
131             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
132                 jBtnDefaultActionPerformed(evt);
133             }
134         });
135
136         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
137         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
138         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 0);
139         jPnlGeneral.add(jBtnDefault, gridBagConstraints);
140         jBtnDefault.getAccessibleContext().setAccessibleName(bundle.getString("ResetToDefault_Acsbl_Name"));
141         jBtnDefault.getAccessibleContext().setAccessibleDescription(bundle.getString("ResetToDefault_Acsbl_Desc"));
142
143         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
144         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
145         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
146         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 0, 5);
147         add(jPnlGeneral, gridBagConstraints);
148
149         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
150         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
151         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
152         gridBagConstraints.weightx = 1.0;
153         gridBagConstraints.weighty = 1.0;
154         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 5);
155         add(jPnlPlaceHolder, gridBagConstraints);
156
157     }// </editor-fold>//GEN-END:initComponents
158

159     private void jBtnDefaultActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jBtnDefaultActionPerformed
160
// Add your handling code here:
161
try {
162             theBean.setContextRoot(null);
163         } catch(PropertyVetoException JavaDoc ex) {
164         }
165         
166         jTxtContextRoot.setText(theBean.getContextRoot());
167     }//GEN-LAST:event_jBtnDefaultActionPerformed
168

169     private void jTxtContextRootKeyReleased(java.awt.event.KeyEvent JavaDoc evt) {//GEN-FIRST:event_jTxtContextRootKeyReleased
170
// Add your handling code here:
171
try {
172             theBean.setContextRoot(jTxtContextRoot.getText());
173         } catch(PropertyVetoException JavaDoc ex) {
174             jTxtContextRoot.setText(theBean.getContextRoot());
175         }
176     }//GEN-LAST:event_jTxtContextRootKeyReleased
177

178     // Variables declaration - do not modify//GEN-BEGIN:variables
179
private javax.swing.JButton JavaDoc jBtnDefault;
180     private javax.swing.JLabel JavaDoc jLblContextRoot;
181     private javax.swing.JLabel JavaDoc jLblWebUri;
182     private javax.swing.JPanel JavaDoc jPnlGeneral;
183     private javax.swing.JPanel JavaDoc jPnlPlaceHolder;
184     private javax.swing.JTextField JavaDoc jTxtContextRoot;
185     private javax.swing.JTextField JavaDoc jTxtWebUri;
186     // End of variables declaration//GEN-END:variables
187

188     private void initUserComponents() {
189         // Add title panel
190
addTitlePanel(bundle.getString("LBL_SunWebModuleRef")); //NOI18N
191

192         // Add error panel
193
addErrorPanel();
194     }
195     
196     /** Initialization of all the fields in the customizer from the bean that
197      * was passed in.
198      */

199     protected void initFields() {
200         jTxtWebUri.setText(theBean.getWebUri());
201         jTxtContextRoot.setText(theBean.getContextRoot());
202         
203         ///jTxtIdentity.setText(theBean.getIdentity());
204
///jTxtRefIdentity.setText(theBean.getRefIdentity());
205
}
206     
207     protected boolean setBean(Object JavaDoc bean) {
208         boolean result = super.setBean(bean);
209         
210         if(bean instanceof WebAppRef) {
211             theBean = (WebAppRef) bean;
212             result = true;
213         } else {
214             // if bean is not a WebAppRef, then it shouldn't have passed Base either.
215
assert (result == false) :
216                 "WebAppRefCustomizer was passed wrong bean type in setBean(Object bean)"; // NOI18N
217

218             theBean = null;
219             result = false;
220         }
221         
222         return result;
223     }
224     
225     public String JavaDoc getHelpId() {
226         return "AS_CFG_WebAppRef";
227     }
228 }
229
Popular Tags