KickJava   Java API By Example, From Geeks To Geeks.

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


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.awt.Component JavaDoc;
22 import java.awt.BorderLayout JavaDoc;
23 import java.beans.PropertyChangeEvent JavaDoc;
24
25 import org.netbeans.tax.TreeNamedObjectMap;
26 import org.netbeans.tax.TreeAttlistDecl;
27 import org.netbeans.tax.TreeException;
28
29 import org.netbeans.modules.xml.tax.beans.Lib;
30 import org.netbeans.modules.xml.tax.util.TAXUtil;
31
32 /**
33  *
34  * @author Libor Kramolis
35  * @version 0.1
36  */

37 public class TreeAttlistDeclCustomizer extends AbstractTreeCustomizer {
38
39     /** Serial Version UID */
40     private static final long serialVersionUID = 5365016831221845705L;
41     
42     
43     //
44
// init
45
//
46

47     /** */
48     public TreeAttlistDeclCustomizer () {
49         super ();
50         
51         initComponents ();
52         elemNameLabel.setDisplayedMnemonic (Util.THIS.getChar ("TreeAttributeDeclCustomizer.elemNameLabel.mne")); // NOI18N
53
tableLabel.setDisplayedMnemonic (Util.THIS.getChar ("MNE_attlistdecl_attributelist_label")); // NOI18N
54
initAccessibility ();
55     }
56     
57     
58     //
59
// itself
60
//
61

62     /**
63      */

64     protected final TreeAttlistDecl getAttlistDecl () {
65         return (TreeAttlistDecl)getTreeObject ();
66     }
67     
68     /**
69      */

70     protected final void safePropertyChange (PropertyChangeEvent JavaDoc pche) {
71         super.safePropertyChange (pche);
72         
73         if (pche.getPropertyName ().equals (TreeAttlistDecl.PROP_ELEMENT_NAME)) {
74             updateElementNameComponent ();
75         }
76     }
77     
78     /**
79      */

80     protected final void updateElementNameComponent () {
81         elemNameField.setText (getAttlistDecl ().getElementName ());
82     }
83     
84     
85     /**
86      */

87     protected final void updateAttlistDeclElementName () {
88         try {
89             getAttlistDecl ().setElementName (elemNameField.getText ());
90         } catch (TreeException exc) {
91             updateElementNameComponent ();
92             TAXUtil.notifyTreeException (exc);
93         }
94     }
95     
96     /**
97      */

98     protected final void initComponentValues () {
99         updateElementNameComponent ();
100     }
101     
102     
103     /**
104      */

105     protected void ownInitComponents () {
106         TreeNamedObjectMap attributes = getAttlistDecl ().getAttributeDefs ();
107         
108         if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("TreeElementCustomizer::ownInitComponents: attributes = " + attributes); // NOI18N
109

110         Component JavaDoc attrsCustom = Lib.getCustomizer (TreeAttlistDecl.class, attributes, "attributeDefs"); // "attributeDefs" - name of TreeAttlistDecl property // NOI18N
111

112         if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("TreeElementCustomizer::ownInitComponents: attrsCustom = " + attrsCustom); // NOI18N
113

114         if (attrsCustom != null) {
115             attributeDefsPanel.add (attrsCustom, BorderLayout.CENTER);
116         }
117     }
118     
119     /**
120      */

121     protected final void updateReadOnlyStatus (boolean editable) {
122         elemNameField.setEditable (editable);
123         attributeDefsPanel.setEnabled (editable); //???
124
}
125     
126     /** This method is called from within the constructor to
127      * initialize the form.
128      * WARNING: Do NOT modify this code. The content of this method is
129      * always regenerated by the FormEditor.
130      */

131     private void initComponents() {//GEN-BEGIN:initComponents
132
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
133
134         elemNameLabel = new javax.swing.JLabel JavaDoc();
135         elemNameField = new javax.swing.JTextField JavaDoc();
136         jPanel1 = new javax.swing.JPanel JavaDoc();
137         jPanel2 = new javax.swing.JPanel JavaDoc();
138         tableLabel = new javax.swing.JLabel JavaDoc();
139         attributeDefsPanel = new javax.swing.JPanel JavaDoc();
140
141         setLayout(new java.awt.GridBagLayout JavaDoc());
142
143         elemNameLabel.setText(Util.THIS.getString ("TreeAttributeDeclCustomizer.elemNameLabel.text"));
144         elemNameLabel.setLabelFor(elemNameField);
145         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
146         gridBagConstraints.gridx = 0;
147         gridBagConstraints.gridy = 0;
148         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
149         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
150         add(elemNameLabel, gridBagConstraints);
151
152         elemNameField.setColumns(20);
153         elemNameField.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
154             public void focusGained(java.awt.event.FocusEvent JavaDoc evt) {
155                 elemNameFieldFocusGained(evt);
156             }
157         });
158
159         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
160         gridBagConstraints.gridx = 1;
161         gridBagConstraints.gridy = 0;
162         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
163         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
164         gridBagConstraints.weightx = 1.0;
165         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 11);
166         add(elemNameField, gridBagConstraints);
167
168         jPanel1.setLayout(new java.awt.GridBagLayout JavaDoc());
169
170         jPanel2.setLayout(new java.awt.GridBagLayout JavaDoc());
171
172         tableLabel.setText(Util.THIS.getString ("TEXT_attlistdecl_attributelist_label"));
173         tableLabel.setLabelFor(attributeDefsPanel);
174         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
175         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
176         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
177         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
178         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
179         gridBagConstraints.weightx = 1.0;
180         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 11);
181         jPanel2.add(tableLabel, gridBagConstraints);
182
183         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
184         gridBagConstraints.gridx = 0;
185         gridBagConstraints.gridy = 0;
186         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
187         jPanel1.add(jPanel2, gridBagConstraints);
188
189         attributeDefsPanel.setLayout(new java.awt.BorderLayout JavaDoc());
190
191         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
192         gridBagConstraints.gridx = 0;
193         gridBagConstraints.gridy = 1;
194         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
195         gridBagConstraints.weightx = 1.0;
196         gridBagConstraints.weighty = 1.0;
197         jPanel1.add(attributeDefsPanel, gridBagConstraints);
198
199         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
200         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
201         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
202         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
203         gridBagConstraints.weightx = 1.0;
204         gridBagConstraints.weighty = 1.0;
205         add(jPanel1, gridBagConstraints);
206
207     }//GEN-END:initComponents
208

209     private void elemNameFieldFocusGained(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_elemNameFieldFocusGained
210
// Accessibility:
211
elemNameField.selectAll ();
212     }//GEN-LAST:event_elemNameFieldFocusGained
213

214     // Variables declaration - do not modify//GEN-BEGIN:variables
215
private javax.swing.JLabel JavaDoc tableLabel;
216     private javax.swing.JPanel JavaDoc attributeDefsPanel;
217     private javax.swing.JPanel JavaDoc jPanel2;
218     private javax.swing.JPanel JavaDoc jPanel1;
219     private javax.swing.JLabel JavaDoc elemNameLabel;
220     private javax.swing.JTextField JavaDoc elemNameField;
221     // End of variables declaration//GEN-END:variables
222

223     
224     /** Initialize accesibility
225      */

226     public void initAccessibility (){
227         
228         this.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_TreeAttlistDeclCustomizer"));
229         elemNameField.getAccessibleContext ().setAccessibleDescription (Util.THIS.getString ("ACSD_elemNameField"));
230         elemNameField.selectAll ();
231     }
232 }
233
Popular Tags