1 19 20 package org.netbeans.editor.ext; 21 22 import java.awt.Dimension ; 23 import java.util.MissingResourceException ; 24 import java.util.ResourceBundle ; 25 import javax.swing.JCheckBox ; 26 import org.netbeans.editor.SettingsNames; 27 import org.openide.util.NbBundle; 28 29 35 public class FindDialogPanel extends javax.swing.JPanel { 36 37 static final long serialVersionUID =5048601763767383114L; 38 39 private final ResourceBundle bundle = NbBundle.getBundle(org.netbeans.editor.BaseKit.class); 40 41 42 public FindDialogPanel() { 43 initComponents (); 44 getAccessibleContext().setAccessibleName(bundle.getString("find-title")); getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_find")); findWhat.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_" + SettingsNames.FIND_WHAT)); replaceWith.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_" + SettingsNames.FIND_REPLACE_WITH)); 49 Dimension findPrefSize = findWhat.getPreferredSize(); 51 Dimension replacePrefSize = replaceWith.getPreferredSize(); 52 if (findPrefSize != null){ 53 findWhat.setPreferredSize(new Dimension ((int)findPrefSize.getWidth(), (int)findPrefSize.getHeight())); 54 } 55 if (replacePrefSize != null){ 56 replaceWith.setPreferredSize(new Dimension ((int)replacePrefSize.getWidth(), (int)replacePrefSize.getHeight())); 57 } 58 } 59 60 65 private void initComponents() { 67 java.awt.GridBagConstraints gridBagConstraints; 68 69 findWhatPanel = new javax.swing.JPanel (); 70 findWhatLabel = new javax.swing.JLabel (); 71 findWhat = new javax.swing.JComboBox (); 72 replaceWithLabel = new javax.swing.JLabel (); 73 replaceWith = new javax.swing.JComboBox (); 74 highlightSearch = createCheckBox( SettingsNames.FIND_HIGHLIGHT_SEARCH, 'H' ); 75 incSearch = createCheckBox( SettingsNames.FIND_INC_SEARCH, 'I' ); 76 matchCase = createCheckBox( SettingsNames.FIND_MATCH_CASE, 'C' ); 77 wholeWords = createCheckBox( SettingsNames.FIND_WHOLE_WORDS, 'W' ); 78 bwdSearch = createCheckBox( SettingsNames.FIND_BACKWARD_SEARCH, 'B' ); 79 wrapSearch = createCheckBox( SettingsNames.FIND_WRAP_SEARCH, 'p' ); 80 regExp = createCheckBox( SettingsNames.FIND_REG_EXP, 'E' ); 81 blockSearch = createCheckBox( SettingsNames.FIND_BLOCK_SEARCH, 'l' ); 82 83 setLayout(new java.awt.GridBagLayout ()); 84 85 findWhatPanel.setLayout(new java.awt.GridBagLayout ()); 86 87 gridBagConstraints = new java.awt.GridBagConstraints (); 88 gridBagConstraints.gridx = 0; 89 gridBagConstraints.gridy = 0; 90 gridBagConstraints.gridwidth = 3; 91 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 92 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 93 gridBagConstraints.weightx = 1.0; 94 gridBagConstraints.insets = new java.awt.Insets (12, 0, 0, 0); 95 add(findWhatPanel, gridBagConstraints); 96 97 findWhatLabel.setLabelFor(findWhat); 98 findWhatLabel.setText(bundle.getString(SettingsNames.FIND_WHAT ) ); 99 findWhatLabel.setDisplayedMnemonic(bundle.getString(SettingsNames.FIND_WHAT + "-mnemonic").charAt(0)); 100 gridBagConstraints = new java.awt.GridBagConstraints (); 101 gridBagConstraints.gridx = 0; 102 gridBagConstraints.gridy = 1; 103 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 104 gridBagConstraints.insets = new java.awt.Insets (0, 12, 5, 0); 105 add(findWhatLabel, gridBagConstraints); 106 107 findWhat.setEditable(true); 108 gridBagConstraints = new java.awt.GridBagConstraints (); 109 gridBagConstraints.gridx = 1; 110 gridBagConstraints.gridy = 1; 111 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 112 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 113 gridBagConstraints.weightx = 1.0; 114 gridBagConstraints.insets = new java.awt.Insets (0, 11, 9, 10); 115 add(findWhat, gridBagConstraints); 116 117 replaceWithLabel.setLabelFor(replaceWith); 118 replaceWithLabel.setText(bundle.getString(SettingsNames.FIND_REPLACE_WITH ) ); 119 replaceWithLabel.setDisplayedMnemonic(bundle.getString(SettingsNames.FIND_REPLACE_WITH + "-mnemonic").charAt(0)); 120 gridBagConstraints = new java.awt.GridBagConstraints (); 121 gridBagConstraints.gridx = 0; 122 gridBagConstraints.gridy = 2; 123 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 124 gridBagConstraints.insets = new java.awt.Insets (0, 12, 9, 0); 125 add(replaceWithLabel, gridBagConstraints); 126 127 replaceWith.setEditable(true); 128 gridBagConstraints = new java.awt.GridBagConstraints (); 129 gridBagConstraints.gridx = 1; 130 gridBagConstraints.gridy = 2; 131 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 132 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 133 gridBagConstraints.weightx = 1.0; 134 gridBagConstraints.insets = new java.awt.Insets (0, 11, 9, 10); 135 add(replaceWith, gridBagConstraints); 136 137 highlightSearch.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); 138 gridBagConstraints = new java.awt.GridBagConstraints (); 139 gridBagConstraints.gridx = 1; 140 gridBagConstraints.gridy = 6; 141 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 142 gridBagConstraints.weighty = 1.0; 143 gridBagConstraints.insets = new java.awt.Insets (11, 11, 11, 0); 144 add(highlightSearch, gridBagConstraints); 145 146 incSearch.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); 147 gridBagConstraints = new java.awt.GridBagConstraints (); 148 gridBagConstraints.gridx = 2; 149 gridBagConstraints.gridy = 6; 150 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 151 gridBagConstraints.insets = new java.awt.Insets (11, 11, 11, 10); 152 add(incSearch, gridBagConstraints); 153 154 matchCase.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); 155 gridBagConstraints = new java.awt.GridBagConstraints (); 156 gridBagConstraints.gridx = 1; 157 gridBagConstraints.gridy = 3; 158 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 159 gridBagConstraints.insets = new java.awt.Insets (3, 11, 0, 0); 160 add(matchCase, gridBagConstraints); 161 162 wholeWords.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); 163 gridBagConstraints = new java.awt.GridBagConstraints (); 164 gridBagConstraints.gridx = 1; 165 gridBagConstraints.gridy = 4; 166 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 167 gridBagConstraints.insets = new java.awt.Insets (0, 11, 0, 0); 168 add(wholeWords, gridBagConstraints); 169 170 bwdSearch.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); 171 gridBagConstraints = new java.awt.GridBagConstraints (); 172 gridBagConstraints.gridx = 2; 173 gridBagConstraints.gridy = 5; 174 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 175 gridBagConstraints.insets = new java.awt.Insets (0, 11, 0, 10); 176 add(bwdSearch, gridBagConstraints); 177 178 wrapSearch.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); 179 gridBagConstraints = new java.awt.GridBagConstraints (); 180 gridBagConstraints.gridx = 2; 181 gridBagConstraints.gridy = 3; 182 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 183 gridBagConstraints.insets = new java.awt.Insets (3, 11, 0, 10); 184 add(wrapSearch, gridBagConstraints); 185 186 regExp.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); 187 gridBagConstraints = new java.awt.GridBagConstraints (); 188 gridBagConstraints.gridx = 1; 189 gridBagConstraints.gridy = 5; 190 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 191 gridBagConstraints.insets = new java.awt.Insets (0, 11, 0, 0); 192 add(regExp, gridBagConstraints); 193 194 blockSearch.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); 195 gridBagConstraints = new java.awt.GridBagConstraints (); 196 gridBagConstraints.gridx = 2; 197 gridBagConstraints.gridy = 4; 198 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 199 gridBagConstraints.insets = new java.awt.Insets (0, 11, 0, 10); 200 add(blockSearch, gridBagConstraints); 201 202 } 204 205 protected javax.swing.JCheckBox blockSearch; 207 protected javax.swing.JCheckBox bwdSearch; 208 protected javax.swing.JComboBox findWhat; 209 protected javax.swing.JLabel findWhatLabel; 210 protected javax.swing.JPanel findWhatPanel; 211 protected javax.swing.JCheckBox highlightSearch; 212 protected javax.swing.JCheckBox incSearch; 213 protected javax.swing.JCheckBox matchCase; 214 protected javax.swing.JCheckBox regExp; 215 protected javax.swing.JComboBox replaceWith; 216 protected javax.swing.JLabel replaceWithLabel; 217 protected javax.swing.JCheckBox wholeWords; 218 protected javax.swing.JCheckBox wrapSearch; 219 221 222 private JCheckBox createCheckBox( String key, char mnemonic ) { 223 JCheckBox box = new JCheckBox ( bundle.getString( key ) ); 224 box.setToolTipText( bundle.getString( key + "-tooltip" ) ); 225 char mnemonicChar; 226 try { 227 mnemonicChar = bundle.getString( key + "-mnemonic").charAt(0); 228 } catch (MissingResourceException e) { 229 mnemonicChar = mnemonic; 230 } 231 box.setMnemonic(mnemonicChar); return box; 233 } 234 235 } 236 | Popular Tags |