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 153331
Collapse All | Expand All

(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/branding/ResourceBundleBrandingPanel.form (-1 lines)
Lines 52-58 Link Here
52
    <Component class="org.openide.explorer.view.BeanTreeView" name="view">
52
    <Component class="org.openide.explorer.view.BeanTreeView" name="view">
53
      <AuxValues>
53
      <AuxValues>
54
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new MyTree();"/>
54
        <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new MyTree();"/>
55
        <AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="view.setUseSubstringInQuickSearch(true);"/>
56
      </AuxValues>
55
      </AuxValues>
57
    </Component>
56
    </Component>
58
    <Component class="javax.swing.JLabel" name="searchLabel">
57
    <Component class="javax.swing.JLabel" name="searchLabel">
(-)a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/branding/ResourceBundleBrandingPanel.java (-2 lines)
Lines 164-171 Link Here
164
            }
164
            }
165
        });
165
        });
166
166
167
        view.setUseSubstringInQuickSearch(true);
168
169
        searchLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
167
        searchLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
170
        searchLabel.setLabelFor(searchField);
168
        searchLabel.setLabelFor(searchField);
171
        org.openide.awt.Mnemonics.setLocalizedText(searchLabel, org.openide.util.NbBundle.getMessage(ResourceBundleBrandingPanel.class, "ResourceBundleBrandingPanel.searchLabel.text")); // NOI18N
169
        org.openide.awt.Mnemonics.setLocalizedText(searchLabel, org.openide.util.NbBundle.getMessage(ResourceBundleBrandingPanel.class, "ResourceBundleBrandingPanel.searchLabel.text")); // NOI18N
(-)a/cnd.qnavigator/src/org/netbeans/modules/cnd/qnavigator/navigator/NavigatorPanelUI.java (-1 lines)
Lines 78-84 Link Here
78
        navigatorPane.setRootVisible(false);
78
        navigatorPane.setRootVisible(false);
79
        navigatorPane.setDropTarget(false);
79
        navigatorPane.setDropTarget(false);
80
        navigatorPane.setDragSource(false);
80
        navigatorPane.setDragSource(false);
81
        navigatorPane.setUseSubstringInQuickSearch(true);
82
        add(navigatorPane, java.awt.BorderLayout.CENTER);
81
        add(navigatorPane, java.awt.BorderLayout.CENTER);
83
        explorerManager.setRootContext(content.getRoot());
82
        explorerManager.setRootContext(content.getRoot());
84
        expandAll();
83
        expandAll();
(-)a/cnd.refactoring/src/org/netbeans/modules/cnd/refactoring/codegen/ui/ElementSelectorPanel.java (-1 lines)
Lines 76-82 Link Here
76
        setLayout(new BorderLayout());
76
        setLayout(new BorderLayout());
77
        elementView = new CheckTreeView();
77
        elementView = new CheckTreeView();
78
        elementView.setRootVisible(false);
78
        elementView.setRootVisible(false);
79
        elementView.setUseSubstringInQuickSearch(true);
80
        add(elementView, BorderLayout.CENTER);
79
        add(elementView, BorderLayout.CENTER);
81
        if (supportInline) {
80
        if (supportInline) {
82
            Mnemonics.setLocalizedText(inline, NbBundle.getMessage(ElementSelectorPanel.class, "LBL_inline_implementation")); // NOI18N
81
            Mnemonics.setLocalizedText(inline, NbBundle.getMessage(ElementSelectorPanel.class, "LBL_inline_implementation")); // NOI18N
(-)a/cnd.simpleunit/src/org/netbeans/modules/cnd/simpleunit/wizard/FunctionSelectorPanel.java (-1 lines)
Lines 69-75 Link Here
69
    public FunctionSelectorPanel(boolean singleSelection) {
69
    public FunctionSelectorPanel(boolean singleSelection) {
70
        setLayout(new BorderLayout());
70
        setLayout(new BorderLayout());
71
        elementView = new CheckTreeView();
71
        elementView = new CheckTreeView();
72
        elementView.setUseSubstringInQuickSearch(true);
73
        add(elementView, BorderLayout.CENTER);
72
        add(elementView, BorderLayout.CENTER);
74
    }
73
    }
75
74
(-)a/favorites/src/org/netbeans/modules/favorites/Tab.java (-1 lines)
Lines 169-175 Link Here
169
        TreeView tView = new MyBeanTreeView();
169
        TreeView tView = new MyBeanTreeView();
170
        tView.setRootVisible(false);
170
        tView.setRootVisible(false);
171
        tView.setDragSource (true);
171
        tView.setDragSource (true);
172
        tView.setUseSubstringInQuickSearch(true);
173
        setLayout(new BorderLayout());
172
        setLayout(new BorderLayout());
174
        add (tView);
173
        add (tView);
175
        return tView;
174
        return tView;
(-)a/java.debug/src/org/netbeans/modules/java/debug/ElementNavigatorProviderImpl.java (-1 lines)
Lines 94-100 Link Here
94
        if (panel == null) {
94
        if (panel == null) {
95
            final BeanTreeView view = new BeanTreeView();
95
            final BeanTreeView view = new BeanTreeView();
96
            view.setRootVisible(true);
96
            view.setRootVisible(true);
97
            view.setUseSubstringInQuickSearch(true);
98
            view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
97
            view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
99
            class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
98
            class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
100
                // Make sure action context works correctly:
99
                // Make sure action context works correctly:
(-)a/java.debug/src/org/netbeans/modules/java/debug/ErrorNavigatorProviderImpl.java (-1 lines)
Lines 80-86 Link Here
80
        if (panel == null) {
80
        if (panel == null) {
81
            final BeanTreeView view = new BeanTreeView();
81
            final BeanTreeView view = new BeanTreeView();
82
            view.setRootVisible(false);
82
            view.setRootVisible(false);
83
            view.setUseSubstringInQuickSearch(true);
84
            view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
83
            view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
85
            class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
84
            class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
86
                // Make sure action context works correctly:
85
                // Make sure action context works correctly:
(-)a/java.debug/src/org/netbeans/modules/java/debug/TreeNavigatorProviderImpl.java (-1 lines)
Lines 115-121 Link Here
115
        if (panel == null) {
115
        if (panel == null) {
116
            final BeanTreeView view = new BeanTreeView();
116
            final BeanTreeView view = new BeanTreeView();
117
            view.setRootVisible(true);
117
            view.setRootVisible(true);
118
            view.setUseSubstringInQuickSearch(true);
119
            view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
118
            view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
120
            class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
119
            class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
121
                // Make sure action context works correctly:
120
                // Make sure action context works correctly:
(-)a/java.editor/src/org/netbeans/modules/java/editor/codegen/ui/ElementSelectorPanel.java (-1 lines)
Lines 68-74 Link Here
68
        setLayout(new BorderLayout());
68
        setLayout(new BorderLayout());
69
        elementView = new CheckTreeView();
69
        elementView = new CheckTreeView();
70
        elementView.setRootVisible(false);
70
        elementView.setRootVisible(false);
71
        elementView.setUseSubstringInQuickSearch(true);
72
        add(elementView, BorderLayout.CENTER);
71
        add(elementView, BorderLayout.CENTER);
73
        setRootElement(elementDescription, singleSelection);
72
        setRootElement(elementDescription, singleSelection);
74
        //make sure that the first element is pre-selected
73
        //make sure that the first element is pre-selected
(-)a/java.navigation/src/org/netbeans/modules/java/navigation/ClassMemberPanelUI.java (-1 lines)
Lines 347-353 Link Here
347
        
347
        
348
        public MyBeanTreeView() {
348
        public MyBeanTreeView() {
349
            toolTipManager = new ToolTipManagerEx( this );
349
            toolTipManager = new ToolTipManagerEx( this );
350
            setUseSubstringInQuickSearch(true);
351
        }
350
        }
352
        
351
        
353
        public boolean getScrollOnExpand() {
352
        public boolean getScrollOnExpand() {
(-)a/maven.grammar/src/org/netbeans/modules/maven/codegen/NewPluginPanel.java (-1 lines)
Lines 422-428 Link Here
422
            btv = new BeanTreeView();
422
            btv = new BeanTreeView();
423
            btv.setRootVisible(false);
423
            btv.setRootVisible(false);
424
            btv.setDefaultActionAllowed(false);
424
            btv.setDefaultActionAllowed(false);
425
            btv.setUseSubstringInQuickSearch(true);
426
            manager = new ExplorerManager();
425
            manager = new ExplorerManager();
427
            manager.setRootContext(getNoResultsRoot());
426
            manager.setRootContext(getNoResultsRoot());
428
            setLayout(new BorderLayout());
427
            setLayout(new BorderLayout());
(-)a/maven.hints/src/org/netbeans/modules/maven/hints/ui/SearchDependencyUI.java (-1 lines)
Lines 107-113 Link Here
107
        beanTreeView.setPopupAllowed(false);
107
        beanTreeView.setPopupAllowed(false);
108
        beanTreeView.setRootVisible(false);
108
        beanTreeView.setRootVisible(false);
109
        beanTreeView.setDefaultActionAllowed(true);
109
        beanTreeView.setDefaultActionAllowed(true);
110
        beanTreeView.setUseSubstringInQuickSearch(true);
111
        addButton.setEnabled(false);
110
        addButton.setEnabled(false);
112
111
113
        txtClassName.setText(clazz);
112
        txtClassName.setText(clazz);
(-)a/maven/src/org/netbeans/modules/maven/newproject/ChooseArchetypePanel.java (-1 lines)
Lines 151-157 Link Here
151
        tv.setPopupAllowed(false);
151
        tv.setPopupAllowed(false);
152
        tv.setRootVisible(false);
152
        tv.setRootVisible(false);
153
        tv.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
153
        tv.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
154
        tv.setUseSubstringInQuickSearch(true);
155
        Childs childs = new Childs();
154
        Childs childs = new Childs();
156
        childs.addArchetype(LOADING_ARCHETYPE);
155
        childs.addArchetype(LOADING_ARCHETYPE);
157
        AbstractNode root = new AbstractNode(childs);
156
        AbstractNode root = new AbstractNode(childs);
(-)a/maven/src/org/netbeans/modules/maven/nodes/AddDependencyPanel.java (-3 lines)
Lines 976-982 Link Here
976
            btv = new BeanTreeView();
976
            btv = new BeanTreeView();
977
            btv.setRootVisible(false);
977
            btv.setRootVisible(false);
978
            btv.setDefaultActionAllowed(true);
978
            btv.setDefaultActionAllowed(true);
979
            btv.setUseSubstringInQuickSearch(true);
980
            manager = new ExplorerManager();
979
            manager = new ExplorerManager();
981
            setLayout(new BorderLayout());
980
            setLayout(new BorderLayout());
982
            add(btv, BorderLayout.CENTER);
981
            add(btv, BorderLayout.CENTER);
Lines 1271-1277 Link Here
1271
            btv = new BeanTreeView();
1270
            btv = new BeanTreeView();
1272
            btv.setRootVisible(false);
1271
            btv.setRootVisible(false);
1273
            btv.setDefaultActionAllowed(true);
1272
            btv.setDefaultActionAllowed(true);
1274
            btv.setUseSubstringInQuickSearch(true);
1275
            //lv.setDefaultProcessor(this);
1273
            //lv.setDefaultProcessor(this);
1276
            manager = new ExplorerManager();
1274
            manager = new ExplorerManager();
1277
            manager.addPropertyChangeListener(this);
1275
            manager.addPropertyChangeListener(this);
Lines 1376-1382 Link Here
1376
            btv = new BeanTreeView();
1374
            btv = new BeanTreeView();
1377
            btv.setRootVisible(false);
1375
            btv.setRootVisible(false);
1378
            btv.setDefaultActionAllowed(true);
1376
            btv.setDefaultActionAllowed(true);
1379
            btv.setUseSubstringInQuickSearch(true);
1380
            manager = new ExplorerManager();
1377
            manager = new ExplorerManager();
1381
            manager.addPropertyChangeListener(this);
1378
            manager.addPropertyChangeListener(this);
1382
            setLayout(new BorderLayout());
1379
            setLayout(new BorderLayout());
(-)a/openide.explorer/src/org/openide/explorer/view/TreeView.java (-12 / +40 lines)
Lines 488-494 Link Here
488
     * matching for the typed characters. Defaults to prefix (false).
488
     * matching for the typed characters. Defaults to prefix (false).
489
     * @since 6.11
489
     * @since 6.11
490
     * @param useSubstring <code>true</code> if substring search is used in quick search
490
     * @param useSubstring <code>true</code> if substring search is used in quick search
491
     * @deprecated Deprecated as the quick search feature uses both substring and prefix
492
     * matching. All prefix matches for the typed characters will appear before substring
493
     * matches.
491
     */
494
     */
495
    @Deprecated
492
    public void setUseSubstringInQuickSearch(boolean useSubstring) {
496
    public void setUseSubstringInQuickSearch(boolean useSubstring) {
493
        quickSearchUsingSubstring = useSubstring;
497
        quickSearchUsingSubstring = useSubstring;
494
    }
498
    }
Lines 2079-2084 Link Here
2079
        private List<TreePath> doSearch(String prefix) {
2083
        private List<TreePath> doSearch(String prefix) {
2080
            List<TreePath> results = new ArrayList<TreePath>();
2084
            List<TreePath> results = new ArrayList<TreePath>();
2081
            Set<TreePath> resSet = new HashSet<TreePath>();
2085
            Set<TreePath> resSet = new HashSet<TreePath>();
2086
            
2087
            // starting index of substring matches within the results
2088
            int startOfSubstringMatches = 0;
2082
2089
2083
            int startIndex = origSelectionPaths != null ? Math.max(0, getRowForPath(origSelectionPaths[0])) : 0;
2090
            int startIndex = origSelectionPaths != null ? Math.max(0, getRowForPath(origSelectionPaths[0])) : 0;
2084
            int size = getRowCount();
2091
            int size = getRowCount();
Lines 2091-2109 Link Here
2091
            while (true) {
2098
            while (true) {
2092
                startIndex = startIndex % size;
2099
                startIndex = startIndex % size;
2093
2100
2094
                TreePath path = null;
2101
                SubstringSearchResult substringSearchResult = getNextSubstringMatch(prefix, startIndex, Position.Bias.Forward);
2095
                if (quickSearchUsingSubstring) {
2102
                TreePath path = substringSearchResult != null? substringSearchResult.treePath: null;
2096
                    path = getNextSubstringMatch(prefix, startIndex, Position.Bias.Forward);
2097
                } else {
2098
                    path = getNextMatch(prefix, startIndex, Position.Bias.Forward);
2099
                }
2100
2103
2101
                if ((path != null) && !resSet.contains(path)) {
2104
                if ((path != null) && !resSet.contains(path)) {
2102
                    startIndex = tree.getRowForPath(path);
2105
                    startIndex = tree.getRowForPath(path);
2103
                    results.add(path);
2106
                    boolean isPrefixMatch = true;
2107
                    // put all prefix matches to the top of the list while
2108
                    // substring matches remains in the end of the list
2109
                    if (substringSearchResult.index == 0) {
2110
                        results.add(startOfSubstringMatches++, path);
2111
                    } else {
2112
                        isPrefixMatch = false;
2113
                        results.add(path);
2114
                    }
2104
                    resSet.add(path);
2115
                    resSet.add(path);
2105
2116
2106
                    if (!quickSearchUsingSubstring) {
2117
                    // calculate max prefix only with prefix matches
2118
                    if (isPrefixMatch) {
2107
                        String elementName = ((VisualizerNode) path.getLastPathComponent()).getDisplayName();
2119
                        String elementName = ((VisualizerNode) path.getLastPathComponent()).getDisplayName();
2108
2120
2109
                        // initialize prefix
2121
                        // initialize prefix
Lines 2135-2142 Link Here
2135
        
2147
        
2136
        /**
2148
        /**
2137
         * Copied and adapted from JTree.getNextMatch(...).
2149
         * Copied and adapted from JTree.getNextMatch(...).
2150
         * 
2151
         * @return An instance of SubstringSearchResult containing the matching TreePath
2152
         *         and the index of the first occurrence of the substring in TreePath.
2138
         */
2153
         */
2139
        private TreePath getNextSubstringMatch(
2154
        private SubstringSearchResult getNextSubstringMatch(
2140
                String substring, int startingRow, Position.Bias bias) {
2155
                String substring, int startingRow, Position.Bias bias) {
2141
2156
2142
            int max = getRowCount();
2157
            int max = getRowCount();
Lines 2157-2165 Link Here
2157
                String text = convertValueToText(
2172
                String text = convertValueToText(
2158
                    path.getLastPathComponent(), isRowSelected(row),
2173
                    path.getLastPathComponent(), isRowSelected(row),
2159
                    isExpanded(row), true, row, false);
2174
                    isExpanded(row), true, row, false);
2160
2175
                
2161
                if (text.toUpperCase().indexOf(substring) >= 0) {
2176
                int index = text.toUpperCase().indexOf(substring);
2162
                    return path;
2177
                if (index >= 0) {
2178
                    return new SubstringSearchResult(path, index);
2163
                }
2179
                }
2164
                row = (row + increment + max) % max;
2180
                row = (row + increment + max) % max;
2165
            } while (row != startingRow);
2181
            } while (row != startingRow);
Lines 2456-2461 Link Here
2456
                }
2472
                }
2457
            }
2473
            }
2458
        }
2474
        }
2475
        
2476
        private class SubstringSearchResult {
2477
            
2478
            TreePath treePath;  // holds the matching TreePath
2479
            int index;          // holds the index of the first occurrence of the substring in TreePath
2480
2481
            public SubstringSearchResult(TreePath treePath, int index) {
2482
                this.treePath = treePath;
2483
                this.index = index;
2484
            }
2485
            
2486
        }
2459
    }
2487
    }
2460
    
2488
    
2461
    private static class DummyTransferHandler extends TransferHandler /*implements UIResource*/ {
2489
    private static class DummyTransferHandler extends TransferHandler /*implements UIResource*/ {
(-)a/openide.explorer/test/unit/src/org/openide/explorer/view/TreeViewQuickSearchTest.java (-9 / +4 lines)
Lines 81-94 Link Here
81
        }
81
        }
82
    }
82
    }
83
    
83
    
84
    public void testSubstringQuickSearch() throws Throwable {
84
    public void testQuickSearch() throws Throwable {
85
        doQuickSearchTest(true);
85
        doQuickSearchTest();
86
    }
87
    public void testPrefixQuickSearch() throws Throwable {
88
        doQuickSearchTest(false);
89
    }
86
    }
90
    
87
    
91
    private void doQuickSearchTest(final boolean substringSearch) throws Throwable {
88
    private void doQuickSearchTest() throws Throwable {
92
        final AbstractNode root = new AbstractNode(new Children.Array());
89
        final AbstractNode root = new AbstractNode(new Children.Array());
93
        root.setName("test root");
90
        root.setName("test root");
94
        
91
        
Lines 107-113 Link Here
107
        
104
        
108
        final BeanTreeView btv = new BeanTreeView();
105
        final BeanTreeView btv = new BeanTreeView();
109
        p.add(BorderLayout.CENTER, btv);
106
        p.add(BorderLayout.CENTER, btv);
110
        btv.setUseSubstringInQuickSearch(substringSearch);
111
        
107
        
112
        f = new JFrame();
108
        f = new JFrame();
113
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
109
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Lines 135-143 Link Here
135
                        KeyEvent ke = new KeyEvent(btv.tree, KeyEvent.KEY_TYPED, 0, 0, KeyEvent.VK_UNDEFINED, 'A');
131
                        KeyEvent ke = new KeyEvent(btv.tree, KeyEvent.KEY_TYPED, 0, 0, KeyEvent.VK_UNDEFINED, 'A');
136
                        btv.tree.dispatchEvent(ke);
132
                        btv.tree.dispatchEvent(ke);
137
                    }
133
                    }
138
                    
139
                    if (phase[0] == 2) {
134
                    if (phase[0] == 2) {
140
                        Node operateOn = substringSearch ? children[2] : children[4];
135
                        Node operateOn = children[4];
141
                        TreePath[] paths = tree.getSelectionPaths();
136
                        TreePath[] paths = tree.getSelectionPaths();
142
                        assertNotNull("One node should be selected, but there are none.", paths);
137
                        assertNotNull("One node should be selected, but there are none.", paths);
143
                        assertEquals("One node should be selected, but there are none.", 1, paths.length);
138
                        assertEquals("One node should be selected, but there are none.", 1, paths.length);
(-)a/options.api/src/org/netbeans/modules/options/classic/NbMainExplorer.java (-1 lines)
Lines 174-180 Link Here
174
        */
174
        */
175
        protected TreeView initGui () {
175
        protected TreeView initGui () {
176
            TreeView v = new BeanTreeView();
176
            TreeView v = new BeanTreeView();
177
            v.setUseSubstringInQuickSearch(true);
178
            v.setDragSource (true);
177
            v.setDragSource (true);
179
            setLayout(new BorderLayout());
178
            setLayout(new BorderLayout());
180
            add (v);
179
            add (v);
(-)a/projectui/src/org/netbeans/modules/project/ui/ProjectTab.java (-1 lines)
Lines 178-184 Link Here
178
        btv = new ProjectTreeView();    // Add the BeanTreeView
178
        btv = new ProjectTreeView();    // Add the BeanTreeView
179
        
179
        
180
        btv.setDragSource (true);
180
        btv.setDragSource (true);
181
        btv.setUseSubstringInQuickSearch(true);
182
        btv.setRootVisible(false);
181
        btv.setRootVisible(false);
183
        
182
        
184
        add( btv, BorderLayout.CENTER ); 
183
        add( btv, BorderLayout.CENTER ); 

Return to bug 153331