1 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 implements JavaTagNames { 30 31 private ButtonGroup bgroup; 32 private JavaDocTag result = null; 33 34 private String TAG_CUSTOM = "@"; 36 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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 122 } 123 124 private void initAccessibility() 125 { 126 getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialogA11yName")); getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialogA11yDesc")); customTextField.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("ACS_NewTagDialog.customTextField.textA11yName")); } 130 131 136 private void initComponents() { 138 java.awt.GridBagConstraints gridBagConstraints; 139 140 jPanel2 = new javax.swing.JPanel (); 141 authorRadioButton = new javax.swing.JRadioButton (); 142 deprecatedRadioButton = new javax.swing.JRadioButton (); 143 paramRadioButton = new javax.swing.JRadioButton (); 144 returnRadioButton = new javax.swing.JRadioButton (); 145 seeRadioButton = new javax.swing.JRadioButton (); 146 serialRadioButton = new javax.swing.JRadioButton (); 147 serialDataRadioButton = new javax.swing.JRadioButton (); 148 serialFieldRadioButton = new javax.swing.JRadioButton (); 149 sinceRadioButton = new javax.swing.JRadioButton (); 150 throwsRadioButton = new javax.swing.JRadioButton (); 151 versionRadioButton = new javax.swing.JRadioButton (); 152 customRadioButton = new javax.swing.JRadioButton (); 153 customTextField = new javax.swing.JTextField (); 154 155 FormListener formListener = new FormListener(); 156 157 setLayout(new java.awt.BorderLayout ()); 158 159 addKeyListener(formListener); 160 161 jPanel2.setLayout(new java.awt.GridBagLayout ()); 162 163 jPanel2.setBorder(new javax.swing.border.EmptyBorder (new java.awt.Insets (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 (); 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 (); 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 (); 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 (); 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 (); 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 (); 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 (); 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 (); 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 (); 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 (); 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 (); 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 (); 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 (); 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 269 private class FormListener implements java.awt.event.ActionListener , java.awt.event.KeyListener { 270 public void actionPerformed(java.awt.event.ActionEvent 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 evt) { 283 if (evt.getSource() == NewTagDialog.this) { 284 NewTagDialog.this.formKeyPressed(evt); 285 } 286 } 287 288 public void keyReleased(java.awt.event.KeyEvent evt) { 289 } 290 291 public void keyTyped(java.awt.event.KeyEvent evt) { 292 } 293 } 294 296 private void formKeyPressed(java.awt.event.KeyEvent evt) { if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_ESCAPE) 298 { 299 result = null; 300 closeDialog(null); 301 } 302 } 304 private void serialDataRadioButtonActionPerformed (java.awt.event.ActionEvent evt) { } 308 private void customTextFieldActionPerformed (java.awt.event.ActionEvent evt) { } 312 private void customRadioButtonActionPerformed (java.awt.event.ActionEvent evt) { } 316 317 private void closeDialog(java.awt.event.WindowEvent evt) { setVisible (false); 319 } 322 323 private javax.swing.JRadioButton authorRadioButton; 325 private javax.swing.JRadioButton customRadioButton; 326 private javax.swing.JTextField customTextField; 327 private javax.swing.JRadioButton deprecatedRadioButton; 328 private javax.swing.JPanel jPanel2; 329 private javax.swing.JRadioButton paramRadioButton; 330 private javax.swing.JRadioButton returnRadioButton; 331 private javax.swing.JRadioButton seeRadioButton; 332 private javax.swing.JRadioButton serialDataRadioButton; 333 private javax.swing.JRadioButton serialFieldRadioButton; 334 private javax.swing.JRadioButton serialRadioButton; 335 private javax.swing.JRadioButton sinceRadioButton; 336 private javax.swing.JRadioButton throwsRadioButton; 337 private javax.swing.JRadioButton versionRadioButton; 338 340 341 JavaDocTag getResult() { 342 if (result != null) 343 return result; 344 345 String command = bgroup.getSelection().getActionCommand(); 346 if ( command.equals( TAG_SEE ) ) { 347 result = JavaDocSupport.createSeeTag( command, "" ); } 349 else if ( command.equals( TAG_PARAM ) ) { 350 result = JavaDocSupport.createParamTag( command, "" ); } 352 else if ( command.equals( TAG_THROWS ) ) { 353 result = JavaDocSupport.createThrowsTag( command, "" ); } 355 else if ( command.equals( TAG_SERIALFIELD ) ) { 356 result = JavaDocSupport.createSerialFieldTag( command, " " ); } 358 else if ( command.equals( TAG_CUSTOM ) ) { 359 result = JavaDocSupport.createTag( command + customTextField.getText(), "" ); } 361 else { 362 result = JavaDocSupport.createTag( command, "" ) ; } 364 return result; 365 } 366 367 } 368 | Popular Tags |