KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.swing.*;
23
24 import org.openide.src.JavaDocTag;
25 import org.openide.src.JavaDocSupport;
26 import org.openide.util.Utilities;
27 import org.netbeans.jmi.javamodel.*;
28
29 public class NewTagDialog extends javax.swing.JPanel JavaDoc implements JavaTagNames {
30
31     private ButtonGroup bgroup;
32     private JavaDocTag result = null;
33
34     private String JavaDoc TAG_CUSTOM = "@"; // NOI18N
35

36     /** Initializes the Form */
37     public NewTagDialog(ClassMember element ) {
38         initComponents ();
39
40         bgroup = new ButtonGroup();
41
42         bgroup.add( authorRadioButton );
43         authorRadioButton.getModel().setActionCommand( TAG_AUTHOR );
44         authorRadioButton.setVisible( false );
45         authorRadioButton.setMnemonic(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.authorRadioButton_Mnemonic").charAt(0)); // NOI18N
46

47         bgroup.add( deprecatedRadioButton );
48         deprecatedRadioButton.getModel().setActionCommand( TAG_DEPRECATED );
49         deprecatedRadioButton.setMnemonic(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.deprecatedRadioButton_Mnemonic").charAt(0)); // NOI18N
50

51         bgroup.add( paramRadioButton );
52         paramRadioButton.getModel().setActionCommand( TAG_PARAM );
53         paramRadioButton.setVisible( false );
54         paramRadioButton.setMnemonic(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.paramRadioButton_Mnemonic").charAt(0)); // NOI18N
55

56         bgroup.add( returnRadioButton );
57         returnRadioButton.getModel().setActionCommand( TAG_RETURN );
58         returnRadioButton.setVisible( false );
59         returnRadioButton.setMnemonic(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.returnRadioButton_Mnemonic").charAt(0)); // NOI18N
60

61         bgroup.add( seeRadioButton );
62         seeRadioButton.getModel().setActionCommand( TAG_SEE );
63         seeRadioButton.setMnemonic(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.seeRadioButton_Mnemonic").charAt(0)); // NOI18N
64

65         bgroup.add( serialRadioButton );
66         serialRadioButton.getModel().setActionCommand( TAG_SERIAL );
67         serialRadioButton.setVisible( false );
68         serialRadioButton.setMnemonic(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.serialRadioButton_Mnemonic").charAt(0)); // NOI18N
69

70         bgroup.add( serialDataRadioButton );
71         serialDataRadioButton.getModel().setActionCommand( TAG_SERIALDATA );
72         serialDataRadioButton.setVisible( false );
73         serialDataRadioButton.setMnemonic(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.serialDataRadioButton_Mnemonic").charAt(0)); // NOI18N
74

75         bgroup.add( serialFieldRadioButton );
76         serialFieldRadioButton.getModel().setActionCommand( TAG_SERIALFIELD );
77         serialFieldRadioButton.setVisible( false );
78         serialFieldRadioButton.setMnemonic(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.serialFieldRadioButton_Mnemonic").charAt(0)); // NOI18N
79

80         bgroup.add( sinceRadioButton );
81         sinceRadioButton.getModel().setActionCommand( TAG_SINCE );
82         sinceRadioButton.setMnemonic(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.sinceRadioButton_Mnemonic").charAt(0)); // NOI18N
83

84         bgroup.add( throwsRadioButton );
85         throwsRadioButton.getModel().setActionCommand( TAG_THROWS );
86         throwsRadioButton.setVisible( false );
87         throwsRadioButton.setMnemonic(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.throwsRadioButton_Mnemonic").charAt(0)); // NOI18N
88

89         bgroup.add( versionRadioButton );
90         versionRadioButton.getModel().setActionCommand( TAG_VERSION );
91         versionRadioButton.setVisible( false );
92         versionRadioButton.setMnemonic(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.versionRadioButton_Mnemonic").charAt(0)); // NOI18N
93

94         bgroup.add( customRadioButton );
95         customRadioButton.getModel().setActionCommand( TAG_CUSTOM );
96         customRadioButton.setMnemonic(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.customRadioButton_Mnemonic").charAt(0)); // NOI18N
97

98         setBounds(Utilities.findCenterBounds(getSize()));
99
100         if ( element instanceof CallableFeature ) {
101             paramRadioButton.setVisible( true );
102             returnRadioButton.setVisible( true );
103             serialDataRadioButton.setVisible( true );
104             throwsRadioButton.setVisible( true );
105         }
106         else if ( element instanceof Field || element instanceof Attribute) {
107             serialRadioButton.setVisible( true );
108             serialFieldRadioButton.setVisible( true );
109         }
110         if ( element instanceof JavaClass ) {
111             authorRadioButton.setVisible( true );
112             versionRadioButton.setVisible( true );
113         }
114
115         initAccessibility();
116         /*
117         getRootPane().setDefaultButton(okButton);
118
119         javax.swing.InputMap im = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
120         im.put(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0), null);
121          */

122     }
123
124     private void initAccessibility()
125     {
126         getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialogA11yName")); // NOI18N
127
getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialogA11yDesc")); // NOI18N
128
customTextField.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialog.customTextField.textA11yName")); // NOI18N
129
}
130
131     /** This method is called from within the constructor to
132      * initialize the form.
133      * WARNING: Do NOT modify this code. The content of this method is
134      * always regenerated by the FormEditor.
135      */

136     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
137
private void initComponents() {
138         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
139
140         jPanel2 = new javax.swing.JPanel JavaDoc();
141         authorRadioButton = new javax.swing.JRadioButton JavaDoc();
142         deprecatedRadioButton = new javax.swing.JRadioButton JavaDoc();
143         paramRadioButton = new javax.swing.JRadioButton JavaDoc();
144         returnRadioButton = new javax.swing.JRadioButton JavaDoc();
145         seeRadioButton = new javax.swing.JRadioButton JavaDoc();
146         serialRadioButton = new javax.swing.JRadioButton JavaDoc();
147         serialDataRadioButton = new javax.swing.JRadioButton JavaDoc();
148         serialFieldRadioButton = new javax.swing.JRadioButton JavaDoc();
149         sinceRadioButton = new javax.swing.JRadioButton JavaDoc();
150         throwsRadioButton = new javax.swing.JRadioButton JavaDoc();
151         versionRadioButton = new javax.swing.JRadioButton JavaDoc();
152         customRadioButton = new javax.swing.JRadioButton JavaDoc();
153         customTextField = new javax.swing.JTextField JavaDoc();
154
155         FormListener formListener = new FormListener();
156
157         setLayout(new java.awt.BorderLayout JavaDoc());
158
159         addKeyListener(formListener);
160
161         jPanel2.setLayout(new java.awt.GridBagLayout JavaDoc());
162
163         jPanel2.setBorder(new javax.swing.border.EmptyBorder JavaDoc(new java.awt.Insets JavaDoc(8, 8, 8, 8)));
164         authorRadioButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javadoc/comments/Bundle").getString("NewTagDialog.authorRadioButton.text"));
165         authorRadioButton.setToolTipText(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialog.authorRadioButton.textA11yDesc"));
166         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
167         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
168         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
169         jPanel2.add(authorRadioButton, gridBagConstraints);
170
171         deprecatedRadioButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javadoc/comments/Bundle").getString("NewTagDialog.deprecatedRadioButton.text"));
172         deprecatedRadioButton.setToolTipText(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialog.deprecatedRadioButton.textA11yDesc"));
173         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
174         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
175         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
176         jPanel2.add(deprecatedRadioButton, gridBagConstraints);
177
178         paramRadioButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javadoc/comments/Bundle").getString("NewTagDialog.paramRadioButton.text"));
179         paramRadioButton.setToolTipText(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialog.paramRadioButton.textA11yDesc"));
180         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
181         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
182         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
183         jPanel2.add(paramRadioButton, gridBagConstraints);
184
185         returnRadioButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javadoc/comments/Bundle").getString("NewTagDialog.returnRadioButton.text"));
186         returnRadioButton.setToolTipText(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialog.returnRadioButton.textA11yDesc"));
187         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
188         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
189         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
190         jPanel2.add(returnRadioButton, gridBagConstraints);
191
192         seeRadioButton.setSelected(true);
193         seeRadioButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javadoc/comments/Bundle").getString("NewTagDialog.seeRadioButton.text"));
194         seeRadioButton.setToolTipText(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialog.seeRadioButton.textA11yDesc"));
195         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
196         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
197         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
198         jPanel2.add(seeRadioButton, gridBagConstraints);
199
200         serialRadioButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javadoc/comments/Bundle").getString("NewTagDialog.serialRadioButton.text"));
201         serialRadioButton.setToolTipText(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialog.serialRadioButton.textA11yDesc"));
202         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
203         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
204         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
205         jPanel2.add(serialRadioButton, gridBagConstraints);
206
207         serialDataRadioButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javadoc/comments/Bundle").getString("NewTagDialog.serialDataRadioButton.text"));
208         serialDataRadioButton.setToolTipText(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialog.serialDataRadioButton.textA11yDesc"));
209         serialDataRadioButton.addActionListener(formListener);
210
211         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
212         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
213         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
214         jPanel2.add(serialDataRadioButton, gridBagConstraints);
215
216         serialFieldRadioButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javadoc/comments/Bundle").getString("NewTagDialog.serialFieldRadioButton.text"));
217         serialFieldRadioButton.setToolTipText(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialog.serialFieldRadioButton.textA11yDesc"));
218         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
219         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
220         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
221         jPanel2.add(serialFieldRadioButton, gridBagConstraints);
222
223         sinceRadioButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javadoc/comments/Bundle").getString("NewTagDialog.sinceRadioButton.text"));
224         sinceRadioButton.setToolTipText(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialog.sinceRadioButton.textA11yDesc"));
225         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
226         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
227         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
228         jPanel2.add(sinceRadioButton, gridBagConstraints);
229
230         throwsRadioButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javadoc/comments/Bundle").getString("NewTagDialog.throwsRadioButton.text"));
231         throwsRadioButton.setToolTipText(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialog.throwsRadioButton.textA11yDesc"));
232         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
233         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
234         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
235         jPanel2.add(throwsRadioButton, gridBagConstraints);
236
237         versionRadioButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javadoc/comments/Bundle").getString("NewTagDialog.versionRadioButton.text"));
238         versionRadioButton.setToolTipText(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialog.versionRadioButton.textA11yDesc"));
239         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
240         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
241         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
242         jPanel2.add(versionRadioButton, gridBagConstraints);
243
244         customRadioButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/javadoc/comments/Bundle").getString("NewTagDialog.customRadioButton.text"));
245         customRadioButton.setToolTipText(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialog.customRadioButton.textA11yDesc"));
246         customRadioButton.addActionListener(formListener);
247
248         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
249         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE;
250         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
251         jPanel2.add(customRadioButton, gridBagConstraints);
252
253         customTextField.setToolTipText(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialog.customTextField.textA11yDesc"));
254         customTextField.addActionListener(formListener);
255
256         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
257         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
258         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
259         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
260         gridBagConstraints.weightx = 1.0;
261         jPanel2.add(customTextField, gridBagConstraints);
262
263         add(jPanel2, java.awt.BorderLayout.CENTER);
264
265     }
266
267     // Code for dispatching events from components to event handlers.
268

269     private class FormListener implements java.awt.event.ActionListener JavaDoc, java.awt.event.KeyListener JavaDoc {
270         public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
271             if (evt.getSource() == serialDataRadioButton) {
272                 NewTagDialog.this.serialDataRadioButtonActionPerformed(evt);
273             }
274             else if (evt.getSource() == customRadioButton) {
275                 NewTagDialog.this.customRadioButtonActionPerformed(evt);
276             }
277             else if (evt.getSource() == customTextField) {
278                 NewTagDialog.this.customTextFieldActionPerformed(evt);
279             }
280         }
281
282         public void keyPressed(java.awt.event.KeyEvent JavaDoc evt) {
283             if (evt.getSource() == NewTagDialog.this) {
284                 NewTagDialog.this.formKeyPressed(evt);
285             }
286         }
287
288         public void keyReleased(java.awt.event.KeyEvent JavaDoc evt) {
289         }
290
291         public void keyTyped(java.awt.event.KeyEvent JavaDoc evt) {
292         }
293     }
294     // </editor-fold>//GEN-END:initComponents
295

296     private void formKeyPressed(java.awt.event.KeyEvent JavaDoc evt) {//GEN-FIRST:event_formKeyPressed
297
if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_ESCAPE)
298         {
299             result = null;
300             closeDialog(null);
301         }
302     }//GEN-LAST:event_formKeyPressed
303

304     private void serialDataRadioButtonActionPerformed (java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_serialDataRadioButtonActionPerformed
305
// Add your handling code here:
306
}//GEN-LAST:event_serialDataRadioButtonActionPerformed
307

308     private void customTextFieldActionPerformed (java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_customTextFieldActionPerformed
309
// Add your handling code here:
310
}//GEN-LAST:event_customTextFieldActionPerformed
311

312     private void customRadioButtonActionPerformed (java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_customRadioButtonActionPerformed
313
// Add your handling code here:
314
}//GEN-LAST:event_customRadioButtonActionPerformed
315

316     /** Closes the dialog */
317     private void closeDialog(java.awt.event.WindowEvent JavaDoc evt) {//GEN-FIRST:event_closeDialog
318
setVisible (false);
319         //dispose ();
320
}//GEN-LAST:event_closeDialog
321

322
323     // Variables declaration - do not modify//GEN-BEGIN:variables
324
private javax.swing.JRadioButton JavaDoc authorRadioButton;
325     private javax.swing.JRadioButton JavaDoc customRadioButton;
326     private javax.swing.JTextField JavaDoc customTextField;
327     private javax.swing.JRadioButton JavaDoc deprecatedRadioButton;
328     private javax.swing.JPanel JavaDoc jPanel2;
329     private javax.swing.JRadioButton JavaDoc paramRadioButton;
330     private javax.swing.JRadioButton JavaDoc returnRadioButton;
331     private javax.swing.JRadioButton JavaDoc seeRadioButton;
332     private javax.swing.JRadioButton JavaDoc serialDataRadioButton;
333     private javax.swing.JRadioButton JavaDoc serialFieldRadioButton;
334     private javax.swing.JRadioButton JavaDoc serialRadioButton;
335     private javax.swing.JRadioButton JavaDoc sinceRadioButton;
336     private javax.swing.JRadioButton JavaDoc throwsRadioButton;
337     private javax.swing.JRadioButton JavaDoc versionRadioButton;
338     // End of variables declaration//GEN-END:variables
339

340
341     JavaDocTag getResult() {
342         if (result != null)
343             return result;
344
345         String JavaDoc command = bgroup.getSelection().getActionCommand();
346         if ( command.equals( TAG_SEE ) ) {
347             result = JavaDocSupport.createSeeTag( command, "" ); // NOI18N
348
}
349         else if ( command.equals( TAG_PARAM ) ) {
350             result = JavaDocSupport.createParamTag( command, "" ); // NOI18N
351
}
352         else if ( command.equals( TAG_THROWS ) ) {
353             result = JavaDocSupport.createThrowsTag( command, "" ); // NOI18N
354
}
355         else if ( command.equals( TAG_SERIALFIELD ) ) {
356             result = JavaDocSupport.createSerialFieldTag( command, " " ); // NOI18N
357
}
358         else if ( command.equals( TAG_CUSTOM ) ) {
359             result = JavaDocSupport.createTag( command + customTextField.getText(), "" ); // NOI18N
360
}
361         else {
362             result = JavaDocSupport.createTag( command, "" ) ; // NOI18N
363
}
364         return result;
365     }
366
367 }
368
Popular Tags