KickJava   Java API By Example, From Geeks To Geeks.

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


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  * MessageDestinationCustomizer.java
21  *
22  * Created on March 17, 2006, 5:28 PM
23  */

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

46 public class MessageDestinationCustomizer extends BaseCustomizer implements PropertyChangeListener JavaDoc {
47     
48     private static final ResourceBundle JavaDoc customizerBundle = ResourceBundle.getBundle(
49         "org.netbeans.modules.j2ee.sun.share.configbean.customizers.Bundle"); // NOI18N
50

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

64     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
65
private void initComponents() {
66         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
67
68         jPanel1 = new javax.swing.JPanel JavaDoc();
69         jLblName = new javax.swing.JLabel JavaDoc();
70         jTxtName = new javax.swing.JTextField JavaDoc();
71         jLblJndiName = new javax.swing.JLabel JavaDoc();
72         jTxtJndiName = new javax.swing.JTextField JavaDoc();
73
74         setLayout(new java.awt.GridBagLayout JavaDoc());
75
76         jPanel1.setLayout(new java.awt.GridBagLayout JavaDoc());
77
78         jLblName.setLabelFor(jTxtName);
79         jLblName.setText(customizerBundle.getString("LBL_MessageDestinationName_1"));
80         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
81         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
82         gridBagConstraints.ipady = 4;
83         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
84         jPanel1.add(jLblName, gridBagConstraints);
85
86         jTxtName.setEditable(false);
87         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
88         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
89         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
90         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
91         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 0, 0);
92         jPanel1.add(jTxtName, gridBagConstraints);
93         jTxtName.getAccessibleContext().setAccessibleName(customizerBundle.getString("ACSN_MessageDestinationName"));
94         jTxtName.getAccessibleContext().setAccessibleDescription(customizerBundle.getString("ACSD_MessageDestinationName"));
95
96         jLblJndiName.setLabelFor(jTxtJndiName);
97         jLblJndiName.setText(customizerBundle.getString("LBL_JNDIName_1"));
98         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
99         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
100         gridBagConstraints.ipady = 4;
101         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
102         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 0);
103         jPanel1.add(jLblJndiName, gridBagConstraints);
104
105         jTxtJndiName.addKeyListener(new java.awt.event.KeyAdapter JavaDoc() {
106             public void keyReleased(java.awt.event.KeyEvent JavaDoc evt) {
107                 jTxtJndiNameKeyReleased(evt);
108             }
109         });
110
111         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
112         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
113         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
114         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
115         gridBagConstraints.weightx = 1.0;
116         gridBagConstraints.weighty = 1.0;
117         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 6, 0, 0);
118         jPanel1.add(jTxtJndiName, gridBagConstraints);
119         jTxtJndiName.getAccessibleContext().setAccessibleName(customizerBundle.getString("ACSN_JNDIName"));
120         jTxtJndiName.getAccessibleContext().setAccessibleDescription(customizerBundle.getString("ACSD_JNDIName"));
121
122         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
123         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
124         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
125         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
126         gridBagConstraints.weightx = 1.0;
127         gridBagConstraints.weighty = 1.0;
128         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 5, 5);
129         add(jPanel1, gridBagConstraints);
130
131     }// </editor-fold>//GEN-END:initComponents
132

133     private void jTxtJndiNameKeyReleased(java.awt.event.KeyEvent JavaDoc evt) {//GEN-FIRST:event_jTxtJndiNameKeyReleased
134
// Add your handling code here:
135
if(theBean != null) {
136             try {
137                 theBean.setJndiName(jTxtJndiName.getText());
138                 validateField(MessageDestination.FIELD_JNDI_NAME);
139             } catch(PropertyVetoException JavaDoc ex) {
140                 jTxtJndiName.setText(theBean.getJndiName());
141             }
142         }
143     }//GEN-LAST:event_jTxtJndiNameKeyReleased
144

145     // Variables declaration - do not modify//GEN-BEGIN:variables
146
private javax.swing.JLabel JavaDoc jLblJndiName;
147     private javax.swing.JLabel JavaDoc jLblName;
148     private javax.swing.JPanel JavaDoc jPanel1;
149     private javax.swing.JTextField JavaDoc jTxtJndiName;
150     private javax.swing.JTextField JavaDoc jTxtName;
151     // End of variables declaration//GEN-END:variables
152

153     private void initUserComponents() {
154         // Add title panel
155
addTitlePanel(customizerBundle.getString("TITLE_MessageDestination")); // NOI18N
156
getAccessibleContext().setAccessibleName(customizerBundle.getString("ACSN_MessageDestination")); // NOI18N
157
getAccessibleContext().setAccessibleDescription(customizerBundle.getString("ACSD_MessageDestination")); // NOI18N
158

159         // Add error panel
160
addErrorPanel();
161     }
162     
163     protected void initFields() {
164         jTxtName.setText(theBean.getMessageDestinationName());
165         jTxtJndiName.setText(theBean.getJndiName());
166     }
167
168     public void propertyChange(PropertyChangeEvent JavaDoc propertyChangeEvent) {
169         String JavaDoc eventName = propertyChangeEvent.getPropertyName();
170         
171         if(MessageDestination.MESSAGE_DESTINATION_NAME.equals(eventName)) {
172             jTxtName.setText(theBean.getMessageDestinationName());
173         }
174     }
175     
176     protected void addListeners() {
177         super.addListeners();
178         theBean.addPropertyChangeListener(this);
179     }
180     
181     protected void removeListeners() {
182         super.removeListeners();
183         theBean.removePropertyChangeListener(this);
184     }
185     
186     protected boolean setBean(Object JavaDoc bean) {
187         boolean result = super.setBean(bean);
188         
189         if(bean instanceof MessageDestination) {
190             theBean = (MessageDestination) bean;
191             result = true;
192         } else {
193             // if bean is not a MessageDestination, then it shouldn't have passed Base either.
194
assert (result == false) :
195                 "MessageDestinationCustomizer was passed wrong bean type in setBean(Object bean)"; // NOI18N
196

197             theBean = null;
198             result = false;
199         }
200         
201         return result;
202     }
203     
204     public String JavaDoc getHelpId() {
205         return "AS_CFG_MessageDestination"; // NOI18N
206
}
207 }
208
Popular Tags