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 139425 Details for
Bug 191432
[spell checking] Allow to spell check projects
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
fix_191432.txt (text/plain), 53.87 KB, created by
Benno Baumgartner
on 2009-06-17 09:51:44 EDT
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Benno Baumgartner
Created:
2009-06-17 09:51:44 EDT
Size:
53.87 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.search >Index: search/org/eclipse/search/internal/ui/text/FileSearchQuery.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java,v >retrieving revision 1.51 >diff -u -r1.51 FileSearchQuery.java >--- search/org/eclipse/search/internal/ui/text/FileSearchQuery.java 31 Dec 2008 21:13:51 -0000 1.51 >+++ search/org/eclipse/search/internal/ui/text/FileSearchQuery.java 17 Jun 2009 13:52:38 -0000 >@@ -29,14 +29,13 @@ > import org.eclipse.search.internal.core.text.PatternConstructor; > import org.eclipse.search.internal.ui.Messages; > import org.eclipse.search.internal.ui.SearchMessages; >-import org.eclipse.search.ui.ISearchQuery; > import org.eclipse.search.ui.ISearchResult; > import org.eclipse.search.ui.text.AbstractTextSearchResult; > import org.eclipse.search.ui.text.FileTextSearchScope; > import org.eclipse.search.ui.text.Match; > > >-public class FileSearchQuery implements ISearchQuery { >+public class FileSearchQuery implements IFileSearchQuery { > > private final static class TextSearchResultCollector extends TextSearchRequestor { > >@@ -275,4 +274,11 @@ > } > return fResult; > } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean isShowLineMatches() { >+ return !isFileNameSearch(); >+ } > } >Index: search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java,v >retrieving revision 1.18 >diff -u -r1.18 FileTreeContentProvider.java >--- search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java 11 Sep 2008 16:42:37 -0000 1.18 >+++ search/org/eclipse/search/internal/ui/text/FileTreeContentProvider.java 17 Jun 2009 13:52:38 -0000 >@@ -71,7 +71,7 @@ > private synchronized void initialize(AbstractTextSearchResult result) { > fResult= result; > fChildrenMap= new HashMap(); >- boolean showLineMatches= !((FileSearchQuery) fResult.getQuery()).isFileNameSearch(); >+ boolean showLineMatches= ((IFileSearchQuery) fResult.getQuery()).isShowLineMatches(); > > if (result != null) { > Object[] elements= result.getElements(); >Index: search/org/eclipse/search/internal/ui/text/FileSearchPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java,v >retrieving revision 1.53 >diff -u -r1.53 FileSearchPage.java >--- search/org/eclipse/search/internal/ui/text/FileSearchPage.java 11 Sep 2008 12:00:39 -0000 1.53 >+++ search/org/eclipse/search/internal/ui/text/FileSearchPage.java 17 Jun 2009 13:52:38 -0000 >@@ -51,6 +51,7 @@ > import org.eclipse.search.internal.ui.Messages; > import org.eclipse.search.internal.ui.SearchMessages; > import org.eclipse.search.ui.IContextMenuConstants; >+import org.eclipse.search.ui.ISearchQuery; > import org.eclipse.search.ui.ISearchResultViewPart; > import org.eclipse.search.ui.text.AbstractTextSearchResult; > import org.eclipse.search.ui.text.AbstractTextSearchViewPage; >@@ -198,8 +199,8 @@ > addSortActions(mgr); > fActionGroup.setContext(new ActionContext(getSite().getSelectionProvider().getSelection())); > fActionGroup.fillContextMenu(mgr); >- FileSearchQuery query= (FileSearchQuery) getInput().getQuery(); >- if (query.getSearchString().length() > 0) { >+ ISearchQuery query= getInput().getQuery(); >+ if (query instanceof FileSearchQuery && ((FileSearchQuery) query).getSearchString().length() > 0) { > IStructuredSelection selection= (IStructuredSelection) getViewer().getSelection(); > if (!selection.isEmpty()) { > ReplaceAction replaceSelection= new ReplaceAction(getSite().getShell(), (FileSearchResult) getInput(), selection.toArray(), true); >@@ -355,7 +356,7 @@ > > private boolean showLineMatches() { > AbstractTextSearchResult input= getInput(); >- return getLayout() == FLAG_LAYOUT_TREE && input != null && !((FileSearchQuery) input.getQuery()).isFileNameSearch(); >+ return getLayout() == FLAG_LAYOUT_TREE && input != null && ((IFileSearchQuery) input.getQuery()).isShowLineMatches(); > } > > } >Index: search/org/eclipse/search/internal/ui/text/TextSearchPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.search/search/org/eclipse/search/internal/ui/text/TextSearchPage.java,v >retrieving revision 1.116 >diff -u -r1.116 TextSearchPage.java >--- search/org/eclipse/search/internal/ui/text/TextSearchPage.java 26 May 2009 13:18:14 -0000 1.116 >+++ search/org/eclipse/search/internal/ui/text/TextSearchPage.java 17 Jun 2009 13:52:38 -0000 >@@ -17,7 +17,6 @@ > import java.io.IOException; > import java.io.StringReader; > import java.util.ArrayList; >-import java.util.HashSet; > import java.util.Iterator; > import java.util.List; > import java.util.regex.PatternSyntaxException; >@@ -38,13 +37,8 @@ > > import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.IStatus; > >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.IWorkspaceRoot; >-import org.eclipse.core.resources.ResourcesPlugin; >- > import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.dialogs.DialogPage; > import org.eclipse.jface.dialogs.ErrorDialog; >@@ -52,7 +46,6 @@ > import org.eclipse.jface.fieldassist.ComboContentAdapter; > import org.eclipse.jface.resource.JFaceColors; > import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.jface.viewers.IStructuredSelection; > > import org.eclipse.jface.text.FindReplaceDocumentAdapter; > import org.eclipse.jface.text.FindReplaceDocumentAdapterContentProposalProvider; >@@ -71,8 +64,8 @@ > import org.eclipse.search.internal.ui.ISearchHelpContextIds; > import org.eclipse.search.internal.ui.SearchMessages; > import org.eclipse.search.internal.ui.SearchPlugin; >+import org.eclipse.search.internal.ui.text.FileSearchScopeConfigurationBlock.FileSearchScopeConfigurationBlockListener; > import org.eclipse.search.internal.ui.util.FileTypeEditor; >-import org.eclipse.search.internal.ui.util.SWTUtil; > import org.eclipse.search.ui.IReplacePage; > import org.eclipse.search.ui.ISearchPage; > import org.eclipse.search.ui.ISearchPageContainer; >@@ -103,20 +96,18 @@ > private boolean fFirstTime= true; > private boolean fIsCaseSensitive; > private boolean fIsRegExSearch; >- private boolean fSearchDerived; > > private Combo fPattern; > private Button fIsCaseSensitiveCheckbox; >- private Combo fExtensions; > private Button fIsRegExCheckbox; > private CLabel fStatusLabel; >- private Button fSearchDerivedCheckbox; > > private ISearchPageContainer fContainer; >- private FileTypeEditor fFileTypeEditor; > > private ContentAssistCommandAdapter fPatterFieldContentAssist; > >+ private FileSearchScopeConfigurationBlock fScopeConfigurationBlock; >+ > private static class SearchPatternData { > public final boolean isCaseSensitive; > public final boolean isRegExSearch; >@@ -215,11 +206,23 @@ > } > } > >+ public TextSearchPage() { >+ fScopeConfigurationBlock= new FileSearchScopeConfigurationBlock(new FileSearchScopeConfigurationBlockListener() { >+ public void extensionsTextChanged() { >+ updateOKStatus(); >+ } >+ >+ public void derivedSelectionChanged() { >+ writeConfiguration(); >+ } >+ }); >+ } >+ > //---- Action Handling ------------------------------------------------ > > private ISearchQuery newQuery() throws CoreException { > SearchPatternData data= getPatternData(); >- TextSearchPageInput input= new TextSearchPageInput(data.textPattern, data.isCaseSensitive, data.isRegExSearch, createTextSearchScope()); >+ TextSearchPageInput input= new TextSearchPageInput(data.textPattern, data.isCaseSensitive, data.isRegExSearch, fScopeConfigurationBlock.createTextSearchScope()); > return TextSearchQueryProvider.getPreferred().createQuery(input); > } > >@@ -269,71 +272,6 @@ > return fPattern.getText(); > } > >- public FileTextSearchScope createTextSearchScope() { >- // Setup search scope >- switch (getContainer().getSelectedScope()) { >- case ISearchPageContainer.WORKSPACE_SCOPE: >- return FileTextSearchScope.newWorkspaceScope(getExtensions(), fSearchDerived); >- case ISearchPageContainer.SELECTION_SCOPE: >- return getSelectedResourcesScope(); >- case ISearchPageContainer.SELECTED_PROJECTS_SCOPE: >- return getEnclosingProjectScope(); >- case ISearchPageContainer.WORKING_SET_SCOPE: >- IWorkingSet[] workingSets= getContainer().getSelectedWorkingSets(); >- return FileTextSearchScope.newSearchScope(workingSets, getExtensions(), fSearchDerived); >- default: >- // unknown scope >- return FileTextSearchScope.newWorkspaceScope(getExtensions(), fSearchDerived); >- } >- } >- >- private FileTextSearchScope getSelectedResourcesScope() { >- HashSet resources= new HashSet(); >- ISelection sel= getContainer().getSelection(); >- if (sel instanceof IStructuredSelection && !sel.isEmpty()) { >- Iterator iter= ((IStructuredSelection) sel).iterator(); >- while (iter.hasNext()) { >- Object curr= iter.next(); >- if (curr instanceof IWorkingSet) { >- IWorkingSet workingSet= (IWorkingSet) curr; >- if (workingSet.isAggregateWorkingSet() && workingSet.isEmpty()) { >- return FileTextSearchScope.newWorkspaceScope(getExtensions(), fSearchDerived); >- } >- IAdaptable[] elements= workingSet.getElements(); >- for (int i= 0; i < elements.length; i++) { >- IResource resource= (IResource)elements[i].getAdapter(IResource.class); >- if (resource != null && resource.isAccessible()) { >- resources.add(resource); >- } >- } >- } else if (curr instanceof IAdaptable) { >- IResource resource= (IResource) ((IAdaptable)curr).getAdapter(IResource.class); >- if (resource != null && resource.isAccessible()) { >- resources.add(resource); >- } >- } >- } >- } >- IResource[] arr= (IResource[]) resources.toArray(new IResource[resources.size()]); >- return FileTextSearchScope.newSearchScope(arr, getExtensions(), fSearchDerived); >- } >- >- private FileTextSearchScope getEnclosingProjectScope() { >- String[] enclosingProjectName= getContainer().getSelectedProjectNames(); >- if (enclosingProjectName == null) { >- return FileTextSearchScope.newWorkspaceScope(getExtensions(), fSearchDerived); >- } >- >- IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); >- IResource[] res= new IResource[enclosingProjectName.length]; >- for (int i= 0; i < res.length; i++) { >- res[i]= root.getProject(enclosingProjectName[i]); >- } >- >- return FileTextSearchScope.newSearchScope(res, getExtensions(), fSearchDerived); >- } >- >- > private SearchPatternData findInPrevious(String pattern) { > for (Iterator iter= fPreviousSearchPatterns.iterator(); iter.hasNext();) { > SearchPatternData element= (SearchPatternData) iter.next(); >@@ -358,7 +296,7 @@ > getPattern(), > isCaseSensitive(), > fIsRegExCheckbox.getSelection(), >- getExtensions(), >+ fScopeConfigurationBlock.getExtensions(), > getContainer().getSelectedScope(), > getContainer().getSelectedWorkingSets()); > fPreviousSearchPatterns.add(0, match); >@@ -385,10 +323,6 @@ > return patterns; > } > >- private String[] getExtensions() { >- return fFileTypeEditor.getFileTypes(); >- } >- > private boolean isCaseSensitive() { > return fIsCaseSensitiveCheckbox.getSelection(); > } >@@ -402,13 +336,13 @@ > fFirstTime= false; > // Set item and text here to prevent page from resizing > fPattern.setItems(getPreviousSearchPatterns()); >- fExtensions.setItems(getPreviousExtensions()); >+ fScopeConfigurationBlock.setExtensions(getPreviousExtensions()); > // if (fExtensions.getItemCount() == 0) { > // loadFilePatternDefaults(); > // } > if (!initializePatternControl()) { > fPattern.select(0); >- fExtensions.setText("*"); //$NON-NLS-1$ >+ fScopeConfigurationBlock.setExtensionsText("*"); //$NON-NLS-1$ > handleWidgetSelected(); > } > } >@@ -420,7 +354,7 @@ > > final void updateOKStatus() { > boolean regexStatus= validateRegex(); >- boolean hasFilePattern= fExtensions.getText().length() > 0; >+ boolean hasFilePattern= fScopeConfigurationBlock.getExtensionsText().length() > 0; > getContainer().setPerformActionEnabled(regexStatus && hasFilePattern); > } > >@@ -443,7 +377,7 @@ > data.heightHint= convertHeightInCharsToPixels(1) / 3; > separator.setLayoutData(data); > >- addFileNameControls(result); >+ fScopeConfigurationBlock.createControl(result); > > setControl(result); > Dialog.applyDialogFont(result); >@@ -558,7 +492,7 @@ > fIsCaseSensitiveCheckbox.setSelection(patternData.isCaseSensitive); > fIsRegExCheckbox.setSelection(patternData.isRegExSearch); > fPattern.setText(patternData.textPattern); >- fFileTypeEditor.setFileTypes(patternData.fileNamePatterns); >+ fScopeConfigurationBlock.setFileTypes(patternData.fileNamePatterns); > if (patternData.workingSets != null) > getContainer().setSelectedWorkingSets(patternData.workingSets); > else >@@ -576,13 +510,13 @@ > fPattern.setText(insertEscapeChars(text)); > > if (getPreviousExtensions().length > 0) { >- fExtensions.setText(getPreviousExtensions()[0]); >+ fScopeConfigurationBlock.setExtensionsText(getPreviousExtensions()[0]); > } else { > String extension= getExtensionFromEditor(); > if (extension != null) >- fExtensions.setText(extension); >+ fScopeConfigurationBlock.setExtensionsText(extension); > else >- fExtensions.setText("*"); //$NON-NLS-1$ >+ fScopeConfigurationBlock.setExtensionsText("*"); //$NON-NLS-1$ > } > return true; > } >@@ -634,61 +568,13 @@ > return null; > } > >- private void addFileNameControls(Composite group) { >- // grid layout with 2 columns >- >- // Line with label, combo and button >- Label label= new Label(group, SWT.LEAD); >- label.setText(SearchMessages.SearchPage_fileNamePatterns_text); >- label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); >- label.setFont(group.getFont()); >- >- fExtensions= new Combo(group, SWT.SINGLE | SWT.BORDER); >- fExtensions.addModifyListener(new ModifyListener() { >- public void modifyText(ModifyEvent e) { >- updateOKStatus(); >- } >- }); >- GridData data= new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1); >- data.widthHint= convertWidthInCharsToPixels(50); >- fExtensions.setLayoutData(data); >- fExtensions.setFont(group.getFont()); >- >- Button button= new Button(group, SWT.PUSH); >- button.setText(SearchMessages.SearchPage_browse); >- GridData gridData= new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1); >- gridData.widthHint= SWTUtil.getButtonWidthHint(button); >- button.setLayoutData(gridData); >- button.setFont(group.getFont()); >- >- fFileTypeEditor= new FileTypeEditor(fExtensions, button); >- >- // Text line which explains the special characters >- Label description= new Label(group, SWT.LEAD); >- description.setText(SearchMessages.SearchPage_fileNamePatterns_hint); >- description.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); >- description.setFont(group.getFont()); >- >- fSearchDerivedCheckbox= new Button(group, SWT.CHECK); >- fSearchDerivedCheckbox.setText(SearchMessages.TextSearchPage_searchDerived_label); >- >- fSearchDerivedCheckbox.setSelection(fSearchDerived); >- fSearchDerivedCheckbox.addSelectionListener(new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- fSearchDerived= fSearchDerivedCheckbox.getSelection(); >- writeConfiguration(); >- } >- }); >- fSearchDerivedCheckbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); >- fSearchDerivedCheckbox.setFont(group.getFont()); >- } >- > /** > * Sets the search page's container. > * @param container the container to set > */ > public void setContainer(ISearchPageContainer container) { > fContainer= container; >+ fScopeConfigurationBlock.setContainer(container); > } > > private ISearchPageContainer getContainer() { >@@ -727,7 +613,7 @@ > IDialogSettings s= getDialogSettings(); > fIsCaseSensitive= s.getBoolean(STORE_CASE_SENSITIVE); > fIsRegExSearch= s.getBoolean(STORE_IS_REG_EX_SEARCH); >- fSearchDerived= s.getBoolean(STORE_SEARCH_DERIVED); >+ fScopeConfigurationBlock.setSearchDerived(s.getBoolean(STORE_SEARCH_DERIVED)); > > try { > int historySize= s.getInt(STORE_HISTORY_SIZE); >@@ -752,7 +638,7 @@ > IDialogSettings s= getDialogSettings(); > s.put(STORE_CASE_SENSITIVE, fIsCaseSensitive); > s.put(STORE_IS_REG_EX_SEARCH, fIsRegExSearch); >- s.put(STORE_SEARCH_DERIVED, fSearchDerived); >+ s.put(STORE_SEARCH_DERIVED, fScopeConfigurationBlock.getSearchDerived()); > > int historySize= Math.min(fPreviousSearchPatterns.size(), HISTORY_SIZE); > s.put(STORE_HISTORY_SIZE, historySize); >Index: search/org/eclipse/search/internal/ui/text/FileSearchResult.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchResult.java,v >retrieving revision 1.11 >diff -u -r1.11 FileSearchResult.java >--- search/org/eclipse/search/internal/ui/text/FileSearchResult.java 31 Dec 2008 21:13:50 -0000 1.11 >+++ search/org/eclipse/search/internal/ui/text/FileSearchResult.java 17 Jun 2009 13:52:38 -0000 >@@ -28,9 +28,9 @@ > public class FileSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter { > private final Match[] EMPTY_ARR= new Match[0]; > >- private FileSearchQuery fQuery; >+ private IFileSearchQuery fQuery; > >- public FileSearchResult(FileSearchQuery job) { >+ public FileSearchResult(IFileSearchQuery job) { > fQuery= job; > } > public ImageDescriptor getImageDescriptor() { >Index: search/org/eclipse/search/internal/ui/SearchMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.properties,v >retrieving revision 1.139 >diff -u -r1.139 SearchMessages.properties >--- search/org/eclipse/search/internal/ui/SearchMessages.properties 26 May 2009 13:18:14 -0000 1.139 >+++ search/org/eclipse/search/internal/ui/SearchMessages.properties 17 Jun 2009 13:52:38 -0000 >@@ -230,6 +230,15 @@ > SelectAllAction_label= Select A&ll > SelectAllAction_tooltip= Select All > >+SpellingSearchPage_spellingEngineDropDown_label=Spelling Engine: >+SpellingSearchPage_spellingEnginePreferencePage_link=Configure the spelling engines on the <a>Spelling Preference Page</a>. >+SpellingSearchQuery_query_label=Spelling Problems Search >+SpellingSearchQuery_result11_label=1 spelling problem in 1 file >+SpellingSearchQuery_result1n_label={0} spelling problem in {1} files >+SpellingSearchQuery_resultn1_label={0} spelling problems in 1 file >+SpellingSearchQuery_resultnn_label={0} spelling problems in {1} files >+SpellingSearchResultPage_fixProblemMenu_label=Fix Spelling Problem >+ > RemovePotentialMatchesAction_removePotentialMatch_text= Remove Potential Match > RemovePotentialMatchesAction_removePotentialMatch_tooltip= Remove Potential Match > RemovePotentialMatchesAction_removePotentialMatches_text= Remove potential Matches >Index: search/org/eclipse/search/internal/ui/SearchMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchMessages.java,v >retrieving revision 1.32 >diff -u -r1.32 SearchMessages.java >--- search/org/eclipse/search/internal/ui/SearchMessages.java 11 Sep 2008 12:00:38 -0000 1.32 >+++ search/org/eclipse/search/internal/ui/SearchMessages.java 17 Jun 2009 13:52:38 -0000 >@@ -196,6 +196,17 @@ > public static String RemovePotentialMatchesAction_dialog_title; > public static String RemovePotentialMatchesAction_dialog_message; > public static String OpenWithMenu_label; >+ >+ public static String SpellingSearchPage_spellingEngineDropDown_label; >+ public static String SpellingSearchPage_spellingEnginePreferencePage_link; >+ public static String SpellingSearchQuery_query_label; >+ public static String SpellingSearchQuery_result11_label; >+ public static String SpellingSearchQuery_result1n_label; >+ public static String SpellingSearchQuery_resultn1_label; >+ public static String SpellingSearchQuery_resultnn_label; >+ public static String SpellingSearchResultPage_fixProblemMenu_label; >+ >+ > static { > NLS.initializeMessages(BUNDLE_NAME, SearchMessages.class); > } >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.search/plugin.xml,v >retrieving revision 1.100 >diff -u -r1.100 plugin.xml >--- plugin.xml 7 Oct 2008 09:17:29 -0000 1.100 >+++ plugin.xml 17 Jun 2009 13:52:38 -0000 >@@ -394,4 +394,30 @@ > point="org.eclipse.core.runtime.preferences"> > <initializer class="org.eclipse.search.internal.ui.SearchPreferenceInitializer"/> > </extension> >+ >+ <!-- >+ Spelling Problem Search >+ --> >+ >+ <extension >+ point="org.eclipse.search.searchPages"> >+ <page >+ canSearchEnclosingProjects="true" >+ class="org.eclipse.search.internal.ui.spelling.SpellingSearchPage" >+ enabled="true" >+ id="org.eclipse.ui.workbench.texteditor.spelling.searchPage" >+ label="Spelling Problems" >+ showScopeSection="true"> >+ </page> >+ </extension> >+ >+ <extension >+ point="org.eclipse.search.searchResultViewPages"> >+ <viewPage >+ class="org.eclipse.search.internal.ui.spelling.SpellingSearchResultPage" >+ id="org.eclipse.ui.workbench.texteditor.spelling.searchResultPage" >+ searchResultClass="org.eclipse.search.internal.ui.spelling.SpellingSearchResult"> >+ </viewPage> >+ </extension> >+ > </plugin> >Index: search/org/eclipse/search/internal/ui/spelling/SpellingSearchPage.java >=================================================================== >RCS file: search/org/eclipse/search/internal/ui/spelling/SpellingSearchPage.java >diff -N search/org/eclipse/search/internal/ui/spelling/SpellingSearchPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ search/org/eclipse/search/internal/ui/spelling/SpellingSearchPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,138 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.search.internal.ui.spelling; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Combo; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Link; >+ >+import org.eclipse.jface.dialogs.DialogPage; >+import org.eclipse.jface.preference.PreferenceDialog; >+import org.eclipse.jface.preference.PreferenceStore; >+ >+import org.eclipse.ui.dialogs.PreferencesUtil; >+ >+import org.eclipse.ui.texteditor.spelling.SpellingEngineDescriptor; >+import org.eclipse.ui.texteditor.spelling.SpellingService; >+ >+import org.eclipse.search.internal.ui.SearchMessages; >+import org.eclipse.search.internal.ui.text.FileSearchScopeConfigurationBlock; >+import org.eclipse.search.internal.ui.text.FileSearchScopeConfigurationBlock.FileSearchScopeConfigurationBlockListener; >+import org.eclipse.search.ui.ISearchPage; >+import org.eclipse.search.ui.ISearchPageContainer; >+import org.eclipse.search.ui.NewSearchUI; >+ >+public class SpellingSearchPage extends DialogPage implements ISearchPage { >+ >+ private final SpellingEngineDescriptor[] fSpellingEngines; >+ >+ private SpellingEngineDescriptor fSelectedEngine; >+ private FileSearchScopeConfigurationBlock fScopeConfigurationBlock; >+ private ISearchPageContainer fContainer; >+ >+ public SpellingSearchPage() { >+ fScopeConfigurationBlock= new FileSearchScopeConfigurationBlock(new FileSearchScopeConfigurationBlockListener() { >+ public void extensionsTextChanged() { >+ boolean hasFilePattern= fScopeConfigurationBlock.getExtensionsText().length() > 0; >+ fContainer.setPerformActionEnabled(hasFilePattern); >+ } >+ >+ public void derivedSelectionChanged() { >+ } >+ }); >+ >+ SpellingService spellingService= new SpellingService(new PreferenceStore()); >+ fSpellingEngines= spellingService.getSpellingEngineDescriptors(); >+ fSelectedEngine= spellingService.getDefaultSpellingEngineDescriptor(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean performAction() { >+ SpellingSearchQuery query= new SpellingSearchQuery(fScopeConfigurationBlock.createTextSearchScope(), fSelectedEngine.getId()); >+ NewSearchUI.runQueryInBackground(query); >+ return true; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void setContainer(ISearchPageContainer container) { >+ fContainer= container; >+ fScopeConfigurationBlock.setContainer(container); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void createControl(Composite parent) { >+ initializeDialogUnits(parent); >+ >+ Composite control= new Composite(parent, SWT.NONE); >+ control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >+ control.setLayout(new GridLayout(2, false)); >+ >+ if (fSpellingEngines.length > 1) { >+ Label label= new Label(control, SWT.NONE); >+ label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 2, 1)); >+ label.setText(SearchMessages.SpellingSearchPage_spellingEngineDropDown_label); >+ >+ final Combo combo= new Combo(control, SWT.DROP_DOWN | SWT.READ_ONLY); >+ combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); >+ >+ int index= 0; >+ String[] items= new String[fSpellingEngines.length]; >+ for (int i= 0; i < items.length; i++) { >+ items[i]= fSpellingEngines[i].getLabel(); >+ if (fSpellingEngines[i] == fSelectedEngine) >+ index= i; >+ } >+ combo.setItems(items); >+ combo.select(index); >+ combo.addSelectionListener(new SelectionAdapter() { >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetSelected(SelectionEvent e) { >+ fSelectedEngine= fSpellingEngines[combo.getSelectionIndex()]; >+ } >+ }); >+ } >+ >+ fScopeConfigurationBlock.createControl(control); >+ fScopeConfigurationBlock.setExtensionsText("*"); //$NON-NLS-1$ >+ >+ Link link= new Link(control, SWT.NONE); >+ GridData layoutData= new GridData(SWT.END, SWT.CENTER, false, false, 2, 1); >+ layoutData.verticalIndent= 15; >+ link.setLayoutData(layoutData); >+ link.setText(SearchMessages.SpellingSearchPage_spellingEnginePreferencePage_link); >+ link.addSelectionListener(new SelectionAdapter() { >+ /** >+ * {@inheritDoc} >+ */ >+ public void widgetSelected(SelectionEvent e) { >+ PreferenceDialog dialog= PreferencesUtil.createPreferenceDialogOn(getShell(), "org.eclipse.ui.editors.preferencePages.Spelling", new String[0], null); //$NON-NLS-1$ >+ dialog.open(); >+ } >+ }); >+ >+ setControl(control); >+ } >+ >+} >Index: search/org/eclipse/search/internal/ui/spelling/SpellingSearchResult.java >=================================================================== >RCS file: search/org/eclipse/search/internal/ui/spelling/SpellingSearchResult.java >diff -N search/org/eclipse/search/internal/ui/spelling/SpellingSearchResult.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ search/org/eclipse/search/internal/ui/spelling/SpellingSearchResult.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.search.internal.ui.spelling; >+ >+import org.eclipse.search.internal.ui.text.FileSearchResult; >+ >+public class SpellingSearchResult extends FileSearchResult { >+ >+ public SpellingSearchResult(SpellingSearchQuery query) { >+ super(query); >+ } >+ >+} >Index: search/org/eclipse/search/internal/ui/text/IFileSearchQuery.java >=================================================================== >RCS file: search/org/eclipse/search/internal/ui/text/IFileSearchQuery.java >diff -N search/org/eclipse/search/internal/ui/text/IFileSearchQuery.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ search/org/eclipse/search/internal/ui/text/IFileSearchQuery.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,19 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.search.internal.ui.text; >+ >+import org.eclipse.search.ui.ISearchQuery; >+ >+public interface IFileSearchQuery extends ISearchQuery { >+ public String getResultLabel(int nMatches); >+ >+ public boolean isShowLineMatches(); >+} >\ No newline at end of file >Index: search/org/eclipse/search/internal/ui/spelling/SpellingLineElement.java >=================================================================== >RCS file: search/org/eclipse/search/internal/ui/spelling/SpellingLineElement.java >diff -N search/org/eclipse/search/internal/ui/spelling/SpellingLineElement.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ search/org/eclipse/search/internal/ui/spelling/SpellingLineElement.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.search.internal.ui.spelling; >+ >+import org.eclipse.core.resources.IFile; >+ >+import org.eclipse.ui.texteditor.spelling.SpellingProblem; >+ >+import org.eclipse.search.internal.ui.text.LineElement; >+ >+public class SpellingLineElement extends LineElement { >+ private final SpellingProblem fProblem; >+ >+ public SpellingLineElement(IFile parent, int lineNumber, int lineStartOffset, String lineContent, SpellingProblem problem) { >+ super(parent, lineNumber, lineStartOffset, lineContent); >+ fProblem= problem; >+ } >+ >+ public SpellingProblem getProblem() { >+ return fProblem; >+ } >+} >Index: search/org/eclipse/search/internal/ui/spelling/SpellingSearchQuery.java >=================================================================== >RCS file: search/org/eclipse/search/internal/ui/spelling/SpellingSearchQuery.java >diff -N search/org/eclipse/search/internal/ui/spelling/SpellingSearchQuery.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ search/org/eclipse/search/internal/ui/spelling/SpellingSearchQuery.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,189 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.search.internal.ui.spelling; >+ >+import java.util.regex.Pattern; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.Status; >+ >+import org.eclipse.core.resources.IFile; >+ >+import org.eclipse.core.filebuffers.FileBuffers; >+import org.eclipse.core.filebuffers.ITextFileBuffer; >+import org.eclipse.core.filebuffers.ITextFileBufferManager; >+import org.eclipse.core.filebuffers.LocationKind; >+ >+import org.eclipse.jface.preference.PreferenceStore; >+ >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+ >+import org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector; >+import org.eclipse.ui.texteditor.spelling.SpellingContext; >+import org.eclipse.ui.texteditor.spelling.SpellingProblem; >+import org.eclipse.ui.texteditor.spelling.SpellingService; >+ >+import org.eclipse.search.core.text.TextSearchEngine; >+import org.eclipse.search.core.text.TextSearchRequestor; >+import org.eclipse.search.internal.ui.Messages; >+import org.eclipse.search.internal.ui.SearchMessages; >+import org.eclipse.search.internal.ui.SearchPlugin; >+import org.eclipse.search.internal.ui.text.IFileSearchQuery; >+import org.eclipse.search.internal.ui.text.LineElement; >+import org.eclipse.search.internal.ui.text.SearchResultUpdater; >+import org.eclipse.search.ui.ISearchResult; >+import org.eclipse.search.ui.text.FileTextSearchScope; >+ >+public class SpellingSearchQuery implements IFileSearchQuery { >+ >+ private static class SpellingSearchRequestor extends TextSearchRequestor { >+ >+ private final SpellingSearchResult fResult; >+ private SpellingService fSpellingService; >+ >+ public SpellingSearchRequestor(SpellingSearchResult result, SpellingService spellingService) { >+ fResult= result; >+ fSpellingService= spellingService; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean acceptFile(final IFile file) throws CoreException { >+ ITextFileBufferManager bufferManager= FileBuffers.getTextFileBufferManager(); >+ bufferManager.connect(file.getFullPath(), LocationKind.IFILE, new NullProgressMonitor()); >+ try { >+ ITextFileBuffer buffer= bufferManager.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE); >+ >+ SpellingContext context= new SpellingContext(); >+ context.setContentType(buffer.getContentType()); >+ >+ final IDocument document= buffer.getDocument(); >+ fSpellingService.check(document, context, new ISpellingProblemCollector() { >+ >+ public void endCollecting() { >+ } >+ >+ public void beginCollecting() { >+ } >+ >+ public void accept(SpellingProblem problem) { >+ try { >+ int lineNumber= document.getLineOfOffset(problem.getOffset()); >+ int lineStartOffset= document.getLineOffset(lineNumber); >+ int lineLength= document.getLineLength(lineNumber); >+ LineElement lineElement= new SpellingLineElement(file, lineNumber, lineStartOffset, document.get(lineStartOffset, lineLength), problem); >+ fResult.addMatch(new SpellingSearchMatch(file, problem, lineElement)); >+ } catch (BadLocationException e) { >+ SearchPlugin.log(e); >+ } >+ } >+ >+ }, new NullProgressMonitor()); >+ } finally { >+ bufferManager.disconnect(file.getFullPath(), LocationKind.IFILE, new NullProgressMonitor()); >+ } >+ return true; >+ } >+ } >+ >+ private final FileTextSearchScope fScope; >+ >+ private final String fSpellingEngineId; >+ private SpellingSearchResult fResult; >+ >+ public SpellingSearchQuery(FileTextSearchScope scope, String spellingEngineId) { >+ fScope= scope; >+ fSpellingEngineId= spellingEngineId; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public ISearchResult getSearchResult() { >+ if (fResult == null) { >+ fResult= new SpellingSearchResult(this); >+ new SearchResultUpdater(fResult); >+ } >+ return fResult; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean canRerun() { >+ return true; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean canRunInBackground() { >+ return true; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getLabel() { >+ return SearchMessages.SpellingSearchQuery_query_label; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IStatus run(IProgressMonitor monitor) throws OperationCanceledException { >+ SpellingSearchResult searchResult= (SpellingSearchResult)getSearchResult(); >+ searchResult.removeAll(); >+ >+ PreferenceStore store= new PreferenceStore(); >+ store.setValue(SpellingService.PREFERENCE_SPELLING_ENABLED, true); >+ store.setValue(SpellingService.PREFERENCE_SPELLING_ENGINE, fSpellingEngineId); >+ >+ SpellingService spellingService= new SpellingService(store); >+ >+ TextSearchEngine engine= TextSearchEngine.create(); >+ engine.search(fScope, new SpellingSearchRequestor(searchResult, spellingService), Pattern.compile(""), monitor); //$NON-NLS-1$ >+ >+ return Status.OK_STATUS; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getResultLabel(int matchesCount) { >+ int fileCount= fResult.getElements().length; >+ >+ Object[] args= new Object[] { new Integer(matchesCount), new Integer(fileCount) }; >+ if (fileCount == 1 && matchesCount == 1) { >+ return SearchMessages.SpellingSearchQuery_result11_label; >+ } else if (fileCount == 1) { >+ return Messages.format(SearchMessages.SpellingSearchQuery_resultn1_label, args); >+ } else if (matchesCount == 1) { >+ return Messages.format(SearchMessages.SpellingSearchQuery_result1n_label, args); >+ } else { >+ return Messages.format(SearchMessages.SpellingSearchQuery_resultnn_label, args); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean isShowLineMatches() { >+ return true; >+ } >+ >+} >\ No newline at end of file >Index: search/org/eclipse/search/internal/ui/spelling/SpellingSearchResultPage.java >=================================================================== >RCS file: search/org/eclipse/search/internal/ui/spelling/SpellingSearchResultPage.java >diff -N search/org/eclipse/search/internal/ui/spelling/SpellingSearchResultPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ search/org/eclipse/search/internal/ui/spelling/SpellingSearchResultPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,125 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.search.internal.ui.spelling; >+ >+import org.eclipse.swt.graphics.ImageData; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.NullProgressMonitor; >+ >+import org.eclipse.core.resources.IResource; >+ >+import org.eclipse.core.filebuffers.FileBuffers; >+import org.eclipse.core.filebuffers.ITextFileBuffer; >+import org.eclipse.core.filebuffers.ITextFileBufferManager; >+import org.eclipse.core.filebuffers.LocationKind; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.IMenuManager; >+import org.eclipse.jface.action.MenuManager; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+ >+import org.eclipse.jface.text.contentassist.ICompletionProposal; >+ >+import org.eclipse.search.internal.ui.SearchMessages; >+import org.eclipse.search.internal.ui.SearchPlugin; >+import org.eclipse.search.internal.ui.text.FileSearchPage; >+import org.eclipse.search.ui.IContextMenuConstants; >+import org.eclipse.search.ui.text.AbstractTextSearchResult; >+import org.eclipse.search.ui.text.AbstractTextSearchViewPage; >+import org.eclipse.search.ui.text.Match; >+ >+public class SpellingSearchResultPage extends FileSearchPage { >+ >+ private static final class ResolveSpellingProblemAction extends Action { >+ >+ private final SpellingLineElement fElement; >+ private final ICompletionProposal fProposal; >+ >+ private final AbstractTextSearchViewPage fPage; >+ >+ public ResolveSpellingProblemAction(SpellingLineElement element, final ICompletionProposal proposal, AbstractTextSearchViewPage page) { >+ super(proposal.getDisplayString()); >+ >+ fElement= element; >+ fProposal= proposal; >+ fPage= page; >+ >+ setImageDescriptor(new ImageDescriptor() { >+ public ImageData getImageData() { >+ return proposal.getImage().getImageData(); >+ } >+ }); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void run() { >+ try { >+ IResource file= fElement.getParent(); >+ >+ ITextFileBufferManager bufferManager= FileBuffers.getTextFileBufferManager(); >+ bufferManager.connect(file.getFullPath(), LocationKind.IFILE, new NullProgressMonitor()); >+ try { >+ ITextFileBuffer buffer= bufferManager.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE); >+ >+ fProposal.apply(buffer.getDocument()); >+ >+ AbstractTextSearchResult input= fPage.getInput(); >+ if (input != null) { >+ Match[] matches= input.getMatches(file); >+ for (int i= 0; i < matches.length; i++) { >+ Match match= matches[i]; >+ if (match instanceof SpellingSearchMatch && ((SpellingSearchMatch)match).getLineElement() == fElement) { >+ input.removeMatch(match); >+ } >+ } >+ } >+ } finally { >+ bufferManager.disconnect(file.getFullPath(), LocationKind.IFILE, new NullProgressMonitor()); >+ } >+ } catch (CoreException e) { >+ SearchPlugin.log(e); >+ } >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ protected void fillContextMenu(IMenuManager mgr) { >+ super.fillContextMenu(mgr); >+ >+ ISelection selection= getSite().getSelectionProvider().getSelection(); >+ if (selection instanceof IStructuredSelection) { >+ IStructuredSelection sselection= (IStructuredSelection) selection; >+ if (sselection.size() == 1 && sselection.getFirstElement() instanceof SpellingLineElement) { >+ SpellingLineElement element= (SpellingLineElement) sselection.getFirstElement(); >+ >+ ICompletionProposal[] proposals= element.getProblem().getProposals(); >+ >+ if (proposals.length > 0) { >+ MenuManager replaceMenu= new MenuManager(SearchMessages.SpellingSearchResultPage_fixProblemMenu_label); >+ >+ for (int i= 0; i < proposals.length; i++) { >+ replaceMenu.add(new ResolveSpellingProblemAction(element, proposals[i], this)); >+ } >+ >+ mgr.appendToGroup(IContextMenuConstants.GROUP_EDIT, replaceMenu); >+ } >+ } >+ } >+ } >+ >+} >Index: search/org/eclipse/search/internal/ui/spelling/SpellingSearchMatch.java >=================================================================== >RCS file: search/org/eclipse/search/internal/ui/spelling/SpellingSearchMatch.java >diff -N search/org/eclipse/search/internal/ui/spelling/SpellingSearchMatch.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ search/org/eclipse/search/internal/ui/spelling/SpellingSearchMatch.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.search.internal.ui.spelling; >+ >+import org.eclipse.core.resources.IFile; >+ >+import org.eclipse.ui.texteditor.spelling.SpellingProblem; >+ >+import org.eclipse.search.internal.ui.text.FileMatch; >+import org.eclipse.search.internal.ui.text.LineElement; >+ >+public class SpellingSearchMatch extends FileMatch { >+ >+ private final SpellingProblem fProblem; >+ private final IFile fFile; >+ >+ public SpellingSearchMatch(IFile file, SpellingProblem problem, LineElement element) { >+ super(file, problem.getOffset(), problem.getLength(), element); >+ >+ fFile= file; >+ fProblem= problem; >+ } >+ >+ public SpellingProblem getProblem() { >+ return fProblem; >+ } >+ >+ public IFile getFile() { >+ return fFile; >+ } >+ >+} >Index: search/org/eclipse/search/internal/ui/text/FileSearchScopeConfigurationBlock.java >=================================================================== >RCS file: search/org/eclipse/search/internal/ui/text/FileSearchScopeConfigurationBlock.java >diff -N search/org/eclipse/search/internal/ui/text/FileSearchScopeConfigurationBlock.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ search/org/eclipse/search/internal/ui/text/FileSearchScopeConfigurationBlock.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,226 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.search.internal.ui.text; >+ >+import java.util.HashSet; >+import java.util.Iterator; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Combo; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Label; >+ >+import org.eclipse.core.runtime.IAdaptable; >+ >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ResourcesPlugin; >+ >+import org.eclipse.jface.layout.PixelConverter; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+ >+import org.eclipse.ui.IWorkingSet; >+ >+import org.eclipse.search.internal.ui.SearchMessages; >+import org.eclipse.search.internal.ui.util.FileTypeEditor; >+import org.eclipse.search.internal.ui.util.SWTUtil; >+import org.eclipse.search.ui.ISearchPageContainer; >+import org.eclipse.search.ui.text.FileTextSearchScope; >+ >+public class FileSearchScopeConfigurationBlock { >+ >+ public static abstract class FileSearchScopeConfigurationBlockListener { >+ public abstract void extensionsTextChanged(); >+ >+ public abstract void derivedSelectionChanged(); >+ } >+ >+ private final FileSearchScopeConfigurationBlockListener fListener; >+ >+ private ISearchPageContainer fContainer; >+ private Combo fExtensions; >+ private Button fSearchDerivedCheckbox; >+ private FileTypeEditor fFileTypeEditor; >+ private boolean fSearchDerived; >+ private Composite fControl; >+ >+ public FileSearchScopeConfigurationBlock(FileSearchScopeConfigurationBlockListener listener) { >+ fListener= listener; >+ } >+ >+ public void setContainer(ISearchPageContainer container) { >+ fContainer= container; >+ } >+ >+ public String[] getExtensions() { >+ return fFileTypeEditor.getFileTypes(); >+ } >+ >+ public String getExtensionsText() { >+ return fExtensions.getText(); >+ } >+ >+ public void setExtensionsText(String text) { >+ fExtensions.setText(text); >+ } >+ >+ public void setExtensions(String[] extensions) { >+ fExtensions.setItems(extensions); >+ } >+ >+ public void setSearchDerived(boolean enabled) { >+ fSearchDerived= enabled; >+ } >+ >+ public boolean getSearchDerived() { >+ return fSearchDerived; >+ } >+ >+ public void setFileTypes(String[] types) { >+ fFileTypeEditor.setFileTypes(types); >+ } >+ >+ public void createControl(Composite parent) { >+ fControl= parent; >+ >+ addFileNameControls(parent); >+ } >+ >+ public FileTextSearchScope createTextSearchScope() { >+ // Setup search scope >+ switch (getContainer().getSelectedScope()) { >+ case ISearchPageContainer.WORKSPACE_SCOPE: >+ return FileTextSearchScope.newWorkspaceScope(getExtensions(), fSearchDerived); >+ case ISearchPageContainer.SELECTION_SCOPE: >+ return getSelectedResourcesScope(); >+ case ISearchPageContainer.SELECTED_PROJECTS_SCOPE: >+ return getEnclosingProjectScope(); >+ case ISearchPageContainer.WORKING_SET_SCOPE: >+ IWorkingSet[] workingSets= getContainer().getSelectedWorkingSets(); >+ return FileTextSearchScope.newSearchScope(workingSets, getExtensions(), fSearchDerived); >+ default: >+ // unknown scope >+ return FileTextSearchScope.newWorkspaceScope(getExtensions(), fSearchDerived); >+ } >+ } >+ >+ private FileTextSearchScope getSelectedResourcesScope() { >+ HashSet resources= new HashSet(); >+ ISelection sel= getContainer().getSelection(); >+ if (sel instanceof IStructuredSelection && !sel.isEmpty()) { >+ Iterator iter= ((IStructuredSelection)sel).iterator(); >+ while (iter.hasNext()) { >+ Object curr= iter.next(); >+ if (curr instanceof IWorkingSet) { >+ IWorkingSet workingSet= (IWorkingSet)curr; >+ if (workingSet.isAggregateWorkingSet() && workingSet.isEmpty()) { >+ return FileTextSearchScope.newWorkspaceScope(getExtensions(), fSearchDerived); >+ } >+ IAdaptable[] elements= workingSet.getElements(); >+ for (int i= 0; i < elements.length; i++) { >+ IResource resource= (IResource)elements[i].getAdapter(IResource.class); >+ if (resource != null && resource.isAccessible()) { >+ resources.add(resource); >+ } >+ } >+ } else if (curr instanceof IAdaptable) { >+ IResource resource= (IResource)((IAdaptable)curr).getAdapter(IResource.class); >+ if (resource != null && resource.isAccessible()) { >+ resources.add(resource); >+ } >+ } >+ } >+ } >+ IResource[] arr= (IResource[])resources.toArray(new IResource[resources.size()]); >+ return FileTextSearchScope.newSearchScope(arr, getExtensions(), fSearchDerived); >+ } >+ >+ private FileTextSearchScope getEnclosingProjectScope() { >+ String[] enclosingProjectName= getContainer().getSelectedProjectNames(); >+ if (enclosingProjectName == null) { >+ return FileTextSearchScope.newWorkspaceScope(getExtensions(), fSearchDerived); >+ } >+ >+ IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); >+ IResource[] res= new IResource[enclosingProjectName.length]; >+ for (int i= 0; i < res.length; i++) { >+ res[i]= root.getProject(enclosingProjectName[i]); >+ } >+ >+ return FileTextSearchScope.newSearchScope(res, getExtensions(), fSearchDerived); >+ } >+ >+ >+ private ISearchPageContainer getContainer() { >+ return fContainer; >+ } >+ >+ private void addFileNameControls(Composite group) { >+ // grid layout with 2 columns >+ >+ // Line with label, combo and button >+ Label label= new Label(group, SWT.LEAD); >+ label.setText(SearchMessages.SearchPage_fileNamePatterns_text); >+ label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); >+ label.setFont(group.getFont()); >+ >+ fExtensions= new Combo(group, SWT.SINGLE | SWT.BORDER); >+ fExtensions.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ fListener.extensionsTextChanged(); >+ } >+ }); >+ GridData data= new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1); >+ data.widthHint= convertWidthInCharsToPixels(50); >+ fExtensions.setLayoutData(data); >+ fExtensions.setFont(group.getFont()); >+ >+ Button button= new Button(group, SWT.PUSH); >+ button.setText(SearchMessages.SearchPage_browse); >+ GridData gridData= new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1); >+ gridData.widthHint= SWTUtil.getButtonWidthHint(button); >+ button.setLayoutData(gridData); >+ button.setFont(group.getFont()); >+ >+ fFileTypeEditor= new FileTypeEditor(fExtensions, button); >+ >+ // Text line which explains the special characters >+ Label description= new Label(group, SWT.LEAD); >+ description.setText(SearchMessages.SearchPage_fileNamePatterns_hint); >+ description.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); >+ description.setFont(group.getFont()); >+ >+ fSearchDerivedCheckbox= new Button(group, SWT.CHECK); >+ fSearchDerivedCheckbox.setText(SearchMessages.TextSearchPage_searchDerived_label); >+ >+ fSearchDerivedCheckbox.setSelection(fSearchDerived); >+ fSearchDerivedCheckbox.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ fSearchDerived= fSearchDerivedCheckbox.getSelection(); >+ fListener.derivedSelectionChanged(); >+ } >+ }); >+ fSearchDerivedCheckbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); >+ fSearchDerivedCheckbox.setFont(group.getFont()); >+ } >+ >+ private int convertWidthInCharsToPixels(int width) { >+ return new PixelConverter(fControl).convertWidthInCharsToPixels(width); >+ } >+ >+}
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 191432
: 139425