This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 218312
Collapse All | Expand All

(-)a/options.api/src/org/netbeans/modules/options/OptionsPanel.java (-267 / +221 lines)
Lines 73-109 Link Here
73
import java.beans.PropertyChangeEvent;
73
import java.beans.PropertyChangeEvent;
74
import java.beans.PropertyChangeListener;
74
import java.beans.PropertyChangeListener;
75
import java.util.ArrayList;
75
import java.util.ArrayList;
76
import java.util.Enumeration;
76
import java.util.HashMap;
77
import java.util.HashMap;
78
import java.util.HashSet;
77
import java.util.Iterator;
79
import java.util.Iterator;
78
import java.util.LinkedHashMap;
80
import java.util.LinkedHashMap;
79
import java.util.List;
81
import java.util.List;
80
import java.util.Map;
82
import java.util.Map;
81
import java.util.Set;
83
import java.util.Set;
82
import javax.swing.AbstractAction;
84
import javax.swing.AbstractAction;
83
import javax.swing.AbstractButton;
84
import javax.swing.BorderFactory;
85
import javax.swing.BorderFactory;
85
import javax.swing.InputMap;
86
import javax.swing.InputMap;
86
import javax.swing.JComboBox;
87
import javax.swing.JComponent;
87
import javax.swing.JComponent;
88
import javax.swing.JFrame;
88
import javax.swing.JFrame;
89
import javax.swing.JLabel;
89
import javax.swing.JLabel;
90
import javax.swing.JList;
91
import javax.swing.JPanel;
90
import javax.swing.JPanel;
92
import javax.swing.JTabbedPane;
91
import javax.swing.JTabbedPane;
93
import javax.swing.JTable;
94
import javax.swing.JTextField;
92
import javax.swing.JTextField;
95
import javax.swing.KeyStroke;
93
import javax.swing.KeyStroke;
96
import javax.swing.ListModel;
97
import javax.swing.SwingUtilities;
94
import javax.swing.SwingUtilities;
98
import javax.swing.UIManager;
95
import javax.swing.UIManager;
99
import javax.swing.border.Border;
96
import javax.swing.border.Border;
100
import javax.swing.border.CompoundBorder;
97
import javax.swing.border.CompoundBorder;
101
import javax.swing.border.EmptyBorder;
98
import javax.swing.border.EmptyBorder;
102
import javax.swing.border.LineBorder;
99
import javax.swing.border.LineBorder;
103
import javax.swing.border.TitledBorder;
104
import javax.swing.table.JTableHeader;
105
import javax.swing.table.TableColumnModel;
106
import javax.swing.table.TableModel;
107
import javax.swing.text.JTextComponent;
100
import javax.swing.text.JTextComponent;
108
import org.netbeans.modules.options.advanced.AdvancedPanel;
101
import org.netbeans.modules.options.advanced.AdvancedPanel;
109
import org.netbeans.modules.options.ui.VariableBorder;
102
import org.netbeans.modules.options.ui.VariableBorder;
Lines 111-116 Link Here
111
import org.openide.awt.Mnemonics;
104
import org.openide.awt.Mnemonics;
112
import org.openide.awt.QuickSearch;
105
import org.openide.awt.QuickSearch;
113
import org.openide.awt.StatusDisplayer;
106
import org.openide.awt.StatusDisplayer;
107
import org.openide.filesystems.FileObject;
108
import org.openide.filesystems.FileUtil;
114
import org.openide.util.HelpCtx;
109
import org.openide.util.HelpCtx;
115
import org.openide.util.Mutex;
110
import org.openide.util.Mutex;
116
import org.openide.util.NbBundle;
111
import org.openide.util.NbBundle;
Lines 128-134 Link Here
128
    
123
    
129
    private int selectedTabIndex = -1;
124
    private int selectedTabIndex = -1;
130
    private HashMap<String, JTabbedPane> categoryid2tabbedpane = new HashMap<String, JTabbedPane>();
125
    private HashMap<String, JTabbedPane> categoryid2tabbedpane = new HashMap<String, JTabbedPane>();
131
    private HashMap<String, ArrayList<String>> categoryid2words = new HashMap<String, ArrayList<String>>();
126
    private HashMap<String, List<String>> categoryid2words = new HashMap<String, List<String>>();
127
    private HashMap<String, HashMap<Integer, TabInfo>> categoryid2tabs = new HashMap<String, HashMap<Integer, TabInfo>>();
132
    private HashMap<String, CategoryInfo> categoryid2jcomponents = new HashMap<String, CategoryInfo>();
128
    private HashMap<String, CategoryInfo> categoryid2jcomponents = new HashMap<String, CategoryInfo>();
133
    private HashMap<JTabbedPane, HashMap<Integer, TabInfo>> tabbedpane2tabs = new HashMap<JTabbedPane, HashMap<Integer, TabInfo>>();
129
    private HashMap<JTabbedPane, HashMap<Integer, TabInfo>> tabbedpane2tabs = new HashMap<JTabbedPane, HashMap<Integer, TabInfo>>();
134
    private HashMap<JTabbedPane, HashMap<Integer, TabInfo>> tabbedpane2removedtabs = new HashMap<JTabbedPane, HashMap<Integer, TabInfo>>();
130
    private HashMap<JTabbedPane, HashMap<Integer, TabInfo>> tabbedpane2removedtabs = new HashMap<JTabbedPane, HashMap<Integer, TabInfo>>();
Lines 351-541 Link Here
351
        for (Map.Entry<String, CategoryModel.Category> set : categories) {
347
        for (Map.Entry<String, CategoryModel.Category> set : categories) {
352
            JComponent jcomp = set.getValue().getComponent();
348
            JComponent jcomp = set.getValue().getComponent();
353
            String id = set.getValue().getID();
349
            String id = set.getValue().getID();
354
            ArrayList<String> strings = categoryid2words.get(id);
355
            if (strings == null) {
356
                strings = new ArrayList<String>();
357
            }
358
            if (!strings.contains(id.toUpperCase())) {
359
                strings.add(id.toUpperCase());
360
            }
361
            categoryid2words.put(id, strings);
362
            if(jcomp instanceof JTabbedPane) {
350
            if(jcomp instanceof JTabbedPane) {
363
                categoryid2tabbedpane.put(id, (JTabbedPane)jcomp);
351
                categoryid2tabbedpane.put(id, (JTabbedPane)jcomp);
364
                handleJTabbedPane((JTabbedPane)jcomp, id);
365
            } else if(jcomp instanceof AdvancedPanel) {
352
            } else if(jcomp instanceof AdvancedPanel) {
366
                categoryid2tabbedpane.put(id, (JTabbedPane)jcomp.getComponent(0));
353
                categoryid2tabbedpane.put(id, (JTabbedPane)jcomp.getComponent(0));
367
                handleJTabbedPane((JTabbedPane)jcomp.getComponent(0), id);
368
            } else if (jcomp instanceof Container) {
354
            } else if (jcomp instanceof Container) {
369
                setCurrentCategory(set.getValue(), null);
370
                handleAllComponents((Container) jcomp, id, null, -1);
355
                handleAllComponents((Container) jcomp, id, null, -1);
371
            }
356
            }
372
        }
357
        }
358
        categoryid2tabs = new HashMap<String, HashMap<Integer, TabInfo>>();
359
        FileObject keywordPanels = FileUtil.getConfigRoot().getFileObject(CategoryModel.OD_LAYER_KEYWORDPANELS_FOLDER_NAME);
360
        for(FileObject keywordPanel : keywordPanels.getChildren()) {
361
            handlePanel(keywordPanel);
362
        }
373
    }
363
    }
374
364
375
    private void handleJTabbedPane(JTabbedPane pane, String categoryID) {
365
    private void handlePanel(FileObject keywordPanel) {
376
        int tabsNum = pane.getTabCount();
366
        String location = "";
377
        selectedTabIndex = pane.getSelectedIndex();
367
        String id = "";
378
        for (int i = 0; i < tabsNum; i++) {
368
        int index = -1;
379
            pane.setSelectedIndex(i);
369
        ArrayList<String> keywords = new ArrayList<String>();
380
            Component tab = pane.getComponentAt(i);
370
381
            
371
        Enumeration<String> attributes = keywordPanel.getAttributes();
382
            HashMap<Integer, TabInfo> hash = tabbedpane2tabs.get(pane);
372
        while(attributes.hasMoreElements()) {
383
            if(hash == null) {
373
            String nextElement = attributes.nextElement();
384
                hash = new HashMap<Integer, TabInfo>();
374
            if(nextElement.equals("location")) {
385
            }
375
                location = keywordPanel.getAttribute(nextElement).toString();
386
            hash.put(i, new TabInfo(pane.getTitleAt(i), CategoryModel.getInstance().getCategory(categoryID).getCategoryName(), tab));
376
            } else if(nextElement.equals("id")) {
387
            tabbedpane2tabs.put(pane, hash);
377
                id = keywordPanel.getAttribute(nextElement).toString();
388
            
378
                if (id.startsWith("#")) {
389
            ArrayList<String> strings = categoryid2words.get(categoryID);
379
                    id = NbBundle.getMessage(keywordPanel.getClass(), id.substring(1));
390
            if (strings == null) {
380
                }
391
                strings = new ArrayList<String>();
381
            } else if(nextElement.equals("index")) {
392
            }
382
                index = (Integer) keywordPanel.getAttribute(nextElement);
393
            if (!strings.contains(pane.getTitleAt(i).toUpperCase())) {
383
            } else if(nextElement.startsWith("keyword")) {
394
                strings.add(pane.getTitleAt(i).toUpperCase());
384
                String keyword = keywordPanel.getAttribute(nextElement).toString();
395
            }
385
                if (keyword.startsWith("#")) {
396
            categoryid2words.put(categoryID, strings);            
386
                    keyword = NbBundle.getMessage(keywordPanel.getClass(), keyword.substring(1));
397
            
387
                }
398
            if (tab instanceof Container) {
388
                keywords.add(keyword);
399
                handleAllComponents((Container) tab, categoryID, pane, i);
400
            }
389
            }
401
        }
390
        }
402
        pane.setSelectedIndex(selectedTabIndex);
391
392
        List<String> words = categoryid2words.get(location);
393
        if (words == null) {
394
            words = new ArrayList<String>();
395
        }
396
397
        Set<String> newWords = new HashSet<String>();
398
        for (String keyword : keywords) {
399
            if (!words.contains(keyword)) {
400
                newWords.add(keyword);
401
            }
402
        }
403
        words.addAll(newWords);
404
        categoryid2words.put(location, words);
405
406
        if (!categoryid2tabs.containsKey(location)) {
407
            categoryid2tabs.put(location, new HashMap<Integer, TabInfo>());
408
        }
409
        HashMap<Integer, TabInfo> categoryTabs = categoryid2tabs.get(location);
410
        TabInfo tabInfo;
411
        if (!categoryTabs.containsKey(index)) {
412
            tabInfo = new TabInfo(id);
413
        } else {
414
            tabInfo = categoryTabs.get(index);
415
        }
416
        tabInfo.addWords(newWords);
417
        categoryTabs.put(index, tabInfo);
418
        categoryid2tabs.put(location, categoryTabs);
403
    }
419
    }
404
420
405
    private void handleAllComponents(Container container, String categoryID, JTabbedPane tabbedPane, int index) {
421
    private void handleAllComponents(Container container, String categoryID, JTabbedPane tabbedPane, int index) {
406
        Component[] components = container.getComponents();
422
        Component[] components = container.getComponents();
407
        Component component = null;
423
        Component component;
408
        ArrayList<String> strings = categoryid2words.get(categoryID);
409
        if(strings == null) {
410
            strings = new ArrayList<String>();
411
        }
412
413
        CategoryInfo categoryInfo = categoryid2jcomponents.get(categoryID);
414
        if (categoryInfo == null) {
415
            categoryInfo = new CategoryInfo();
416
        }
417
        for (int i = 0; i < components.length; i++) {
424
        for (int i = 0; i < components.length; i++) {
418
            component = components[i];
425
            component = components[i];
419
            String text = "";
426
            String text;
420
            
427
//            
421
            if (component instanceof JComponent) {
422
                final Border border = ((JComponent)component).getBorder();
423
                if (border instanceof TitledBorder) {
424
                    TitledBorder titledBorder = (TitledBorder) border;
425
                    text = titledBorder.getTitle();
426
                    if (text != null && !text.isEmpty() && !strings.contains(text.toUpperCase())) {
427
                        strings.add(text.toUpperCase());
428
                    }
429
                }
430
                categoryInfo.addComponent(text, (JComponent)component);
431
            }
432
            
433
            if (component instanceof JLabel) {
428
            if (component instanceof JLabel) {
434
                text = ((JLabel) component).getText();
429
                text = ((JLabel) component).getText();
435
                if (text != null && !text.isEmpty() && !strings.contains(text.toUpperCase())) {
436
                    strings.add(text.toUpperCase());
437
                }
438
                // hack to search into Keymaps category
430
                // hack to search into Keymaps category
439
                if(categoryID.equals("Keymaps") && text.equals("Search:")) { // NOI18N
431
                if(categoryID.equals("Keymaps") && text.equals("Search:")) { // NOI18N
440
                    keymapsSearch = (JTextField)((JLabel) component).getLabelFor();
432
                    keymapsSearch = (JTextField)((JLabel) component).getLabelFor();
441
                }
433
                }
442
            } else if (component instanceof AbstractButton) {
434
            } 
443
                text = ((AbstractButton) component).getText();
444
                if (text != null && !text.isEmpty() && !strings.contains(text.toUpperCase())) {
445
                    strings.add(text.toUpperCase());
446
                }
447
            } else if (component instanceof JTextComponent) {
448
                text = ((JTextComponent) component).getText();
449
                if (text != null && !text.isEmpty() && !strings.contains(text.toUpperCase())) {
450
                    strings.add(text.toUpperCase());
451
                }
452
            } else if (component instanceof JComboBox) {
453
                StringBuilder sb = new StringBuilder();
454
                for (int j = 0; j < ((JComboBox) component).getItemCount(); j++) {
455
                    Object object = ((JComboBox) component).getItemAt(j);
456
                    text = object.toString();
457
                    if (text != null && !text.isEmpty()) {
458
                        if (!strings.contains(text.toUpperCase())) {
459
                            strings.add(text.toUpperCase());
460
                        }
461
                        sb.append(text.toUpperCase().concat(" "));
462
                    }
463
                }
464
                text = sb.toString().trim();
465
            } else if (component instanceof JList) {
466
                StringBuilder sb = new StringBuilder();
467
                ListModel model = ((JList) component).getModel();
468
                if (model != null) {
469
                    for (int j = 0; j < model.getSize(); j++) {
470
                        Object object = model.getElementAt(j);
471
                        if (object != null) {
472
                            text = object.toString();
473
                            if (text != null && !text.isEmpty()) {
474
                                if (!strings.contains(text.toUpperCase())) {
475
                                    strings.add(text.toUpperCase());
476
                                }
477
                                sb.append(text.toUpperCase().concat(" "));
478
                            }
479
                        }
480
                    }
481
                }
482
                text = sb.toString().trim();
483
            } else if (component instanceof JTable) {
484
                StringBuilder sb = new StringBuilder();
485
                JTableHeader header = ((JTable) component).getTableHeader();
486
                if (header != null) {
487
                    TableColumnModel columnModel = header.getColumnModel();
488
                    for (int j = 0; j < columnModel.getColumnCount(); j++) {
489
                        Object object = columnModel.getColumn(j).getHeaderValue();
490
                        if (object != null) {
491
                            text = object.toString();
492
                            if (text != null && !text.isEmpty()) {
493
                                if (!strings.contains(text.toUpperCase())) {
494
                                    strings.add(text.toUpperCase());
495
                                }
496
                                sb.append(text.toUpperCase().concat(" "));
497
                            }
498
                        }
499
                    }
500
                }
501
                
502
                TableModel model = ((JTable) component).getModel();
503
                for (int j = 0; j < model.getRowCount(); j++) {
504
                    for (int k = 0; k < model.getColumnCount(); k++) {
505
                        Object object = model.getValueAt(j, k);
506
                        if(object != null) {
507
                            text = object.toString();
508
                            if (text != null && !text.isEmpty()) {
509
                                if (!strings.contains(text.toUpperCase())) {
510
                                    strings.add(text.toUpperCase());
511
                                }
512
                                sb.append(text.toUpperCase().concat(" "));
513
                            }
514
                        }
515
                    }                    
516
                }
517
                text = sb.toString().trim();
518
            }
519
520
            if (component instanceof JComponent) {
521
                categoryInfo.addComponent(text, (JComponent) component);
522
            }
523
            
524
            categoryid2jcomponents.put(categoryID, categoryInfo);
525
            categoryid2words.put(categoryID, strings);
526
            
527
            if (tabbedPane != null && index > -1) {
528
                TabInfo tabInfo = tabbedpane2tabs.get(tabbedPane).get(index);
529
                if (text != null && !text.isEmpty() && !tabInfo.getWords().contains(text.toUpperCase())) {
530
                    tabInfo.addWord(text.toUpperCase());
531
                    tabbedpane2tabs.get(tabbedPane).put(index, tabInfo);
532
                }
533
            }
534
            if(component instanceof JTabbedPane) {
435
            if(component instanceof JTabbedPane) {
535
                if(categoryid2tabbedpane.get(categoryID) == null) {
436
                if(categoryid2tabbedpane.get(categoryID) == null) {
536
                    categoryid2tabbedpane.put(categoryID, (JTabbedPane)component);
437
                    categoryid2tabbedpane.put(categoryID, (JTabbedPane)component);
537
                }
438
                }
538
                handleJTabbedPane((JTabbedPane)component, categoryID);
539
            } else {
439
            } else {
540
                handleAllComponents((Container)component, categoryID, tabbedPane, index);
440
                handleAllComponents((Container)component, categoryID, tabbedPane, index);
541
            }
441
            }
Lines 574-579 Link Here
574
    private class TabInfo {
474
    private class TabInfo {
575
475
576
        private String tabTitle;
476
        private String tabTitle;
477
        private String tabSubpath;
577
        private Component tab;
478
        private Component tab;
578
        private String categoryName;
479
        private String categoryName;
579
        private ArrayList<String> words;
480
        private ArrayList<String> words;
Lines 587-596 Link Here
587
            words.add(categoryName.toUpperCase());
488
            words.add(categoryName.toUpperCase());
588
        }
489
        }
589
490
491
        public TabInfo(String tabSubpath) {
492
            this.tabSubpath = tabSubpath;
493
            this.words = new ArrayList<String>();
494
        }
495
590
        public String getTabTitle() {
496
        public String getTabTitle() {
591
            return tabTitle;
497
            return tabTitle;
592
        }
498
        }
593
499
500
        public String getTabSubpath() {
501
            return tabSubpath;
502
        }
503
594
        public Component getTab() {
504
        public Component getTab() {
595
            return tab;
505
            return tab;
596
        }
506
        }
Lines 606-611 Link Here
606
        public void addWord(String word) {
516
        public void addWord(String word) {
607
            words.add(word.toUpperCase());
517
            words.add(word.toUpperCase());
608
        }
518
        }
519
520
        public void addWords(Set<String> words) {
521
            for (String word : words) {
522
                addWord(word);
523
            }
524
        }
609
    }
525
    }
610
526
611
    final class OptionsQSCallback implements QuickSearch.Callback {
527
    final class OptionsQSCallback implements QuickSearch.Callback {
Lines 664-762 Link Here
664
            });
580
            });
665
        }
581
        }
666
        
582
        
583
        private int getNextEnabledTabIndex(JTabbedPane pane, int currentIndex) {
584
            for (int i = currentIndex + 1; i < pane.getTabCount(); i++) {
585
                if(pane.isEnabledAt(i)) {
586
                    return i;
587
                }
588
            }
589
            for (int i = 0; i < currentIndex; i++) {
590
                if(pane.isEnabledAt(i)) {
591
                    return i;
592
                }
593
            }
594
            return -1;
595
        }
596
667
        private void handleSearch(String searchText) {
597
        private void handleSearch(String searchText) {
668
            String visibleCategory = null;
598
            String visibleCategory = null;
669
            String exactCategory = null;
599
            String exactCategory = null;
600
            String exactSubpath = null;
670
            int exactTabIndex = 0;
601
            int exactTabIndex = 0;
671
            for (String id : CategoryModel.getInstance().getCategoryIDs()) {
602
            for (String id : CategoryModel.getInstance().getCategoryIDs()) {
672
                ArrayList<String> entry = categoryid2words.get(id);
603
                List<String> entry = categoryid2words.get(id);
673
                boolean found = false;
604
                if (entry != null) {
674
                for (String text : entry) {
605
                    boolean found = false;
675
                    if (text.contains(searchText.toUpperCase())) {
606
                    for (String text : entry) {
676
                        found = true;
607
                        if (text.toUpperCase().contains(searchText.toUpperCase())) {
677
                        if(id.toUpperCase().contains(searchText.toUpperCase())) {
608
                            found = true;
678
                            exactCategory = id;
609
                            if (id.toUpperCase().contains(searchText.toUpperCase())) {
610
                                exactCategory = id;
611
                            }
612
                            break;
679
                        }
613
                        }
680
                        break;
681
                    }
614
                    }
682
                }
615
683
                
616
                    if (found) {
684
                if (found) {
617
                        visibleCategory = id;
685
                    visibleCategory = id;
618
                        removedCategories.remove(id);
686
                    removedCategories.remove(id);
619
                        buttons.get(id).setEnabled(true);
687
                    buttons.get(id).setVisible(true);
620
                        JTabbedPane pane = categoryid2tabbedpane.get(id);
688
                    JTabbedPane pane = categoryid2tabbedpane.get(id);
621
                        if (categoryid2tabs.get(id) != null) {
689
                    if (pane != null) {
622
                            HashMap<Integer, TabInfo> tabsInfo = categoryid2tabs.get(id);
690
                        HashMap<Integer, TabInfo> tabsInfo = tabbedpane2tabs.get(pane);
623
                            boolean cont = true;
691
                        for (Integer tabIndex : tabsInfo.keySet()) {
624
                            if (tabsInfo.containsKey(-1)) {
692
                            ArrayList<String> tabWords = tabsInfo.get(tabIndex).getWords();
625
                                int tabIndex = -1;
693
                            boolean foundInTab = false;
626
                                ArrayList<String> tabWords = tabsInfo.get(tabIndex).getWords();
694
                            for (int i = 0; i < tabWords.size(); i++) {
627
                                boolean foundInTab = false;
695
                                String txt = tabWords.get(i).toString().toUpperCase();
628
                                for (int i = 0; i < tabWords.size(); i++) {
696
                                if (txt.contains(searchText.toUpperCase())) {
629
                                    String txt = tabWords.get(i).toString().toUpperCase();
697
                                    foundInTab = true;
630
                                    if (txt.contains(searchText.toUpperCase())) {
698
                                    String tabTitle = tabsInfo.get(tabIndex).getTabTitle();
631
                                        foundInTab = true;
699
                                    if (tabTitle.toUpperCase().contains(searchText.toUpperCase())) {
632
                                        String tabTitle = tabsInfo.get(tabIndex).getTabTitle();
700
                                        if (exactCategory == null
633
                                        String tabSubpath = tabsInfo.get(tabIndex).getTabSubpath();
701
                                                || (exactCategory != null && exactCategory.equals(id) 
634
                                        exactTabIndex = tabIndex;
702
                                                    && exactCategory.toUpperCase().contains(searchText.toUpperCase()))) {
635
                                        exactSubpath = tabSubpath;
703
                                            exactTabIndex = tabIndex;
636
                                        setCurrentCategory(CategoryModel.getInstance().getCategory(id), exactSubpath);
704
                                            setCurrentCategory(CategoryModel.getInstance().getCategory(id), null);
637
                                        break;
638
                                    }
639
                                }
640
                                if (foundInTab) {
641
                                    cont = false;
642
                                    for (Integer tabIndex2 : tabsInfo.keySet()) {
643
                                        if (tabIndex2 != -1) {
644
                                            pane.setEnabledAt(tabIndex2, false);
645
                                        }
646
                                        pane.setSelectedIndex(tabIndex);
647
                                    }
648
                                }
649
                            }
650
                            if (cont) {
651
                                for (Integer tabIndex : tabsInfo.keySet()) {
652
                                    if (tabIndex != -1) {
653
                                        ArrayList<String> tabWords = tabsInfo.get(tabIndex).getWords();
654
                                        boolean foundInTab = false;
655
                                        for (int i = 0; i < tabWords.size(); i++) {
656
                                            String txt = tabWords.get(i).toString().toUpperCase();
657
                                            if (txt.contains(searchText.toUpperCase())) {
658
                                                foundInTab = true;
659
                                                String tabTitle = tabsInfo.get(tabIndex).getTabTitle();
660
                                                String tabSubpath = tabsInfo.get(tabIndex).getTabSubpath();
661
                                                exactTabIndex = tabIndex;
662
                                                exactSubpath = tabSubpath;
663
                                                setCurrentCategory(CategoryModel.getInstance().getCategory(id), exactSubpath);
664
                                                break;
665
                                            }
666
                                        }
667
                                        if (foundInTab) {
668
                                            pane.setEnabledAt(tabIndex, true);
669
                                            if (exactTabIndex == tabIndex) {
670
                                                pane.setSelectedIndex(tabIndex);
671
                                            }
672
                                        } else {
673
                                            pane.setEnabledAt(tabIndex, false);
674
                                            pane.setSelectedIndex(getNextEnabledTabIndex(pane, tabIndex));
705
                                        }
675
                                        }
706
                                    }
676
                                    }
677
                                }
678
                            }
679
                        } else {
680
                            setCurrentCategory(CategoryModel.getInstance().getCategory(id), null);
681
                        }
682
                    } else {
683
                        if (!removedCategories.contains(id)) {
684
                            removedCategories.add(id);
685
                        }
686
                        JTabbedPane pane = categoryid2tabbedpane.get(id);
687
                        if (categoryid2tabs.get(id) != null) {
688
                            HashMap<Integer, TabInfo> tabsInfo = categoryid2tabs.get(id);
689
                            for (Integer tabIndex : tabsInfo.keySet()) {
690
                                if(tabIndex != -1) {
691
                                    pane.setEnabledAt(tabIndex, false);
692
                                }
693
                            }
694
                        }
695
                        buttons.get(id).setEnabled(false);
696
                        if (removedCategories.size() == buttons.size()) {
697
                            setCurrentCategory(null, null);
698
                            visibleCategory = null;
699
                        } else {
700
                            for (String id3 : CategoryModel.getInstance().getCategoryIDs()) {
701
                                if (buttons.get(id3).isVisible() && exactCategory == null && exactSubpath == null) {
702
                                    setCurrentCategory(CategoryModel.getInstance().getCategory(id3), null);
703
                                    visibleCategory = id3;
707
                                    break;
704
                                    break;
708
                                }
705
                                }
709
                            }
706
                            }
710
                            HashMap<Integer, TabInfo> removedTabsInfo = tabbedpane2removedtabs.get(pane);
711
                            if (removedTabsInfo == null) {
712
                                removedTabsInfo = new HashMap<Integer, TabInfo>();
713
                            }
714
                            if (foundInTab) {
715
                                int removedTabsBefore = 0;
716
                                for (Integer removedTabIndex : removedTabsInfo.keySet()) {
717
                                    if (removedTabIndex < tabIndex) {
718
                                        removedTabsBefore++;
719
                                    }
720
                                }
721
                                if (removedTabsInfo.get(tabIndex) != null) {
722
                                    pane.insertTab(removedTabsInfo.get(tabIndex).getTabTitle(), null, removedTabsInfo.get(tabIndex).getTab(), null, tabIndex - removedTabsBefore);
723
                                    removedTabsInfo.remove(tabIndex);
724
                                    tabbedpane2removedtabs.put(pane, removedTabsInfo);
725
                                }
726
                                if (exactTabIndex == tabIndex) {
727
                                    pane.setSelectedIndex(tabIndex - removedTabsBefore);
728
                                }
729
                            } else {
730
                                int removedTabs = tabbedpane2removedtabs.get(pane) == null ? 0 : tabbedpane2removedtabs.get(pane).size();
731
                                if (removedTabs != tabbedpane2tabs.get(pane).size()) {
732
                                    if (!removedTabsInfo.containsKey(tabIndex)) {
733
                                        int removedTabsBefore = 0;
734
                                        for (Integer removedTabIndex : removedTabsInfo.keySet()) {
735
                                            if (removedTabIndex < tabIndex) {
736
                                                removedTabsBefore++;
737
                                            }
738
                                        }
739
                                        removedTabsInfo.put(tabIndex, tabsInfo.get(tabIndex));
740
                                        tabbedpane2removedtabs.put(pane, removedTabsInfo);
741
                                        pane.removeTabAt(tabIndex - removedTabsBefore);
742
                                    }
743
                                }
744
                            }
745
                        }
707
                        }
746
                    } else {
747
                        setCurrentCategory(CategoryModel.getInstance().getCategory(id), null);
748
                    }
708
                    }
749
                } else {
709
                } else {
750
                    if (!removedCategories.contains(id)) {
710
                    if (!removedCategories.contains(id)) {
751
                        removedCategories.add(id);
711
                        removedCategories.add(id);
752
                    }
712
                    }
753
                    buttons.get(id).setVisible(false);
713
                    JTabbedPane pane = categoryid2tabbedpane.get(id);
754
                    if(removedCategories.size() == buttons.size()) {
714
                    if (categoryid2tabs.get(id) != null) {
715
                        HashMap<Integer, TabInfo> tabsInfo = categoryid2tabs.get(id);
716
                        for (Integer tabIndex : tabsInfo.keySet()) {
717
                            pane.setEnabledAt(tabIndex, false);
718
                        }
719
                    }
720
                    buttons.get(id).setEnabled(false);
721
                    if (removedCategories.size() == buttons.size()) {
755
                        setCurrentCategory(null, null);
722
                        setCurrentCategory(null, null);
756
                        visibleCategory = null;
723
                        visibleCategory = null;
757
                    } else {
724
                    } else {
758
                        for (String id3 : CategoryModel.getInstance().getCategoryIDs()) {
725
                        for (String id3 : CategoryModel.getInstance().getCategoryIDs()) {
759
                            if (buttons.get(id3).isVisible() && exactCategory == null) {
726
                            if (buttons.get(id3).isVisible() && exactCategory == null && exactSubpath == null) {
760
                                setCurrentCategory(CategoryModel.getInstance().getCategory(id3), null);
727
                                setCurrentCategory(CategoryModel.getInstance().getCategory(id3), null);
761
                                visibleCategory = id3;
728
                                visibleCategory = id3;
762
                                break;
729
                                break;
Lines 765-789 Link Here
765
                    }
732
                    }
766
                }
733
                }
767
            }
734
            }
768
            if(visibleCategory != null) {
735
            if (keymapsSearch != null) {
769
                componentsShowing.clear();
770
                CategoryInfo catInfo = categoryid2jcomponents.get(visibleCategory);
771
                if (catInfo != null) {
772
                    for (String key : catInfo.getKeys()) {
773
                        if (key.contains(searchText.toUpperCase())) {
774
                            ArrayList<JComponent> comps = catInfo.getComponents(key);
775
                            if (comps != null) {
776
                                for (JComponent comp : comps) {
777
                                    if(comp.isShowing()) {
778
                                        componentsShowing.add(comp);
779
                                    }
780
                                }
781
                            }
782
                        }
783
                    }
784
                }
785
            }
786
            if(keymapsSearch != null) {
787
                keymapsSearch.setText(searchText);
736
                keymapsSearch.setText(searchText);
788
            }
737
            }
789
        }
738
        }
Lines 800-806 Link Here
800
        @Override
749
        @Override
801
        public void quickSearchConfirmed() {
750
        public void quickSearchConfirmed() {
802
            clearAll();
751
            clearAll();
803
        }
752
            }
804
753
805
        @Override
754
        @Override
806
        public void quickSearchCanceled() {
755
        public void quickSearchCanceled() {
Lines 808-827 Link Here
808
        }
757
        }
809
758
810
        private void clearAll() {
759
        private void clearAll() {
811
            for (String category : removedCategories) {
760
            for (String id : CategoryModel.getInstance().getCategoryIDs()) {
812
                buttons.get(category).setVisible(true);
761
                JTabbedPane pane = categoryid2tabbedpane.get(id);
762
                if (categoryid2tabs.get(id) != null) {
763
                    HashMap<Integer, TabInfo> tabsInfo = categoryid2tabs.get(id);
764
                    for (Integer tabIndex : tabsInfo.keySet()) {
765
                        if(tabIndex != -1) {
766
                            pane.setEnabledAt(tabIndex, true);
767
                        }
768
                    }
769
                }
770
                buttons.get(id).setEnabled(true);
813
            }
771
            }
814
772
815
            for (JTabbedPane pane : tabbedpane2removedtabs.keySet()) {
816
                HashMap<Integer, TabInfo> stuff = tabbedpane2removedtabs.get(pane);
817
                for (Integer index : stuff.keySet()) {
818
                    TabInfo stuff2 = stuff.get(index);
819
                    pane.insertTab(stuff2.getTabTitle(), null, stuff2.getTab(), null, index);
820
                }
821
            }
822
            setCurrentCategory(CategoryModel.getInstance().getCurrent(), null);
773
            setCurrentCategory(CategoryModel.getInstance().getCurrent(), null);
823
            removedCategories.clear();
774
            removedCategories.clear();
824
            tabbedpane2removedtabs.clear();
775
            tabbedpane2removedtabs.clear();
776
            if (keymapsSearch != null) {
777
                keymapsSearch.setText("");
778
            }
825
        }
779
        }
826
    }
780
    }
827
    
781
    

Return to bug 218312