Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 74001 Details for
Bug 29692
[find/replace] Highlight all matches in editor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Initial effort (patches "org.eclipse.ui.workbench.texteditor")
findreplace-highlightall-alpha.diff (text/plain), 6.71 KB, created by
Cagatay Calli
on 2007-07-17 18:12:32 EDT
(
hide
)
Description:
Initial effort (patches "org.eclipse.ui.workbench.texteditor")
Filename:
MIME Type:
Creator:
Cagatay Calli
Created:
2007-07-17 18:12:32 EDT
Size:
6.71 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench.texteditor >Index: src/org/eclipse/ui/texteditor/FindReplaceAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java,v >retrieving revision 1.21 >diff -u -r1.21 FindReplaceAction.java >--- src/org/eclipse/ui/texteditor/FindReplaceAction.java 18 Apr 2007 12:20:16 -0000 1.21 >+++ src/org/eclipse/ui/texteditor/FindReplaceAction.java 17 Jul 2007 21:53:08 -0000 >@@ -122,6 +122,7 @@ > if (fPart instanceof ITextEditorExtension2) { > ITextEditorExtension2 extension= (ITextEditorExtension2) fPart; > isEditable= extension.isEditorInputModifiable(); >+ fDialog.setSourceViewer(((AbstractTextEditor)fPart).getSourceViewer()); > } else if (target != null) > isEditable= target.isEditable(); > fDialog.updateTarget(target, isEditable, false); >Index: src/org/eclipse/ui/texteditor/FindReplaceDialog.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java,v >retrieving revision 1.71 >diff -u -r1.71 FindReplaceDialog.java >--- src/org/eclipse/ui/texteditor/FindReplaceDialog.java 15 Jul 2007 14:32:09 -0000 1.71 >+++ src/org/eclipse/ui/texteditor/FindReplaceDialog.java 17 Jul 2007 21:53:10 -0000 >@@ -12,10 +12,27 @@ > > import java.util.ArrayList; > import java.util.HashSet; >+import java.util.Iterator; > import java.util.List; > import java.util.Set; > import java.util.regex.PatternSyntaxException; > >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.dialogs.IDialogSettings; >+import org.eclipse.jface.fieldassist.ComboContentAdapter; >+import org.eclipse.jface.fieldassist.FieldDecoration; >+import org.eclipse.jface.fieldassist.FieldDecorationRegistry; >+import org.eclipse.jface.resource.JFaceColors; >+import org.eclipse.jface.text.IFindReplaceTarget; >+import org.eclipse.jface.text.IFindReplaceTargetExtension; >+import org.eclipse.jface.text.IFindReplaceTargetExtension3; >+import org.eclipse.jface.text.IRegion; >+import org.eclipse.jface.text.Position; >+import org.eclipse.jface.text.Region; >+import org.eclipse.jface.text.TextUtilities; >+import org.eclipse.jface.text.source.Annotation; >+import org.eclipse.jface.text.source.AnnotationModel; >+import org.eclipse.jface.text.source.ISourceViewer; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.BusyIndicator; > import org.eclipse.swt.events.ModifyEvent; >@@ -36,21 +53,6 @@ > import org.eclipse.swt.widgets.Group; > import org.eclipse.swt.widgets.Label; > import org.eclipse.swt.widgets.Shell; >- >-import org.eclipse.jface.dialogs.Dialog; >-import org.eclipse.jface.dialogs.IDialogSettings; >-import org.eclipse.jface.fieldassist.ComboContentAdapter; >-import org.eclipse.jface.fieldassist.FieldDecoration; >-import org.eclipse.jface.fieldassist.FieldDecorationRegistry; >-import org.eclipse.jface.resource.JFaceColors; >- >-import org.eclipse.jface.text.IFindReplaceTarget; >-import org.eclipse.jface.text.IFindReplaceTargetExtension; >-import org.eclipse.jface.text.IFindReplaceTargetExtension3; >-import org.eclipse.jface.text.IRegion; >-import org.eclipse.jface.text.Region; >-import org.eclipse.jface.text.TextUtilities; >- > import org.eclipse.ui.IEditorPart; > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchWindow; >@@ -202,6 +204,10 @@ > * @since 3.0 > */ > private boolean fGiveFocusToFindField= true; >+ >+ private ISourceViewer fSourceViewer; >+ >+ private Button fHighlightAllButton; > > > /** >@@ -341,6 +347,15 @@ > > // Make the all the buttons the same size as the Remove Selection button. > fReplaceAllButton.setEnabled(isEditable()); >+ >+ >+ fHighlightAllButton= makeButton(panel, "Highlight All", 106, false, new SelectionAdapter() { //$NON-NLS-1$ >+ public void widgetSelected(SelectionEvent e) { >+ performHighlightAll(true); >+ updateFindHistory(); >+ } >+ }); >+ setGridData(fHighlightAllButton, SWT.FILL, true, SWT.FILL, false); > > return panel; > } >@@ -1380,6 +1395,7 @@ > * Locates the user's findString in the text of the target. > */ > private void performSearch() { >+ clearFindAnnotations(); > performSearch(isIncrementalSearch() && !isRegExSearchAvailableAndChecked(), true); > } > >@@ -1827,4 +1843,85 @@ > settings.put(sectionName, names); > > } >+ >+ /** >+ * Sets the source viewer to the argument if the target supports it >+ * @param sourceViewer the source viewer >+ */ >+ public void setSourceViewer(ISourceViewer sourceViewer){ >+ fSourceViewer = sourceViewer; >+ } >+ >+ public boolean highlightAll(String findString,boolean caseSensitive,boolean wholeWord,boolean regExSearch){ >+ int index = 1; >+ int startIndex = -1; >+ boolean somethingFound = false; >+ >+ if(fSourceViewer==null) >+ return false; >+ >+ while(index != -1){ >+ index = findAndSelect(index+findString.length(),findString, true, caseSensitive, wholeWord, regExSearch); >+ >+ if(startIndex != -1 && startIndex == index) break; >+ >+ if(index != -1){ >+ if(!somethingFound) startIndex = index; >+ >+ somethingFound = true; >+ >+ AnnotationModel model = (AnnotationModel) fSourceViewer.getAnnotationModel(); >+ Annotation findAnnotation = new Annotation("org.eclipse.search.results",true,findString); //$NON-NLS-1$ >+ Position position = new Position(index,findString.length()); >+ model.addAnnotation(findAnnotation, position); >+ >+ } >+ } >+ >+ return somethingFound; >+ } >+ >+ protected void performHighlightAll(boolean mustInitIncrementalBaseLocation) { >+ clearFindAnnotations(); >+ >+ if (mustInitIncrementalBaseLocation) >+ initIncrementalBaseLocation(); >+ >+ String findString= getFindString(); >+ boolean somethingFound= false; >+ >+ if (findString != null && findString.length() > 0) { >+ >+ try { >+ somethingFound= highlightAll(findString, isCaseSensitiveSearch(), isWholeWordSearch(), isRegExSearchAvailableAndChecked()); >+ if (somethingFound) { >+ statusMessage(""); //$NON-NLS-1$ >+ } else { >+ statusMessage(EditorMessages.FindReplace_Status_noMatch_label); >+ } >+ } catch (PatternSyntaxException ex) { >+ statusError(ex.getLocalizedMessage()); >+ } catch (IllegalStateException ex) { >+ // we don't keep state in this dialog >+ } >+ } >+ writeSelection(); >+ updateButtonState(!somethingFound); >+ >+ } >+ >+ private void clearFindAnnotations(){ >+ if(fSourceViewer==null) >+ return; >+ >+ AnnotationModel model = (AnnotationModel) fSourceViewer.getAnnotationModel(); >+ Iterator iter = model.getAnnotationIterator(); >+ >+ while(iter.hasNext()){ >+ Annotation findAnnotation = (Annotation) iter.next(); >+ if(findAnnotation.getType().equals("org.eclipse.search.results")){ //$NON-NLS-1$ >+ model.removeAnnotation(findAnnotation); >+ } >+ } >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 29692
:
33046
|
74001
|
74158
|
74197
|
74294
|
74295
|
74445
|
74447
|
74449
|
74801
|
264257