1 19 20 package org.netbeans.modules.search.types; 21 22 import java.util.List ; 23 import javax.accessibility.AccessibleContext ; 24 import javax.swing.Box ; 25 import javax.swing.BoxLayout ; 26 import javax.swing.JComboBox ; 27 import javax.swing.JLabel ; 28 import org.openide.awt.Mnemonics; 29 import org.openide.util.*; 30 import org.openidex.search.SearchHistory; 31 import org.openidex.search.SearchPattern; 32 34 35 40 public final class FullTextCustomizer extends TextCustomizer { 41 42 43 private final JComboBox replaceComboBox = new JComboBox (); 44 45 46 public FullTextCustomizer() { 47 super(); 48 addReplacePanel(createReplacePanel()); 49 50 HelpCtx.setHelpIDString(this, FullTextType.class.toString()); 51 } 52 53 59 private Box createReplacePanel() { 60 JLabel lblReplaceWith = new JLabel (); 61 62 Mnemonics.setLocalizedText( 63 lblReplaceWith, 64 NbBundle.getMessage(FullTextCustomizer.class, 65 "TEXT_LABEL_REPLACE_WITH")); AccessibleContext ac = replaceComboBox.getAccessibleContext(); 67 ac.setAccessibleName( 68 NbBundle.getMessage(getClass(), "ACSN_REPLACE_STRING")); ac.setAccessibleDescription( 70 NbBundle.getMessage(getClass(), "ACSD_REPLACE_STRING")); 72 lblReplaceWith.setLabelFor(replaceComboBox); 73 replaceComboBox.setEditable(true); 74 activateEnterKeyBypass(replaceComboBox); 75 76 Box box = new Box (BoxLayout.Y_AXIS); 77 box.add(lblReplaceWith); 78 box.add(Box.createVerticalStrut(4)); 79 box.add(replaceComboBox); 80 81 return box; 82 } 83 84 87 @Override 88 public void onOk() { 89 final String text = getComboText(replaceComboBox); 90 ((FullTextType) peer).setReplaceString((text != null) ? text 91 : ""); super.onOk(); 93 } 94 95 96 protected String getBorderLabel() { 97 return NbBundle.getMessage(FullTextType.class, 98 "TEXT_LABEL_TEXT_CONTAINS"); } 100 101 108 protected List getSearchPatterns() { 109 return SearchHistory.getDefault().getSearchPatterns(); 110 } 111 112 116 protected void addSearchPattern(SearchPattern pattern) { 117 SearchHistory.getDefault().add(pattern); 118 } 119 } 120 | Popular Tags |