1 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 ; 27 import org.openide.text.CloneableEditorSupport; 28 29 34 public class SeeTagPanel extends TagPanel { 35 36 private static final String cardName = "CRD_SEE"; 38 39 static final long serialVersionUID =-6495497486819375562L; 40 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)); 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")); classTextField.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(SeeTagPanel.class).getString("ACS_SeeTagPanel.classTextField.textA11yName")); jLabel3.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(SeeTagPanel.class).getString("ACS_SeeTagPanel.jLabel3.textA11yDesc")); memberTextField.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(SeeTagPanel.class).getString("ACS_SeeTagPanel.identifierTextField.textA11yName")); jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(SeeTagPanel.class).getString("ACS_SeeTagPanel.jLabel1.textA11yDesc")); descriptionTextArea.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(SeeTagPanel.class).getString("ACS_SeeTagPanel.tagTextArea.textA11yName")); } 62 63 68 private void initComponents() { 70 java.awt.GridBagConstraints gridBagConstraints; 71 72 jLabel2 = new javax.swing.JLabel (); 73 classTextField = new javax.swing.JTextField (); 74 jLabel3 = new javax.swing.JLabel (); 75 memberTextField = new javax.swing.JTextField (); 76 jLabel1 = new javax.swing.JLabel (); 77 descriptionScrollPane = new javax.swing.JScrollPane (); 78 descriptionTextArea = new javax.swing.JEditorPane (); descriptionTextArea.setEditorKit(CloneableEditorSupport.getEditorKit("text/html")); 79 80 setLayout(new java.awt.GridBagLayout ()); 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 (); 86 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 87 gridBagConstraints.insets = new java.awt.Insets (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 () { 95 public void actionPerformed(java.awt.event.ActionEvent evt) { 96 nameTextFieldActionPerformed(evt); 97 } 98 }); 99 100 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 111 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 112 gridBagConstraints.insets = new java.awt.Insets (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 () { 120 public void actionPerformed(java.awt.event.ActionEvent evt) { 121 typeTextFieldActionPerformed(evt); 122 } 123 }); 124 125 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 136 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 137 gridBagConstraints.insets = new java.awt.Insets (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 () { 142 public void focusGained(java.awt.event.FocusEvent evt) { 143 descriptionTextAreaFocusGained(evt); 144 } 145 public void focusLost(java.awt.event.FocusEvent evt) { 146 descriptionTextAreaFocusLost(evt); 147 } 148 }); 149 150 descriptionScrollPane.setViewportView(descriptionTextArea); 151 152 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (2, 1, 2, 2); 159 add(descriptionScrollPane, gridBagConstraints); 160 161 } 163 private void descriptionTextAreaFocusGained (java.awt.event.FocusEvent evt) { enableHTMLButtons( true ); 165 } 167 private void descriptionTextAreaFocusLost (java.awt.event.FocusEvent evt) { enableHTMLButtons( false ); 169 commitTagChange(); 170 } 172 173 174 175 private void nameTextFieldActionPerformed (java.awt.event.ActionEvent evt) { } 179 private void typeTextFieldActionPerformed (java.awt.event.ActionEvent evt) { } 183 184 private javax.swing.JTextField classTextField; 186 private javax.swing.JScrollPane descriptionScrollPane; 187 private javax.swing.JEditorPane descriptionTextArea; 188 private javax.swing.JLabel jLabel1; 189 private javax.swing.JLabel jLabel2; 190 private javax.swing.JLabel jLabel3; 191 private javax.swing.JTextField memberTextField; 192 194 void setData( JavaDocTag tag ) { 195 String description = tag.text().trim(); 196 if ((description != null) && (! "".equals(description))) { descriptionTextArea.setText( description ); 198 } else { 199 try { 200 descriptionTextArea.getDocument().remove(0, descriptionTextArea.getDocument().getLength()); 201 } catch (BadLocationException e) { 202 ErrorManager.getDefault().annotate(e, "Failed to remove the text in the descriptionTextArea."); } 204 } 205 classTextField.setText( ((JavaDocTag.See)tag).referencedClassName() ); 207 memberTextField.setText( ((JavaDocTag.See)tag).referencedMemberName() ); 208 } 209 210 JavaDocTag getTag( String tagName ) { 211 return JavaDocSupport.createSeeTag( tagName, 212 descriptionTextArea.getText() ); 213 } 214 215 String getCardName() { 216 return cardName; 217 } 218 219 void grabFirstFocus() { 220 descriptionTextArea.requestFocus(); 222 } 225 } 226 | Popular Tags |