1 19 20 21 package org.netbeans.modules.i18n; 22 23 24 import java.util.ResourceBundle ; 25 import javax.swing.JLabel ; 26 import javax.swing.JPanel ; 27 import javax.swing.JTextField ; 28 import javax.swing.text.StyledDocument ; 29 30 31 37 38 public abstract class InfoPanel extends JPanel { 39 40 41 private ResourceBundle bundle; 42 43 44 45 public InfoPanel(HardCodedString hcString, StyledDocument document) { 46 if(bundle == null) 47 bundle = I18nUtil.getBundle(); 48 49 initComponents (); 50 initAccessibility (); 51 52 setHardCodedString(hcString, document); 53 } 54 55 58 protected abstract void setHardCodedString(HardCodedString hcString, StyledDocument document); 59 60 61 protected JTextField getStringText() { 62 return stringText; 63 } 64 65 66 protected JTextField getFoundInText() { 67 return foundInText; 68 } 69 70 71 protected JTextField getComponentText() { 72 return componentText; 73 } 74 75 76 protected JTextField getPropertyText() { 77 return propertyText; 78 } 79 80 81 protected JLabel getComponentLabel() { 82 return componentLabel; 83 } 84 85 86 protected JLabel getPropertyLabel() { 87 return propertyLabel; 88 } 89 90 private void initAccessibility() { 91 this.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_InfoPanel")); 92 stringText.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_stringText")); 93 propertyText.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_propertyText")); 94 componentText.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_componentText")); 95 foundInText.getAccessibleContext().setAccessibleDescription(bundle.getString("ACS_foundInText")); 96 } 97 98 99 104 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 106 107 stringLabel = new javax.swing.JLabel (); 108 stringText = new javax.swing.JTextField (); 109 foundInLabel = new javax.swing.JLabel (); 110 foundInText = new javax.swing.JTextField (); 111 componentLabel = new javax.swing.JLabel (); 112 componentText = new javax.swing.JTextField (); 113 propertyLabel = new javax.swing.JLabel (); 114 propertyText = new javax.swing.JTextField (); 115 116 setLayout(new java.awt.GridBagLayout ()); 117 118 stringLabel.setText(bundle.getString("CTL_StringLabel")); 119 stringLabel.setLabelFor(stringText); 120 gridBagConstraints = new java.awt.GridBagConstraints (); 121 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 122 gridBagConstraints.insets = new java.awt.Insets (12, 12, 0, 0); 123 add(stringLabel, gridBagConstraints); 124 125 stringText.setEditable(false); 126 stringText.selectAll(); 127 stringText.addFocusListener(new java.awt.event.FocusAdapter () { 128 public void focusGained(java.awt.event.FocusEvent evt) { 129 stringTextFocusGained(evt); 130 } 131 }); 132 133 gridBagConstraints = new java.awt.GridBagConstraints (); 134 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 135 gridBagConstraints.weightx = 1.0; 136 gridBagConstraints.insets = new java.awt.Insets (12, 11, 0, 11); 137 add(stringText, gridBagConstraints); 138 139 foundInLabel.setText(bundle.getString("CTL_FoundInLabel")); 140 foundInLabel.setLabelFor(foundInText); 141 gridBagConstraints = new java.awt.GridBagConstraints (); 142 gridBagConstraints.gridx = 0; 143 gridBagConstraints.gridy = 1; 144 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 145 gridBagConstraints.insets = new java.awt.Insets (11, 12, 0, 0); 146 add(foundInLabel, gridBagConstraints); 147 148 foundInText.setEditable(false); 149 foundInText.selectAll(); 150 foundInText.addFocusListener(new java.awt.event.FocusAdapter () { 151 public void focusGained(java.awt.event.FocusEvent evt) { 152 foundInTextFocusGained(evt); 153 } 154 }); 155 156 gridBagConstraints = new java.awt.GridBagConstraints (); 157 gridBagConstraints.gridx = 1; 158 gridBagConstraints.gridy = 1; 159 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 160 gridBagConstraints.weightx = 1.0; 161 gridBagConstraints.insets = new java.awt.Insets (11, 11, 0, 11); 162 add(foundInText, gridBagConstraints); 163 164 componentLabel.setText(bundle.getString("CTL_ComponentLabel")); 165 componentLabel.setLabelFor(componentText); 166 gridBagConstraints = new java.awt.GridBagConstraints (); 167 gridBagConstraints.gridx = 0; 168 gridBagConstraints.gridy = 2; 169 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 170 gridBagConstraints.insets = new java.awt.Insets (11, 12, 0, 0); 171 add(componentLabel, gridBagConstraints); 172 173 componentText.setEditable(false); 174 componentText.selectAll(); 175 componentText.addFocusListener(new java.awt.event.FocusAdapter () { 176 public void focusGained(java.awt.event.FocusEvent evt) { 177 componentTextFocusGained(evt); 178 } 179 }); 180 181 gridBagConstraints = new java.awt.GridBagConstraints (); 182 gridBagConstraints.gridx = 1; 183 gridBagConstraints.gridy = 2; 184 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 185 gridBagConstraints.weightx = 1.0; 186 gridBagConstraints.insets = new java.awt.Insets (11, 11, 0, 11); 187 add(componentText, gridBagConstraints); 188 189 propertyLabel.setText(bundle.getString("CTL_PropertyLabel")); 190 propertyLabel.setLabelFor(propertyText); 191 gridBagConstraints = new java.awt.GridBagConstraints (); 192 gridBagConstraints.gridx = 0; 193 gridBagConstraints.gridy = 3; 194 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 195 gridBagConstraints.insets = new java.awt.Insets (11, 12, 11, 0); 196 add(propertyLabel, gridBagConstraints); 197 198 propertyText.setEditable(false); 199 propertyText.selectAll(); 200 propertyText.addFocusListener(new java.awt.event.FocusAdapter () { 201 public void focusGained(java.awt.event.FocusEvent evt) { 202 propertyTextFocusGained(evt); 203 } 204 }); 205 206 gridBagConstraints = new java.awt.GridBagConstraints (); 207 gridBagConstraints.gridx = 1; 208 gridBagConstraints.gridy = 3; 209 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 210 gridBagConstraints.weightx = 1.0; 211 gridBagConstraints.insets = new java.awt.Insets (11, 11, 11, 11); 212 add(propertyText, gridBagConstraints); 213 214 } 216 private void propertyTextFocusGained(java.awt.event.FocusEvent evt) { propertyText.selectAll(); 219 } 221 private void componentTextFocusGained(java.awt.event.FocusEvent evt) { componentText.selectAll(); 224 } 226 private void foundInTextFocusGained(java.awt.event.FocusEvent evt) { foundInText.selectAll(); 229 } 231 private void stringTextFocusGained(java.awt.event.FocusEvent evt) { stringText.selectAll(); 234 } 236 237 private javax.swing.JLabel propertyLabel; 239 private javax.swing.JLabel stringLabel; 240 private javax.swing.JTextField stringText; 241 private javax.swing.JTextField propertyText; 242 private javax.swing.JLabel foundInLabel; 243 private javax.swing.JLabel componentLabel; 244 private javax.swing.JTextField componentText; 245 private javax.swing.JTextField foundInText; 246 248 } 249 | Popular Tags |