KickJava   Java API By Example, From Geeks To Geeks.

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


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.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 /**
30  *
31  * @author Libor Kramolis
32  * @version 0.1
33  */

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

44     /** */
45     public TreeCDATASectionCustomizer () {
46         super ();
47         
48         initComponents ();
49         initAccessibility ();
50     }
51     
52     
53     //
54
// itself
55
//
56

57     /**
58      */

59     protected final TreeCDATASection getCDATASection () {
60         return (TreeCDATASection)getTreeObject ();
61     }
62     
63     /**
64      */

65     protected final void safePropertyChange (PropertyChangeEvent JavaDoc pche) {
66         super.safePropertyChange (pche);
67         
68         if (pche.getPropertyName ().equals (TreeData.PROP_DATA)) {
69             updateDataComponent ();
70         }
71     }
72     
73     /**
74      */

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     /**
85      */

86     protected final void updateDataComponent () {
87         dataTextArea.setText (getCDATASection ().getData ());
88     }
89     
90     /**
91      */

92     protected final void initComponentValues () {
93         updateDataComponent ();
94     }
95     
96     
97     /**
98      */

99     protected final void updateReadOnlyStatus (boolean editable) {
100         dataTextArea.setEditable (editable);
101     }
102     
103     
104     /** This method is called from within the constructor to
105      * initialize the form.
106      * WARNING: Do NOT modify this code. The content of this method is
107      * always regenerated by the FormEditor.
108      */

109     private void initComponents() {//GEN-BEGIN:initComponents
110
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
111
112         dataPanel = new javax.swing.JPanel JavaDoc();
113         dataScroll = new javax.swing.JScrollPane JavaDoc();
114         dataTextArea = new javax.swing.JTextArea JavaDoc();
115
116         setLayout(new java.awt.GridBagLayout JavaDoc());
117
118         setPreferredSize(new java.awt.Dimension JavaDoc(350, 230));
119         dataPanel.setLayout(new java.awt.BorderLayout JavaDoc());
120
121         dataTextArea.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
122             public void focusGained(java.awt.event.FocusEvent JavaDoc evt) {
123                 dataTextAreaFocusGained(evt);
124             }
125             public void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
126                 dataTextAreaFocusLost(evt);
127             }
128         });
129
130         dataTextArea.addKeyListener(new java.awt.event.KeyAdapter JavaDoc() {
131             public void keyPressed(java.awt.event.KeyEvent JavaDoc 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 JavaDoc();
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 JavaDoc(12, 12, 0, 11);
147         add(dataPanel, gridBagConstraints);
148
149     }//GEN-END:initComponents
150

151     private void dataTextAreaFocusGained(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_dataTextAreaFocusGained
152
if ("new".equals(getClientProperty("xml-edit-mode"))) { // NOI18N
153
dataTextArea.selectAll();
154         }
155     }//GEN-LAST:event_dataTextAreaFocusGained
156

157     private void dataTextAreaKeyPressed(java.awt.event.KeyEvent JavaDoc evt) {//GEN-FIRST:event_dataTextAreaKeyPressed
158
// Add your handling code here:
159
if ( applyKeyPressed (evt) ) {
160             updateCDATASectionData ();
161         }
162     }//GEN-LAST:event_dataTextAreaKeyPressed
163

164     private void dataTextAreaFocusLost(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_dataTextAreaFocusLost
165
// Add your handling code here:
166
updateCDATASectionData ();
167     }//GEN-LAST:event_dataTextAreaFocusLost
168

169     // Variables declaration - do not modify//GEN-BEGIN:variables
170
private javax.swing.JTextArea JavaDoc dataTextArea;
171     private javax.swing.JPanel JavaDoc dataPanel;
172     private javax.swing.JScrollPane JavaDoc dataScroll;
173     // End of variables declaration//GEN-END:variables
174

175     /** Initialize accesibility
176      */

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