KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > search2 > internal > ui > text2 > DefaultTextSearchQueryProvider


1 /*******************************************************************************
2  * Copyright (c) 2006 Wind River Systems and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * Markus Schorn - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.search2.internal.ui.text2;
13
14 import org.eclipse.core.resources.IResource;
15
16 import org.eclipse.ui.IWorkingSet;
17
18 import org.eclipse.search.ui.ISearchQuery;
19 import org.eclipse.search.ui.text.FileTextSearchScope;
20 import org.eclipse.search.ui.text.TextSearchQueryProvider;
21
22 import org.eclipse.search.internal.ui.text.FileSearchQuery;
23
24 public class DefaultTextSearchQueryProvider extends TextSearchQueryProvider {
25
26     /* (non-Javadoc)
27      * @see org.eclipse.search.ui.text.TextSearchQueryProvider#createQuery(TextSearchInput)
28      */

29     public ISearchQuery createQuery(TextSearchInput input) {
30         FileTextSearchScope scope= input.getScope();
31         String JavaDoc text= input.getSearchText();
32         boolean regEx= input.isRegExSearch();
33         boolean caseSensitive= input.isCaseSensitiveSearch();
34         return new FileSearchQuery(text, regEx, caseSensitive, scope);
35     }
36
37     /* (non-Javadoc)
38      * @see org.eclipse.search.ui.text.TextSearchQueryProvider#createQuery(java.lang.String)
39      */

40     public ISearchQuery createQuery(String JavaDoc searchForString) {
41         FileTextSearchScope scope= FileTextSearchScope.newWorkspaceScope(getPreviousFileNamePatterns(), false);
42         return new FileSearchQuery(searchForString, false, true, scope);
43     }
44     
45     /* (non-Javadoc)
46      * @see org.eclipse.search.ui.text.TextSearchQueryProvider#createQuery(java.lang.String, org.eclipse.core.resources.IResource[])
47      */

48     public ISearchQuery createQuery(String JavaDoc selectedText, IResource[] resources) {
49         FileTextSearchScope scope= FileTextSearchScope.newSearchScope(resources, getPreviousFileNamePatterns(), false);
50         return new FileSearchQuery(selectedText, false, true, scope);
51     }
52
53     /* (non-Javadoc)
54      * @see org.eclipse.search.ui.text.TextSearchQueryProvider#createQuery(java.lang.String, org.eclipse.ui.IWorkingSet[])
55      */

56     public ISearchQuery createQuery(String JavaDoc selectedText, IWorkingSet[] ws) {
57         FileTextSearchScope scope= FileTextSearchScope.newSearchScope(ws, getPreviousFileNamePatterns(), false);
58         return new FileSearchQuery(selectedText, false, true, scope);
59     }
60     
61     private String JavaDoc[] getPreviousFileNamePatterns() {
62         return new String JavaDoc[] { "*" }; //$NON-NLS-1$
63
}
64     
65 }
66
Popular Tags