KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > editor > lib2 > search > EditorFindDialogPanel


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 package org.netbeans.modules.editor.lib2.search;
21
22 import java.awt.Dimension JavaDoc;
23 import java.util.MissingResourceException JavaDoc;
24 import java.util.ResourceBundle JavaDoc;
25 import javax.swing.JCheckBox JavaDoc;
26 import org.openide.util.NbBundle;
27
28 /**
29  *
30  * @author Miloslav Metelka, Petr Nejedly
31  * @version 1.0
32  */

33 public class EditorFindDialogPanel extends javax.swing.JPanel JavaDoc {
34
35     static final long serialVersionUID =5048601763767383114L;
36
37     private final ResourceBundle JavaDoc bundle = NbBundle.getBundle(EditorFindDialogPanel.class);
38
39     /** Initializes the Form */
40     public EditorFindDialogPanel() {
41         initComponents ();
42         getAccessibleContext().setAccessibleName(bundle.getString("find-title")); // NOI18N
43
getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_find")); // NOI18N
44
findWhat.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_" + EditorFindSupport.FIND_WHAT)); // NOI18N
45
replaceWith.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_" + EditorFindSupport.FIND_REPLACE_WITH)); // NOI18N
46

47         // #71956
48
Dimension JavaDoc findPrefSize = findWhat.getPreferredSize();
49         Dimension JavaDoc replacePrefSize = replaceWith.getPreferredSize();
50         if (findPrefSize != null){
51             findWhat.setPreferredSize(new Dimension JavaDoc((int)findPrefSize.getWidth(), (int)findPrefSize.getHeight()));
52         }
53         if (replacePrefSize != null){
54             replaceWith.setPreferredSize(new Dimension JavaDoc((int)replacePrefSize.getWidth(), (int)replacePrefSize.getHeight()));
55         }
56     }
57
58     /** This method is called from within the constructor to
59      * initialize the form.
60      * WARNING: Do NOT modify this code. The content of this method is
61      * always regenerated by the FormEditor.
62      */

63     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
64
private void initComponents() {
65         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
66
67         findWhatPanel = new javax.swing.JPanel JavaDoc();
68         findWhatLabel = new javax.swing.JLabel JavaDoc();
69         findWhat = new javax.swing.JComboBox JavaDoc();
70         replaceWithLabel = new javax.swing.JLabel JavaDoc();
71         replaceWith = new javax.swing.JComboBox JavaDoc();
72         highlightSearch = createCheckBox( EditorFindSupport.FIND_HIGHLIGHT_SEARCH, 'H' );
73         incSearch = createCheckBox( EditorFindSupport.FIND_INC_SEARCH, 'I' );
74         matchCase = createCheckBox( EditorFindSupport.FIND_MATCH_CASE, 'C' );
75         wholeWords = createCheckBox( EditorFindSupport.FIND_WHOLE_WORDS, 'W' );
76         bwdSearch = createCheckBox( EditorFindSupport.FIND_BACKWARD_SEARCH, 'B' );
77         wrapSearch = createCheckBox( EditorFindSupport.FIND_WRAP_SEARCH, 'p' );
78         regExp = createCheckBox( EditorFindSupport.FIND_REG_EXP, 'E' );
79         blockSearch = createCheckBox( EditorFindSupport.FIND_BLOCK_SEARCH, 'l' );
80
81         setLayout(new java.awt.GridBagLayout JavaDoc());
82
83         findWhatPanel.setLayout(new java.awt.GridBagLayout JavaDoc());
84
85         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
86         gridBagConstraints.gridx = 0;
87         gridBagConstraints.gridy = 0;
88         gridBagConstraints.gridwidth = 3;
89         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
90         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
91         gridBagConstraints.weightx = 1.0;
92         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 0, 0, 0);
93         add(findWhatPanel, gridBagConstraints);
94
95         findWhatLabel.setLabelFor(findWhat);
96         findWhatLabel.setText(bundle.getString(EditorFindSupport.FIND_WHAT ) );
97         findWhatLabel.setDisplayedMnemonic(bundle.getString(EditorFindSupport.FIND_WHAT + "-mnemonic").charAt(0));
98         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
99         gridBagConstraints.gridx = 0;
100         gridBagConstraints.gridy = 1;
101         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
102         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 5, 0);
103         add(findWhatLabel, gridBagConstraints);
104
105         findWhat.setEditable(true);
106         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
107         gridBagConstraints.gridx = 1;
108         gridBagConstraints.gridy = 1;
109         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
110         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
111         gridBagConstraints.weightx = 1.0;
112         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 11, 9, 10);
113         add(findWhat, gridBagConstraints);
114
115         replaceWithLabel.setLabelFor(replaceWith);
116         replaceWithLabel.setText(bundle.getString(EditorFindSupport.FIND_REPLACE_WITH ) );
117         replaceWithLabel.setDisplayedMnemonic(bundle.getString(EditorFindSupport.FIND_REPLACE_WITH + "-mnemonic").charAt(0));
118         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
119         gridBagConstraints.gridx = 0;
120         gridBagConstraints.gridy = 2;
121         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
122         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 9, 0);
123         add(replaceWithLabel, gridBagConstraints);
124
125         replaceWith.setEditable(true);
126         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
127         gridBagConstraints.gridx = 1;
128         gridBagConstraints.gridy = 2;
129         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
130         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
131         gridBagConstraints.weightx = 1.0;
132         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 11, 9, 10);
133         add(replaceWith, gridBagConstraints);
134
135         highlightSearch.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
136         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
137         gridBagConstraints.gridx = 1;
138         gridBagConstraints.gridy = 6;
139         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
140         gridBagConstraints.weighty = 1.0;
141         gridBagConstraints.insets = new java.awt.Insets JavaDoc(11, 11, 11, 0);
142         add(highlightSearch, gridBagConstraints);
143
144         incSearch.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
145         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
146         gridBagConstraints.gridx = 2;
147         gridBagConstraints.gridy = 6;
148         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
149         gridBagConstraints.insets = new java.awt.Insets JavaDoc(11, 11, 11, 10);
150         add(incSearch, gridBagConstraints);
151
152         matchCase.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
153         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
154         gridBagConstraints.gridx = 1;
155         gridBagConstraints.gridy = 3;
156         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
157         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 11, 0, 0);
158         add(matchCase, gridBagConstraints);
159
160         wholeWords.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
161         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
162         gridBagConstraints.gridx = 1;
163         gridBagConstraints.gridy = 4;
164         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
165         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 11, 0, 0);
166         add(wholeWords, gridBagConstraints);
167
168         bwdSearch.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
169         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
170         gridBagConstraints.gridx = 2;
171         gridBagConstraints.gridy = 5;
172         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
173         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 11, 0, 10);
174         add(bwdSearch, gridBagConstraints);
175
176         wrapSearch.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
177         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
178         gridBagConstraints.gridx = 2;
179         gridBagConstraints.gridy = 3;
180         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
181         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 11, 0, 10);
182         add(wrapSearch, gridBagConstraints);
183
184         regExp.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
185         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
186         gridBagConstraints.gridx = 1;
187         gridBagConstraints.gridy = 5;
188         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
189         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 11, 0, 0);
190         add(regExp, gridBagConstraints);
191
192         blockSearch.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
193         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
194         gridBagConstraints.gridx = 2;
195         gridBagConstraints.gridy = 4;
196         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
197         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 11, 0, 10);
198         add(blockSearch, gridBagConstraints);
199
200     }// </editor-fold>//GEN-END:initComponents
201

202
203     // Variables declaration - do not modify//GEN-BEGIN:variables
204
protected javax.swing.JCheckBox JavaDoc blockSearch;
205     protected javax.swing.JCheckBox JavaDoc bwdSearch;
206     protected javax.swing.JComboBox JavaDoc findWhat;
207     protected javax.swing.JLabel JavaDoc findWhatLabel;
208     protected javax.swing.JPanel JavaDoc findWhatPanel;
209     protected javax.swing.JCheckBox JavaDoc highlightSearch;
210     protected javax.swing.JCheckBox JavaDoc incSearch;
211     protected javax.swing.JCheckBox JavaDoc matchCase;
212     protected javax.swing.JCheckBox JavaDoc regExp;
213     protected javax.swing.JComboBox JavaDoc replaceWith;
214     protected javax.swing.JLabel JavaDoc replaceWithLabel;
215     protected javax.swing.JCheckBox JavaDoc wholeWords;
216     protected javax.swing.JCheckBox JavaDoc wrapSearch;
217     // End of variables declaration//GEN-END:variables
218

219
220     private JCheckBox JavaDoc createCheckBox( String JavaDoc key, char mnemonic ) {
221         JCheckBox JavaDoc box = new JCheckBox JavaDoc( bundle.getString( key ) );
222         box.setToolTipText( bundle.getString( key + "-tooltip" ) );
223         char mnemonicChar;
224         try {
225             mnemonicChar = bundle.getString( key + "-mnemonic").charAt(0);
226         } catch (MissingResourceException JavaDoc e) {
227             mnemonicChar = mnemonic;
228         }
229         box.setMnemonic(mnemonicChar); // NOI18N
230
return box;
231     }
232     
233 }
234
Popular Tags