1 19 package org.netbeans.modules.xml.tax.beans.customizer; 20 21 import java.beans.PropertyChangeEvent ; 22 23 import org.netbeans.tax.TreeGeneralEntityReference; 24 import org.netbeans.tax.TreeEntityReference; 25 import org.netbeans.tax.TreeException; 26 27 import org.netbeans.modules.xml.tax.util.TAXUtil; 28 29 34 public class TreeGeneralEntityReferenceCustomizer extends AbstractTreeCustomizer { 35 36 37 private static final long serialVersionUID = 6668177697987096689L; 38 39 40 44 45 public TreeGeneralEntityReferenceCustomizer () { 46 super (); 47 48 initComponents (); 49 nameLabel.setDisplayedMnemonic (Util.THIS.getChar ("MNE_geRef_name")); initAccessibility (); 51 } 52 53 54 58 60 protected final TreeGeneralEntityReference getGeneralEntityReference () { 61 return (TreeGeneralEntityReference)getTreeObject (); 62 } 63 64 66 protected final void safePropertyChange (PropertyChangeEvent pche) { 67 super.safePropertyChange (pche); 68 69 if (pche.getPropertyName ().equals (TreeEntityReference.PROP_NAME)) { 70 updateNameComponent (); 71 } 72 } 73 74 76 protected final void updateGeneralEntityReferenceName () { 77 try { 78 getGeneralEntityReference ().setName (nameField.getText ()); 79 } catch (TreeException exc) { 80 updateNameComponent (); 81 TAXUtil.notifyTreeException (exc); 82 } 83 } 84 85 87 protected final void updateNameComponent () { 88 nameField.setText (getGeneralEntityReference ().getName ()); 89 } 90 91 93 protected final void initComponentValues () { 94 updateNameComponent (); 95 } 96 97 99 protected void updateReadOnlyStatus (boolean editable) { 100 nameField.setEditable (editable); 101 } 102 103 104 109 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 111 112 nameLabel = new javax.swing.JLabel (); 113 nameField = new javax.swing.JTextField (); 114 fillPanel = new javax.swing.JPanel (); 115 116 setLayout(new java.awt.GridBagLayout ()); 117 118 nameLabel.setText(Util.THIS.getString ("PROP_geRef_name")); 119 nameLabel.setLabelFor(nameField); 120 gridBagConstraints = new java.awt.GridBagConstraints (); 121 gridBagConstraints.gridx = 0; 122 gridBagConstraints.gridy = 0; 123 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 124 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 125 add(nameLabel, gridBagConstraints); 126 127 nameField.setColumns(20); 128 nameField.addActionListener(new java.awt.event.ActionListener () { 129 public void actionPerformed(java.awt.event.ActionEvent evt) { 130 nameFieldActionPerformed(evt); 131 } 132 }); 133 134 nameField.addFocusListener(new java.awt.event.FocusAdapter () { 135 public void focusLost(java.awt.event.FocusEvent evt) { 136 nameFieldFocusLost(evt); 137 } 138 }); 139 140 gridBagConstraints = new java.awt.GridBagConstraints (); 141 gridBagConstraints.gridx = 1; 142 gridBagConstraints.gridy = 0; 143 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 144 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 145 gridBagConstraints.weightx = 1.0; 146 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 147 add(nameField, gridBagConstraints); 148 149 fillPanel.setPreferredSize(new java.awt.Dimension (0, 0)); 150 gridBagConstraints = new java.awt.GridBagConstraints (); 151 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 152 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 153 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 154 gridBagConstraints.weightx = 1.0; 155 gridBagConstraints.weighty = 1.0; 156 add(fillPanel, gridBagConstraints); 157 158 } 160 162 private void nameFieldFocusLost (java.awt.event.FocusEvent evt) { updateGeneralEntityReferenceName (); 165 } 167 169 private void nameFieldActionPerformed (java.awt.event.ActionEvent evt) { updateGeneralEntityReferenceName (); 172 } 174 private javax.swing.JLabel nameLabel; 176 private javax.swing.JTextField nameField; 177 private javax.swing.JPanel fillPanel; 178 180 182 public void initAccessibility (){ 183 184 this.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_TreeGeneralEntityReferenceCustomizer")); 185 nameField.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_nameField6")); 186 } 187 } 188 | Popular Tags |