1 19 package org.netbeans.modules.xml.tax.beans.customizer; 20 21 import java.beans.PropertyChangeEvent ; 22 23 import org.netbeans.tax.TreeNotationDecl; 24 import org.netbeans.tax.TreeException; 25 26 import org.netbeans.modules.xml.tax.util.TAXUtil; 27 28 33 public class TreeNotationDeclCustomizer extends AbstractTreeCustomizer { 34 35 36 private static final long serialVersionUID = 844910700645886601L; 37 38 39 43 44 public TreeNotationDeclCustomizer () { 45 super (); 46 47 initComponents (); 48 nameLabel.setDisplayedMnemonic (Util.THIS.getChar ("MNE_dtdNotationName")); publicLabel.setDisplayedMnemonic (Util.THIS.getChar ("MNE_dtdNotationPublicId")); systemLabel.setDisplayedMnemonic (Util.THIS.getChar ("MNE_dtdNotationSystemId")); 52 initAccessibility (); 53 } 54 55 56 60 62 protected final TreeNotationDecl getNotationDecl () { 63 return (TreeNotationDecl)getTreeObject (); 64 } 65 66 68 protected final void safePropertyChange (PropertyChangeEvent pche) { 69 super.safePropertyChange (pche); 70 71 if (pche.getPropertyName ().equals (TreeNotationDecl.PROP_NAME)) { 72 updateNameComponent (); 73 } else if (pche.getPropertyName ().equals (TreeNotationDecl.PROP_PUBLIC_ID)) { 74 updatePublicIdComponent (); 75 } else if (pche.getPropertyName ().equals (TreeNotationDecl.PROP_SYSTEM_ID)) { 76 updateSystemIdComponent (); 77 } 78 } 79 80 82 protected final void updateNotationDeclName () { 83 try { 84 getNotationDecl ().setName (nameField.getText ()); 85 } catch (TreeException exc) { 86 updateNameComponent (); 87 TAXUtil.notifyTreeException (exc); 88 } 89 } 90 91 93 protected final void updateNameComponent () { 94 nameField.setText (getNotationDecl ().getName ()); 95 } 96 97 99 protected final void updateNotationDeclPublicId () { 100 try { 101 getNotationDecl ().setPublicId (text2null (publicField.getText ())); 102 } catch (TreeException exc) { 103 updatePublicIdComponent (); 104 TAXUtil.notifyTreeException (exc); 105 } 106 } 107 108 110 protected final void updatePublicIdComponent () { 111 publicField.setText (null2text (getNotationDecl ().getPublicId ())); 112 } 113 114 116 protected final void updateNotationDeclSystemId () { 117 try { 118 getNotationDecl ().setSystemId (text2null (systemField.getText ())); 119 } catch (TreeException exc) { 120 updateSystemIdComponent (); 121 TAXUtil.notifyTreeException (exc); 122 } 123 } 124 125 127 protected final void updateSystemIdComponent () { 128 systemField.setText (null2text (getNotationDecl ().getSystemId ())); 129 } 130 131 133 protected final void initComponentValues () { 134 updateNameComponent (); 135 updatePublicIdComponent (); 136 updateSystemIdComponent (); 137 } 138 139 140 142 protected void updateReadOnlyStatus (boolean editable) { 143 nameField.setEditable (editable); 144 systemField.setEditable (editable); 145 publicField.setEditable (editable); 146 } 147 148 149 154 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 156 157 nameLabel = new javax.swing.JLabel (); 158 nameField = new javax.swing.JTextField (); 159 publicLabel = new javax.swing.JLabel (); 160 publicField = new javax.swing.JTextField (); 161 systemLabel = new javax.swing.JLabel (); 162 systemField = new javax.swing.JTextField (); 163 fillPanel = new javax.swing.JPanel (); 164 165 setLayout(new java.awt.GridBagLayout ()); 166 167 nameLabel.setText(Util.THIS.getString ("PROP_dtdNotationName")); 168 nameLabel.setLabelFor(nameField); 169 gridBagConstraints = new java.awt.GridBagConstraints (); 170 gridBagConstraints.gridx = 0; 171 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 172 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 173 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 174 add(nameLabel, gridBagConstraints); 175 176 nameField.setColumns(20); 177 nameField.addActionListener(new java.awt.event.ActionListener () { 178 public void actionPerformed(java.awt.event.ActionEvent evt) { 179 nameFieldActionPerformed(evt); 180 } 181 }); 182 183 nameField.addFocusListener(new java.awt.event.FocusAdapter () { 184 public void focusGained(java.awt.event.FocusEvent evt) { 185 nameFieldFocusGained(evt); 186 } 187 public void focusLost(java.awt.event.FocusEvent evt) { 188 nameFieldFocusLost(evt); 189 } 190 }); 191 192 gridBagConstraints = new java.awt.GridBagConstraints (); 193 gridBagConstraints.gridx = 1; 194 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 195 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 196 gridBagConstraints.weightx = 1.0; 197 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 198 add(nameField, gridBagConstraints); 199 200 publicLabel.setText(Util.THIS.getString ("PROP_dtdNotationPublicId")); 201 publicLabel.setLabelFor(publicField); 202 gridBagConstraints = new java.awt.GridBagConstraints (); 203 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 204 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 205 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 206 add(publicLabel, gridBagConstraints); 207 208 publicField.setColumns(20); 209 publicField.addActionListener(new java.awt.event.ActionListener () { 210 public void actionPerformed(java.awt.event.ActionEvent evt) { 211 publicFieldActionPerformed(evt); 212 } 213 }); 214 215 publicField.addFocusListener(new java.awt.event.FocusAdapter () { 216 public void focusGained(java.awt.event.FocusEvent evt) { 217 publicFieldFocusGained(evt); 218 } 219 public void focusLost(java.awt.event.FocusEvent evt) { 220 publicFieldFocusLost(evt); 221 } 222 }); 223 224 gridBagConstraints = new java.awt.GridBagConstraints (); 225 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 226 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 227 gridBagConstraints.weightx = 1.0; 228 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 229 add(publicField, gridBagConstraints); 230 231 systemLabel.setText(Util.THIS.getString ("PROP_dtdNotationSystemId")); 232 systemLabel.setLabelFor(systemField); 233 gridBagConstraints = new java.awt.GridBagConstraints (); 234 gridBagConstraints.gridx = 0; 235 gridBagConstraints.gridy = 2; 236 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 237 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 238 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 239 add(systemLabel, gridBagConstraints); 240 241 systemField.setColumns(20); 242 systemField.addActionListener(new java.awt.event.ActionListener () { 243 public void actionPerformed(java.awt.event.ActionEvent evt) { 244 systemFieldActionPerformed(evt); 245 } 246 }); 247 248 systemField.addFocusListener(new java.awt.event.FocusAdapter () { 249 public void focusGained(java.awt.event.FocusEvent evt) { 250 systemFieldFocusGained(evt); 251 } 252 public void focusLost(java.awt.event.FocusEvent evt) { 253 systemFieldFocusLost(evt); 254 } 255 }); 256 257 gridBagConstraints = new java.awt.GridBagConstraints (); 258 gridBagConstraints.gridx = 1; 259 gridBagConstraints.gridy = 2; 260 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 261 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 262 gridBagConstraints.weightx = 1.0; 263 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 264 add(systemField, gridBagConstraints); 265 266 fillPanel.setPreferredSize(new java.awt.Dimension (0, 0)); 267 gridBagConstraints = new java.awt.GridBagConstraints (); 268 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 269 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 270 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 271 gridBagConstraints.weightx = 1.0; 272 gridBagConstraints.weighty = 1.0; 273 add(fillPanel, gridBagConstraints); 274 275 } 277 private void systemFieldFocusGained(java.awt.event.FocusEvent evt) { systemField.selectAll (); 280 } 282 private void publicFieldFocusGained(java.awt.event.FocusEvent evt) { publicField.selectAll (); 285 } 287 private void nameFieldFocusGained(java.awt.event.FocusEvent evt) { nameField.selectAll (); 290 } 292 private void systemFieldFocusLost(java.awt.event.FocusEvent evt) { updateNotationDeclSystemId (); 295 } 297 private void systemFieldActionPerformed(java.awt.event.ActionEvent evt) { updateNotationDeclSystemId (); 300 } 302 private void publicFieldFocusLost(java.awt.event.FocusEvent evt) { updateNotationDeclPublicId (); 305 } 307 private void publicFieldActionPerformed(java.awt.event.ActionEvent evt) { updateNotationDeclPublicId (); 310 } 312 private void nameFieldFocusLost(java.awt.event.FocusEvent evt) { updateNotationDeclName (); 315 } 317 private void nameFieldActionPerformed(java.awt.event.ActionEvent evt) { updateNotationDeclName (); 320 } 322 private javax.swing.JLabel nameLabel; 324 private javax.swing.JLabel publicLabel; 325 private javax.swing.JTextField nameField; 326 private javax.swing.JTextField publicField; 327 private javax.swing.JLabel systemLabel; 328 private javax.swing.JTextField systemField; 329 private javax.swing.JPanel fillPanel; 330 332 334 public void initAccessibility (){ 335 336 this.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_TreeNotationDeclCustomizer")); 337 338 nameField.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_nameField3")); 339 nameField.selectAll (); 340 341 publicField.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_publicField2")); 342 publicField.selectAll (); 343 344 systemField.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_systemField1")); 345 systemField.selectAll (); 346 } 347 } 348 | Popular Tags |