1 19 package org.netbeans.modules.xml.tax.beans.customizer; 20 21 import java.beans.PropertyChangeEvent ; 22 23 import org.netbeans.tax.TreeCDATASection; 24 import org.netbeans.tax.TreeException; 25 import org.netbeans.tax.TreeData; 26 27 import org.netbeans.modules.xml.tax.util.TAXUtil; 28 29 34 public class TreeCDATASectionCustomizer extends AbstractTreeCustomizer { 35 36 37 private static final long serialVersionUID =-7665482206368732519L; 38 39 40 44 45 public TreeCDATASectionCustomizer () { 46 super (); 47 48 initComponents (); 49 initAccessibility (); 50 } 51 52 53 57 59 protected final TreeCDATASection getCDATASection () { 60 return (TreeCDATASection)getTreeObject (); 61 } 62 63 65 protected final void safePropertyChange (PropertyChangeEvent pche) { 66 super.safePropertyChange (pche); 67 68 if (pche.getPropertyName ().equals (TreeData.PROP_DATA)) { 69 updateDataComponent (); 70 } 71 } 72 73 75 protected final void updateCDATASectionData () { 76 try { 77 getCDATASection ().setData (dataTextArea.getText ()); 78 } catch (TreeException exc) { 79 updateDataComponent (); 80 TAXUtil.notifyTreeException (exc); 81 } 82 } 83 84 86 protected final void updateDataComponent () { 87 dataTextArea.setText (getCDATASection ().getData ()); 88 } 89 90 92 protected final void initComponentValues () { 93 updateDataComponent (); 94 } 95 96 97 99 protected final void updateReadOnlyStatus (boolean editable) { 100 dataTextArea.setEditable (editable); 101 } 102 103 104 109 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 111 112 dataPanel = new javax.swing.JPanel (); 113 dataScroll = new javax.swing.JScrollPane (); 114 dataTextArea = new javax.swing.JTextArea (); 115 116 setLayout(new java.awt.GridBagLayout ()); 117 118 setPreferredSize(new java.awt.Dimension (350, 230)); 119 dataPanel.setLayout(new java.awt.BorderLayout ()); 120 121 dataTextArea.addFocusListener(new java.awt.event.FocusAdapter () { 122 public void focusGained(java.awt.event.FocusEvent evt) { 123 dataTextAreaFocusGained(evt); 124 } 125 public void focusLost(java.awt.event.FocusEvent evt) { 126 dataTextAreaFocusLost(evt); 127 } 128 }); 129 130 dataTextArea.addKeyListener(new java.awt.event.KeyAdapter () { 131 public void keyPressed(java.awt.event.KeyEvent evt) { 132 dataTextAreaKeyPressed(evt); 133 } 134 }); 135 136 dataScroll.setViewportView(dataTextArea); 137 138 dataPanel.add(dataScroll, java.awt.BorderLayout.CENTER); 139 140 gridBagConstraints = new java.awt.GridBagConstraints (); 141 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 142 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 143 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 144 gridBagConstraints.weightx = 1.0; 145 gridBagConstraints.weighty = 1.0; 146 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 147 add(dataPanel, gridBagConstraints); 148 149 } 151 private void dataTextAreaFocusGained(java.awt.event.FocusEvent evt) { if ("new".equals(getClientProperty("xml-edit-mode"))) { dataTextArea.selectAll(); 154 } 155 } 157 private void dataTextAreaKeyPressed(java.awt.event.KeyEvent evt) { if ( applyKeyPressed (evt) ) { 160 updateCDATASectionData (); 161 } 162 } 164 private void dataTextAreaFocusLost(java.awt.event.FocusEvent evt) { updateCDATASectionData (); 167 } 169 private javax.swing.JTextArea dataTextArea; 171 private javax.swing.JPanel dataPanel; 172 private javax.swing.JScrollPane dataScroll; 173 175 177 public void initAccessibility (){ 178 179 this.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_TreeCDATASectionCustomizer")); 180 dataTextArea.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_dataPanel2")); 181 dataTextArea.getAccessibleContext ().setAccessibleName (Util.THIS.getString ("ACSN_dataPanel2")); 182 } 183 } 184 | Popular Tags |