Lines 12-21
Link Here
|
12 |
|
12 |
|
13 |
import java.util.ArrayList; |
13 |
import java.util.ArrayList; |
14 |
import java.util.HashSet; |
14 |
import java.util.HashSet; |
|
|
15 |
import java.util.Iterator; |
15 |
import java.util.List; |
16 |
import java.util.List; |
16 |
import java.util.Set; |
17 |
import java.util.Set; |
17 |
import java.util.regex.PatternSyntaxException; |
18 |
import java.util.regex.PatternSyntaxException; |
18 |
|
19 |
|
|
|
20 |
import org.eclipse.jface.dialogs.Dialog; |
21 |
import org.eclipse.jface.dialogs.IDialogSettings; |
22 |
import org.eclipse.jface.fieldassist.ComboContentAdapter; |
23 |
import org.eclipse.jface.fieldassist.FieldDecoration; |
24 |
import org.eclipse.jface.fieldassist.FieldDecorationRegistry; |
25 |
import org.eclipse.jface.resource.JFaceColors; |
26 |
import org.eclipse.jface.text.IFindReplaceTarget; |
27 |
import org.eclipse.jface.text.IFindReplaceTargetExtension; |
28 |
import org.eclipse.jface.text.IFindReplaceTargetExtension3; |
29 |
import org.eclipse.jface.text.IRegion; |
30 |
import org.eclipse.jface.text.Position; |
31 |
import org.eclipse.jface.text.Region; |
32 |
import org.eclipse.jface.text.TextUtilities; |
33 |
import org.eclipse.jface.text.source.Annotation; |
34 |
import org.eclipse.jface.text.source.AnnotationModel; |
35 |
import org.eclipse.jface.text.source.ISourceViewer; |
19 |
import org.eclipse.swt.SWT; |
36 |
import org.eclipse.swt.SWT; |
20 |
import org.eclipse.swt.custom.BusyIndicator; |
37 |
import org.eclipse.swt.custom.BusyIndicator; |
21 |
import org.eclipse.swt.events.ModifyEvent; |
38 |
import org.eclipse.swt.events.ModifyEvent; |
Lines 36-56
Link Here
|
36 |
import org.eclipse.swt.widgets.Group; |
53 |
import org.eclipse.swt.widgets.Group; |
37 |
import org.eclipse.swt.widgets.Label; |
54 |
import org.eclipse.swt.widgets.Label; |
38 |
import org.eclipse.swt.widgets.Shell; |
55 |
import org.eclipse.swt.widgets.Shell; |
39 |
|
|
|
40 |
import org.eclipse.jface.dialogs.Dialog; |
41 |
import org.eclipse.jface.dialogs.IDialogSettings; |
42 |
import org.eclipse.jface.fieldassist.ComboContentAdapter; |
43 |
import org.eclipse.jface.fieldassist.FieldDecoration; |
44 |
import org.eclipse.jface.fieldassist.FieldDecorationRegistry; |
45 |
import org.eclipse.jface.resource.JFaceColors; |
46 |
|
47 |
import org.eclipse.jface.text.IFindReplaceTarget; |
48 |
import org.eclipse.jface.text.IFindReplaceTargetExtension; |
49 |
import org.eclipse.jface.text.IFindReplaceTargetExtension3; |
50 |
import org.eclipse.jface.text.IRegion; |
51 |
import org.eclipse.jface.text.Region; |
52 |
import org.eclipse.jface.text.TextUtilities; |
53 |
|
54 |
import org.eclipse.ui.IEditorPart; |
56 |
import org.eclipse.ui.IEditorPart; |
55 |
import org.eclipse.ui.IWorkbenchPage; |
57 |
import org.eclipse.ui.IWorkbenchPage; |
56 |
import org.eclipse.ui.IWorkbenchWindow; |
58 |
import org.eclipse.ui.IWorkbenchWindow; |
Lines 202-207
Link Here
|
202 |
* @since 3.0 |
204 |
* @since 3.0 |
203 |
*/ |
205 |
*/ |
204 |
private boolean fGiveFocusToFindField= true; |
206 |
private boolean fGiveFocusToFindField= true; |
|
|
207 |
|
208 |
private ISourceViewer fSourceViewer; |
209 |
|
210 |
private Button fHighlightAllButton; |
205 |
|
211 |
|
206 |
|
212 |
|
207 |
/** |
213 |
/** |
Lines 341-346
Link Here
|
341 |
|
347 |
|
342 |
// Make the all the buttons the same size as the Remove Selection button. |
348 |
// Make the all the buttons the same size as the Remove Selection button. |
343 |
fReplaceAllButton.setEnabled(isEditable()); |
349 |
fReplaceAllButton.setEnabled(isEditable()); |
|
|
350 |
|
351 |
|
352 |
fHighlightAllButton= makeButton(panel, "Highlight All", 106, false, new SelectionAdapter() { //$NON-NLS-1$ |
353 |
public void widgetSelected(SelectionEvent e) { |
354 |
performHighlightAll(true); |
355 |
updateFindHistory(); |
356 |
} |
357 |
}); |
358 |
setGridData(fHighlightAllButton, SWT.FILL, true, SWT.FILL, false); |
344 |
|
359 |
|
345 |
return panel; |
360 |
return panel; |
346 |
} |
361 |
} |
Lines 1380-1385
Link Here
|
1380 |
* Locates the user's findString in the text of the target. |
1395 |
* Locates the user's findString in the text of the target. |
1381 |
*/ |
1396 |
*/ |
1382 |
private void performSearch() { |
1397 |
private void performSearch() { |
|
|
1398 |
clearFindAnnotations(); |
1383 |
performSearch(isIncrementalSearch() && !isRegExSearchAvailableAndChecked(), true); |
1399 |
performSearch(isIncrementalSearch() && !isRegExSearchAvailableAndChecked(), true); |
1384 |
} |
1400 |
} |
1385 |
|
1401 |
|
Lines 1827-1830
Link Here
|
1827 |
settings.put(sectionName, names); |
1843 |
settings.put(sectionName, names); |
1828 |
|
1844 |
|
1829 |
} |
1845 |
} |
|
|
1846 |
|
1847 |
/** |
1848 |
* Sets the source viewer to the argument if the target supports it |
1849 |
* @param sourceViewer the source viewer |
1850 |
*/ |
1851 |
public void setSourceViewer(ISourceViewer sourceViewer){ |
1852 |
fSourceViewer = sourceViewer; |
1853 |
} |
1854 |
|
1855 |
public boolean highlightAll(String findString,boolean caseSensitive,boolean wholeWord,boolean regExSearch){ |
1856 |
int index = 1; |
1857 |
int startIndex = -1; |
1858 |
boolean somethingFound = false; |
1859 |
|
1860 |
if(fSourceViewer==null) |
1861 |
return false; |
1862 |
|
1863 |
while(index != -1){ |
1864 |
index = findAndSelect(index+findString.length(),findString, true, caseSensitive, wholeWord, regExSearch); |
1865 |
|
1866 |
if(startIndex != -1 && startIndex == index) break; |
1867 |
|
1868 |
if(index != -1){ |
1869 |
if(!somethingFound) startIndex = index; |
1870 |
|
1871 |
somethingFound = true; |
1872 |
|
1873 |
AnnotationModel model = (AnnotationModel) fSourceViewer.getAnnotationModel(); |
1874 |
Annotation findAnnotation = new Annotation("org.eclipse.search.results",true,findString); //$NON-NLS-1$ |
1875 |
Position position = new Position(index,findString.length()); |
1876 |
model.addAnnotation(findAnnotation, position); |
1877 |
|
1878 |
} |
1879 |
} |
1880 |
|
1881 |
return somethingFound; |
1882 |
} |
1883 |
|
1884 |
protected void performHighlightAll(boolean mustInitIncrementalBaseLocation) { |
1885 |
clearFindAnnotations(); |
1886 |
|
1887 |
if (mustInitIncrementalBaseLocation) |
1888 |
initIncrementalBaseLocation(); |
1889 |
|
1890 |
String findString= getFindString(); |
1891 |
boolean somethingFound= false; |
1892 |
|
1893 |
if (findString != null && findString.length() > 0) { |
1894 |
|
1895 |
try { |
1896 |
somethingFound= highlightAll(findString, isCaseSensitiveSearch(), isWholeWordSearch(), isRegExSearchAvailableAndChecked()); |
1897 |
if (somethingFound) { |
1898 |
statusMessage(""); //$NON-NLS-1$ |
1899 |
} else { |
1900 |
statusMessage(EditorMessages.FindReplace_Status_noMatch_label); |
1901 |
} |
1902 |
} catch (PatternSyntaxException ex) { |
1903 |
statusError(ex.getLocalizedMessage()); |
1904 |
} catch (IllegalStateException ex) { |
1905 |
// we don't keep state in this dialog |
1906 |
} |
1907 |
} |
1908 |
writeSelection(); |
1909 |
updateButtonState(!somethingFound); |
1910 |
|
1911 |
} |
1912 |
|
1913 |
private void clearFindAnnotations(){ |
1914 |
if(fSourceViewer==null) |
1915 |
return; |
1916 |
|
1917 |
AnnotationModel model = (AnnotationModel) fSourceViewer.getAnnotationModel(); |
1918 |
Iterator iter = model.getAnnotationIterator(); |
1919 |
|
1920 |
while(iter.hasNext()){ |
1921 |
Annotation findAnnotation = (Annotation) iter.next(); |
1922 |
if(findAnnotation.getType().equals("org.eclipse.search.results")){ //$NON-NLS-1$ |
1923 |
model.removeAnnotation(findAnnotation); |
1924 |
} |
1925 |
} |
1926 |
} |
1830 |
} |
1927 |
} |