KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > javadoc > comments > SerialFieldTagPanel


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
20 package org.netbeans.modules.javadoc.comments;
21
22 import java.util.ResourceBundle JavaDoc;
23 import org.openide.ErrorManager;
24 import org.openide.src.JavaDocTag;
25 import org.openide.src.JavaDocSupport;
26
27 import javax.swing.text.BadLocationException JavaDoc;
28 import org.openide.text.CloneableEditorSupport;
29
30 /**
31  *
32  * @author
33  */

34 public class SerialFieldTagPanel extends TagPanel {
35
36     private static final String JavaDoc cardName = "CRD_SERIAL_FIELD"; // NOI18N
37

38
39     static final long serialVersionUID =5117666281468847966L;
40     /** Initializes the Form */
41     public SerialFieldTagPanel( JavaDocEditorPanel editorPanel ) {
42         super( editorPanel );
43
44         initComponents ( );
45         ResourceBundle JavaDoc b = org.openide.util.NbBundle.getBundle(SerialFieldTagPanel.class);
46         jLabel2.setDisplayedMnemonic(b.getString("CTL_SerialFieldTagPanel.jLabel2.text_Mnemonic").charAt(0)); // NOI18N
47
jLabel3.setDisplayedMnemonic(b.getString("CTL_SerialFieldTagPanel.jLabel3.text_Mnemonic").charAt(0)); // NOI18N
48
jLabel1.setDisplayedMnemonic(b.getString("CTL_SerialFieldTagPanel.jLabel1.text_Mnemonic").charAt(0)); // NOI18N
49

50         editorPanel.registerComponent( descriptionTextArea );
51         addHTMLComponent( descriptionTextArea );
52         initAccessibility(b);
53     }
54
55     private void initAccessibility(ResourceBundle JavaDoc b)
56     {
57         jLabel2.getAccessibleContext().setAccessibleDescription(b.getString("ACS_SerialFieldTagPanel.jLabel2.textA11yDesc")); // NOI18N
58
nameTextField.getAccessibleContext().setAccessibleName(b.getString("ACS_SerialFieldTagPanel.nameTextField.textA11yName")); // NOI18N
59
jLabel3.getAccessibleContext().setAccessibleDescription(b.getString("ACS_SerialFieldTagPanel.jLabel3.textA11yDesc")); // NOI18N
60
typeTextField.getAccessibleContext().setAccessibleName(b.getString("ACS_SerialFieldTagPanel.typeTextField.textA11yName")); // NOI18N
61
jLabel1.getAccessibleContext().setAccessibleDescription(b.getString("ACS_SerialFieldTagPanel.jLabel1.textA11yDesc")); // NOI18N
62
descriptionTextArea.getAccessibleContext().setAccessibleName(b.getString("ACS_SerialFieldTagPanel.descriptionTextArea.textA11yName")); // NOI18N
63
}
64
65     /** This method is called from within the constructor to
66      * initialize the form.
67      * WARNING: Do NOT modify this code. The content of this method is
68      * always regenerated by the FormEditor.
69      */

70     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
71
private void initComponents() {
72         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
73
74         jLabel2 = new javax.swing.JLabel JavaDoc();
75         nameTextField = new javax.swing.JTextField JavaDoc();
76         jLabel3 = new javax.swing.JLabel JavaDoc();
77         typeTextField = new javax.swing.JTextField JavaDoc();
78         jLabel1 = new javax.swing.JLabel JavaDoc();
79         descriptionScrollPane = new javax.swing.JScrollPane JavaDoc();
80         descriptionTextArea = new javax.swing.JEditorPane JavaDoc(); descriptionTextArea.setEditorKit(CloneableEditorSupport.getEditorKit("text/html"));
81
82         setLayout(new java.awt.GridBagLayout JavaDoc());
83
84         jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
85         jLabel2.setLabelFor(nameTextField);
86         jLabel2.setText(org.openide.util.NbBundle.getBundle(SerialFieldTagPanel.class).getString("CTL_SerialFieldTagPanel.jLabel2.text"));
87         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
88         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
89         gridBagConstraints.insets = new java.awt.Insets JavaDoc(2, 2, 2, 1);
90         add(jLabel2, gridBagConstraints);
91
92         nameTextField.setText("jTextField1");
93         nameTextField.setToolTipText(org.openide.util.NbBundle.getBundle(SerialFieldTagPanel.class).getString("ACS_SerialFieldTagPanel.nameTextField.textA11yDesc"));
94         nameTextField.addActionListener(new java.awt.event.ActionListener JavaDoc() {
95             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
96                 nameTextFieldActionPerformed(evt);
97             }
98         });
99         nameTextField.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
100             public void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
101                 fieldFocusLost(evt);
102             }
103         });
104
105         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
106         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
107         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
108         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
109         gridBagConstraints.insets = new java.awt.Insets JavaDoc(2, 1, 2, 2);
110         add(nameTextField, gridBagConstraints);
111
112         jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
113         jLabel3.setLabelFor(typeTextField);
114         jLabel3.setText(org.openide.util.NbBundle.getBundle(SerialFieldTagPanel.class).getString("CTL_SerialFieldTagPanel.jLabel3.text"));
115         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
116         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
117         gridBagConstraints.insets = new java.awt.Insets JavaDoc(2, 2, 2, 1);
118         add(jLabel3, gridBagConstraints);
119
120         typeTextField.setText("jTextField2");
121         typeTextField.setToolTipText(org.openide.util.NbBundle.getBundle(SerialFieldTagPanel.class).getString("ACS_SerialFieldTagPanel.typeTextField.textA11yDesc"));
122         typeTextField.addActionListener(new java.awt.event.ActionListener JavaDoc() {
123             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
124                 typeTextFieldActionPerformed(evt);
125             }
126         });
127         typeTextField.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
128             public void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
129                 fieldFocusLost(evt);
130             }
131         });
132
133         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
134         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
135         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
136         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
137         gridBagConstraints.insets = new java.awt.Insets JavaDoc(2, 1, 2, 2);
138         add(typeTextField, gridBagConstraints);
139
140         jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
141         jLabel1.setLabelFor(descriptionTextArea);
142         jLabel1.setText(org.openide.util.NbBundle.getBundle(SerialFieldTagPanel.class).getString("CTL_SerialFieldTagPanel.jLabel1.text"));
143         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
144         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
145         gridBagConstraints.insets = new java.awt.Insets JavaDoc(2, 2, 2, 1);
146         add(jLabel1, gridBagConstraints);
147
148         descriptionTextArea.setToolTipText(org.openide.util.NbBundle.getBundle(SerialFieldTagPanel.class).getString("ACS_SerialFieldTagPanel.descriptionTextArea.textA11yDesc"));
149         descriptionTextArea.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
150             public void focusGained(java.awt.event.FocusEvent JavaDoc evt) {
151                 descriptionTextAreaFocusGained(evt);
152             }
153             public void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
154                 descriptionTextAreaFocusLost(evt);
155             }
156         });
157
158         descriptionScrollPane.setViewportView(descriptionTextArea);
159
160         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
161         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
162         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
163         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
164         gridBagConstraints.weightx = 1.0;
165         gridBagConstraints.weighty = 1.0;
166         gridBagConstraints.insets = new java.awt.Insets JavaDoc(2, 1, 2, 2);
167         add(descriptionScrollPane, gridBagConstraints);
168
169     }// </editor-fold>//GEN-END:initComponents
170

171     private void descriptionTextAreaFocusLost (java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_descriptionTextAreaFocusLost
172
enableHTMLButtons( false );
173         fieldFocusLost( evt );
174     }//GEN-LAST:event_descriptionTextAreaFocusLost
175

176     private void descriptionTextAreaFocusGained (java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_descriptionTextAreaFocusGained
177
enableHTMLButtons( true );
178     }//GEN-LAST:event_descriptionTextAreaFocusGained
179

180     private void fieldFocusLost (java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_fieldFocusLost
181

182         /*
183         if ( evt.getSource() == nameTextField ) {
184           System.out.println("UUYUname");
185           if ( checkField( nameTextField ) ) {
186             return;
187           }
188     }
189
190         if ( evt.getSource() == typeTextField ) {
191           System.out.println("YTYTtypoe");
192           if ( checkField( typeTextField ) ) {
193             return;
194           }
195     }
196         */

197
198         commitTagChange();
199     }//GEN-LAST:event_fieldFocusLost
200

201
202     private void nameTextFieldActionPerformed (java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_nameTextFieldActionPerformed
203
// Add your handling code here:
204
}//GEN-LAST:event_nameTextFieldActionPerformed
205

206     private void typeTextFieldActionPerformed (java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_typeTextFieldActionPerformed
207
// Add your handling code here:
208
}//GEN-LAST:event_typeTextFieldActionPerformed
209

210
211     // Variables declaration - do not modify//GEN-BEGIN:variables
212
private javax.swing.JScrollPane JavaDoc descriptionScrollPane;
213     private javax.swing.JEditorPane JavaDoc descriptionTextArea;
214     private javax.swing.JLabel JavaDoc jLabel1;
215     private javax.swing.JLabel JavaDoc jLabel2;
216     private javax.swing.JLabel JavaDoc jLabel3;
217     private javax.swing.JTextField JavaDoc nameTextField;
218     private javax.swing.JTextField JavaDoc typeTextField;
219     // End of variables declaration//GEN-END:variables
220

221     void setData( JavaDocTag tag ) {
222         String JavaDoc fieldName = ((JavaDocTag.SerialField)tag).fieldName();
223         nameTextField.setText( fieldName == null ? "" : fieldName ); //NOI18N
224

225         String JavaDoc fieldType = ((JavaDocTag.SerialField)tag).fieldType();
226         typeTextField.setText( fieldType == null ? "" : fieldType ); //NOI18N
227

228         String JavaDoc description = ((JavaDocTag.SerialField)tag).description();
229         if ((description != null) && (! "".equals(description))) { //NOI18N
230
descriptionTextArea.setText( description );
231         } else {
232             try {
233                 descriptionTextArea.getDocument().remove(0, descriptionTextArea.getDocument().getLength());
234             } catch (BadLocationException JavaDoc e) {
235                 ErrorManager.getDefault().annotate(e, "Failed to remove the text in the descriptionTextArea."); //NOI18N
236
}
237         }
238
239         // descriptionTextArea.setCaretPosition( 0 );
240
}
241
242     JavaDocTag getTag( String JavaDoc tagName ) {
243
244         return JavaDocSupport.createSerialFieldTag( tagName,
245                 nameTextField.getText() + " " + // NOI18N
246
typeTextField.getText() + " " + // NOI18N
247
descriptionTextArea.getText() );
248     }
249
250
251     String JavaDoc getCardName() {
252         return cardName;
253     }
254
255     void grabFirstFocus() {
256         nameTextField.requestFocus();
257     }
258 }
259
Popular Tags