1 19 package org.netbeans.modules.xml.tax.beans.customizer; 20 21 import java.awt.Component ; 22 import java.awt.BorderLayout ; 23 import java.beans.PropertyChangeEvent ; 24 25 import org.netbeans.tax.TreeNamedObjectMap; 26 import org.netbeans.tax.TreeAttlistDecl; 27 import org.netbeans.tax.TreeException; 28 29 import org.netbeans.modules.xml.tax.beans.Lib; 30 import org.netbeans.modules.xml.tax.util.TAXUtil; 31 32 37 public class TreeAttlistDeclCustomizer extends AbstractTreeCustomizer { 38 39 40 private static final long serialVersionUID = 5365016831221845705L; 41 42 43 47 48 public TreeAttlistDeclCustomizer () { 49 super (); 50 51 initComponents (); 52 elemNameLabel.setDisplayedMnemonic (Util.THIS.getChar ("TreeAttributeDeclCustomizer.elemNameLabel.mne")); tableLabel.setDisplayedMnemonic (Util.THIS.getChar ("MNE_attlistdecl_attributelist_label")); initAccessibility (); 55 } 56 57 58 62 64 protected final TreeAttlistDecl getAttlistDecl () { 65 return (TreeAttlistDecl)getTreeObject (); 66 } 67 68 70 protected final void safePropertyChange (PropertyChangeEvent pche) { 71 super.safePropertyChange (pche); 72 73 if (pche.getPropertyName ().equals (TreeAttlistDecl.PROP_ELEMENT_NAME)) { 74 updateElementNameComponent (); 75 } 76 } 77 78 80 protected final void updateElementNameComponent () { 81 elemNameField.setText (getAttlistDecl ().getElementName ()); 82 } 83 84 85 87 protected final void updateAttlistDeclElementName () { 88 try { 89 getAttlistDecl ().setElementName (elemNameField.getText ()); 90 } catch (TreeException exc) { 91 updateElementNameComponent (); 92 TAXUtil.notifyTreeException (exc); 93 } 94 } 95 96 98 protected final void initComponentValues () { 99 updateElementNameComponent (); 100 } 101 102 103 105 protected void ownInitComponents () { 106 TreeNamedObjectMap attributes = getAttlistDecl ().getAttributeDefs (); 107 108 if ( Util.THIS.isLoggable() ) Util.THIS.debug ("TreeElementCustomizer::ownInitComponents: attributes = " + attributes); 110 Component attrsCustom = Lib.getCustomizer (TreeAttlistDecl.class, attributes, "attributeDefs"); 112 if ( Util.THIS.isLoggable() ) Util.THIS.debug ("TreeElementCustomizer::ownInitComponents: attrsCustom = " + attrsCustom); 114 if (attrsCustom != null) { 115 attributeDefsPanel.add (attrsCustom, BorderLayout.CENTER); 116 } 117 } 118 119 121 protected final void updateReadOnlyStatus (boolean editable) { 122 elemNameField.setEditable (editable); 123 attributeDefsPanel.setEnabled (editable); } 125 126 131 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 133 134 elemNameLabel = new javax.swing.JLabel (); 135 elemNameField = new javax.swing.JTextField (); 136 jPanel1 = new javax.swing.JPanel (); 137 jPanel2 = new javax.swing.JPanel (); 138 tableLabel = new javax.swing.JLabel (); 139 attributeDefsPanel = new javax.swing.JPanel (); 140 141 setLayout(new java.awt.GridBagLayout ()); 142 143 elemNameLabel.setText(Util.THIS.getString ("TreeAttributeDeclCustomizer.elemNameLabel.text")); 144 elemNameLabel.setLabelFor(elemNameField); 145 gridBagConstraints = new java.awt.GridBagConstraints (); 146 gridBagConstraints.gridx = 0; 147 gridBagConstraints.gridy = 0; 148 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 149 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 150 add(elemNameLabel, gridBagConstraints); 151 152 elemNameField.setColumns(20); 153 elemNameField.addFocusListener(new java.awt.event.FocusAdapter () { 154 public void focusGained(java.awt.event.FocusEvent evt) { 155 elemNameFieldFocusGained(evt); 156 } 157 }); 158 159 gridBagConstraints = new java.awt.GridBagConstraints (); 160 gridBagConstraints.gridx = 1; 161 gridBagConstraints.gridy = 0; 162 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 163 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 164 gridBagConstraints.weightx = 1.0; 165 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 166 add(elemNameField, gridBagConstraints); 167 168 jPanel1.setLayout(new java.awt.GridBagLayout ()); 169 170 jPanel2.setLayout(new java.awt.GridBagLayout ()); 171 172 tableLabel.setText(Util.THIS.getString ("TEXT_attlistdecl_attributelist_label")); 173 tableLabel.setLabelFor(attributeDefsPanel); 174 gridBagConstraints = new java.awt.GridBagConstraints (); 175 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 176 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 177 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 178 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 179 gridBagConstraints.weightx = 1.0; 180 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 181 jPanel2.add(tableLabel, gridBagConstraints); 182 183 gridBagConstraints = new java.awt.GridBagConstraints (); 184 gridBagConstraints.gridx = 0; 185 gridBagConstraints.gridy = 0; 186 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 187 jPanel1.add(jPanel2, gridBagConstraints); 188 189 attributeDefsPanel.setLayout(new java.awt.BorderLayout ()); 190 191 gridBagConstraints = new java.awt.GridBagConstraints (); 192 gridBagConstraints.gridx = 0; 193 gridBagConstraints.gridy = 1; 194 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 195 gridBagConstraints.weightx = 1.0; 196 gridBagConstraints.weighty = 1.0; 197 jPanel1.add(attributeDefsPanel, gridBagConstraints); 198 199 gridBagConstraints = new java.awt.GridBagConstraints (); 200 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 201 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 202 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 203 gridBagConstraints.weightx = 1.0; 204 gridBagConstraints.weighty = 1.0; 205 add(jPanel1, gridBagConstraints); 206 207 } 209 private void elemNameFieldFocusGained(java.awt.event.FocusEvent evt) { elemNameField.selectAll (); 212 } 214 private javax.swing.JLabel tableLabel; 216 private javax.swing.JPanel attributeDefsPanel; 217 private javax.swing.JPanel jPanel2; 218 private javax.swing.JPanel jPanel1; 219 private javax.swing.JLabel elemNameLabel; 220 private javax.swing.JTextField elemNameField; 221 223 224 226 public void initAccessibility (){ 227 228 this.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_TreeAttlistDeclCustomizer")); 229 elemNameField.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_elemNameField")); 230 elemNameField.selectAll (); 231 } 232 } 233 | Popular Tags |