1 19 package org.netbeans.modules.xml.tax.beans.customizer; 20 21 import java.beans.PropertyChangeEvent ; 22 23 import org.netbeans.tax.TreeDocumentFragment; 24 import org.netbeans.tax.TreeException; 25 26 import org.netbeans.modules.xml.tax.util.TAXUtil; 27 28 33 public class TreeDocumentFragmentCustomizer extends AbstractTreeCustomizer { 34 35 36 private static final long serialVersionUID =6588833590608041474L; 37 38 39 43 44 public TreeDocumentFragmentCustomizer () { 45 super (); 46 initComponents (); 47 versionLabel.setDisplayedMnemonic (Util.THIS.getChar ("MNE_docFrag_version")); encodingLabel.setDisplayedMnemonic (Util.THIS.getChar ("MNE_docFrag_encoding")); } 50 51 52 56 58 protected final TreeDocumentFragment getDocumentFragment () { 59 return (TreeDocumentFragment)getTreeObject (); 60 } 61 62 65 protected final void safePropertyChange (PropertyChangeEvent pche) { 66 super.safePropertyChange (pche); 67 68 if (pche.getPropertyName ().equals (TreeDocumentFragment.PROP_VERSION)) { 69 updateVersionComponent (); 70 } else if (pche.getPropertyName ().equals (TreeDocumentFragment.PROP_ENCODING)) { 71 updateEncodingComponent (); 72 } 73 } 74 75 77 protected final void updateDTDVersion () { 78 if ( cbVersion.getSelectedItem () == null ) { 79 return; 80 } 81 82 try { 83 getDocumentFragment ().setVersion (text2null ((String ) cbVersion.getSelectedItem ())); 84 } catch (TreeException exc) { 85 updateVersionComponent (); 86 TAXUtil.notifyTreeException (exc); 87 } 88 } 89 90 92 protected final void updateVersionComponent () { 93 cbVersion.setSelectedItem (null2text (getDocumentFragment ().getVersion ())); 94 } 95 96 98 protected final void updateDTDEncoding () { 99 if ( cbEncoding.getSelectedItem () == null ) { 100 return; 101 } 102 103 try { 104 getDocumentFragment ().setEncoding (text2null ((String ) cbEncoding.getSelectedItem ())); 105 } catch (TreeException exc) { 106 updateEncodingComponent (); 107 TAXUtil.notifyTreeException (exc); 108 } 109 } 110 111 113 protected final void updateEncodingComponent () { 114 cbEncoding.setSelectedItem (null2text (getDocumentFragment ().getEncoding ())); 115 } 116 117 119 protected void initComponentValues () { 120 updateVersionComponent (); 121 updateEncodingComponent (); 122 } 123 124 126 protected final void updateReadOnlyStatus (boolean editable) { 127 cbVersion.setEnabled (editable); 128 cbEncoding.setEnabled (editable); 129 } 130 131 136 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 138 139 versionLabel = new javax.swing.JLabel (); 140 cbVersion = new javax.swing.JComboBox (); 141 encodingLabel = new javax.swing.JLabel (); 142 cbEncoding = new javax.swing.JComboBox (); 143 jPanel1 = new javax.swing.JPanel (); 144 145 setLayout(new java.awt.GridBagLayout ()); 146 147 versionLabel.setText(Util.THIS.getString ("PROP_docFrag_version")); 148 versionLabel.setLabelFor(cbVersion); 149 gridBagConstraints = new java.awt.GridBagConstraints (); 150 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 151 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 152 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 153 add(versionLabel, gridBagConstraints); 154 155 gridBagConstraints = new java.awt.GridBagConstraints (); 156 gridBagConstraints.gridx = 1; 157 gridBagConstraints.gridy = 0; 158 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 159 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 160 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 161 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 162 add(cbVersion, gridBagConstraints); 163 164 encodingLabel.setText(Util.THIS.getString ("PROP_docFrag_encoding")); 165 encodingLabel.setLabelFor(cbEncoding); 166 gridBagConstraints = new java.awt.GridBagConstraints (); 167 gridBagConstraints.gridx = 0; 168 gridBagConstraints.gridy = 1; 169 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 170 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 171 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 172 add(encodingLabel, gridBagConstraints); 173 174 gridBagConstraints = new java.awt.GridBagConstraints (); 175 gridBagConstraints.gridx = 1; 176 gridBagConstraints.gridy = 1; 177 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 178 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 179 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 180 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 181 add(cbEncoding, gridBagConstraints); 182 183 gridBagConstraints = new java.awt.GridBagConstraints (); 184 gridBagConstraints.gridx = 0; 185 gridBagConstraints.gridy = 2; 186 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 187 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 188 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 189 gridBagConstraints.weightx = 1.0; 190 gridBagConstraints.weighty = 1.0; 191 add(jPanel1, gridBagConstraints); 192 193 } 195 private javax.swing.JComboBox cbVersion; 197 private javax.swing.JLabel versionLabel; 198 private javax.swing.JComboBox cbEncoding; 199 private javax.swing.JPanel jPanel1; 200 private javax.swing.JLabel encodingLabel; 201 203 } 204 | Popular Tags |