KickJava   Java API By Example, From Geeks To Geeks.

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


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.TreeDocumentFragment;
24 import org.netbeans.tax.TreeException;
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 TreeDocumentFragmentCustomizer extends AbstractTreeCustomizer {
34
35     /** Serial Version UID */
36     private static final long serialVersionUID =6588833590608041474L;
37
38
39     //
40
// init
41
//
42

43     /** Creates new customizer TreeDocumentFragmentCustomizer. */
44     public TreeDocumentFragmentCustomizer () {
45         super ();
46         initComponents ();
47         versionLabel.setDisplayedMnemonic (Util.THIS.getChar ("MNE_docFrag_version")); // NOI18N
48
encodingLabel.setDisplayedMnemonic (Util.THIS.getChar ("MNE_docFrag_encoding")); // NOI18N
49
}
50     
51     
52     //
53
// itself
54
//
55

56     /**
57      */

58     protected final TreeDocumentFragment getDocumentFragment () {
59         return (TreeDocumentFragment)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 (TreeDocumentFragment.PROP_VERSION)) {
69             updateVersionComponent ();
70         } else if (pche.getPropertyName ().equals (TreeDocumentFragment.PROP_ENCODING)) {
71             updateEncodingComponent ();
72         }
73     }
74     
75     /**
76      */

77     protected final void updateDTDVersion () {
78         if ( cbVersion.getSelectedItem () == null ) {
79             return;
80         }
81         
82         try {
83             getDocumentFragment ().setVersion (text2null ((String JavaDoc) cbVersion.getSelectedItem ()));
84         } catch (TreeException exc) {
85             updateVersionComponent ();
86             TAXUtil.notifyTreeException (exc);
87         }
88     }
89     
90     /**
91      */

92     protected final void updateVersionComponent () {
93         cbVersion.setSelectedItem (null2text (getDocumentFragment ().getVersion ()));
94     }
95     
96     /**
97      */

98     protected final void updateDTDEncoding () {
99         if ( cbEncoding.getSelectedItem () == null ) {
100             return;
101         }
102         
103         try {
104             getDocumentFragment ().setEncoding (text2null ((String JavaDoc) cbEncoding.getSelectedItem ()));
105         } catch (TreeException exc) {
106             updateEncodingComponent ();
107             TAXUtil.notifyTreeException (exc);
108         }
109     }
110     
111     /**
112      */

113     protected final void updateEncodingComponent () {
114         cbEncoding.setSelectedItem (null2text (getDocumentFragment ().getEncoding ()));
115     }
116     
117     /**
118      */

119     protected void initComponentValues () {
120         updateVersionComponent ();
121         updateEncodingComponent ();
122     }
123     
124     /**
125      */

126     protected final void updateReadOnlyStatus (boolean editable) {
127         cbVersion.setEnabled (editable);
128         cbEncoding.setEnabled (editable);
129     }
130     
131     /** This method is called from within the constructor to
132      * initialize the form.
133      * WARNING: Do NOT modify this code. The content of this method is
134      * always regenerated by the FormEditor.
135      */

136     private void initComponents() {//GEN-BEGIN:initComponents
137
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
138
139         versionLabel = new javax.swing.JLabel JavaDoc();
140         cbVersion = new javax.swing.JComboBox JavaDoc();
141         encodingLabel = new javax.swing.JLabel JavaDoc();
142         cbEncoding = new javax.swing.JComboBox JavaDoc();
143         jPanel1 = new javax.swing.JPanel JavaDoc();
144
145         setLayout(new java.awt.GridBagLayout JavaDoc());
146
147         versionLabel.setText(Util.THIS.getString ("PROP_docFrag_version"));
148         versionLabel.setLabelFor(cbVersion);
149         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
150         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
151         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
152         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
153         add(versionLabel, gridBagConstraints);
154
155         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(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 JavaDoc();
167         gridBagConstraints.gridx = 0;
168         gridBagConstraints.gridy = 1;
169         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
170         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
171         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
172         add(encodingLabel, gridBagConstraints);
173
174         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(12, 12, 0, 11);
180         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
181         add(cbEncoding, gridBagConstraints);
182
183         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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     }//GEN-END:initComponents
194

195     // Variables declaration - do not modify//GEN-BEGIN:variables
196
private javax.swing.JComboBox JavaDoc cbVersion;
197     private javax.swing.JLabel JavaDoc versionLabel;
198     private javax.swing.JComboBox JavaDoc cbEncoding;
199     private javax.swing.JPanel JavaDoc jPanel1;
200     private javax.swing.JLabel JavaDoc encodingLabel;
201     // End of variables declaration//GEN-END:variables
202

203 }
204
Popular Tags