KickJava   Java API By Example, From Geeks To Geeks.

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


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

44     /** */
45     public TreeGeneralEntityReferenceCustomizer () {
46         super ();
47         
48         initComponents ();
49         nameLabel.setDisplayedMnemonic (Util.THIS.getChar ("MNE_geRef_name")); // NOI18N
50
initAccessibility ();
51     }
52     
53     
54     //
55
// itself
56
//
57

58     /**
59      */

60     protected final TreeGeneralEntityReference getGeneralEntityReference () {
61         return (TreeGeneralEntityReference)getTreeObject ();
62     }
63     
64     /**
65      */

66     protected final void safePropertyChange (PropertyChangeEvent JavaDoc pche) {
67         super.safePropertyChange (pche);
68         
69         if (pche.getPropertyName ().equals (TreeEntityReference.PROP_NAME)) {
70             updateNameComponent ();
71         }
72     }
73     
74     /**
75      */

76     protected final void updateGeneralEntityReferenceName () {
77         try {
78             getGeneralEntityReference ().setName (nameField.getText ());
79         } catch (TreeException exc) {
80             updateNameComponent ();
81             TAXUtil.notifyTreeException (exc);
82         }
83     }
84     
85     /**
86      */

87     protected final void updateNameComponent () {
88         nameField.setText (getGeneralEntityReference ().getName ());
89     }
90     
91     /**
92      */

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

99     protected void updateReadOnlyStatus (boolean editable) {
100         nameField.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         nameLabel = new javax.swing.JLabel JavaDoc();
113         nameField = new javax.swing.JTextField JavaDoc();
114         fillPanel = new javax.swing.JPanel JavaDoc();
115
116         setLayout(new java.awt.GridBagLayout JavaDoc());
117
118         nameLabel.setText(Util.THIS.getString ("PROP_geRef_name"));
119         nameLabel.setLabelFor(nameField);
120         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
121         gridBagConstraints.gridx = 0;
122         gridBagConstraints.gridy = 0;
123         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
124         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
125         add(nameLabel, gridBagConstraints);
126
127         nameField.setColumns(20);
128         nameField.addActionListener(new java.awt.event.ActionListener JavaDoc() {
129             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
130                 nameFieldActionPerformed(evt);
131             }
132         });
133
134         nameField.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
135             public void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
136                 nameFieldFocusLost(evt);
137             }
138         });
139
140         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
141         gridBagConstraints.gridx = 1;
142         gridBagConstraints.gridy = 0;
143         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
144         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
145         gridBagConstraints.weightx = 1.0;
146         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 11);
147         add(nameField, gridBagConstraints);
148
149         fillPanel.setPreferredSize(new java.awt.Dimension JavaDoc(0, 0));
150         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
151         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
152         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
153         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
154         gridBagConstraints.weightx = 1.0;
155         gridBagConstraints.weighty = 1.0;
156         add(fillPanel, gridBagConstraints);
157
158     }//GEN-END:initComponents
159

160     /**
161      */

162     private void nameFieldFocusLost (java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_nameFieldFocusLost
163
// Add your handling code here:
164
updateGeneralEntityReferenceName ();
165     }//GEN-LAST:event_nameFieldFocusLost
166

167     /**
168      */

169     private void nameFieldActionPerformed (java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_nameFieldActionPerformed
170
// Add your handling code here:
171
updateGeneralEntityReferenceName ();
172     }//GEN-LAST:event_nameFieldActionPerformed
173

174     // Variables declaration - do not modify//GEN-BEGIN:variables
175
private javax.swing.JLabel JavaDoc nameLabel;
176     private javax.swing.JTextField JavaDoc nameField;
177     private javax.swing.JPanel JavaDoc fillPanel;
178     // End of variables declaration//GEN-END:variables
179

180     /** Initialize accesibility
181      */

182     public void initAccessibility (){
183         
184         this.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_TreeGeneralEntityReferenceCustomizer"));
185         nameField.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_nameField6"));
186     }
187 }
188
Popular Tags