1 19 20 package org.netbeans.modules.editor.lib2.search; 21 22 import java.awt.Dimension ; 23 import java.util.MissingResourceException ; 24 import java.util.ResourceBundle ; 25 import javax.swing.JCheckBox ; 26 import org.openide.util.NbBundle; 27 28 33 public class EditorFindDialogPanel extends javax.swing.JPanel { 34 35 static final long serialVersionUID =5048601763767383114L; 36 37 private final ResourceBundle bundle = NbBundle.getBundle(EditorFindDialogPanel.class); 38 39 40 public EditorFindDialogPanel() { 41 initComponents (); 42 getAccessibleContext().setAccessibleName(bundle.getString("find-title")); getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_find")); findWhat.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_" + EditorFindSupport.FIND_WHAT)); replaceWith.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_" + EditorFindSupport.FIND_REPLACE_WITH)); 47 Dimension findPrefSize = findWhat.getPreferredSize(); 49 Dimension replacePrefSize = replaceWith.getPreferredSize(); 50 if (findPrefSize != null){ 51 findWhat.setPreferredSize(new Dimension ((int)findPrefSize.getWidth(), (int)findPrefSize.getHeight())); 52 } 53 if (replacePrefSize != null){ 54 replaceWith.setPreferredSize(new Dimension ((int)replacePrefSize.getWidth(), (int)replacePrefSize.getHeight())); 55 } 56 } 57 58 63 private void initComponents() { 65 java.awt.GridBagConstraints gridBagConstraints; 66 67 findWhatPanel = new javax.swing.JPanel (); 68 findWhatLabel = new javax.swing.JLabel (); 69 findWhat = new javax.swing.JComboBox (); 70 replaceWithLabel = new javax.swing.JLabel (); 71 replaceWith = new javax.swing.JComboBox (); 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 ()); 82 83 findWhatPanel.setLayout(new java.awt.GridBagLayout ()); 84 85 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 99 gridBagConstraints.gridx = 0; 100 gridBagConstraints.gridy = 1; 101 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 102 gridBagConstraints.insets = new java.awt.Insets (0, 12, 5, 0); 103 add(findWhatLabel, gridBagConstraints); 104 105 findWhat.setEditable(true); 106 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 119 gridBagConstraints.gridx = 0; 120 gridBagConstraints.gridy = 2; 121 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 122 gridBagConstraints.insets = new java.awt.Insets (0, 12, 9, 0); 123 add(replaceWithLabel, gridBagConstraints); 124 125 replaceWith.setEditable(true); 126 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 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 (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 (); 146 gridBagConstraints.gridx = 2; 147 gridBagConstraints.gridy = 6; 148 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 149 gridBagConstraints.insets = new java.awt.Insets (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 (); 154 gridBagConstraints.gridx = 1; 155 gridBagConstraints.gridy = 3; 156 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 157 gridBagConstraints.insets = new java.awt.Insets (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 (); 162 gridBagConstraints.gridx = 1; 163 gridBagConstraints.gridy = 4; 164 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 165 gridBagConstraints.insets = new java.awt.Insets (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 (); 170 gridBagConstraints.gridx = 2; 171 gridBagConstraints.gridy = 5; 172 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 173 gridBagConstraints.insets = new java.awt.Insets (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 (); 178 gridBagConstraints.gridx = 2; 179 gridBagConstraints.gridy = 3; 180 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 181 gridBagConstraints.insets = new java.awt.Insets (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 (); 186 gridBagConstraints.gridx = 1; 187 gridBagConstraints.gridy = 5; 188 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 189 gridBagConstraints.insets = new java.awt.Insets (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 (); 194 gridBagConstraints.gridx = 2; 195 gridBagConstraints.gridy = 4; 196 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 197 gridBagConstraints.insets = new java.awt.Insets (0, 11, 0, 10); 198 add(blockSearch, gridBagConstraints); 199 200 } 202 203 protected javax.swing.JCheckBox blockSearch; 205 protected javax.swing.JCheckBox bwdSearch; 206 protected javax.swing.JComboBox findWhat; 207 protected javax.swing.JLabel findWhatLabel; 208 protected javax.swing.JPanel findWhatPanel; 209 protected javax.swing.JCheckBox highlightSearch; 210 protected javax.swing.JCheckBox incSearch; 211 protected javax.swing.JCheckBox matchCase; 212 protected javax.swing.JCheckBox regExp; 213 protected javax.swing.JComboBox replaceWith; 214 protected javax.swing.JLabel replaceWithLabel; 215 protected javax.swing.JCheckBox wholeWords; 216 protected javax.swing.JCheckBox wrapSearch; 217 219 220 private JCheckBox createCheckBox( String key, char mnemonic ) { 221 JCheckBox box = new JCheckBox ( 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 e) { 227 mnemonicChar = mnemonic; 228 } 229 box.setMnemonic(mnemonicChar); return box; 231 } 232 233 } 234 | Popular Tags |