Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 208794 | Differences between
and this patch

Collapse All | Expand All

(-)a/options.api/src/org/netbeans/modules/options/OptionsPanel.java (+81 lines)
 Lines 44-49    Link Here 
44
44
45
package org.netbeans.modules.options;
45
package org.netbeans.modules.options;
46
46
47
import java.awt.AWTEvent;
47
import java.awt.Color;
48
import java.awt.Color;
48
import java.awt.Component;
49
import java.awt.Component;
49
import java.awt.Cursor;
50
import java.awt.Cursor;
 Lines 73-78    Link Here 
73
import java.util.Iterator;
74
import java.util.Iterator;
74
import java.util.LinkedHashMap;
75
import java.util.LinkedHashMap;
75
import java.util.Map;
76
import java.util.Map;
77
import java.util.Set;
76
import javax.swing.AbstractAction;
78
import javax.swing.AbstractAction;
77
import javax.swing.BorderFactory;
79
import javax.swing.BorderFactory;
78
import javax.swing.InputMap;
80
import javax.swing.InputMap;
 Lines 86-95    Link Here 
86
import javax.swing.border.CompoundBorder;
88
import javax.swing.border.CompoundBorder;
87
import javax.swing.border.EmptyBorder;
89
import javax.swing.border.EmptyBorder;
88
import javax.swing.border.LineBorder;
90
import javax.swing.border.LineBorder;
91
import javax.swing.text.Position.Bias;
92
import org.netbeans.api.quicksearch.QuickSearch;
93
import org.netbeans.api.quicksearch.QuickSearchListener;
89
import org.netbeans.modules.options.ui.VariableBorder;
94
import org.netbeans.modules.options.ui.VariableBorder;
95
import org.netbeans.spi.options.OptionsCategory;
90
import org.netbeans.spi.options.OptionsPanelController;
96
import org.netbeans.spi.options.OptionsPanelController;
91
import org.openide.awt.Mnemonics;
97
import org.openide.awt.Mnemonics;
92
import org.openide.util.HelpCtx;
98
import org.openide.util.HelpCtx;
99
import org.openide.util.Lookup;
93
import org.openide.util.NbBundle;
100
import org.openide.util.NbBundle;
94
import org.openide.util.NbPreferences;
101
import org.openide.util.NbPreferences;
95
import org.openide.util.RequestProcessor;
102
import org.openide.util.RequestProcessor;
 Lines 114-119    Link Here 
114
    
121
    
115
    private final Color borderMac = new Color(141, 141, 141);
122
    private final Color borderMac = new Color(141, 141, 141);
116
    private final Font labelFontMac = new Font("Lucida Grande", 0, 10);            
123
    private final Font labelFontMac = new Font("Lucida Grande", 0, 10);            
124
    private QuickSearch qs;
117
    
125
    
118
    private static String loc (String key) {
126
    private static String loc (String key) {
119
        return NbBundle.getMessage (OptionsPanel.class, key);
127
        return NbBundle.getMessage (OptionsPanel.class, key);
 Lines 269-274    Link Here 
269
                b.setSelected();
277
                b.setSelected();
270
            }
278
            }
271
        }
279
        }
280
        GridBagConstraints qsConstraints = new GridBagConstraints();
281
        qsConstraints.gridx = buttons.size() + 1;
282
        qsConstraints.anchor = GridBagConstraints.NORTHEAST;
283
        qsConstraints.gridy = 0;
284
        qs = QuickSearch.attach(pCategories2, qsConstraints);
285
        qs.addQuickSearchListener(new QSListener());
286
        qs.setAsynchronous(true);
287
        enableEvents(AWTEvent.KEY_EVENT_MASK);
272
    }
288
    }
273
        
289
        
274
    private void initActions () {
290
    private void initActions () {
 Lines 399-405    Link Here 
399
        }        
415
        }        
400
        return retval;
416
        return retval;
401
    }
417
    }
418
    
419
    private KeyEvent processingEvent = null;
402
420
421
    @Override
422
    protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
423
        if (condition == WHEN_ANCESTOR_OF_FOCUSED_COMPONENT && !e.isConsumed()) {
424
            if (e == processingEvent) return false;
425
            processingEvent = e;
426
            qs.processKeyEvent(e);
427
            processingEvent = null;
428
            if (e.isConsumed()) {
429
                return true;
430
            }
431
        }
432
        return super.processKeyBinding(ks, e, condition, pressed);
433
    }
434
    
403
    // innerclasses ............................................................
435
    // innerclasses ............................................................
404
    
436
    
405
    private class SelectAction extends AbstractAction {
437
    private class SelectAction extends AbstractAction {
 Lines 441-446    Link Here 
441
        }
473
        }
442
    }
474
    }
443
    
475
    
476
    private class QSListener implements QuickSearchListener {
477
478
        @Override
479
        public void quickSearchUpdate(String searchText) {
480
            System.out.println("quickSearchUpdate("+searchText+")");
481
            searchText = searchText.toUpperCase();
482
            for (Lookup.Item<OptionsCategory> entry : QuickSearchProvider.getODCategories()) {
483
                for (Map.Entry<String, Set<String>> kw : QuickSearchProvider.getKeywords(entry).entrySet()) {
484
                    for (String keyword : kw.getValue()) {
485
                        if (keyword.toUpperCase().indexOf(searchText) > -1) {
486
                            displayOption(kw.getKey(), keyword);
487
                        }
488
                    }
489
                }
490
            }
491
            
492
        }
493
494
        @Override
495
        public void showNextSelection(Bias bias) {
496
            
497
        }
498
499
        @Override
500
        public String findMaxPrefix(String prefix) {
501
            return prefix;
502
        }
503
504
        @Override
505
        public void quickSearchConfirmed() {
506
            
507
        }
508
509
        @Override
510
        public void quickSearchCanceled() {
511
            
512
        }
513
        
514
    }
515
    
516
    private void displayOption(final String path, final String keyword) {
517
        SwingUtilities.invokeLater(new Runnable() {
518
            @Override
519
            public void run() {
520
                OptionsDisplayerImpl.selectCategory(path);
521
            }
522
        });
523
    }
524
    
444
    class CategoryButton extends JLabel implements MouseListener {
525
    class CategoryButton extends JLabel implements MouseListener {
445
        private final CategoryModel.Category category;                
526
        private final CategoryModel.Category category;                
446
        CategoryButton (final CategoryModel.Category category) {
527
        CategoryButton (final CategoryModel.Category category) {
(-)a/options.api/src/org/netbeans/modules/options/QuickSearchProvider.java (-2 / +2 lines)
 Lines 77-83    Link Here 
77
        }
77
        }
78
    }
78
    }
79
79
80
    private Map<String, Set<String>> getKeywords(Lookup.Item<OptionsCategory> it) {
80
    static Map<String, Set<String>> getKeywords(Lookup.Item<OptionsCategory> it) {
81
        OptionsCategory category = it.getInstance();
81
        OptionsCategory category = it.getInstance();
82
82
83
            Map<String, Set<String>> kws = new HashMap<String, Set<String>>();
83
            Map<String, Set<String>> kws = new HashMap<String, Set<String>>();
 Lines 100-106    Link Here 
100
            return kws;
100
            return kws;
101
        }
101
        }
102
102
103
    private Iterable<? extends Lookup.Item<OptionsCategory>> getODCategories() {
103
    static Iterable<? extends Lookup.Item<OptionsCategory>> getODCategories() {
104
        Lookup lookup = Lookups.forPath(CategoryModel.OD_LAYER_FOLDER_NAME);
104
        Lookup lookup = Lookups.forPath(CategoryModel.OD_LAYER_FOLDER_NAME);
105
        Lookup.Result<OptionsCategory> result = lookup.lookupResult(OptionsCategory.class);
105
        Lookup.Result<OptionsCategory> result = lookup.lookupResult(OptionsCategory.class);
106
        return result.allItems();
106
        return result.allItems();

Return to bug 208794
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo