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

(-)a/spi.quicksearch/apichanges.xml (+165 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
5
Copyright 2014 Oracle and/or its affiliates. All rights reserved.
6
7
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
8
Other names may be trademarks of their respective owners.
9
10
The contents of this file are subject to the terms of either the GNU
11
General Public License Version 2 only ("GPL") or the Common
12
Development and Distribution License("CDDL") (collectively, the
13
"License"). You may not use this file except in compliance with the
14
License. You can obtain a copy of the License at
15
http://www.netbeans.org/cddl-gplv2.html
16
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
17
specific language governing permissions and limitations under the
18
License.  When distributing the software, include this License Header
19
Notice in each file and include the License file at
20
nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
21
particular file as subject to the "Classpath" exception as provided
22
by Oracle in the GPL Version 2 section of the License file that
23
accompanied this code. If applicable, add the following below the
24
License Header, with the fields enclosed by brackets [] replaced by
25
your own identifying information:
26
"Portions Copyrighted [year] [name of copyright owner]"
27
28
If you wish your version of this file to be governed by only the CDDL
29
or only the GPL Version 2, indicate your decision by adding
30
"[Contributor] elects to include this software in this distribution
31
under the [CDDL or GPL Version 2] license." If you do not indicate a
32
single choice of license, a recipient has the option to distribute
33
your version of this file under either the CDDL, the GPL Version 2 or
34
to extend the choice of license to its licensees as provided above.
35
However, if you add GPL Version 2 code and therefore, elected the GPL
36
Version 2 license, then the option applies only if the new code is
37
made subject to such option by the copyright holder.
38
39
Contributor(s):
40
41
Portions Copyrighted 2014 Sun Microsystems, Inc.
42
-->
43
44
<?xml-stylesheet type="text/xml" href="../nbbuild/javadoctools/apichanges.xsl"?>
45
<!DOCTYPE apichanges PUBLIC "-//NetBeans//DTD API changes list 1.0//EN" "../nbbuild/javadoctools/apichanges.dtd">
46
47
<!--
48
49
INFO FOR PEOPLE ADDING CHANGES:
50
51
Check the DTD (apichanges.dtd) for details on the syntax. You do not
52
need to regenerate the HTML, as this is part of Javadoc generation; just
53
change the XML. Rough syntax of a change (several parts optional):
54
55
<change>
56
    <api name="compiler"/>
57
    <summary>Some brief description here, can use <b>XHTML</b></summary>
58
    <version major="1" minor="99"/>
59
    <date day="13" month="6" year="2001"/>
60
    <author login="jrhacker"/>
61
    <compatibility addition="yes"/>
62
    <description>
63
        The main description of the change here.
64
        Again can use full <b>XHTML</b> as needed.
65
    </description>
66
    <class package="org.openide.compiler" name="DoWhatIWantCompiler"/>
67
    <issue number="14309"/>
68
</change>
69
70
Also permitted elements: <package>, <branch>. <version> is API spec
71
version, recommended for all new changes. <compatibility> should say
72
if things were added/modified/deprecated/etc. and give all information
73
related to upgrading old code. List affected top-level classes and
74
link to issue numbers if applicable. See the DTD for more details.
75
76
Changes need not be in any particular order, they are sorted in various
77
ways by the stylesheet anyway.
78
79
Dates are assumed to mean "on the trunk". If you *also* make the same
80
change on a stabilization branch, use the <branch> tag to indicate this
81
and explain why the change was made on a branch in the <description>.
82
83
Please only change this file on the trunk! Rather: you can change it
84
on branches if you want, but these changes will be ignored; only the
85
trunk version of this file is important.
86
87
Deprecations do not count as incompatible, assuming that code using the
88
deprecated calls continues to see their documented behavior. But do
89
specify deprecation="yes" in <compatibility>.
90
91
This file is not a replacement for Javadoc: it is intended to list changes,
92
not describe the complete current behavior, for which ordinary documentation
93
is the proper place.
94
95
-->
96
97
<apichanges>
98
99
    <!-- First, a list of API names you may use: -->
100
    <apidefs>
101
        <apidef name="spi.quicksearch">Quick Search API</apidef>
102
    </apidefs>
103
104
    <!-- ACTUAL CHANGES BEGIN HERE: -->
105
106
    <changes>
107
108
        <change id="SearchRequest.getMaxResults">
109
            <api name="spi.quicksearch"/>
110
            <summary>Add methods for working with results limit</summary>
111
            <version major="1" minor="24"/>
112
            <date day="23" month="5" year="2014"/>
113
            <author login="jhavlin"/>
114
            <compatibility addition="yes"/>
115
            <description>
116
                <p>
117
                    Some search providers can perform some optimizations if
118
                    they know what is the limit on number of search results
119
                    in advance. So there is new method
120
                    SearchRequest.getMaxResults to retrieve the current limit,
121
                    and method SearchResponse.setMoreResults to explicitly
122
                    inform that there are more results not added to the
123
                    SearchResponse.
124
                </p>
125
            </description>
126
            <class package="org.netbeans.spi.quicksearch" name="SearchRequest"/>
127
            <class package="org.netbeans.spi.quicksearch" name="SearchResponse"/>
128
            <issue number="244432"/>
129
        </change>
130
    </changes>
131
132
    <htmlcontents>
133
        <!--
134
                            NO NO NO NO NO!
135
136
         ==============>    DO NOT EDIT ME!  <==============
137
138
          AUTOMATICALLY GENERATED FROM APICHANGES.XML, DO NOT EDIT
139
140
                SEE openide/io/api/doc/changes/changes.xml
141
        -->
142
        <head>
143
            <title>Change History for the Quick Search API</title>
144
            <link rel="stylesheet" href="prose.css" type="text/css"/>
145
        </head>
146
        <body>
147
148
            <p class="overviewlink">
149
                <a href="overview-summary.html">Overview</a>
150
            </p>
151
152
            <h1>Introduction</h1>
153
154
            <p>This document lists changes made to the <a href="@org-netbeans-spi-quicksearch@/index.html">Quick Search API</a>.</p>
155
156
            <!-- The actual lists of changes, as summaries and details: -->
157
            <hr/>
158
            <standard-changelists module-code-name="org.netbeans.spi.quicksearch"/>
159
160
            <hr/>
161
            <p>@FOOTER@</p>
162
        </body>
163
    </htmlcontents>
164
165
</apichanges>
(-)a/spi.quicksearch/manifest.mf (-1 / +1 lines)
Lines 2-6 Link Here
2
OpenIDE-Module: org.netbeans.spi.quicksearch
2
OpenIDE-Module: org.netbeans.spi.quicksearch
3
OpenIDE-Module-Layer: org/netbeans/modules/quicksearch/resources/layer.xml
3
OpenIDE-Module-Layer: org/netbeans/modules/quicksearch/resources/layer.xml
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/spi/quicksearch/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/spi/quicksearch/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.23
5
OpenIDE-Module-Specification-Version: 1.24
6
6
(-)a/spi.quicksearch/nbproject/project.properties (+1 lines)
Lines 2-6 Link Here
2
javac.source=1.6
2
javac.source=1.6
3
javac.compilerargs=-Xlint -Xlint:-serial
3
javac.compilerargs=-Xlint -Xlint:-serial
4
javadoc.arch=${basedir}/arch.xml
4
javadoc.arch=${basedir}/arch.xml
5
javadoc.apichanges=${basedir}/apichanges.xml
5
6
6
test.config.stableBTD.includes=**/*Test.class
7
test.config.stableBTD.includes=**/*Test.class
(-)a/spi.quicksearch/src/org/netbeans/modules/quicksearch/Accessor.java (-1 / +1 lines)
Lines 71-77 Link Here
71
//        assert DEFAULT != null : "The DEFAULT field must be initialized";
71
//        assert DEFAULT != null : "The DEFAULT field must be initialized";
72
    }
72
    }
73
    
73
    
74
    public abstract SearchRequest createRequest (String text, List<? extends KeyStroke> stroke);
74
    public abstract SearchRequest createRequest (String text, List<? extends KeyStroke> stroke, int maxResults);
75
    
75
    
76
    public abstract SearchResponse createResponse (CategoryResult catResult, SearchRequest sRequest);
76
    public abstract SearchResponse createResponse (CategoryResult catResult, SearchRequest sRequest);
77
        
77
        
(-)a/spi.quicksearch/src/org/netbeans/modules/quicksearch/CategoryResult.java (+13 lines)
Lines 47-53 Link Here
47
import java.util.List;
47
import java.util.List;
48
import javax.swing.SwingUtilities;
48
import javax.swing.SwingUtilities;
49
import org.netbeans.modules.quicksearch.ResultsModel.ItemResult;
49
import org.netbeans.modules.quicksearch.ResultsModel.ItemResult;
50
import org.netbeans.spi.quicksearch.SearchRequest;
50
import org.openide.util.NbBundle;
51
import org.openide.util.NbBundle;
52
import sun.awt.FontConfiguration;
51
53
52
/**
54
/**
53
 * Thread safe model of provider results of asociated category.
55
 * Thread safe model of provider results of asociated category.
Lines 175-178 Link Here
175
        
177
        
176
    }
178
    }
177
179
180
    /**
181
     * Inform that there are more results to add, but they won't be added
182
     * because of exceeded limit on number of items.
183
     *
184
     * @see SearchRequest#getMaxResults().
185
     */
186
    public void setMoreResults() {
187
        if (!allResults) {
188
            moreResults = true;
189
        }
190
    }
178
}
191
}
(-)a/spi.quicksearch/src/org/netbeans/modules/quicksearch/CommandEvaluator.java (-1 / +2 lines)
Lines 98-108 Link Here
98
    public static org.openide.util.Task evaluate (String command, ResultsModel model) {
98
    public static org.openide.util.Task evaluate (String command, ResultsModel model) {
99
        List<CategoryResult> l = new ArrayList<CategoryResult>();
99
        List<CategoryResult> l = new ArrayList<CategoryResult>();
100
        String[] commands = parseCommand(command);
100
        String[] commands = parseCommand(command);
101
        SearchRequest sRequest = Accessor.DEFAULT.createRequest(commands[1], null);
102
        List<Task> tasks = new ArrayList<Task>();
101
        List<Task> tasks = new ArrayList<Task>();
103
102
104
        List<Category> provCats = new ArrayList<Category>();
103
        List<Category> provCats = new ArrayList<Category>();
105
        boolean allResults = getProviderCategories(commands, provCats);
104
        boolean allResults = getProviderCategories(commands, provCats);
105
        SearchRequest sRequest = Accessor.DEFAULT.createRequest(commands[1], null,
106
                (allResults ? CategoryResult.ALL_MAX_RESULTS : CategoryResult.MAX_RESULTS));
106
107
107
        for (ProviderModel.Category curCat : provCats) {
108
        for (ProviderModel.Category curCat : provCats) {
108
            CategoryResult catResult = new CategoryResult(curCat, allResults);
109
            CategoryResult catResult = new CategoryResult(curCat, allResults);
(-)a/spi.quicksearch/src/org/netbeans/spi/quicksearch/AccessorImpl.java (-2 / +2 lines)
Lines 58-65 Link Here
58
class AccessorImpl extends Accessor {
58
class AccessorImpl extends Accessor {
59
59
60
    @Override
60
    @Override
61
    public SearchRequest createRequest (String text, List<? extends KeyStroke> stroke) {
61
    public SearchRequest createRequest (String text, List<? extends KeyStroke> stroke, int maxResults) {
62
        return new SearchRequest(text, stroke);
62
        return new SearchRequest(text, stroke, maxResults);
63
    }
63
    }
64
64
65
    @Override
65
    @Override
(-)a/spi.quicksearch/src/org/netbeans/spi/quicksearch/SearchRequest.java (-3 / +19 lines)
Lines 63-76 Link Here
63
    }    
63
    }    
64
    
64
    
65
    /** Text to search for */
65
    /** Text to search for */
66
    private String text;
66
    private final String text;
67
    private final int maxResults;
67
    
68
    
68
    /** Shortcut to search for */
69
    /** Shortcut to search for */
69
    private List <? extends KeyStroke> stroke;
70
    private final List <? extends KeyStroke> stroke;
70
71
71
    SearchRequest (String text, List<? extends KeyStroke> stroke) {
72
    SearchRequest (String text, List<? extends KeyStroke> stroke, int maxResults) {
72
        this.text = text;
73
        this.text = text;
73
        this.stroke = stroke;
74
        this.stroke = stroke;
75
        this.maxResults = maxResults;
74
    }
76
    }
75
77
76
    /**
78
    /**
Lines 93-96 Link Here
93
        return stroke;
95
        return stroke;
94
    }
96
    }
95
97
98
    /**
99
     * Get maximal number of results that can be displayed under current
100
     * circumstances. You can use this information to optimize you search. But
101
     * remember that it is sometimes important to know whether there are more
102
     * results than the current limit L. So either add L+1 results, or call
103
     * method {@link SearchResponse#setMoreResults()}.
104
     *
105
     * @return The current limit on number of displayable results.
106
     * @see SearchResponse#setMoreResults()
107
     * @since spi.quicksearch/1.24
108
     */
109
    public int getMaxResults() {
110
        return maxResults;
111
    }
96
}
112
}
(-)a/spi.quicksearch/src/org/netbeans/spi/quicksearch/SearchResponse.java (-2 / +12 lines)
Lines 57-64 Link Here
57
 */
57
 */
58
public final class SearchResponse {
58
public final class SearchResponse {
59
59
60
    private CategoryResult catResult;
60
    private final CategoryResult catResult;
61
    private SearchRequest sRequest;
61
    private final SearchRequest sRequest;
62
   
62
   
63
    /** Package private creation, made available to other packages via
63
    /** Package private creation, made available to other packages via
64
     * Accessor pattern.
64
     * Accessor pattern.
Lines 123-126 Link Here
123
                htmlDisplayName, shortcut, displayHint));
123
                htmlDisplayName, shortcut, displayHint));
124
    }
124
    }
125
125
126
    /**
127
     * Inform that there are more results to add, but they won't be added
128
     * because of exceeded limit on number of items.
129
     *
130
     * @see SearchRequest#getMaxResults().
131
     * @since spi.quicksearch/1.24
132
     */
133
    public void setMoreResults() {
134
        catResult.setMoreResults();
135
    }
126
}
136
}
(-)a/spi.quicksearch/test/unit/src/org/netbeans/modules/quicksearch/ResultsModelTest.java (-1 / +1 lines)
Lines 131-137 Link Here
131
        assertHTML("<html>leave my keys alone!", "<html>leave my keys alone!", "key");
131
        assertHTML("<html>leave my keys alone!", "<html>leave my keys alone!", "key");
132
    }
132
    }
133
    private void assertHTML(String displayed, String provided, String searched) {
133
    private void assertHTML(String displayed, String provided, String searched) {
134
        assertEquals(displayed, new ResultsModel.ItemResult(null, Accessor.DEFAULT.createRequest(searched, null), null, provided).getDisplayName());
134
        assertEquals(displayed, new ResultsModel.ItemResult(null, Accessor.DEFAULT.createRequest(searched, null, 7), null, provided).getDisplayName());
135
    }
135
    }
136
136
137
}
137
}

Return to bug 244432