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

(-)apichanges.xml (-1 / +14 lines)
Lines 23-29 Link Here
23
<apidef name="explorer">Explorer API</apidef>
23
<apidef name="explorer">Explorer API</apidef>
24
</apidefs>
24
</apidefs>
25
<changes>
25
<changes>
26
26
    <change id="setUseSubstringInQuickSearch">
27
        <api name="explorer"/>
28
        <summary>Added method TreeView.setUseSubstringInQuickSearch(boolean).</summary>
29
        <version major="6" minor="11"/>
30
        <date day="11" month="7" year="2007"/>
31
        <author login="dstrupl"/>
32
        <compatibility binary="compatible" source="compatible" deprecation="no" deletion="no"/>
33
        <description>Added method setUseSubstringInQuickSearch(boolean). This
34
        method allows using substring search for the typed in text in the quick
35
        search feature instead of the (default) prefix search.
36
        </description>
37
        <class package="org.openide.explorer" name="TreeView" link="yes"/>
38
        <issue number="108729"/>
39
    </change>
27
     <change id="extendedDelete">
40
     <change id="extendedDelete">
28
        <api name="explorer"/>
41
        <api name="explorer"/>
29
        <summary>Added an interface and a registration slot
42
        <summary>Added an interface and a registration slot
(-)src/org/openide/explorer/view/TreeView.java (-2 / +57 lines)
Lines 191-196 Link Here
191
    transient private int allowedDragActions = DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_REFERENCE;
191
    transient private int allowedDragActions = DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_REFERENCE;
192
    transient private int allowedDropActions = DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_REFERENCE;
192
    transient private int allowedDropActions = DnDConstants.ACTION_COPY_OR_MOVE | DnDConstants.ACTION_REFERENCE;
193
193
194
    /**
195
     * Whether the quick search uses prefix or substring. 
196
     * Defaults to false meaning prefix is used.
197
     */
198
    transient private boolean quickSearchUsingSubstring = false;
199
194
    /** Constructor.
200
    /** Constructor.
195
    */
201
    */
196
    public TreeView() {
202
    public TreeView() {
Lines 383-388 Link Here
383
        tree.setShowsRootHandles(!visible);
389
        tree.setShowsRootHandles(!visible);
384
    }
390
    }
385
391
392
    /**
393
     * Set whether the quick search feature uses substring or prefix
394
     * matching for the typed characters. Defaults to prefix (false).
395
     * @since 6.11
396
     * @param useSubstring <code>true</code> if substring search is used in quick search
397
     */
398
    public void setUseSubstringInQuickSearch(boolean useSubstring) {
399
        quickSearchUsingSubstring = useSubstring;
400
    }
401
    
386
    /********** Support for the Drag & Drop operations *********/
402
    /********** Support for the Drag & Drop operations *********/
387
    /** Drag support is enabled by default.
403
    /** Drag support is enabled by default.
388
    * @return true if dragging from the view is enabled, false
404
    * @return true if dragging from the view is enabled, false
Lines 1705-1716 Link Here
1705
            while (true) {
1721
            while (true) {
1706
                startIndex = startIndex % size;
1722
                startIndex = startIndex % size;
1707
1723
1708
                TreePath path = getNextMatch(prefix, startIndex, Position.Bias.Forward);
1724
                TreePath path = null;
1725
                if (quickSearchUsingSubstring) {
1726
                    path = getNextSubstringMatch(prefix, startIndex, Position.Bias.Forward);
1727
                } else {
1728
                    path = getNextMatch(prefix, startIndex, Position.Bias.Forward);
1729
                }
1709
1730
1710
                if ((path != null) && !results.contains(path)) {
1731
                if ((path != null) && !results.contains(path)) {
1711
                    startIndex = tree.getRowForPath(path);
1732
                    startIndex = tree.getRowForPath(path);
1712
                    results.add(path);
1733
                    results.add(path);
1713
1734
1735
                    if (!quickSearchUsingSubstring) {
1714
                    String elementName = ((VisualizerNode) path.getLastPathComponent()).getDisplayName();
1736
                    String elementName = ((VisualizerNode) path.getLastPathComponent()).getDisplayName();
1715
1737
1716
                    // initialize prefix
1738
                    // initialize prefix
Lines 1719-1725 Link Here
1719
                    }
1741
                    }
1720
1742
1721
                    maxPrefix = findMaxPrefix(maxPrefix, elementName);
1743
                    maxPrefix = findMaxPrefix(maxPrefix, elementName);
1722
1744
                    }
1723
                    // try next element
1745
                    // try next element
1724
                    startIndex++;
1746
                    startIndex++;
1725
                } else {
1747
                } else {
Lines 1741-1746 Link Here
1741
        }
1763
        }
1742
1764
1743
        /**
1765
        /**
1766
         * Copied and adapted from JTree.getNextMatch(...).
1767
         */
1768
        private TreePath getNextSubstringMatch(
1769
                String substring, int startingRow, Position.Bias bias) {
1770
1771
            int max = getRowCount();
1772
            if (substring == null) {
1773
                throw new IllegalArgumentException();
1774
            }
1775
            if (startingRow < 0 || startingRow >= max) {
1776
                throw new IllegalArgumentException();
1777
            }
1778
            substring = substring.toUpperCase();
1779
1780
            // start search from the next/previous element froom the 
1781
            // selected element
1782
            int increment = (bias == Position.Bias.Forward) ? 1 : -1;
1783
            int row = startingRow;
1784
            do {
1785
                TreePath path = getPathForRow(row);
1786
                String text = convertValueToText(
1787
                    path.getLastPathComponent(), isRowSelected(row),
1788
                    isExpanded(row), true, row, false);
1789
1790
                if (text.toUpperCase().indexOf(substring) >= 0) {
1791
                    return path;
1792
                }
1793
                row = (row + increment + max) % max;
1794
            } while (row != startingRow);
1795
            return null;
1796
        }
1797
1798
        /**
1744
         * Adds the search field to the tree.
1799
         * Adds the search field to the tree.
1745
         */
1800
         */
1746
        private void displaySearchField() {
1801
        private void displaySearchField() {
(-)manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.explorer
2
OpenIDE-Module: org.openide.explorer
3
OpenIDE-Module-Specification-Version: 6.10
3
OpenIDE-Module-Specification-Version: 6.11
4
OpenIDE-Module-Implementation-Version: 1
4
OpenIDE-Module-Implementation-Version: 1
5
OpenIDE-Module-Localizing-Bundle: org/openide/explorer/Bundle.properties
5
OpenIDE-Module-Localizing-Bundle: org/openide/explorer/Bundle.properties
6
6

Return to bug 108729