KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > tax > beans > customizer > TreeConditionalSectionCustomizer


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.xml.tax.beans.customizer;
20
21 import java.beans.PropertyChangeEvent JavaDoc;
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 /**
29  *
30  * @author Libor Kramolis
31  * @version 0.1
32  */

33 public class TreeConditionalSectionCustomizer extends AbstractTreeCustomizer {
34
35     /** Serial Version UID */
36     private static final long serialVersionUID =-396968653847909885L;
37
38
39     //
40
// init
41
//
42

43     /** Creates new customizer TreeConditionalSectionCustomizer. */
44     public TreeConditionalSectionCustomizer () {
45         super ();
46         
47         initComponents ();
48         initAccessibility();
49     }
50     
51     
52     //
53
// itself
54
//
55

56     /**
57      */

58     protected final TreeConditionalSection getConditionalSection () {
59         return (TreeConditionalSection)getTreeObject ();
60     }
61     
62     /**
63      * It will be called from AWT thread and it will never be caller during init stage.
64      */

65     protected final void safePropertyChange (PropertyChangeEvent JavaDoc 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     /**
108      */

109     protected void initComponentValues () {
110         updateIncludeIgnoreComponent ();
111         updateIgnoredContentComponent ();
112     }
113     
114     /**
115      */

116     protected void updateReadOnlyStatus (boolean editable) {
117         includeRadioButton.setEnabled (editable); //???
118
ignoreRadioButton.setEnabled (editable); //???
119
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     /** This method is called from within the constructor to
131      * initialize the form.
132      * WARNING: Do NOT modify this code. The content of this method is
133      * always regenerated by the FormEditor.
134      */

135     private void initComponents() {//GEN-BEGIN:initComponents
136
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
137
138         includeButtonGroup = new javax.swing.ButtonGroup JavaDoc();
139         includeRadioButton = new javax.swing.JRadioButton JavaDoc();
140         ignoreRadioButton = new javax.swing.JRadioButton JavaDoc();
141         ignoredContentScrollPane = new javax.swing.JScrollPane JavaDoc();
142         ignoredContentTextArea = new javax.swing.JTextArea JavaDoc();
143         fillPanel = new javax.swing.JPanel JavaDoc();
144
145         setLayout(new java.awt.GridBagLayout JavaDoc());
146
147         setPreferredSize(new java.awt.Dimension JavaDoc(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 JavaDoc();
152         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
153         gridBagConstraints.weightx = 1.0;
154         gridBagConstraints.insets = new java.awt.Insets JavaDoc(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 JavaDoc();
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 JavaDoc(12, 12, 0, 11);
164         add(ignoreRadioButton, gridBagConstraints);
165
166         ignoredContentScrollPane.setPreferredSize(new java.awt.Dimension JavaDoc(350, 200));
167         ignoredContentScrollPane.setViewportView(ignoredContentTextArea);
168
169         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(12, 12, 0, 11);
177         add(ignoredContentScrollPane, gridBagConstraints);
178
179         fillPanel.setPreferredSize(new java.awt.Dimension JavaDoc(0, 0));
180         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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     }//GEN-END:initComponents
191

192     // Variables declaration - do not modify//GEN-BEGIN:variables
193
private javax.swing.JRadioButton JavaDoc ignoreRadioButton;
194     private javax.swing.JScrollPane JavaDoc ignoredContentScrollPane;
195     private javax.swing.ButtonGroup JavaDoc includeButtonGroup;
196     private javax.swing.JTextArea JavaDoc ignoredContentTextArea;
197     private javax.swing.JRadioButton JavaDoc includeRadioButton;
198     private javax.swing.JPanel JavaDoc fillPanel;
199     // End of variables declaration//GEN-END:variables
200

201 }
202
Popular Tags