KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

57     /**
58      */

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

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

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

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

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

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

157     private void nameFieldFocusGained(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_nameFieldFocusGained
158
if ("new".equals(getClientProperty("xml-edit-mode"))) { // NOI18N
159
nameField.selectAll();
160         }
161     }//GEN-LAST:event_nameFieldFocusGained
162

163     /**
164      */

165     private void nameFieldFocusLost (java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_nameFieldFocusLost
166
// Add your handling code here:
167
updateParameterEntityReferenceName ();
168     }//GEN-LAST:event_nameFieldFocusLost
169

170     /**
171      */

172     private void nameFieldActionPerformed (java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_nameFieldActionPerformed
173
// Add your handling code here:
174
updateParameterEntityReferenceName ();
175     }//GEN-LAST:event_nameFieldActionPerformed
176

177     // Variables declaration - do not modify//GEN-BEGIN:variables
178
private javax.swing.JLabel JavaDoc nameLabel;
179     private javax.swing.JTextField JavaDoc nameField;
180     // End of variables declaration//GEN-END:variables
181

182 }
183
Popular Tags