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

(-)src/org/openide/explorer/view/TreeView.java (-18 / +20 lines)
Lines 1291-1305 Link Here
1291
            private int currentSelectionIndex;
1291
            private int currentSelectionIndex;
1292
            
1292
            
1293
            public void changedUpdate(DocumentEvent e) {
1293
            public void changedUpdate(DocumentEvent e) {
1294
                searchForNode();
1294
                searchForNode (true);
1295
            }
1295
            }
1296
            
1296
            
1297
            public void insertUpdate(DocumentEvent e) {
1297
            public void insertUpdate(DocumentEvent e) {
1298
                searchForNode();
1298
                searchForNode (false);
1299
            }
1299
            }
1300
            
1300
            
1301
            public void removeUpdate(DocumentEvent e) {
1301
            public void removeUpdate(DocumentEvent e) {
1302
                searchForNode();
1302
                searchForNode (true);
1303
            }
1303
            }
1304
            public void keyPressed(KeyEvent e) {
1304
            public void keyPressed(KeyEvent e) {
1305
                int keyCode = e.getKeyCode();
1305
                int keyCode = e.getKeyCode();
Lines 1308-1320 Link Here
1308
                    ExplorerTree.this.requestFocus();
1308
                    ExplorerTree.this.requestFocus();
1309
                } else if (keyCode == KeyEvent.VK_UP) {
1309
                } else if (keyCode == KeyEvent.VK_UP) {
1310
                    currentSelectionIndex--;
1310
                    currentSelectionIndex--;
1311
                    displaySearchResult();
1311
                    displaySearchResult (true);
1312
                    // Stop processing the event here. Otherwise it's dispatched
1312
                    // Stop processing the event here. Otherwise it's dispatched
1313
                    // to the tree too (which scrolls)
1313
                    // to the tree too (which scrolls)
1314
                    e.consume();
1314
                    e.consume();
1315
                } else if (keyCode == KeyEvent.VK_DOWN) {
1315
                } else if (keyCode == KeyEvent.VK_DOWN) {
1316
                    currentSelectionIndex++;
1316
                    currentSelectionIndex++;
1317
                    displaySearchResult();
1317
                    displaySearchResult (true);
1318
                    // Stop processing the event here. Otherwise it's dispatched
1318
                    // Stop processing the event here. Otherwise it's dispatched
1319
                    // to the tree too (which scrolls)
1319
                    // to the tree too (which scrolls)
1320
                    e.consume();
1320
                    e.consume();
Lines 1331-1350 Link Here
1331
            }
1331
            }
1332
            
1332
            
1333
            /** Searches for a node in the tree. */
1333
            /** Searches for a node in the tree. */
1334
            private void searchForNode() {
1334
            private void searchForNode(boolean forceChangeSelection) {
1335
                currentSelectionIndex = 0;
1335
                currentSelectionIndex = 0;
1336
                results.clear();
1336
                results.clear();
1337
                maxPrefix = null;
1337
                maxPrefix = null;
1338
                String text = searchTextField.getText().toUpperCase();
1338
                String text = searchTextField.getText().toUpperCase();
1339
                if (text.length() > 0) {
1339
                if (text.length() > 0) {
1340
                    doSearch(text, results);
1340
                    results = doSearch (text);
1341
                    displaySearchResult();
1341
                    displaySearchResult (forceChangeSelection);
1342
                }
1342
                }
1343
            }
1343
            }
1344
            
1344
            
1345
            private void displaySearchResult() {
1345
            private void displaySearchResult (boolean forceChangeSelection) {
1346
                int sz = results.size();
1346
                int sz = results.size();
1347
                if (sz > 0) {
1347
                if (sz > 0) {
1348
                    
1349
                    if (!forceChangeSelection && results.contains (getSelectionPath ())) {
1350
                        // current selection matches => no change
1351
                        return ;
1352
                    }
1353
                    
1348
                    if (currentSelectionIndex < 0) {
1354
                    if (currentSelectionIndex < 0) {
1349
                        currentSelectionIndex = sz - 1;
1355
                        currentSelectionIndex = sz - 1;
1350
                    } else if (currentSelectionIndex >= sz) {
1356
                    } else if (currentSelectionIndex >= sz) {
Lines 1369-1384 Link Here
1369
1375
1370
        private int originalScrollMode;
1376
        private int originalScrollMode;
1371
        
1377
        
1372
        private void doSearch(String str, ArrayList results) {
1378
        private ArrayList doSearch (String str) {
1373
            int rows[] = getSelectionRows();
1379
            ArrayList results = new ArrayList ();
1374
            int row = (rows == null || rows.length == 0) ? 0 : rows[0];
1380
            for (int i = 0; i < getRowCount (); i++) {
1375
            int rowCount = getRowCount();
1381
                addPathIfMatches (str, i, results);
1376
            for (int i = row; i < getRowCount(); i++) {
1377
                addPathIfMatches(str, i, results);
1378
            }
1379
            for (int i = 0; i < row && i < rowCount; i++) {
1380
                addPathIfMatches(str, i, results);
1381
            }
1382
            }
1383
            return results;
1382
        }
1384
        }
1383
        
1385
        
1384
        private void addPathIfMatches(String str, int row, ArrayList results) {
1386
        private void addPathIfMatches(String str, int row, ArrayList results) {

Return to bug 32915