View | Details | Raw Unified | Return to bug 306196 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/ui/search/JavaSearchPage.java (-10 / +77 lines)
Lines 71-77 Link Here
71
import org.eclipse.jdt.internal.corext.util.Messages;
71
import org.eclipse.jdt.internal.corext.util.Messages;
72
72
73
import org.eclipse.jdt.ui.search.ElementQuerySpecification;
73
import org.eclipse.jdt.ui.search.ElementQuerySpecification;
74
import org.eclipse.jdt.ui.search.PatternQuerySpecification;
74
import org.eclipse.jdt.ui.search.FfrPatternQuerySpecification;
75
import org.eclipse.jdt.ui.search.QuerySpecification;
75
import org.eclipse.jdt.ui.search.QuerySpecification;
76
76
77
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
77
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
Lines 87-92 Link Here
87
public class JavaSearchPage extends DialogPage implements ISearchPage {
87
public class JavaSearchPage extends DialogPage implements ISearchPage {
88
88
89
	private static class SearchPatternData {
89
	private static class SearchPatternData {
90
		private final int matchMode;
90
		private final int searchFor;
91
		private final int searchFor;
91
		private final int limitTo;
92
		private final int limitTo;
92
		private final String pattern;
93
		private final String pattern;
Lines 98-109 Link Here
98
		private IJavaElement javaElement;
99
		private IJavaElement javaElement;
99
100
100
		public SearchPatternData(int searchFor, int limitTo, int matchLocations, boolean isCaseSensitive, String pattern, IJavaElement element, int includeMask) {
101
		public SearchPatternData(int searchFor, int limitTo, int matchLocations, boolean isCaseSensitive, String pattern, IJavaElement element, int includeMask) {
101
			this(searchFor, limitTo, matchLocations, pattern, isCaseSensitive, element, ISearchPageContainer.WORKSPACE_SCOPE, null, includeMask);
102
			this(searchFor, limitTo, SearchPattern.R_EXACT_MATCH, matchLocations, pattern, isCaseSensitive, element, ISearchPageContainer.WORKSPACE_SCOPE, null, includeMask);
102
		}
103
		}
103
104
104
		public SearchPatternData(int searchFor, int limitTo, int matchLocations, String pattern, boolean isCaseSensitive, IJavaElement element, int scope, IWorkingSet[] workingSets, int includeMask) {
105
		public SearchPatternData(int searchFor, int limitTo, int matchMode, int matchLocations, String pattern, boolean isCaseSensitive, IJavaElement element, int includeMask) {
106
			this(searchFor, limitTo, matchMode, matchLocations, pattern, isCaseSensitive, element, ISearchPageContainer.WORKSPACE_SCOPE, null, includeMask);
107
		}
108
109
		public SearchPatternData(int searchFor, int limitTo, int matchMode, int matchLocations, String pattern, boolean isCaseSensitive, IJavaElement element, int scope, IWorkingSet[] workingSets, int includeMask) {
105
			this.searchFor= searchFor;
110
			this.searchFor= searchFor;
106
			this.limitTo= limitTo;
111
			this.limitTo= limitTo;
112
			this.matchMode = matchMode;
107
			this.matchLocations= matchLocations;
113
			this.matchLocations= matchLocations;
108
			this.pattern= pattern;
114
			this.pattern= pattern;
109
			this.isCaseSensitive= isCaseSensitive;
115
			this.isCaseSensitive= isCaseSensitive;
Lines 130-135 Link Here
130
			return limitTo;
136
			return limitTo;
131
		}
137
		}
132
138
139
		public int getMatchMode() {
140
			return this.matchMode;
141
		}
142
133
		public String getPattern() {
143
		public String getPattern() {
134
			return pattern;
144
			return pattern;
135
		}
145
		}
Lines 159-164 Link Here
159
			settings.put("scope", scope); //$NON-NLS-1$
169
			settings.put("scope", scope); //$NON-NLS-1$
160
			settings.put("pattern", pattern); //$NON-NLS-1$
170
			settings.put("pattern", pattern); //$NON-NLS-1$
161
			settings.put("limitTo", limitTo); //$NON-NLS-1$
171
			settings.put("limitTo", limitTo); //$NON-NLS-1$
172
			settings.put("matchMode", this.matchMode); //$NON-NLS-1$
162
			settings.put("matchLocations", matchLocations); //$NON-NLS-1$
173
			settings.put("matchLocations", matchLocations); //$NON-NLS-1$
163
			settings.put("javaElement", javaElement != null ? javaElement.getHandleIdentifier() : ""); //$NON-NLS-1$ //$NON-NLS-2$
174
			settings.put("javaElement", javaElement != null ? javaElement.getHandleIdentifier() : ""); //$NON-NLS-1$ //$NON-NLS-2$
164
			settings.put("isCaseSensitive", isCaseSensitive); //$NON-NLS-1$
175
			settings.put("isCaseSensitive", isCaseSensitive); //$NON-NLS-1$
Lines 204-210 Link Here
204
				int searchFor= settings.getInt("searchFor"); //$NON-NLS-1$
215
				int searchFor= settings.getInt("searchFor"); //$NON-NLS-1$
205
				int scope= settings.getInt("scope"); //$NON-NLS-1$
216
				int scope= settings.getInt("scope"); //$NON-NLS-1$
206
				int limitTo= settings.getInt("limitTo"); //$NON-NLS-1$
217
				int limitTo= settings.getInt("limitTo"); //$NON-NLS-1$
207
218
				int matchMode= settings.getInt("matchMode"); //$NON-NLS-1$
219
				
208
				int matchLocations= 0;
220
				int matchLocations= 0;
209
				if (settings.get("matchLocations") != null) { //$NON-NLS-1$
221
				if (settings.get("matchLocations") != null) { //$NON-NLS-1$
210
					matchLocations= settings.getInt("matchLocations"); //$NON-NLS-1$
222
					matchLocations= settings.getInt("matchLocations"); //$NON-NLS-1$
Lines 221-227 Link Here
221
						includeMask= JavaSearchScopeFactory.ALL;
233
						includeMask= JavaSearchScopeFactory.ALL;
222
					}
234
					}
223
				}
235
				}
224
				return new SearchPatternData(searchFor, limitTo, matchLocations, pattern, isCaseSensitive, elem, scope, workingSets, includeMask);
236
				return new SearchPatternData(searchFor, limitTo, matchMode, matchLocations, pattern, isCaseSensitive, elem, scope, workingSets, includeMask);
225
			} catch (NumberFormatException e) {
237
			} catch (NumberFormatException e) {
226
				return null;
238
				return null;
227
			}
239
			}
Lines 278-283 Link Here
278
	private int fMatchLocations;
290
	private int fMatchLocations;
279
	private Link fMatchLocationsLink;
291
	private Link fMatchLocationsLink;
280
292
293
	private Button[] matchMode;
294
	
281
	/**
295
	/**
282
	 *
296
	 *
283
	 */
297
	 */
Lines 341-347 Link Here
341
				SearchUtil.warnIfBinaryConstant(data.getJavaElement(), getShell());
355
				SearchUtil.warnIfBinaryConstant(data.getJavaElement(), getShell());
342
			querySpec= new ElementQuerySpecification(data.getJavaElement(), limitTo, scope, scopeDescription);
356
			querySpec= new ElementQuerySpecification(data.getJavaElement(), limitTo, scope, scopeDescription);
343
		} else {
357
		} else {
344
			querySpec= new PatternQuerySpecification(data.getPattern(), searchFor, data.isCaseSensitive(), limitTo, scope, scopeDescription);
358
			FfrPatternQuerySpecification ffrQuerySpec= new FfrPatternQuerySpecification(data.getPattern(), searchFor, data.getMatchMode(), data.isCaseSensitive(), data.getLimitTo(), scope, scopeDescription);
359
			querySpec = ffrQuerySpec;
345
			data.setJavaElement(null);
360
			data.setJavaElement(null);
346
		}
361
		}
347
362
Lines 375-381 Link Here
375
		fillLimitToGroup(searchFor, limitTo);
390
		fillLimitToGroup(searchFor, limitTo);
376
		return limitTo;
391
		return limitTo;
377
	}
392
	}
378
393
	
394
	private int getMatchMode() {
395
		int mode = SearchPattern.R_EXACT_MATCH;
396
		for (int i= 1, l=this.matchMode.length; i<l; i++) {
397
			if (this.matchMode[i].getSelection()) {
398
				mode |= 1 << i;
399
			}
400
		}
401
		return mode;
402
	}
403
	
404
	private void setMatchMode(int mode) {
405
		if (mode == 0) {
406
			this.matchMode[0].setSelection(true);
407
			return;
408
		}
409
		this.matchMode[0].setSelection(false);
410
		for (int i= 1; i < this.matchMode.length; i++) {
411
			this.matchMode[i].setSelection((mode & (1 <<i)) != 0);
412
		}
413
	}
414
	
379
	private int getIncludeMask() {
415
	private int getIncludeMask() {
380
		int mask= 0;
416
		int mask= 0;
381
		for (int i= 0; i < fIncludeMasks.length; i++) {
417
		for (int i= 0; i < fIncludeMasks.length; i++) {
Lines 459-464 Link Here
459
		match= new SearchPatternData(
495
		match= new SearchPatternData(
460
				getSearchFor(),
496
				getSearchFor(),
461
				getLimitTo(),
497
				getLimitTo(),
498
				getMatchMode(),
462
				fMatchLocations,
499
				fMatchLocations,
463
				pattern,
500
				pattern,
464
				fCaseSensitive.getSelection(),
501
				fCaseSensitive.getSelection(),
Lines 524-529 Link Here
524
		Control limitTo= createLimitTo(result);
561
		Control limitTo= createLimitTo(result);
525
		limitTo.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1));
562
		limitTo.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1));
526
563
564
		Control mode= createMatchMode(result);
565
		mode.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1));
566
527
		Control includeMask= createIncludeMask(result);
567
		Control includeMask= createIncludeMask(result);
528
		includeMask.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
568
		includeMask.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
529
569
Lines 665-671 Link Here
665
		SearchPatternData initialData= (SearchPatternData) fPreviousSearchPatterns.get(selectionIndex);
705
		SearchPatternData initialData= (SearchPatternData) fPreviousSearchPatterns.get(selectionIndex);
666
706
667
		setSearchFor(initialData.getSearchFor());
707
		setSearchFor(initialData.getSearchFor());
668
		setLimitTo(initialData.getSearchFor(), initialData.getLimitTo());
708
		setMatchMode(initialData.getMatchMode());
709
		int limitToVal= setLimitTo(initialData.getSearchFor(), initialData.getLimitTo());
669
		setIncludeMask(initialData.getIncludeMask());
710
		setIncludeMask(initialData.getIncludeMask());
670
		setMatchLocations(initialData.getMatchLocations());
711
		setMatchLocations(initialData.getMatchLocations());
671
712
Lines 695-701 Link Here
695
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_method, METHOD, false),
736
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_method, METHOD, false),
696
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_package, PACKAGE, false),
737
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_package, PACKAGE, false),
697
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_constructor, CONSTRUCTOR, false),
738
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_constructor, CONSTRUCTOR, false),
698
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_field, FIELD, false)
739
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_field, FIELD, false),
740
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_class, IJavaSearchConstants.CLASS, false),
741
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_interface, IJavaSearchConstants.INTERFACE, false),
742
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_enum, IJavaSearchConstants.ENUM, false),
743
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_annotation, IJavaSearchConstants.ANNOTATION_TYPE, false),
744
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_class_enum, IJavaSearchConstants.CLASS_AND_ENUM, false),
745
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_searchFor_class_interface, IJavaSearchConstants.CLASS_AND_INTERFACE, false)
699
		};
746
		};
700
747
701
		// Fill with dummy radio buttons
748
		// Fill with dummy radio buttons
Lines 812-818 Link Here
812
		updateUseJRE();
859
		updateUseJRE();
813
	}
860
	}
814
861
862
	private Control createMatchMode(Composite parent) {
863
		Group result= new Group(parent, SWT.NONE);
864
		result.setText(SearchMessages.SearchPage_matchMode_label); 
865
		result.setLayout(new GridLayout(2, true));
866
867
		this.matchMode = new Button[] {
868
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_matchMode_exact, SearchPattern.R_EXACT_MATCH, true),
869
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_matchMode_prefix,SearchPattern.R_PREFIX_MATCH, false),
870
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_matchMode_pattern,SearchPattern.R_PATTERN_MATCH, false),
871
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_matchMode_regexp,SearchPattern.R_REGEXP_MATCH, false),
872
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_matchMode_erasure,SearchPattern.R_ERASURE_MATCH, false),
873
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_matchMode_equivalent,SearchPattern.R_EQUIVALENT_MATCH, false),
874
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_matchMode_full,SearchPattern.R_FULL_MATCH, false),
875
			createButton(result, SWT.RADIO, SearchMessages.SearchPage_matchMode_camelcase,SearchPattern.R_CAMELCASE_MATCH, false),
876
		};
877
		return result;
878
	}
815
879
880
	
881
	
816
	protected final void performConfigureMatchLocation() {
882
	protected final void performConfigureMatchLocation() {
817
		for (int i= 0; i < fLimitTo.length; i++) {
883
		for (int i= 0; i < fLimitTo.length; i++) {
818
			Button curr= fLimitTo[i];
884
			Button curr= fLimitTo[i];
Lines 903-909 Link Here
903
		fCaseSensitive.setEnabled(fJavaElement == null);
969
		fCaseSensitive.setEnabled(fJavaElement == null);
904
970
905
		setSearchFor(initData.getSearchFor());
971
		setSearchFor(initData.getSearchFor());
906
		setLimitTo(initData.getSearchFor(), initData.getLimitTo());
972
		setMatchMode(initData.getMatchMode());
973
		int limitToVal= setLimitTo(initData.getSearchFor(), initData.getLimitTo());
907
		setIncludeMask(initData.getIncludeMask());
974
		setIncludeMask(initData.getIncludeMask());
908
		setMatchLocations(initData.getMatchLocations());
975
		setMatchLocations(initData.getMatchLocations());
909
976
(-)ui/org/eclipse/jdt/internal/ui/search/JavaSearchQuery.java (+4 lines)
Lines 40-45 Link Here
40
40
41
import org.eclipse.jdt.ui.JavaElementLabels;
41
import org.eclipse.jdt.ui.JavaElementLabels;
42
import org.eclipse.jdt.ui.search.ElementQuerySpecification;
42
import org.eclipse.jdt.ui.search.ElementQuerySpecification;
43
import org.eclipse.jdt.ui.search.FfrPatternQuerySpecification;
43
import org.eclipse.jdt.ui.search.IMatchPresentation;
44
import org.eclipse.jdt.ui.search.IMatchPresentation;
44
import org.eclipse.jdt.ui.search.IQueryParticipant;
45
import org.eclipse.jdt.ui.search.IQueryParticipant;
45
import org.eclipse.jdt.ui.search.ISearchRequestor;
46
import org.eclipse.jdt.ui.search.ISearchRequestor;
Lines 126-131 Link Here
126
				PatternQuerySpecification patternSpec = (PatternQuerySpecification) fPatternData;
127
				PatternQuerySpecification patternSpec = (PatternQuerySpecification) fPatternData;
127
				stringPattern= patternSpec.getPattern();
128
				stringPattern= patternSpec.getPattern();
128
				int matchMode= getMatchMode(stringPattern) | SearchPattern.R_ERASURE_MATCH;
129
				int matchMode= getMatchMode(stringPattern) | SearchPattern.R_ERASURE_MATCH;
130
				if (patternSpec instanceof FfrPatternQuerySpecification) {
131
					matchMode = ((FfrPatternQuerySpecification) patternSpec).matchMode();
132
				}
129
				if (patternSpec.isCaseSensitive())
133
				if (patternSpec.isCaseSensitive())
130
					matchMode |= SearchPattern.R_CASE_SENSITIVE;
134
					matchMode |= SearchPattern.R_CASE_SENSITIVE;
131
				pattern= SearchPattern.createPattern(patternSpec.getPattern(), patternSpec.getSearchFor(), patternSpec.getLimitTo(), matchMode);
135
				pattern= SearchPattern.createPattern(patternSpec.getPattern(), patternSpec.getSearchFor(), patternSpec.getLimitTo(), matchMode);
(-)ui/org/eclipse/jdt/internal/ui/search/SearchMessages.java (+15 lines)
Lines 71-76 Link Here
71
	public static String SearchPage_searchFor_field;
71
	public static String SearchPage_searchFor_field;
72
	public static String SearchPage_searchFor_package;
72
	public static String SearchPage_searchFor_package;
73
	public static String SearchPage_searchFor_constructor;
73
	public static String SearchPage_searchFor_constructor;
74
	public static String SearchPage_searchFor_class;
75
	public static String SearchPage_searchFor_interface;
76
	public static String SearchPage_searchFor_enum;
77
	public static String SearchPage_searchFor_annotation;
78
	public static String SearchPage_searchFor_class_enum;
79
	public static String SearchPage_searchFor_class_interface;
80
	public static String SearchPage_matchMode_label;
81
	public static String SearchPage_matchMode_exact;
82
	public static String SearchPage_matchMode_prefix;
83
	public static String SearchPage_matchMode_pattern;
84
	public static String SearchPage_matchMode_regexp;
85
	public static String SearchPage_matchMode_erasure;
86
	public static String SearchPage_matchMode_equivalent;
87
	public static String SearchPage_matchMode_full;
88
	public static String SearchPage_matchMode_camelcase;
74
	public static String SearchPage_limitTo_label;
89
	public static String SearchPage_limitTo_label;
75
	public static String SearchPage_limitTo_declarations;
90
	public static String SearchPage_limitTo_declarations;
76
	public static String SearchPage_limitTo_implementors;
91
	public static String SearchPage_limitTo_implementors;
(-)ui/org/eclipse/jdt/internal/ui/search/SearchMessages.properties (+23 lines)
Lines 53-58 Link Here
53
SearchPage_searchIn_projects=Re&quired projects
53
SearchPage_searchIn_projects=Re&quired projects
54
SearchPage_searchIn_libraries=Applicatio&n libraries
54
SearchPage_searchIn_libraries=Applicatio&n libraries
55
SearchPage_searchFor_constructor= Constr&uctor
55
SearchPage_searchFor_constructor= Constr&uctor
56
SearchPage_searchFor_class= &Class
57
SearchPage_searchFor_interface= &Interface
58
SearchPage_searchFor_enum= &Enum
59
SearchPage_searchFor_annotation= &Annotation
60
SearchPage_searchFor_class_enum= Class+En&um
61
SearchPage_searchFor_class_interface= Class+Inte&rface
62
63
SearchPage_matchMode_label= Match Mode
64
SearchPage_matchMode_exact= &Exact
65
SearchPage_matchMode_prefix= &Prefix
66
SearchPage_matchMode_pattern= Pa&ttern
67
SearchPage_matchMode_regexp= &Regexp
68
SearchPage_matchMode_erasure= Eras&ure
69
SearchPage_matchMode_equivalent= E&quivalent
70
SearchPage_matchMode_full= &Full
71
SearchPage_matchMode_camelcase= &Camel Case
56
72
57
SearchPage_limitTo_label= Limit To
73
SearchPage_limitTo_label= Limit To
58
SearchPage_limitTo_declarations= Dec&larations
74
SearchPage_limitTo_declarations= Dec&larations
Lines 65-70 Link Here
65
SearchPage_expression_label= Search strin&g (* = any string, ? = any character):
81
SearchPage_expression_label= Search strin&g (* = any string, ? = any character):
66
SearchPage_expression_caseSensitive= &Case sensitive
82
SearchPage_expression_caseSensitive= &Case sensitive
67
83
84
#SearchPage_searchJRE_label=Search the JRE s&ystem libraries
85
SearchPage_includeMask_label=Search include mask
86
SearchPage_includeMask_sources=Sources
87
SearchPage_includeMask_applicationLibraries=Application Libraries
88
SearchPage_includeMask_systemLibraries=System Libraries
89
SearchPage_includeMask_referencedProjects=Referenced Projects
90
68
# Concatenate two working set names e.g. "Source, Lib"
91
# Concatenate two working set names e.g. "Source, Lib"
69
SearchUtil_workingSetConcatenation= {0}, {1}
92
SearchUtil_workingSetConcatenation= {0}, {1}
70
93
(-)ui/org/eclipse/jdt/ui/search/FfrPatternQuerySpecification.java (+34 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation 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
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.ui.search;
12
13
import org.eclipse.jdt.core.search.IJavaSearchScope;
14
15
public class FfrPatternQuerySpecification extends PatternQuerySpecification {
16
private int matchMode;
17
public String[] logicalPatterns;
18
public int patternKind = 0;
19
20
public FfrPatternQuerySpecification(String pattern,
21
		int searchFor,
22
		int mode,
23
		boolean caseSensitive,
24
		int limitTo,
25
		IJavaSearchScope scope,
26
		String scopeDescription) {
27
	super(pattern, searchFor, caseSensitive, limitTo, scope, scopeDescription);
28
	this.matchMode = mode;
29
}
30
31
public int matchMode() {
32
	return this.matchMode;
33
}
34
}

Return to bug 306196