1 19 package org.netbeans.modules.xml.tax.beans.customizer; 20 21 import java.beans.PropertyChangeEvent ; 22 23 import org.netbeans.tax.TreeException; 24 import org.netbeans.tax.TreeConditionalSection; 25 26 import org.netbeans.modules.xml.tax.util.TAXUtil; 27 28 33 public class TreeConditionalSectionCustomizer extends AbstractTreeCustomizer { 34 35 36 private static final long serialVersionUID =-396968653847909885L; 37 38 39 43 44 public TreeConditionalSectionCustomizer () { 45 super (); 46 47 initComponents (); 48 initAccessibility(); 49 } 50 51 52 56 58 protected final TreeConditionalSection getConditionalSection () { 59 return (TreeConditionalSection)getTreeObject (); 60 } 61 62 65 protected final void safePropertyChange (PropertyChangeEvent pche) { 66 super.safePropertyChange (pche); 67 68 if (pche.getPropertyName ().equals (TreeConditionalSection.PROP_INCLUDE)) { 69 updateIncludeIgnoreComponent (); 70 } else if (pche.getPropertyName ().equals (TreeConditionalSection.PROP_IGNORED_CONTENT)) { 71 updateIgnoredContentComponent (); 72 } 73 } 74 75 76 protected void updateIncludeIgnoreComponent () { 77 includeRadioButton.setSelected (getConditionalSection ().isInclude ()); 78 ignoreRadioButton.setSelected (!!! getConditionalSection ().isInclude ()); 79 80 ignoredContentScrollPane.setVisible (!!! getConditionalSection ().isInclude ()); 81 fillPanel.setVisible (getConditionalSection ().isInclude ()); 82 } 83 84 protected void updateConditionalSectionInclude () { 85 try { 86 getConditionalSection ().setInclude (includeRadioButton.isSelected ()); 87 } catch (TreeException exc) { 88 updateIncludeIgnoreComponent (); 89 TAXUtil.notifyTreeException (exc); 90 } 91 } 92 93 protected void updateIgnoredContentComponent () { 94 ignoredContentTextArea.setText (null2text (getConditionalSection ().getIgnoredContent ())); 95 } 96 97 protected void updateConditionalSectionIgnoredContent () { 98 try { 99 getConditionalSection ().setIgnoredContent (text2null (ignoredContentTextArea.getText ())); 100 } catch (TreeException exc) { 101 updateIgnoredContentComponent (); 102 TAXUtil.notifyTreeException (exc); 103 } 104 } 105 106 107 109 protected void initComponentValues () { 110 updateIncludeIgnoreComponent (); 111 updateIgnoredContentComponent (); 112 } 113 114 116 protected void updateReadOnlyStatus (boolean editable) { 117 includeRadioButton.setEnabled (editable); ignoreRadioButton.setEnabled (editable); ignoredContentTextArea.setEditable (editable); 120 } 121 122 123 private void initAccessibility() { 124 this.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_TreeConditionalSectionCustomizer")); 125 ignoredContentTextArea.getAccessibleContext ().setAccessibleName (Util.THIS.getString ("ACSN_ignoredContentPane")); 126 includeRadioButton.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_includeRadioButton")); 127 ignoreRadioButton.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_ignoreRadioButton")); 128 } 129 130 135 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 137 138 includeButtonGroup = new javax.swing.ButtonGroup (); 139 includeRadioButton = new javax.swing.JRadioButton (); 140 ignoreRadioButton = new javax.swing.JRadioButton (); 141 ignoredContentScrollPane = new javax.swing.JScrollPane (); 142 ignoredContentTextArea = new javax.swing.JTextArea (); 143 fillPanel = new javax.swing.JPanel (); 144 145 setLayout(new java.awt.GridBagLayout ()); 146 147 setPreferredSize(new java.awt.Dimension (350, 100)); 148 includeRadioButton.setSelected(true); 149 includeRadioButton.setText(Util.THIS.getString ("PROP_condSection_include")); 150 includeButtonGroup.add(includeRadioButton); 151 gridBagConstraints = new java.awt.GridBagConstraints (); 152 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 153 gridBagConstraints.weightx = 1.0; 154 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 155 add(includeRadioButton, gridBagConstraints); 156 157 ignoreRadioButton.setText(Util.THIS.getString ("PROP_condSection_ignore")); 158 includeButtonGroup.add(ignoreRadioButton); 159 gridBagConstraints = new java.awt.GridBagConstraints (); 160 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 161 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 162 gridBagConstraints.weightx = 1.0; 163 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 164 add(ignoreRadioButton, gridBagConstraints); 165 166 ignoredContentScrollPane.setPreferredSize(new java.awt.Dimension (350, 200)); 167 ignoredContentScrollPane.setViewportView(ignoredContentTextArea); 168 169 gridBagConstraints = new java.awt.GridBagConstraints (); 170 gridBagConstraints.gridx = 0; 171 gridBagConstraints.gridy = 1; 172 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 173 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 174 gridBagConstraints.weightx = 1.0; 175 gridBagConstraints.weighty = 1.0; 176 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 11); 177 add(ignoredContentScrollPane, gridBagConstraints); 178 179 fillPanel.setPreferredSize(new java.awt.Dimension (0, 0)); 180 gridBagConstraints = new java.awt.GridBagConstraints (); 181 gridBagConstraints.gridx = 0; 182 gridBagConstraints.gridy = 1; 183 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 184 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 185 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 186 gridBagConstraints.weightx = 1.0; 187 gridBagConstraints.weighty = 1.0; 188 add(fillPanel, gridBagConstraints); 189 190 } 192 private javax.swing.JRadioButton ignoreRadioButton; 194 private javax.swing.JScrollPane ignoredContentScrollPane; 195 private javax.swing.ButtonGroup includeButtonGroup; 196 private javax.swing.JTextArea ignoredContentTextArea; 197 private javax.swing.JRadioButton includeRadioButton; 198 private javax.swing.JPanel fillPanel; 199 201 } 202 | Popular Tags |