KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > i18n > InfoPanel


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
21 package org.netbeans.modules.i18n;
22
23
24 import java.util.ResourceBundle JavaDoc;
25 import javax.swing.JLabel JavaDoc;
26 import javax.swing.JPanel JavaDoc;
27 import javax.swing.JTextField JavaDoc;
28 import javax.swing.text.StyledDocument JavaDoc;
29
30
31 /**
32  * Former part of ResourceBundlePanel (now <code>I18nPanel</code>). Helper base class for showing information
33  * about found hard coded in java sources (java & form objects).
34  *
35  * @author Peter Zavadsky
36  */

37
38 public abstract class InfoPanel extends JPanel JavaDoc {
39
40     /** Helper bundle in which are internationalized string from this source. */
41     private ResourceBundle JavaDoc bundle;
42
43     
44     /** Creates new form InfoPanel */
45     public InfoPanel(HardCodedString hcString, StyledDocument JavaDoc document) {
46         if(bundle == null)
47             bundle = I18nUtil.getBundle();
48
49         initComponents ();
50         initAccessibility ();
51         
52         setHardCodedString(hcString, document);
53     }
54
55     /** Sets <code>HardCodedString</code> to inform about.
56      * @param hcString hard coded string to inform about
57      * @param document document contaning hard coded string */

58     protected abstract void setHardCodedString(HardCodedString hcString, StyledDocument JavaDoc document);
59
60     /** String text field accessor. */
61     protected JTextField JavaDoc getStringText() {
62         return stringText;
63     }
64     
65     /** Found in text fiedl accessor. */
66     protected JTextField JavaDoc getFoundInText() {
67         return foundInText;
68     }
69     
70     /** Component text field accessor. */
71     protected JTextField JavaDoc getComponentText() {
72         return componentText;
73     }
74     
75     /** Property text field accessor. */
76     protected JTextField JavaDoc getPropertyText() {
77         return propertyText;
78     }
79     
80     /** Componenet label accessor. */
81     protected JLabel JavaDoc getComponentLabel() {
82         return componentLabel;
83     }
84     
85     /** Property label accessor. */
86     protected JLabel JavaDoc 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     /** This method is called from within the constructor to
100      * initialize the form.
101      * WARNING: Do NOT modify this code. The content of this method is
102      * always regenerated by the FormEditor.
103      */

104     private void initComponents() {//GEN-BEGIN:initComponents
105
java.awt.GridBagConstraints JavaDoc gridBagConstraints;
106
107         stringLabel = new javax.swing.JLabel JavaDoc();
108         stringText = new javax.swing.JTextField JavaDoc();
109         foundInLabel = new javax.swing.JLabel JavaDoc();
110         foundInText = new javax.swing.JTextField JavaDoc();
111         componentLabel = new javax.swing.JLabel JavaDoc();
112         componentText = new javax.swing.JTextField JavaDoc();
113         propertyLabel = new javax.swing.JLabel JavaDoc();
114         propertyText = new javax.swing.JTextField JavaDoc();
115
116         setLayout(new java.awt.GridBagLayout JavaDoc());
117
118         stringLabel.setText(bundle.getString("CTL_StringLabel"));
119         stringLabel.setLabelFor(stringText);
120         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
121         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
122         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
123         add(stringLabel, gridBagConstraints);
124
125         stringText.setEditable(false);
126         stringText.selectAll();
127         stringText.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
128             public void focusGained(java.awt.event.FocusEvent JavaDoc evt) {
129                 stringTextFocusGained(evt);
130             }
131         });
132
133         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
134         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
135         gridBagConstraints.weightx = 1.0;
136         gridBagConstraints.insets = new java.awt.Insets JavaDoc(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 JavaDoc();
142         gridBagConstraints.gridx = 0;
143         gridBagConstraints.gridy = 1;
144         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
145         gridBagConstraints.insets = new java.awt.Insets JavaDoc(11, 12, 0, 0);
146         add(foundInLabel, gridBagConstraints);
147
148         foundInText.setEditable(false);
149         foundInText.selectAll();
150         foundInText.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
151             public void focusGained(java.awt.event.FocusEvent JavaDoc evt) {
152                 foundInTextFocusGained(evt);
153             }
154         });
155
156         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(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 JavaDoc();
167         gridBagConstraints.gridx = 0;
168         gridBagConstraints.gridy = 2;
169         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
170         gridBagConstraints.insets = new java.awt.Insets JavaDoc(11, 12, 0, 0);
171         add(componentLabel, gridBagConstraints);
172
173         componentText.setEditable(false);
174         componentText.selectAll();
175         componentText.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
176             public void focusGained(java.awt.event.FocusEvent JavaDoc evt) {
177                 componentTextFocusGained(evt);
178             }
179         });
180
181         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(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 JavaDoc();
192         gridBagConstraints.gridx = 0;
193         gridBagConstraints.gridy = 3;
194         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
195         gridBagConstraints.insets = new java.awt.Insets JavaDoc(11, 12, 11, 0);
196         add(propertyLabel, gridBagConstraints);
197
198         propertyText.setEditable(false);
199         propertyText.selectAll();
200         propertyText.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
201             public void focusGained(java.awt.event.FocusEvent JavaDoc evt) {
202                 propertyTextFocusGained(evt);
203             }
204         });
205
206         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(11, 11, 11, 11);
212         add(propertyText, gridBagConstraints);
213
214     }//GEN-END:initComponents
215

216     private void propertyTextFocusGained(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_propertyTextFocusGained
217
// Accessibility
218
propertyText.selectAll();
219     }//GEN-LAST:event_propertyTextFocusGained
220

221     private void componentTextFocusGained(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_componentTextFocusGained
222
// Accessibility
223
componentText.selectAll();
224     }//GEN-LAST:event_componentTextFocusGained
225

226     private void foundInTextFocusGained(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_foundInTextFocusGained
227
// Accessibility
228
foundInText.selectAll();
229     }//GEN-LAST:event_foundInTextFocusGained
230

231     private void stringTextFocusGained(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_stringTextFocusGained
232
// Accessibility
233
stringText.selectAll();
234     }//GEN-LAST:event_stringTextFocusGained
235

236
237     // Variables declaration - do not modify//GEN-BEGIN:variables
238
private javax.swing.JLabel JavaDoc propertyLabel;
239     private javax.swing.JLabel JavaDoc stringLabel;
240     private javax.swing.JTextField JavaDoc stringText;
241     private javax.swing.JTextField JavaDoc propertyText;
242     private javax.swing.JLabel JavaDoc foundInLabel;
243     private javax.swing.JLabel JavaDoc componentLabel;
244     private javax.swing.JTextField JavaDoc componentText;
245     private javax.swing.JTextField JavaDoc foundInText;
246     // End of variables declaration//GEN-END:variables
247

248 }
249
Popular Tags