001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: /*
042: * MessageDestinationCustomizer.java
043: *
044: * Created on March 17, 2006, 5:28 PM
045: */
046:
047: package org.netbeans.modules.j2ee.sun.share.configbean.customizers;
048:
049: import java.util.ResourceBundle;
050:
051: import java.beans.Customizer;
052: import java.beans.PropertyVetoException;
053: import java.beans.PropertyChangeEvent;
054: import java.beans.PropertyChangeListener;
055:
056: import javax.swing.JPanel;
057:
058: import org.netbeans.modules.j2ee.sun.share.configbean.MessageDestination;
059: import org.netbeans.modules.j2ee.sun.share.configbean.ErrorMessageDB;
060: import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.CustomizerErrorPanel;
061: import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.CustomizerTitlePanel;
062: import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.BaseCustomizer;
063:
064: /**
065: *
066: * @author Peter Williams
067: */
068: public class MessageDestinationCustomizer extends BaseCustomizer
069: implements PropertyChangeListener {
070:
071: private final ResourceBundle customizerBundle = ResourceBundle
072: .getBundle("org.netbeans.modules.j2ee.sun.share.configbean.customizers.Bundle"); // NOI18N
073:
074: private MessageDestination theBean;
075:
076: /** Creates new form MessageDestinationCustomizer */
077: public MessageDestinationCustomizer() {
078: initComponents();
079: initUserComponents();
080: }
081:
082: /** This method is called from within the constructor to
083: * initialize the form.
084: * WARNING: Do NOT modify this code. The content of this method is
085: * always regenerated by the Form Editor.
086: */
087: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
088: private void initComponents() {
089: java.awt.GridBagConstraints gridBagConstraints;
090:
091: jPanel1 = new javax.swing.JPanel();
092: jLblName = new javax.swing.JLabel();
093: jTxtName = new javax.swing.JTextField();
094: jLblJndiName = new javax.swing.JLabel();
095: jTxtJndiName = new javax.swing.JTextField();
096:
097: setLayout(new java.awt.GridBagLayout());
098:
099: jPanel1.setLayout(new java.awt.GridBagLayout());
100:
101: jLblName.setLabelFor(jTxtName);
102: jLblName.setText(customizerBundle
103: .getString("LBL_MessageDestinationName_1"));
104: gridBagConstraints = new java.awt.GridBagConstraints();
105: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
106: gridBagConstraints.ipady = 4;
107: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
108: jPanel1.add(jLblName, gridBagConstraints);
109:
110: jTxtName.setEditable(false);
111: gridBagConstraints = new java.awt.GridBagConstraints();
112: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
113: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
114: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
115: gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0);
116: jPanel1.add(jTxtName, gridBagConstraints);
117: jTxtName.getAccessibleContext().setAccessibleName(
118: customizerBundle
119: .getString("ACSN_MessageDestinationName"));
120: jTxtName.getAccessibleContext().setAccessibleDescription(
121: customizerBundle
122: .getString("ACSD_MessageDestinationName"));
123:
124: jLblJndiName.setLabelFor(jTxtJndiName);
125: jLblJndiName.setText(customizerBundle
126: .getString("LBL_JNDIName_1"));
127: gridBagConstraints = new java.awt.GridBagConstraints();
128: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
129: gridBagConstraints.ipady = 4;
130: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
131: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
132: jPanel1.add(jLblJndiName, gridBagConstraints);
133:
134: jTxtJndiName.addKeyListener(new java.awt.event.KeyAdapter() {
135: public void keyReleased(java.awt.event.KeyEvent evt) {
136: jTxtJndiNameKeyReleased(evt);
137: }
138: });
139:
140: gridBagConstraints = new java.awt.GridBagConstraints();
141: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
142: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
143: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
144: gridBagConstraints.weightx = 1.0;
145: gridBagConstraints.weighty = 1.0;
146: gridBagConstraints.insets = new java.awt.Insets(6, 6, 0, 0);
147: jPanel1.add(jTxtJndiName, gridBagConstraints);
148: jTxtJndiName.getAccessibleContext().setAccessibleName(
149: customizerBundle.getString("ACSN_JNDIName"));
150: jTxtJndiName.getAccessibleContext().setAccessibleDescription(
151: customizerBundle.getString("ACSD_JNDIName"));
152:
153: gridBagConstraints = new java.awt.GridBagConstraints();
154: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
155: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
156: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
157: gridBagConstraints.weightx = 1.0;
158: gridBagConstraints.weighty = 1.0;
159: gridBagConstraints.insets = new java.awt.Insets(0, 6, 5, 5);
160: add(jPanel1, gridBagConstraints);
161:
162: }// </editor-fold>//GEN-END:initComponents
163:
164: private void jTxtJndiNameKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtJndiNameKeyReleased
165: // Add your handling code here:
166: if (theBean != null) {
167: try {
168: theBean.setJndiName(jTxtJndiName.getText());
169: validateField(MessageDestination.FIELD_JNDI_NAME);
170: } catch (PropertyVetoException ex) {
171: jTxtJndiName.setText(theBean.getJndiName());
172: }
173: }
174: }//GEN-LAST:event_jTxtJndiNameKeyReleased
175:
176: // Variables declaration - do not modify//GEN-BEGIN:variables
177: private javax.swing.JLabel jLblJndiName;
178: private javax.swing.JLabel jLblName;
179: private javax.swing.JPanel jPanel1;
180: private javax.swing.JTextField jTxtJndiName;
181: private javax.swing.JTextField jTxtName;
182:
183: // End of variables declaration//GEN-END:variables
184:
185: private void initUserComponents() {
186: // Add title panel
187: addTitlePanel(customizerBundle
188: .getString("TITLE_MessageDestination")); // NOI18N
189: getAccessibleContext().setAccessibleName(
190: customizerBundle.getString("ACSN_MessageDestination")); // NOI18N
191: getAccessibleContext().setAccessibleDescription(
192: customizerBundle.getString("ACSD_MessageDestination")); // NOI18N
193:
194: // Add error panel
195: addErrorPanel();
196: }
197:
198: protected void initFields() {
199: jTxtName.setText(theBean.getMessageDestinationName());
200: jTxtJndiName.setText(theBean.getJndiName());
201: }
202:
203: public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
204: String eventName = propertyChangeEvent.getPropertyName();
205:
206: if (MessageDestination.MESSAGE_DESTINATION_NAME
207: .equals(eventName)) {
208: jTxtName.setText(theBean.getMessageDestinationName());
209: }
210: }
211:
212: protected void addListeners() {
213: super .addListeners();
214: theBean.addPropertyChangeListener(this );
215: }
216:
217: protected void removeListeners() {
218: super .removeListeners();
219: theBean.removePropertyChangeListener(this );
220: }
221:
222: protected boolean setBean(Object bean) {
223: boolean result = super .setBean(bean);
224:
225: if (bean instanceof MessageDestination) {
226: theBean = (MessageDestination) bean;
227: result = true;
228: } else {
229: // if bean is not a MessageDestination, then it shouldn't have passed Base either.
230: assert (result == false) : "MessageDestinationCustomizer was passed wrong bean type in setBean(Object bean)"; // NOI18N
231:
232: theBean = null;
233: result = false;
234: }
235:
236: return result;
237: }
238:
239: public String getHelpId() {
240: return "AS_CFG_MessageDestination"; // NOI18N
241: }
242: }
|