KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.openide.ErrorManager;
23 import org.openide.src.JavaDocTag;
24 import org.openide.src.JavaDocSupport;
25
26 import javax.swing.text.BadLocationException JavaDoc;
27 import org.openide.text.CloneableEditorSupport;
28
29 /**
30  *
31  * @author
32  * @version
33  */

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

38
39     static final long serialVersionUID =-6495497486819375562L;
40     /** Initializes the Form */
41     public SeeTagPanel( JavaDocEditorPanel editorPanel ) {
42         super( editorPanel );
43
44         initComponents ();
45         jLabel1.setDisplayedMnemonic(org.openide.util.NbBundle.getBundle(SeeTagPanel.class).getString("CTL_SeeTagPanel.jLabel1.text_Mnemonic").charAt(0)); // NOI18N
46

47         editorPanel.registerComponent( descriptionTextArea );
48
49         addHTMLComponent( descriptionTextArea );
50         initAccessibility();
51     }
52     
53     private void initAccessibility()
54     {
55         jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(SeeTagPanel.class).getString("ACS_SeeTagPanel.jLabel2.textA11yDesc")); // NOI18N
56
classTextField.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(SeeTagPanel.class).getString("ACS_SeeTagPanel.classTextField.textA11yName")); // NOI18N
57
jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(SeeTagPanel.class).getString("ACS_SeeTagPanel.jLabel3.textA11yDesc")); // NOI18N
58
memberTextField.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(SeeTagPanel.class).getString("ACS_SeeTagPanel.identifierTextField.textA11yName")); // NOI18N
59
jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(SeeTagPanel.class).getString("ACS_SeeTagPanel.jLabel1.textA11yDesc")); // NOI18N
60
descriptionTextArea.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(SeeTagPanel.class).getString("ACS_SeeTagPanel.tagTextArea.textA11yName")); // NOI18N
61
}
62
63     /** This method is called from within the constructor to
64      * initialize the form.
65      * WARNING: Do NOT modify this code. The content of this method is
66      * always regenerated by the FormEditor.
67      */

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

163     private void descriptionTextAreaFocusGained (java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_descriptionTextAreaFocusGained
164
enableHTMLButtons( true );
165     }//GEN-LAST:event_descriptionTextAreaFocusGained
166

167     private void descriptionTextAreaFocusLost (java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_descriptionTextAreaFocusLost
168
enableHTMLButtons( false );
169         commitTagChange();
170     }//GEN-LAST:event_descriptionTextAreaFocusLost
171

172
173
174
175     private void nameTextFieldActionPerformed (java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_nameTextFieldActionPerformed
176
// Add your handling code here:
177
}//GEN-LAST:event_nameTextFieldActionPerformed
178

179     private void typeTextFieldActionPerformed (java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_typeTextFieldActionPerformed
180
// Add your handling code here:
181
}//GEN-LAST:event_typeTextFieldActionPerformed
182

183
184     // Variables declaration - do not modify//GEN-BEGIN:variables
185
private javax.swing.JTextField JavaDoc classTextField;
186     private javax.swing.JScrollPane JavaDoc descriptionScrollPane;
187     private javax.swing.JEditorPane JavaDoc descriptionTextArea;
188     private javax.swing.JLabel JavaDoc jLabel1;
189     private javax.swing.JLabel JavaDoc jLabel2;
190     private javax.swing.JLabel JavaDoc jLabel3;
191     private javax.swing.JTextField JavaDoc memberTextField;
192     // End of variables declaration//GEN-END:variables
193

194     void setData( JavaDocTag tag ) {
195         String JavaDoc description = tag.text().trim();
196         if ((description != null) && (! "".equals(description))) { //NOI18N
197
descriptionTextArea.setText( description );
198         } else {
199             try {
200                 descriptionTextArea.getDocument().remove(0, descriptionTextArea.getDocument().getLength());
201             } catch (BadLocationException JavaDoc e) {
202                 ErrorManager.getDefault().annotate(e, "Failed to remove the text in the descriptionTextArea."); //NOI18N
203
}
204         }
205         //descriptionTextArea.setCaretPosition( 0 );
206
classTextField.setText( ((JavaDocTag.See)tag).referencedClassName() );
207         memberTextField.setText( ((JavaDocTag.See)tag).referencedMemberName() );
208     }
209
210     JavaDocTag getTag( String JavaDoc tagName ) {
211         return JavaDocSupport.createSeeTag( tagName,
212                                             descriptionTextArea.getText() );
213     }
214
215     String JavaDoc getCardName() {
216         return cardName;
217     }
218
219     void grabFirstFocus() {
220         // JHK 9/29/2000 - description since other fields are non-editable
221
descriptionTextArea.requestFocus();
222         //classTextField.requestFocus();
223
//((java.awt.event.FocusListener)descriptionTextArea.getCaret()).focusLost( null );
224
}
225 }
226
Popular Tags