1 19 20 package org.netbeans.modules.javadoc.comments; 21 22 import java.util.ResourceBundle ; 23 import org.openide.ErrorManager; 24 import org.openide.src.JavaDocTag; 25 import org.openide.src.JavaDocSupport; 26 27 import javax.swing.text.BadLocationException ; 28 import org.openide.text.CloneableEditorSupport; 29 30 34 public class SerialFieldTagPanel extends TagPanel { 35 36 private static final String cardName = "CRD_SERIAL_FIELD"; 38 39 static final long serialVersionUID =5117666281468847966L; 40 41 public SerialFieldTagPanel( JavaDocEditorPanel editorPanel ) { 42 super( editorPanel ); 43 44 initComponents ( ); 45 ResourceBundle b = org.openide.util.NbBundle.getBundle(SerialFieldTagPanel.class); 46 jLabel2.setDisplayedMnemonic(b.getString("CTL_SerialFieldTagPanel.jLabel2.text_Mnemonic").charAt(0)); jLabel3.setDisplayedMnemonic(b.getString("CTL_SerialFieldTagPanel.jLabel3.text_Mnemonic").charAt(0)); jLabel1.setDisplayedMnemonic(b.getString("CTL_SerialFieldTagPanel.jLabel1.text_Mnemonic").charAt(0)); 50 editorPanel.registerComponent( descriptionTextArea ); 51 addHTMLComponent( descriptionTextArea ); 52 initAccessibility(b); 53 } 54 55 private void initAccessibility(ResourceBundle b) 56 { 57 jLabel2.getAccessibleContext().setAccessibleDescription(b.getString("ACS_SerialFieldTagPanel.jLabel2.textA11yDesc")); nameTextField.getAccessibleContext().setAccessibleName(b.getString("ACS_SerialFieldTagPanel.nameTextField.textA11yName")); jLabel3.getAccessibleContext().setAccessibleDescription(b.getString("ACS_SerialFieldTagPanel.jLabel3.textA11yDesc")); typeTextField.getAccessibleContext().setAccessibleName(b.getString("ACS_SerialFieldTagPanel.typeTextField.textA11yName")); jLabel1.getAccessibleContext().setAccessibleDescription(b.getString("ACS_SerialFieldTagPanel.jLabel1.textA11yDesc")); descriptionTextArea.getAccessibleContext().setAccessibleName(b.getString("ACS_SerialFieldTagPanel.descriptionTextArea.textA11yName")); } 64 65 70 private void initComponents() { 72 java.awt.GridBagConstraints gridBagConstraints; 73 74 jLabel2 = new javax.swing.JLabel (); 75 nameTextField = new javax.swing.JTextField (); 76 jLabel3 = new javax.swing.JLabel (); 77 typeTextField = new javax.swing.JTextField (); 78 jLabel1 = new javax.swing.JLabel (); 79 descriptionScrollPane = new javax.swing.JScrollPane (); 80 descriptionTextArea = new javax.swing.JEditorPane (); descriptionTextArea.setEditorKit(CloneableEditorSupport.getEditorKit("text/html")); 81 82 setLayout(new java.awt.GridBagLayout ()); 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 (); 88 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 89 gridBagConstraints.insets = new java.awt.Insets (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 () { 95 public void actionPerformed(java.awt.event.ActionEvent evt) { 96 nameTextFieldActionPerformed(evt); 97 } 98 }); 99 nameTextField.addFocusListener(new java.awt.event.FocusAdapter () { 100 public void focusLost(java.awt.event.FocusEvent evt) { 101 fieldFocusLost(evt); 102 } 103 }); 104 105 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 116 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 117 gridBagConstraints.insets = new java.awt.Insets (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 () { 123 public void actionPerformed(java.awt.event.ActionEvent evt) { 124 typeTextFieldActionPerformed(evt); 125 } 126 }); 127 typeTextField.addFocusListener(new java.awt.event.FocusAdapter () { 128 public void focusLost(java.awt.event.FocusEvent evt) { 129 fieldFocusLost(evt); 130 } 131 }); 132 133 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 144 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 145 gridBagConstraints.insets = new java.awt.Insets (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 () { 150 public void focusGained(java.awt.event.FocusEvent evt) { 151 descriptionTextAreaFocusGained(evt); 152 } 153 public void focusLost(java.awt.event.FocusEvent evt) { 154 descriptionTextAreaFocusLost(evt); 155 } 156 }); 157 158 descriptionScrollPane.setViewportView(descriptionTextArea); 159 160 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (2, 1, 2, 2); 167 add(descriptionScrollPane, gridBagConstraints); 168 169 } 171 private void descriptionTextAreaFocusLost (java.awt.event.FocusEvent evt) { enableHTMLButtons( false ); 173 fieldFocusLost( evt ); 174 } 176 private void descriptionTextAreaFocusGained (java.awt.event.FocusEvent evt) { enableHTMLButtons( true ); 178 } 180 private void fieldFocusLost (java.awt.event.FocusEvent evt) { 182 197 198 commitTagChange(); 199 } 201 202 private void nameTextFieldActionPerformed (java.awt.event.ActionEvent evt) { } 206 private void typeTextFieldActionPerformed (java.awt.event.ActionEvent evt) { } 210 211 private javax.swing.JScrollPane descriptionScrollPane; 213 private javax.swing.JEditorPane descriptionTextArea; 214 private javax.swing.JLabel jLabel1; 215 private javax.swing.JLabel jLabel2; 216 private javax.swing.JLabel jLabel3; 217 private javax.swing.JTextField nameTextField; 218 private javax.swing.JTextField typeTextField; 219 221 void setData( JavaDocTag tag ) { 222 String fieldName = ((JavaDocTag.SerialField)tag).fieldName(); 223 nameTextField.setText( fieldName == null ? "" : fieldName ); 225 String fieldType = ((JavaDocTag.SerialField)tag).fieldType(); 226 typeTextField.setText( fieldType == null ? "" : fieldType ); 228 String description = ((JavaDocTag.SerialField)tag).description(); 229 if ((description != null) && (! "".equals(description))) { descriptionTextArea.setText( description ); 231 } else { 232 try { 233 descriptionTextArea.getDocument().remove(0, descriptionTextArea.getDocument().getLength()); 234 } catch (BadLocationException e) { 235 ErrorManager.getDefault().annotate(e, "Failed to remove the text in the descriptionTextArea."); } 237 } 238 239 } 241 242 JavaDocTag getTag( String tagName ) { 243 244 return JavaDocSupport.createSerialFieldTag( tagName, 245 nameTextField.getText() + " " + typeTextField.getText() + " " + descriptionTextArea.getText() ); 248 } 249 250 251 String getCardName() { 252 return cardName; 253 } 254 255 void grabFirstFocus() { 256 nameTextField.requestFocus(); 257 } 258 } 259 | Popular Tags |