1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers; 26 27 import java.util.ResourceBundle ; 28 29 import java.beans.Customizer ; 30 import java.beans.PropertyVetoException ; 31 import java.beans.PropertyChangeEvent ; 32 import java.beans.PropertyChangeListener ; 33 34 import javax.swing.JPanel ; 35 36 import org.netbeans.modules.j2ee.sun.share.configbean.MessageDestinationRef; 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 46 public class MessageDestinationRefCustomizer extends BaseCustomizer implements PropertyChangeListener { 47 48 private static final ResourceBundle customizerBundle = ResourceBundle.getBundle( 49 "org.netbeans.modules.j2ee.sun.share.configbean.customizers.Bundle"); 51 private MessageDestinationRef theBean; 52 53 54 public MessageDestinationRefCustomizer() { 55 initComponents(); 56 initUserComponents(); 57 } 58 59 64 private void initComponents() { 66 java.awt.GridBagConstraints gridBagConstraints; 67 68 jPanel1 = new javax.swing.JPanel (); 69 jLblName = new javax.swing.JLabel (); 70 jTxtName = new javax.swing.JTextField (); 71 jLblJndiName = new javax.swing.JLabel (); 72 jTxtJndiName = new javax.swing.JTextField (); 73 74 setLayout(new java.awt.GridBagLayout ()); 75 76 jPanel1.setLayout(new java.awt.GridBagLayout ()); 77 78 jLblName.setLabelFor(jTxtName); 79 jLblName.setText(customizerBundle.getString("LBL_MessageDestinationReferenceName_1")); 80 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (); 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 (0, 6, 0, 0); 92 jPanel1.add(jTxtName, gridBagConstraints); 93 jTxtName.getAccessibleContext().setAccessibleName(customizerBundle.getString("ACSN_MessageDestinationReferenceName")); 94 jTxtName.getAccessibleContext().setAccessibleDescription(customizerBundle.getString("ACSD_MessageDestinationReferenceName")); 95 96 jLblJndiName.setLabelFor(jTxtJndiName); 97 jLblJndiName.setText(customizerBundle.getString("LBL_JNDIName_1")); 98 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (6, 0, 0, 0); 103 jPanel1.add(jLblJndiName, gridBagConstraints); 104 105 jTxtJndiName.addKeyListener(new java.awt.event.KeyAdapter () { 106 public void keyReleased(java.awt.event.KeyEvent evt) { 107 jTxtJndiNameKeyReleased(evt); 108 } 109 }); 110 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.weightx = 1.0; 116 gridBagConstraints.weighty = 1.0; 117 gridBagConstraints.insets = new java.awt.Insets (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 (); 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 (0, 6, 5, 5); 129 add(jPanel1, gridBagConstraints); 130 131 } 133 private void jTxtJndiNameKeyReleased(java.awt.event.KeyEvent evt) { if(theBean != null) { 136 try { 137 theBean.setJndiName(jTxtJndiName.getText()); 138 validateField(MessageDestinationRef.FIELD_JNDI_NAME); 139 } catch(PropertyVetoException ex) { 140 jTxtJndiName.setText(theBean.getJndiName()); 141 } 142 } 143 } 145 private javax.swing.JLabel jLblJndiName; 147 private javax.swing.JLabel jLblName; 148 private javax.swing.JPanel jPanel1; 149 private javax.swing.JTextField jTxtJndiName; 150 private javax.swing.JTextField jTxtName; 151 153 private void initUserComponents() { 154 addTitlePanel(customizerBundle.getString("TITLE_MessageDestinationReference")); getAccessibleContext().setAccessibleName(customizerBundle.getString("ACSN_MessageDestinationReference")); getAccessibleContext().setAccessibleDescription(customizerBundle.getString("ACSD_MessageDestinationReference")); 159 addErrorPanel(); 161 } 162 163 protected void initFields() { 164 jTxtName.setText(theBean.getMessageDestinationRefName()); 165 jTxtJndiName.setText(theBean.getJndiName()); 166 } 167 168 public void propertyChange(PropertyChangeEvent propertyChangeEvent) { 169 String eventName = propertyChangeEvent.getPropertyName(); 170 171 if(MessageDestinationRef.MESSAGE_DESTINATION_REF_NAME.equals(eventName)) { 172 jTxtName.setText(theBean.getMessageDestinationRefName()); 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 bean) { 187 boolean result = super.setBean(bean); 188 189 if(bean instanceof MessageDestinationRef) { 190 theBean = (MessageDestinationRef) bean; 191 result = true; 192 } else { 193 assert (result == false) : 195 "MessageDestinationRefCustomizer was passed wrong bean type in setBean(Object bean)"; 197 theBean = null; 198 result = false; 199 } 200 201 return result; 202 } 203 204 public String getHelpId() { 205 return "AS_CFG_MessageDestinationRef"; } 207 } 208 | Popular Tags |