1 19 package org.netbeans.modules.xml.tax.beans.customizer; 20 21 import java.beans.PropertyChangeEvent ; 22 23 import org.netbeans.tax.TreeEntityReference; 24 import org.netbeans.tax.TreeParameterEntityReference; 25 import org.netbeans.tax.TreeException; 26 27 import org.netbeans.modules.xml.tax.util.TAXUtil; 28 29 34 public class TreeParameterEntityReferenceCustomizer extends AbstractTreeCustomizer { 35 36 37 private static final long serialVersionUID = 6668177697987096689L; 38 39 40 44 45 public TreeParameterEntityReferenceCustomizer () { 46 super (); 47 48 initComponents (); 49 nameLabel.setDisplayedMnemonic (Util.THIS.getChar ("MNE_peRef_name")); } 51 52 53 57 59 protected final TreeParameterEntityReference getParameterEntityReference () { 60 return (TreeParameterEntityReference)getTreeObject (); 61 } 62 63 65 protected final void safePropertyChange (PropertyChangeEvent pche) { 66 super.safePropertyChange (pche); 67 68 if (pche.getPropertyName ().equals (TreeEntityReference.PROP_NAME)) { 69 updateNameComponent (); 70 } 71 } 72 73 75 protected final void updateParameterEntityReferenceName () { 76 try { 77 getParameterEntityReference ().setName (nameField.getText ()); 78 } catch (TreeException exc) { 79 updateNameComponent (); 80 TAXUtil.notifyTreeException (exc); 81 } 82 } 83 84 86 protected final void updateNameComponent () { 87 nameField.setText (getParameterEntityReference ().getName ()); 88 } 89 90 92 protected final void initComponentValues () { 93 updateNameComponent (); 94 } 95 96 97 99 protected final 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 115 setLayout(new java.awt.GridBagLayout ()); 116 117 nameLabel.setText(Util.THIS.getString ("PROP_peRef_name")); 118 nameLabel.setLabelFor(nameField); 119 gridBagConstraints = new java.awt.GridBagConstraints (); 120 gridBagConstraints.gridx = 0; 121 gridBagConstraints.gridy = 0; 122 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 123 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 124 gridBagConstraints.weighty = 1.0; 125 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 126 add(nameLabel, gridBagConstraints); 127 128 nameField.setColumns(20); 129 nameField.addActionListener(new java.awt.event.ActionListener () { 130 public void actionPerformed(java.awt.event.ActionEvent evt) { 131 nameFieldActionPerformed(evt); 132 } 133 }); 134 135 nameField.addFocusListener(new java.awt.event.FocusAdapter () { 136 public void focusGained(java.awt.event.FocusEvent evt) { 137 nameFieldFocusGained(evt); 138 } 139 public void focusLost(java.awt.event.FocusEvent evt) { 140 nameFieldFocusLost(evt); 141 } 142 }); 143 144 gridBagConstraints = new java.awt.GridBagConstraints (); 145 gridBagConstraints.gridx = 1; 146 gridBagConstraints.gridy = 0; 147 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 148 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 149 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 150 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 151 gridBagConstraints.weightx = 1.0; 152 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 153 add(nameField, gridBagConstraints); 154 155 } 157 private void nameFieldFocusGained(java.awt.event.FocusEvent evt) { if ("new".equals(getClientProperty("xml-edit-mode"))) { nameField.selectAll(); 160 } 161 } 163 165 private void nameFieldFocusLost (java.awt.event.FocusEvent evt) { updateParameterEntityReferenceName (); 168 } 170 172 private void nameFieldActionPerformed (java.awt.event.ActionEvent evt) { updateParameterEntityReferenceName (); 175 } 177 private javax.swing.JLabel nameLabel; 179 private javax.swing.JTextField nameField; 180 182 } 183 | Popular Tags |