Lines 77-113
Link Here
|
77 |
import java.beans.PropertyChangeListener; |
77 |
import java.beans.PropertyChangeListener; |
78 |
import java.util.ArrayList; |
78 |
import java.util.ArrayList; |
79 |
import java.util.Arrays; |
79 |
import java.util.Arrays; |
|
|
80 |
import java.util.Collections; |
81 |
import java.util.Comparator; |
80 |
import java.util.HashMap; |
82 |
import java.util.HashMap; |
|
|
83 |
import java.util.HashSet; |
81 |
import java.util.Iterator; |
84 |
import java.util.Iterator; |
82 |
import java.util.LinkedHashMap; |
85 |
import java.util.LinkedHashMap; |
83 |
import java.util.Map; |
86 |
import java.util.Map; |
84 |
import java.util.Set; |
87 |
import java.util.Set; |
85 |
import javax.swing.AbstractAction; |
88 |
import javax.swing.AbstractAction; |
86 |
import javax.swing.AbstractButton; |
|
|
87 |
import javax.swing.BorderFactory; |
89 |
import javax.swing.BorderFactory; |
88 |
import javax.swing.InputMap; |
90 |
import javax.swing.InputMap; |
89 |
import javax.swing.JComboBox; |
|
|
90 |
import javax.swing.JComponent; |
91 |
import javax.swing.JComponent; |
91 |
import javax.swing.JFrame; |
92 |
import javax.swing.JFrame; |
92 |
import javax.swing.JLabel; |
93 |
import javax.swing.JLabel; |
93 |
import javax.swing.JList; |
|
|
94 |
import javax.swing.JPanel; |
94 |
import javax.swing.JPanel; |
95 |
import javax.swing.JTabbedPane; |
95 |
import javax.swing.JTabbedPane; |
96 |
import javax.swing.JTable; |
|
|
97 |
import javax.swing.JTextField; |
96 |
import javax.swing.JTextField; |
98 |
import javax.swing.KeyStroke; |
97 |
import javax.swing.KeyStroke; |
99 |
import javax.swing.ListModel; |
|
|
100 |
import javax.swing.SwingUtilities; |
98 |
import javax.swing.SwingUtilities; |
101 |
import javax.swing.UIManager; |
99 |
import javax.swing.UIManager; |
102 |
import javax.swing.border.Border; |
100 |
import javax.swing.border.Border; |
103 |
import javax.swing.border.CompoundBorder; |
101 |
import javax.swing.border.CompoundBorder; |
104 |
import javax.swing.border.EmptyBorder; |
102 |
import javax.swing.border.EmptyBorder; |
105 |
import javax.swing.border.LineBorder; |
103 |
import javax.swing.border.LineBorder; |
106 |
import javax.swing.border.TitledBorder; |
|
|
107 |
import javax.swing.table.JTableHeader; |
108 |
import javax.swing.table.TableColumnModel; |
109 |
import javax.swing.table.TableModel; |
110 |
import javax.swing.text.JTextComponent; |
104 |
import javax.swing.text.JTextComponent; |
|
|
105 |
import org.netbeans.api.options.OptionsDisplayer; |
111 |
import org.netbeans.modules.options.CategoryModel.Category; |
106 |
import org.netbeans.modules.options.CategoryModel.Category; |
112 |
import org.netbeans.modules.options.advanced.AdvancedPanel; |
107 |
import org.netbeans.modules.options.advanced.AdvancedPanel; |
113 |
import org.netbeans.modules.options.ui.VariableBorder; |
108 |
import org.netbeans.modules.options.ui.VariableBorder; |
Lines 115-120
Link Here
|
115 |
import org.openide.awt.Mnemonics; |
110 |
import org.openide.awt.Mnemonics; |
116 |
import org.openide.awt.QuickSearch; |
111 |
import org.openide.awt.QuickSearch; |
117 |
import org.openide.awt.StatusDisplayer; |
112 |
import org.openide.awt.StatusDisplayer; |
|
|
113 |
import org.openide.filesystems.FileObject; |
114 |
import org.openide.filesystems.FileUtil; |
118 |
import org.openide.util.HelpCtx; |
115 |
import org.openide.util.HelpCtx; |
119 |
import org.openide.util.Mutex; |
116 |
import org.openide.util.Mutex; |
120 |
import org.openide.util.NbBundle; |
117 |
import org.openide.util.NbBundle; |
Lines 404-592
Link Here
|
404 |
for (Map.Entry<String, CategoryModel.Category> set : categories) { |
401 |
for (Map.Entry<String, CategoryModel.Category> set : categories) { |
405 |
JComponent jcomp = set.getValue().getComponent(); |
402 |
JComponent jcomp = set.getValue().getComponent(); |
406 |
String id = set.getValue().getID(); |
403 |
String id = set.getValue().getID(); |
407 |
ArrayList<String> strings = categoryid2words.get(id); |
|
|
408 |
if (strings == null) { |
409 |
strings = new ArrayList<String>(); |
410 |
} |
411 |
if (!strings.contains(id.toUpperCase())) { |
412 |
strings.add(id.toUpperCase()); |
413 |
} |
414 |
categoryid2words.put(id, strings); |
415 |
if(jcomp instanceof JTabbedPane) { |
404 |
if(jcomp instanceof JTabbedPane) { |
416 |
categoryid2tabbedpane.put(id, (JTabbedPane)jcomp); |
405 |
categoryid2tabbedpane.put(id, (JTabbedPane)jcomp); |
417 |
handleJTabbedPane((JTabbedPane)jcomp, id); |
|
|
418 |
} else if(jcomp instanceof AdvancedPanel) { |
406 |
} else if(jcomp instanceof AdvancedPanel) { |
419 |
categoryid2tabbedpane.put(id, (JTabbedPane)jcomp.getComponent(0)); |
407 |
categoryid2tabbedpane.put(id, (JTabbedPane)jcomp.getComponent(0)); |
420 |
handleJTabbedPane((JTabbedPane)jcomp.getComponent(0), id); |
|
|
421 |
} else if (jcomp instanceof Container) { |
408 |
} else if (jcomp instanceof Container) { |
422 |
setCurrentCategory(set.getValue(), null); |
|
|
423 |
handleAllComponents((Container) jcomp, id, null, -1); |
409 |
handleAllComponents((Container) jcomp, id, null, -1); |
424 |
} |
410 |
} |
425 |
} |
411 |
} |
|
|
412 |
|
413 |
FileObject keywordPanels = FileUtil.getConfigRoot().getFileObject(CategoryModel.OD_LAYER_KEYWORDS_FOLDER_NAME); |
414 |
|
415 |
for(FileObject keywordPanel : keywordPanels.getChildren()) { |
416 |
String location = keywordPanel.getAttribute("location").toString(); //NOI18N |
417 |
if (location.equals(OptionsDisplayer.ADVANCED)) { |
418 |
String id = keywordPanel.getAttribute("tabTitle").toString(); //NOI18N |
419 |
if(dublicateKeywordPanels.containsKey(id)) { |
420 |
int value = dublicateKeywordPanels.get(id); |
421 |
value++; |
422 |
dublicateKeywordPanels.put(id, value); |
423 |
} else { |
424 |
dublicateKeywordPanels.put(id, 0); |
425 |
} |
426 |
advanced.add(keywordPanel); |
427 |
} |
428 |
} |
429 |
Collections.sort(advanced, new AdvancedComparable()); |
430 |
|
431 |
for (int i = 0; i < advanced.size(); i++) { |
432 |
FileObject fo = advanced.get(i); |
433 |
fileObject2Index.put(fo, i); |
434 |
} |
435 |
for (int i = 0; i < advanced.size(); i++) { |
436 |
FileObject fo = advanced.get(i); |
437 |
String id = fo.getAttribute("tabTitle").toString(); //NOI18N |
438 |
int val = dublicateKeywordPanels.get(id); |
439 |
if(val != 0) { |
440 |
fileObject2Index.put(fo, fileObject2Index.get(fo)); |
441 |
for (int j = i + 1; j <= i + val; j++) { |
442 |
FileObject fo2 = advanced.get(j); |
443 |
fileObject2Index.put(fo2, fileObject2Index.get(fo)); |
444 |
} |
445 |
for (int j = i + val + 1; j < advanced.size(); j++) { |
446 |
FileObject fo2 = advanced.get(j); |
447 |
fileObject2Index.put(fo2, fileObject2Index.get(fo2) - val); |
448 |
} |
449 |
i = i + val; |
450 |
} |
451 |
} |
452 |
for(FileObject keywordPanel : keywordPanels.getChildren()) { |
453 |
handlePanel(keywordPanel); |
454 |
} |
455 |
} |
456 |
|
457 |
private ArrayList<FileObject> advanced = new ArrayList<FileObject>(); |
458 |
private HashMap<String, Integer> dublicateKeywordPanels = new HashMap<String, Integer>(); |
459 |
private HashMap<FileObject, Integer> fileObject2Index = new HashMap<FileObject, Integer>(); |
460 |
|
461 |
private class AdvancedComparable implements Comparator<FileObject> { |
462 |
|
463 |
@Override |
464 |
public int compare(FileObject r1, FileObject r2) { |
465 |
return r1.getAttribute("tabTitle").toString().compareTo(r2.getAttribute("tabTitle").toString()); //NOI18N |
466 |
} |
426 |
} |
467 |
} |
427 |
|
468 |
|
428 |
private void handleJTabbedPane(JTabbedPane pane, String categoryID) { |
469 |
private void handlePanel(FileObject keywordPanel) { |
429 |
int tabsNum = pane.getTabCount(); |
470 |
String location = keywordPanel.getAttribute("location").toString(); //NOI18N |
430 |
selectedTabIndex = pane.getSelectedIndex(); |
471 |
int tabIndex = (Integer) keywordPanel.getAttribute("index"); //NOI18N |
431 |
|
472 |
|
432 |
if (!categoryid2tabs.containsKey(categoryID)) { |
473 |
if (location.equals(OptionsDisplayer.ADVANCED)) { |
433 |
categoryid2tabs.put(categoryID, new HashMap<Integer, TabInfo>()); |
474 |
tabIndex = fileObject2Index.get(keywordPanel); |
434 |
} |
475 |
} |
435 |
HashMap<Integer, TabInfo> categoryTabs = categoryid2tabs.get(categoryID); |
476 |
|
|
|
477 |
ArrayList<String> keywords = new ArrayList<String>(); |
478 |
keywords.addAll(Arrays.asList(keywordPanel.getAttribute("keywords").toString().split(","))); //NOI18N |
479 |
|
480 |
ArrayList<String> words = categoryid2words.get(location); |
481 |
if (words == null) { |
482 |
words = new ArrayList<String>(); |
483 |
} |
484 |
|
485 |
Set<String> newWords = new HashSet<String>(); |
486 |
for (String keyword : keywords) { |
487 |
if (!words.contains(keyword)) { |
488 |
newWords.add(keyword); |
489 |
} |
490 |
} |
491 |
|
492 |
words.addAll(newWords); |
493 |
categoryid2words.put(location, words); |
494 |
|
495 |
if (!categoryid2tabs.containsKey(location)) { |
496 |
categoryid2tabs.put(location, new HashMap<Integer, TabInfo>()); |
497 |
} |
498 |
HashMap<Integer, TabInfo> categoryTabs = categoryid2tabs.get(location); |
436 |
TabInfo tabInfo; |
499 |
TabInfo tabInfo; |
437 |
|
500 |
if (!categoryTabs.containsKey(tabIndex)) { |
438 |
for (int i = 0; i < tabsNum; i++) { |
501 |
tabInfo = new TabInfo(); |
439 |
pane.setSelectedIndex(i); |
502 |
} else { |
440 |
Component tab = pane.getComponentAt(i); |
503 |
tabInfo = categoryTabs.get(tabIndex); |
441 |
|
|
|
442 |
if (!categoryTabs.containsKey(i)) { |
443 |
tabInfo = new TabInfo(pane.getTitleAt(i), CategoryModel.getInstance().getCategory(categoryID).getCategoryName(), tab); |
444 |
} else { |
445 |
tabInfo = categoryTabs.get(i); |
446 |
} |
447 |
categoryTabs.put(i, tabInfo); |
448 |
categoryid2tabs.put(categoryID, categoryTabs); |
449 |
|
450 |
ArrayList<String> strings = categoryid2words.get(categoryID); |
451 |
if (strings == null) { |
452 |
strings = new ArrayList<String>(); |
453 |
} |
454 |
if (!strings.contains(pane.getTitleAt(i).toUpperCase())) { |
455 |
strings.add(pane.getTitleAt(i).toUpperCase()); |
456 |
} |
457 |
categoryid2words.put(categoryID, strings); |
458 |
|
459 |
if (tab instanceof Container) { |
460 |
handleAllComponents((Container) tab, categoryID, pane, i); |
461 |
} |
462 |
} |
504 |
} |
463 |
pane.setSelectedIndex(selectedTabIndex); |
505 |
tabInfo.addWords(newWords); |
464 |
} |
506 |
categoryTabs.put(tabIndex, tabInfo); |
|
|
507 |
categoryid2tabs.put(location, categoryTabs); |
508 |
} |
465 |
|
509 |
|
466 |
private void handleAllComponents(Container container, String categoryID, JTabbedPane tabbedPane, int index) { |
510 |
private void handleAllComponents(Container container, String categoryID, JTabbedPane tabbedPane, int index) { |
467 |
Component[] components = container.getComponents(); |
511 |
Component[] components = container.getComponents(); |
468 |
Component component = null; |
512 |
Component component; |
469 |
ArrayList<String> strings = categoryid2words.get(categoryID); |
|
|
470 |
if(strings == null) { |
471 |
strings = new ArrayList<String>(); |
472 |
} |
473 |
|
474 |
for (int i = 0; i < components.length; i++) { |
513 |
for (int i = 0; i < components.length; i++) { |
475 |
component = components[i]; |
514 |
component = components[i]; |
476 |
String text = ""; |
515 |
String text; |
477 |
|
|
|
478 |
if (component instanceof JComponent) { |
479 |
final Border border = ((JComponent)component).getBorder(); |
480 |
if (border instanceof TitledBorder) { |
481 |
TitledBorder titledBorder = (TitledBorder) border; |
482 |
text = titledBorder.getTitle(); |
483 |
if (text != null && !text.isEmpty() && !strings.contains(text.toUpperCase())) { |
484 |
strings.add(text.toUpperCase()); |
485 |
} |
486 |
} |
487 |
} |
488 |
|
516 |
|
489 |
if (component instanceof JLabel) { |
517 |
if (component instanceof JLabel) { |
490 |
text = ((JLabel) component).getText(); |
518 |
text = ((JLabel) component).getText(); |
491 |
if (text != null && !text.isEmpty() && !strings.contains(text.toUpperCase())) { |
|
|
492 |
strings.add(text.toUpperCase()); |
493 |
} |
494 |
// hack to search into Keymaps category |
519 |
// hack to search into Keymaps category |
495 |
if(categoryID.equals("Keymaps") && text.equals("Search:")) { // NOI18N |
520 |
if(categoryID.equals("Keymaps") && text.equals("Search:")) { // NOI18N |
496 |
keymapsSearch = (JTextField)((JLabel) component).getLabelFor(); |
521 |
keymapsSearch = (JTextField)((JLabel) component).getLabelFor(); |
497 |
} |
522 |
} |
498 |
} else if (component instanceof AbstractButton) { |
|
|
499 |
text = ((AbstractButton) component).getText(); |
500 |
if (text != null && !text.isEmpty() && !strings.contains(text.toUpperCase())) { |
501 |
strings.add(text.toUpperCase()); |
502 |
} |
503 |
} else if (component instanceof JTextComponent) { |
504 |
text = ((JTextComponent) component).getText(); |
505 |
if (text != null && !text.isEmpty() && !strings.contains(text.toUpperCase())) { |
506 |
strings.add(text.toUpperCase()); |
507 |
} |
508 |
} else if (component instanceof JComboBox) { |
509 |
StringBuilder sb = new StringBuilder(); |
510 |
for (int j = 0; j < ((JComboBox) component).getItemCount(); j++) { |
511 |
Object object = ((JComboBox) component).getItemAt(j); |
512 |
text = object.toString(); |
513 |
if (text != null && !text.isEmpty()) { |
514 |
if (!strings.contains(text.toUpperCase())) { |
515 |
strings.add(text.toUpperCase()); |
516 |
} |
517 |
sb.append(text.toUpperCase().concat(" ")); |
518 |
} |
519 |
} |
520 |
text = sb.toString().trim(); |
521 |
} else if (component instanceof JList) { |
522 |
StringBuilder sb = new StringBuilder(); |
523 |
ListModel model = ((JList) component).getModel(); |
524 |
if (model != null) { |
525 |
for (int j = 0; j < model.getSize(); j++) { |
526 |
Object object = model.getElementAt(j); |
527 |
if (object != null) { |
528 |
text = object.toString(); |
529 |
if (text != null && !text.isEmpty()) { |
530 |
if (!strings.contains(text.toUpperCase())) { |
531 |
strings.add(text.toUpperCase()); |
532 |
} |
533 |
sb.append(text.toUpperCase().concat(" ")); |
534 |
} |
535 |
} |
536 |
} |
537 |
} |
538 |
text = sb.toString().trim(); |
539 |
} else if (component instanceof JTable) { |
540 |
StringBuilder sb = new StringBuilder(); |
541 |
JTableHeader header = ((JTable) component).getTableHeader(); |
542 |
if (header != null) { |
543 |
TableColumnModel columnModel = header.getColumnModel(); |
544 |
for (int j = 0; j < columnModel.getColumnCount(); j++) { |
545 |
Object object = columnModel.getColumn(j).getHeaderValue(); |
546 |
if (object != null) { |
547 |
text = object.toString(); |
548 |
if (text != null && !text.isEmpty()) { |
549 |
if (!strings.contains(text.toUpperCase())) { |
550 |
strings.add(text.toUpperCase()); |
551 |
} |
552 |
sb.append(text.toUpperCase().concat(" ")); |
553 |
} |
554 |
} |
555 |
} |
556 |
} |
557 |
|
558 |
TableModel model = ((JTable) component).getModel(); |
559 |
for (int j = 0; j < model.getRowCount(); j++) { |
560 |
for (int k = 0; k < model.getColumnCount(); k++) { |
561 |
Object object = model.getValueAt(j, k); |
562 |
if(object != null) { |
563 |
text = object.toString(); |
564 |
if (text != null && !text.isEmpty()) { |
565 |
if (!strings.contains(text.toUpperCase())) { |
566 |
strings.add(text.toUpperCase()); |
567 |
} |
568 |
sb.append(text.toUpperCase().concat(" ")); |
569 |
} |
570 |
} |
571 |
} |
572 |
} |
573 |
text = sb.toString().trim(); |
574 |
} |
575 |
|
576 |
categoryid2words.put(categoryID, strings); |
577 |
|
578 |
if (tabbedPane != null && index > -1) { |
579 |
TabInfo tabInfo = categoryid2tabs.get(categoryID).get(index); |
580 |
if (text != null && !text.isEmpty() && !tabInfo.getWords().contains(text.toUpperCase())) { |
581 |
tabInfo.addWord(text.toUpperCase()); |
582 |
categoryid2tabs.get(categoryID).put(index, tabInfo); |
583 |
} |
584 |
} |
523 |
} |
585 |
if(component instanceof JTabbedPane) { |
524 |
if(component instanceof JTabbedPane) { |
586 |
if(categoryid2tabbedpane.get(categoryID) == null) { |
525 |
if(categoryid2tabbedpane.get(categoryID) == null) { |
587 |
categoryid2tabbedpane.put(categoryID, (JTabbedPane)component); |
526 |
categoryid2tabbedpane.put(categoryID, (JTabbedPane)component); |
588 |
} |
527 |
} |
589 |
handleJTabbedPane((JTabbedPane)component, categoryID); |
|
|
590 |
} else { |
528 |
} else { |
591 |
handleAllComponents((Container)component, categoryID, tabbedPane, index); |
529 |
handleAllComponents((Container)component, categoryID, tabbedPane, index); |
592 |
} |
530 |
} |
Lines 596-625
Link Here
|
596 |
|
534 |
|
597 |
private class TabInfo { |
535 |
private class TabInfo { |
598 |
|
536 |
|
599 |
private String tabTitle; |
|
|
600 |
private Component tab; |
601 |
private String categoryName; |
602 |
private ArrayList<String> words; |
537 |
private ArrayList<String> words; |
603 |
|
538 |
|
604 |
public TabInfo(String tabTitle, String categoryName, Component tab) { |
539 |
public TabInfo() { |
605 |
this.tabTitle = tabTitle; |
|
|
606 |
this.categoryName = categoryName; |
607 |
this.tab = tab; |
608 |
this.words = new ArrayList<String>(); |
540 |
this.words = new ArrayList<String>(); |
609 |
words.add(tabTitle.toUpperCase()); |
|
|
610 |
words.add(categoryName.toUpperCase()); |
611 |
} |
612 |
|
613 |
public String getTabTitle() { |
614 |
return tabTitle; |
615 |
} |
616 |
|
617 |
public Component getTab() { |
618 |
return tab; |
619 |
} |
620 |
|
621 |
public String getCategoryName() { |
622 |
return categoryName; |
623 |
} |
541 |
} |
624 |
|
542 |
|
625 |
public ArrayList<String> getWords() { |
543 |
public ArrayList<String> getWords() { |
Lines 629-634
Link Here
|
629 |
public void addWord(String word) { |
547 |
public void addWord(String word) { |
630 |
words.add(word.toUpperCase()); |
548 |
words.add(word.toUpperCase()); |
631 |
} |
549 |
} |
|
|
550 |
|
551 |
public void addWords(Set<String> words) { |
552 |
for (String word : words) { |
553 |
addWord(word); |
554 |
} |
555 |
} |
632 |
} |
556 |
} |
633 |
|
557 |
|
634 |
final class OptionsQSCallback implements QuickSearch.Callback { |
558 |
final class OptionsQSCallback implements QuickSearch.Callback { |
Lines 679-768
Link Here
|
679 |
} |
603 |
} |
680 |
|
604 |
|
681 |
private void handleSearch(String searchText) { |
605 |
private void handleSearch(String searchText) { |
682 |
String visibleCategory = null; |
|
|
683 |
String exactCategory = null; |
606 |
String exactCategory = null; |
684 |
int exactTabIndex = 0; |
607 |
int exactTabIndex = -1; |
685 |
for (String id : CategoryModel.getInstance().getCategoryIDs()) { |
608 |
for (String id : CategoryModel.getInstance().getCategoryIDs()) { |
686 |
ArrayList<String> entry = categoryid2words.get(id); |
609 |
ArrayList<String> entry = categoryid2words.get(id); |
687 |
boolean found = false; |
610 |
if (entry != null) { |
688 |
for (String text : entry) { |
611 |
boolean found = false; |
689 |
if (text.contains(searchText.toUpperCase())) { |
612 |
for (String text : entry) { |
690 |
found = true; |
613 |
if (text.contains(searchText.toUpperCase())) { |
691 |
if(id.toUpperCase().contains(searchText.toUpperCase())) { |
614 |
found = true; |
692 |
exactCategory = id; |
615 |
if (id.toUpperCase().contains(searchText.toUpperCase())) { |
|
|
616 |
exactCategory = id; |
617 |
} |
618 |
break; |
693 |
} |
619 |
} |
|
|
620 |
} |
621 |
|
622 |
if (found) { |
623 |
disabledCategories.remove(id); |
624 |
buttons.get(id).setEnabled(true); |
625 |
JTabbedPane pane = categoryid2tabbedpane.get(id); |
626 |
if (categoryid2tabs.get(id) != null) { |
627 |
HashMap<Integer, TabInfo> tabsInfo = categoryid2tabs.get(id); |
628 |
for (Integer tabIndex : tabsInfo.keySet()) { |
629 |
if (tabIndex != -1) { |
630 |
ArrayList<String> tabWords = tabsInfo.get(tabIndex).getWords(); |
631 |
boolean foundInTab = false; |
632 |
for (int i = 0; i < tabWords.size(); i++) { |
633 |
String txt = tabWords.get(i).toString().toUpperCase(); |
634 |
if (txt.contains(searchText.toUpperCase())) { |
635 |
foundInTab = true; |
636 |
exactTabIndex = tabIndex; |
637 |
setCurrentCategory(CategoryModel.getInstance().getCategory(id), null); |
638 |
break; |
639 |
} |
640 |
} |
641 |
if (foundInTab) { |
642 |
pane.setEnabledAt(tabIndex, true); |
643 |
if (exactTabIndex == tabIndex) { |
644 |
pane.setSelectedIndex(tabIndex); |
645 |
} |
646 |
} else { |
647 |
pane.setEnabledAt(tabIndex, false); |
648 |
if(exactTabIndex == -1) { |
649 |
pane.setSelectedIndex(getNextEnabledTabIndex(pane, tabIndex)); |
650 |
} |
651 |
} |
652 |
} else { |
653 |
setCurrentCategory(CategoryModel.getInstance().getCategory(id), null); |
654 |
} |
655 |
} |
656 |
} else { |
657 |
setCurrentCategory(CategoryModel.getInstance().getCategory(id), null); |
658 |
} |
659 |
} else { |
660 |
handleNotFound(id, exactCategory); |
661 |
} |
662 |
} else { |
663 |
handleNotFound(id, exactCategory); |
664 |
} |
665 |
if (keymapsSearch != null) { |
666 |
keymapsSearch.setText(searchText); |
667 |
} |
668 |
} |
669 |
} |
670 |
|
671 |
private void handleNotFound(String id, String exactCategory) { |
672 |
if (!disabledCategories.contains(id)) { |
673 |
disabledCategories.add(id); |
674 |
} |
675 |
JTabbedPane pane = categoryid2tabbedpane.get(id); |
676 |
if (categoryid2tabs.get(id) != null && pane != null) { |
677 |
HashMap<Integer, TabInfo> tabsInfo = categoryid2tabs.get(id); |
678 |
for (Integer tabIndex : tabsInfo.keySet()) { |
679 |
if (tabIndex != -1) { |
680 |
pane.setEnabledAt(tabIndex, false); |
681 |
} |
682 |
} |
683 |
pane.setSelectedIndex(-1); |
684 |
} |
685 |
buttons.get(id).setEnabled(false); |
686 |
if (disabledCategories.size() == buttons.size()) { |
687 |
setCurrentCategory(null, null); |
688 |
} else { |
689 |
for (String id3 : CategoryModel.getInstance().getCategoryIDs()) { |
690 |
if (buttons.get(id3).isEnabled() && exactCategory == null) { |
691 |
setCurrentCategory(CategoryModel.getInstance().getCategory(id3), null); |
694 |
break; |
692 |
break; |
695 |
} |
693 |
} |
696 |
} |
694 |
} |
697 |
|
|
|
698 |
if (found) { |
699 |
visibleCategory = id; |
700 |
disabledCategories.remove(id); |
701 |
buttons.get(id).setEnabled(true); |
702 |
JTabbedPane pane = categoryid2tabbedpane.get(id); |
703 |
if (categoryid2tabs.get(id) != null) { |
704 |
HashMap<Integer, TabInfo> tabsInfo = categoryid2tabs.get(id); |
705 |
for (Integer tabIndex : tabsInfo.keySet()) { |
706 |
ArrayList<String> tabWords = tabsInfo.get(tabIndex).getWords(); |
707 |
boolean foundInTab = false; |
708 |
for (int i = 0; i < tabWords.size(); i++) { |
709 |
String txt = tabWords.get(i).toString().toUpperCase(); |
710 |
if (txt.contains(searchText.toUpperCase())) { |
711 |
foundInTab = true; |
712 |
String tabTitle = tabsInfo.get(tabIndex).getTabTitle(); |
713 |
if (tabTitle.toUpperCase().contains(searchText.toUpperCase())) { |
714 |
if (exactCategory == null |
715 |
|| (exactCategory != null && exactCategory.equals(id) |
716 |
&& exactCategory.toUpperCase().contains(searchText.toUpperCase()))) { |
717 |
exactTabIndex = tabIndex; |
718 |
setCurrentCategory(CategoryModel.getInstance().getCategory(id), null); |
719 |
} |
720 |
} |
721 |
break; |
722 |
} |
723 |
} |
724 |
if (foundInTab) { |
725 |
pane.setEnabledAt(tabIndex, true); |
726 |
if (exactTabIndex == tabIndex) { |
727 |
pane.setSelectedIndex(tabIndex); |
728 |
} |
729 |
} else { |
730 |
pane.setEnabledAt(tabIndex, false); |
731 |
pane.setSelectedIndex(getNextEnabledTabIndex(pane, tabIndex)); |
732 |
} |
733 |
} |
734 |
} else { |
735 |
setCurrentCategory(CategoryModel.getInstance().getCategory(id), null); |
736 |
} |
737 |
} else { |
738 |
if (!disabledCategories.contains(id)) { |
739 |
disabledCategories.add(id); |
740 |
} |
741 |
JTabbedPane pane = categoryid2tabbedpane.get(id); |
742 |
if (categoryid2tabs.get(id) != null) { |
743 |
HashMap<Integer, TabInfo> tabsInfo = categoryid2tabs.get(id); |
744 |
for (Integer tabIndex : tabsInfo.keySet()) { |
745 |
pane.setEnabledAt(tabIndex, false); |
746 |
} |
747 |
pane.setSelectedIndex(-1); |
748 |
} |
749 |
buttons.get(id).setEnabled(false); |
750 |
if(disabledCategories.size() == buttons.size()) { |
751 |
setCurrentCategory(null, null); |
752 |
visibleCategory = null; |
753 |
} else { |
754 |
for (String id3 : CategoryModel.getInstance().getCategoryIDs()) { |
755 |
if (buttons.get(id3).isEnabled() && exactCategory == null) { |
756 |
setCurrentCategory(CategoryModel.getInstance().getCategory(id3), null); |
757 |
visibleCategory = id3; |
758 |
break; |
759 |
} |
760 |
} |
761 |
} |
762 |
} |
763 |
} |
764 |
if(keymapsSearch != null) { |
765 |
keymapsSearch.setText(searchText); |
766 |
} |
695 |
} |
767 |
} |
696 |
} |
768 |
|
697 |
|
Lines 817-823
Link Here
|
817 |
if (categoryid2tabs.get(id) != null) { |
746 |
if (categoryid2tabs.get(id) != null) { |
818 |
HashMap<Integer, TabInfo> tabsInfo = categoryid2tabs.get(id); |
747 |
HashMap<Integer, TabInfo> tabsInfo = categoryid2tabs.get(id); |
819 |
for (Integer tabIndex : tabsInfo.keySet()) { |
748 |
for (Integer tabIndex : tabsInfo.keySet()) { |
820 |
pane.setEnabledAt(tabIndex, true); |
749 |
if(tabIndex != -1) { |
|
|
750 |
pane.setEnabledAt(tabIndex, true); |
751 |
} |
821 |
} |
752 |
} |
822 |
} |
753 |
} |
823 |
buttons.get(id).setEnabled(true); |
754 |
buttons.get(id).setEnabled(true); |
Lines 825-831
Link Here
|
825 |
setCurrentCategory(CategoryModel.getInstance().getCurrent(), null); |
756 |
setCurrentCategory(CategoryModel.getInstance().getCurrent(), null); |
826 |
disabledCategories.clear(); |
757 |
disabledCategories.clear(); |
827 |
if(keymapsSearch != null) { |
758 |
if(keymapsSearch != null) { |
828 |
keymapsSearch.setText(""); |
759 |
keymapsSearch.setText(""); //NOI18N |
829 |
} |
760 |
} |
830 |
} |
761 |
} |
831 |
} |
762 |
} |