KickJava   Java API By Example, From Geeks To Geeks.

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


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.TreeNotationDecl;
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 TreeNotationDeclCustomizer extends AbstractTreeCustomizer {
34
35     /** Serial Version UID */
36     private static final long serialVersionUID = 844910700645886601L;
37
38
39     //
40
// init
41
//
42

43     /** */
44     public TreeNotationDeclCustomizer () {
45         super ();
46         
47         initComponents ();
48         nameLabel.setDisplayedMnemonic (Util.THIS.getChar ("MNE_dtdNotationName")); // NOI18N
49
publicLabel.setDisplayedMnemonic (Util.THIS.getChar ("MNE_dtdNotationPublicId")); // NOI18N
50
systemLabel.setDisplayedMnemonic (Util.THIS.getChar ("MNE_dtdNotationSystemId")); // NOI18N
51

52         initAccessibility ();
53     }
54     
55     
56     //
57
// itself
58
//
59

60     /**
61      */

62     protected final TreeNotationDecl getNotationDecl () {
63         return (TreeNotationDecl)getTreeObject ();
64     }
65     
66     /**
67      */

68     protected final void safePropertyChange (PropertyChangeEvent JavaDoc pche) {
69         super.safePropertyChange (pche);
70         
71         if (pche.getPropertyName ().equals (TreeNotationDecl.PROP_NAME)) {
72             updateNameComponent ();
73         } else if (pche.getPropertyName ().equals (TreeNotationDecl.PROP_PUBLIC_ID)) {
74             updatePublicIdComponent ();
75         } else if (pche.getPropertyName ().equals (TreeNotationDecl.PROP_SYSTEM_ID)) {
76             updateSystemIdComponent ();
77         }
78     }
79     
80     /**
81      */

82     protected final void updateNotationDeclName () {
83         try {
84             getNotationDecl ().setName (nameField.getText ());
85         } catch (TreeException exc) {
86             updateNameComponent ();
87             TAXUtil.notifyTreeException (exc);
88         }
89     }
90     
91     /**
92      */

93     protected final void updateNameComponent () {
94         nameField.setText (getNotationDecl ().getName ());
95     }
96     
97     /**
98      */

99     protected final void updateNotationDeclPublicId () {
100         try {
101             getNotationDecl ().setPublicId (text2null (publicField.getText ()));
102         } catch (TreeException exc) {
103             updatePublicIdComponent ();
104             TAXUtil.notifyTreeException (exc);
105         }
106     }
107     
108     /**
109      */

110     protected final void updatePublicIdComponent () {
111         publicField.setText (null2text (getNotationDecl ().getPublicId ()));
112     }
113     
114     /**
115      */

116     protected final void updateNotationDeclSystemId () {
117         try {
118             getNotationDecl ().setSystemId (text2null (systemField.getText ()));
119         } catch (TreeException exc) {
120             updateSystemIdComponent ();
121             TAXUtil.notifyTreeException (exc);
122         }
123     }
124     
125     /**
126      */

127     protected final void updateSystemIdComponent () {
128         systemField.setText (null2text (getNotationDecl ().getSystemId ()));
129     }
130     
131     /**
132      */

133     protected final void initComponentValues () {
134         updateNameComponent ();
135         updatePublicIdComponent ();
136         updateSystemIdComponent ();
137     }
138     
139     
140     /**
141      */

142     protected void updateReadOnlyStatus (boolean editable) {
143         nameField.setEditable (editable);
144         systemField.setEditable (editable);
145         publicField.setEditable (editable);
146     }
147     
148     
149     /** This method is called from within the constructor to
150      * initialize the form.
151      * WARNING: Do NOT modify this code. The content of this method is
152      * always regenerated by the FormEditor.
153      */

154     private void initComponents() {//GEN-BEGIN:initComponents
155
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
156
157         nameLabel = new javax.swing.JLabel JavaDoc();
158         nameField = new javax.swing.JTextField JavaDoc();
159         publicLabel = new javax.swing.JLabel JavaDoc();
160         publicField = new javax.swing.JTextField JavaDoc();
161         systemLabel = new javax.swing.JLabel JavaDoc();
162         systemField = new javax.swing.JTextField JavaDoc();
163         fillPanel = new javax.swing.JPanel JavaDoc();
164
165         setLayout(new java.awt.GridBagLayout JavaDoc());
166
167         nameLabel.setText(Util.THIS.getString ("PROP_dtdNotationName"));
168         nameLabel.setLabelFor(nameField);
169         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
170         gridBagConstraints.gridx = 0;
171         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
172         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
173         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
174         add(nameLabel, gridBagConstraints);
175
176         nameField.setColumns(20);
177         nameField.addActionListener(new java.awt.event.ActionListener JavaDoc() {
178             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
179                 nameFieldActionPerformed(evt);
180             }
181         });
182
183         nameField.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
184             public void focusGained(java.awt.event.FocusEvent JavaDoc evt) {
185                 nameFieldFocusGained(evt);
186             }
187             public void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
188                 nameFieldFocusLost(evt);
189             }
190         });
191
192         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
193         gridBagConstraints.gridx = 1;
194         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
195         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
196         gridBagConstraints.weightx = 1.0;
197         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 11);
198         add(nameField, gridBagConstraints);
199
200         publicLabel.setText(Util.THIS.getString ("PROP_dtdNotationPublicId"));
201         publicLabel.setLabelFor(publicField);
202         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
203         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
204         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
205         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
206         add(publicLabel, gridBagConstraints);
207
208         publicField.setColumns(20);
209         publicField.addActionListener(new java.awt.event.ActionListener JavaDoc() {
210             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
211                 publicFieldActionPerformed(evt);
212             }
213         });
214
215         publicField.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
216             public void focusGained(java.awt.event.FocusEvent JavaDoc evt) {
217                 publicFieldFocusGained(evt);
218             }
219             public void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
220                 publicFieldFocusLost(evt);
221             }
222         });
223
224         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
225         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
226         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
227         gridBagConstraints.weightx = 1.0;
228         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 11);
229         add(publicField, gridBagConstraints);
230
231         systemLabel.setText(Util.THIS.getString ("PROP_dtdNotationSystemId"));
232         systemLabel.setLabelFor(systemField);
233         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
234         gridBagConstraints.gridx = 0;
235         gridBagConstraints.gridy = 2;
236         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
237         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
238         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
239         add(systemLabel, gridBagConstraints);
240
241         systemField.setColumns(20);
242         systemField.addActionListener(new java.awt.event.ActionListener JavaDoc() {
243             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
244                 systemFieldActionPerformed(evt);
245             }
246         });
247
248         systemField.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
249             public void focusGained(java.awt.event.FocusEvent JavaDoc evt) {
250                 systemFieldFocusGained(evt);
251             }
252             public void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
253                 systemFieldFocusLost(evt);
254             }
255         });
256
257         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
258         gridBagConstraints.gridx = 1;
259         gridBagConstraints.gridy = 2;
260         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
261         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
262         gridBagConstraints.weightx = 1.0;
263         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 11);
264         add(systemField, gridBagConstraints);
265
266         fillPanel.setPreferredSize(new java.awt.Dimension JavaDoc(0, 0));
267         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
268         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
269         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
270         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
271         gridBagConstraints.weightx = 1.0;
272         gridBagConstraints.weighty = 1.0;
273         add(fillPanel, gridBagConstraints);
274
275     }//GEN-END:initComponents
276

277     private void systemFieldFocusGained(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_systemFieldFocusGained
278
// Accessibility:
279
systemField.selectAll ();
280     }//GEN-LAST:event_systemFieldFocusGained
281

282     private void publicFieldFocusGained(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_publicFieldFocusGained
283
// Accessibility:
284
publicField.selectAll ();
285     }//GEN-LAST:event_publicFieldFocusGained
286

287     private void nameFieldFocusGained(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_nameFieldFocusGained
288
// Accessibility:
289
nameField.selectAll ();
290     }//GEN-LAST:event_nameFieldFocusGained
291

292     private void systemFieldFocusLost(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_systemFieldFocusLost
293
// Add your handling code here:
294
updateNotationDeclSystemId ();
295     }//GEN-LAST:event_systemFieldFocusLost
296

297     private void systemFieldActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_systemFieldActionPerformed
298
// Add your handling code here:
299
updateNotationDeclSystemId ();
300     }//GEN-LAST:event_systemFieldActionPerformed
301

302     private void publicFieldFocusLost(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_publicFieldFocusLost
303
// Add your handling code here:
304
updateNotationDeclPublicId ();
305     }//GEN-LAST:event_publicFieldFocusLost
306

307     private void publicFieldActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_publicFieldActionPerformed
308
// Add your handling code here:
309
updateNotationDeclPublicId ();
310     }//GEN-LAST:event_publicFieldActionPerformed
311

312     private void nameFieldFocusLost(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_nameFieldFocusLost
313
// Add your handling code here:
314
updateNotationDeclName ();
315     }//GEN-LAST:event_nameFieldFocusLost
316

317     private void nameFieldActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_nameFieldActionPerformed
318
// Add your handling code here:
319
updateNotationDeclName ();
320     }//GEN-LAST:event_nameFieldActionPerformed
321

322     // Variables declaration - do not modify//GEN-BEGIN:variables
323
private javax.swing.JLabel JavaDoc nameLabel;
324     private javax.swing.JLabel JavaDoc publicLabel;
325     private javax.swing.JTextField JavaDoc nameField;
326     private javax.swing.JTextField JavaDoc publicField;
327     private javax.swing.JLabel JavaDoc systemLabel;
328     private javax.swing.JTextField JavaDoc systemField;
329     private javax.swing.JPanel JavaDoc fillPanel;
330     // End of variables declaration//GEN-END:variables
331

332     /** Initialize accesibility
333      */

334     public void initAccessibility (){
335         
336         this.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_TreeNotationDeclCustomizer"));
337         
338         nameField.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_nameField3"));
339         nameField.selectAll ();
340         
341         publicField.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_publicField2"));
342         publicField.selectAll ();
343         
344         systemField.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_systemField1"));
345         systemField.selectAll ();
346     }
347 }
348
Popular Tags