diff options
Diffstat (limited to 'org.eclipse.search/new search/org/eclipse')
73 files changed, 1000 insertions, 1003 deletions
diff --git a/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchEngine.java b/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchEngine.java index fa3445e1944..6ea2cb9209f 100644 --- a/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchEngine.java +++ b/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchEngine.java @@ -32,7 +32,7 @@ import org.eclipse.search.internal.ui.SearchPlugin; * @since 3.2 */ public abstract class TextSearchEngine { - + /** * Creates an instance of the search engine. By default this is the default text search engine (see {@link #createDefault()}), * but extensions can offer more sophisticated search engine implementations. @@ -41,7 +41,7 @@ public abstract class TextSearchEngine { public static TextSearchEngine create() { return SearchPlugin.getDefault().getTextSearchEngineRegistry().getPreferred(); } - + /** * Creates the default, built-in, text search engine that implements a brute-force search, not using * any search index. @@ -53,13 +53,13 @@ public abstract class TextSearchEngine { public IStatus search(TextSearchScope scope, TextSearchRequestor requestor, Pattern searchPattern, IProgressMonitor monitor) { return new TextSearchVisitor(requestor, searchPattern).search(scope, monitor); } - + public IStatus search(IFile[] scope, TextSearchRequestor requestor, Pattern searchPattern, IProgressMonitor monitor) { return new TextSearchVisitor(requestor, searchPattern).search(scope, monitor); } }; } - + /** * Uses a given search pattern to find matches in the content of workspace file resources. If a file is open in an editor, the * editor buffer is searched. @@ -83,5 +83,5 @@ public abstract class TextSearchEngine { * @return the status containing information about problems in resources searched. */ public abstract IStatus search(IFile[] scope, TextSearchRequestor requestor, Pattern searchPattern, IProgressMonitor monitor); - + } diff --git a/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchMatchAccess.java b/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchMatchAccess.java index 2ad73b8b776..2abcc6b4d1f 100644 --- a/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchMatchAccess.java +++ b/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchMatchAccess.java @@ -14,10 +14,10 @@ package org.eclipse.search.core.text; import org.eclipse.core.resources.IFile; /** - * A {@link TextSearchMatchAccess} gives access to a pattern match found by the {@link TextSearchEngine}. + * A {@link TextSearchMatchAccess} gives access to a pattern match found by the {@link TextSearchEngine}. * <p> * Please note that <code>{@link TextSearchMatchAccess}</code> objects <b>do not - * </b> have value semantic. The state of the object might change over + * </b> have value semantic. The state of the object might change over * time especially since objects are reused for different call backs. Clients shall not keep a reference to * a {@link TextSearchMatchAccess} element. * </p> @@ -27,48 +27,48 @@ import org.eclipse.core.resources.IFile; * @since 3.2 */ public abstract class TextSearchMatchAccess { - + /** * Returns the file the match was found in. - * + * * @return the file the match was found. */ public abstract IFile getFile(); - + /** * Returns the offset of this search match. - * + * * @return the offset of this search match */ public abstract int getMatchOffset(); - + /** * Returns the length of this search match. - * + * * @return the length of this search match */ public abstract int getMatchLength(); - + /** * Returns the length of this file's content. - * + * * @return the length of this file's content. */ public abstract int getFileContentLength(); - + /** * Returns a character of the file's content at the given offset - * + * * @param offset the offset * @return the character at the given offset * @throws IndexOutOfBoundsException an {@link IndexOutOfBoundsException} is * thrown when the <code>offset</code> is negative or not less than the file content's length. */ public abstract char getFileContentChar(int offset); - + /** * Returns the file's content at the given offsets. - * + * * @param offset the offset of the requested content * @param length the of the requested content * @return the substring of the file's content diff --git a/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchRequestor.java b/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchRequestor.java index 842c1d946ac..6547a66107a 100644 --- a/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchRequestor.java +++ b/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchRequestor.java @@ -16,10 +16,10 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.resources.IFile; /** - * Collects the results from a search engine query. + * Collects the results from a search engine query. * Clients implement a subclass to pass to {@link TextSearchEngine#search(TextSearchScope, * TextSearchRequestor, java.util.regex.Pattern, org.eclipse.core.runtime.IProgressMonitor)} - * and implement the {@link #acceptPatternMatch(TextSearchMatchAccess)} + * and implement the {@link #acceptPatternMatch(TextSearchMatchAccess)} * method, and possibly override other life cycle methods. * <p> * The search engine calls {@link #beginReporting()} when a search starts, @@ -41,7 +41,7 @@ import org.eclipse.core.resources.IFile; * @since 3.2 */ public abstract class TextSearchRequestor { - + /** * Notification sent before starting the search action. * Typically, this would tell a search requestor to clear previously @@ -67,7 +67,7 @@ public abstract class TextSearchRequestor { public void endReporting() { // do nothing } - + /** * Notification sent before search starts in the given file. This method is called for all files that are contained * in the search scope. @@ -83,7 +83,7 @@ public abstract class TextSearchRequestor { public boolean acceptFile(IFile file) throws CoreException { return true; } - + /** * Notification sent that a file might contain binary context. * It is the choice of the search engine to report binary files and it is the heuristic of the search engine to decide @@ -96,14 +96,14 @@ public abstract class TextSearchRequestor { * <p> * The default behaviour is to skip binary files * </p> - * + * * @param file the file that might be binary * @return If false, no pattern matches will be reported for the content of this file. */ public boolean reportBinaryFile(IFile file) { return false; } - + /** * Accepts the given search match and decides if the search should continue for this file. * diff --git a/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchScope.java b/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchScope.java index adad971f2b1..a2f13d98603 100644 --- a/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchScope.java +++ b/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchScope.java @@ -27,19 +27,19 @@ import org.eclipse.search.internal.core.text.FilesOfScopeCalculator; * A {@link TextSearchScope} defines the scope of a search. The scope consists of all workbench resources that are accepted * by {@link #contains(IResourceProxy)} and that either are a root element ({@link #getRoots()}) or have a root element * in their parent chain. - * + * * @see #newSearchScope(IResource[], java.util.regex.Pattern, boolean) * @since 3.2 */ public abstract class TextSearchScope { - - + + /** * Creates a scope that consists of all files that match the <code>fileNamePattern</code> and that * either are one of the roots, or have one of the roots in their parent chain. * If <code>visitDerivedResources</code> is not enabled, all files that are marked derived or * have a derived container in their parent chain are not part of the scope. - * + * * @param rootResources the resources that are the roots of the scope * @param fileNamePattern file name pattern for this scope. * @param visitDerivedResources if set also derived folders and files are searched. @@ -50,32 +50,32 @@ public abstract class TextSearchScope { scope.setFileNamePattern(fileNamePattern); return scope; } - - + + /** * Returns the resources that form the root. Roots can not contain each other. Root elements are only part of the * scope if they are also accepted by {@link #contains(IResourceProxy)}. - * + * * @return returns the set of root resources. The default behavior is to return the workspace root. */ public IResource[] getRoots() { return new IResource[] { ResourcesPlugin.getWorkspace().getRoot() }; } - + /** * Returns if a given resource is part of the scope. If a container is not part of the scope, also all its members * are not part of the scope. - * - * @param proxy the resource proxy to test. + * + * @param proxy the resource proxy to test. * @return returns <code>true</code> if a resource is part of the scope. if <code>false</code> is returned the resource * and all its children are not part of the scope. */ public abstract boolean contains(IResourceProxy proxy); - + /** * Evaluates all files in this scope. - * + * * @param status a {@link MultiStatus} to collect the error status that occurred while collecting resources. * @return returns the files in the scope. */ @@ -83,5 +83,5 @@ public abstract class TextSearchScope { return new FilesOfScopeCalculator(this, status).process(); } - + } diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/IContextMenuConstants.java b/org.eclipse.search/new search/org/eclipse/search/ui/IContextMenuConstants.java index 48ba05f173d..669c22c6007 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/IContextMenuConstants.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/IContextMenuConstants.java @@ -17,9 +17,9 @@ import org.eclipse.ui.IWorkbenchActionConstants; * <p> * This interface declares constants only; it is not intended to be implemented. * </p> - * + * * @since 2.0 - * + * * @noimplement This interface is not intended to be implemented by clients. */ public interface IContextMenuConstants { @@ -47,7 +47,7 @@ public interface IContextMenuConstants { * </p> */ public static final String GROUP_OPEN= "group.open"; //$NON-NLS-1$ - + /** * Pop-up menu: name of group for show actions (value <code>"group.show"</code>). * <p> @@ -59,7 +59,7 @@ public interface IContextMenuConstants { * </p> */ public static final String GROUP_SHOW= "group.show"; //$NON-NLS-1$ - + /** * Pop-up menu: name of group for new actions (value <code>"group.new"</code>). * <p> @@ -76,53 +76,53 @@ public interface IContextMenuConstants { * Pop-up menu: name of group for build actions (value <code>"group.build"</code>). */ public static final String GROUP_BUILD= "group.build"; //$NON-NLS-1$ - + /** * Pop-up menu: name of group for reorganize actions (value <code>"group.reorganize"</code>). - */ - public static final String GROUP_REORGANIZE= IWorkbenchActionConstants.GROUP_REORGANIZE; - + */ + public static final String GROUP_REORGANIZE= IWorkbenchActionConstants.GROUP_REORGANIZE; + /** * Pop-up menu: name of group for code generation or refactoring actions ( * value <code>"group.generate"</code>). - */ + */ public static final String GROUP_GENERATE= "group.generate"; //$NON-NLS-1$ /** * Pop-up menu: name of group for search actions (value <code>"group.search"</code>). - */ + */ public static final String GROUP_SEARCH= "group.search"; //$NON-NLS-1$ - + /** * Pop-up menu: name of group for additional actions (value <code>"group.additions"</code>). - */ + */ public static final String GROUP_ADDITIONS= "additions"; //$NON-NLS-1$ /** * Pop-up menu: name of group for viewer setup actions (value <code>"group.viewerSetup"</code>). - */ + */ public static final String GROUP_VIEWER_SETUP= "group.viewerSetup"; //$NON-NLS-1$ - + /** * Pop-up menu: name of group for filtering (value <code>"group.filtering"</code>). * @since 3.3 - */ + */ public static final String GROUP_FILTERING= "group.filtering"; //$NON-NLS-1$ /** * Pop-up menu: name of group for properties actions (value <code>"group.properties"</code>). - */ + */ public static final String GROUP_PROPERTIES= "group.properties"; //$NON-NLS-1$ /** * Pop-up menu: name of group for cut/copy/paste actions (value <code>"group.edit"</code>). * @since 3.3 */ - public static final String GROUP_EDIT = "group.edit"; //$NON-NLS-1$ - + public static final String GROUP_EDIT = "group.edit"; //$NON-NLS-1$ + /** * Pop-up menu: name of group for remove match actions (value <code>"group.removeMatches"</code>). * @since 2.1 - */ + */ public static final String GROUP_REMOVE_MATCHES= "group.removeMatches"; //$NON-NLS-1$ } diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/IQueryListener.java b/org.eclipse.search/new search/org/eclipse/search/ui/IQueryListener.java index 84d72cad92a..1eee41d4bf2 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/IQueryListener.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/IQueryListener.java @@ -13,36 +13,36 @@ package org.eclipse.search.ui; /** * <p>A listener for changes to the set of search queries. Queries are added by running - * them via {@link org.eclipse.search.ui.NewSearchUI#runQueryInBackground(ISearchQuery) NewSearchUI#runQueryInBackground(ISearchQuery)} or + * them via {@link org.eclipse.search.ui.NewSearchUI#runQueryInBackground(ISearchQuery) NewSearchUI#runQueryInBackground(ISearchQuery)} or * {@link org.eclipse.search.ui.NewSearchUI#runQueryInForeground(org.eclipse.jface.operation.IRunnableContext,ISearchQuery) NewSearchUI#runQueryInForeground(IRunnableContext,ISearchQuery)}</p> * <p>The search UI determines when queries are rerun, stopped or deleted (and will notify * interested parties via this interface). Listeners can be added and removed in the {@link org.eclipse.search.ui.NewSearchUI NewSearchUI} class. * </p> * <p>Clients may implement this interface.</p> - * + * * @since 3.0 */ public interface IQueryListener { /** * Called when an query has been added to the system. - * + * * @param query the query that has been added */ - + void queryAdded(ISearchQuery query); /** * Called when a query has been removed. - * + * * @param query the query that has been removed */ void queryRemoved(ISearchQuery query); - + /** * Called before an <code>ISearchQuery</code> is starting. * @param query the query about to start */ void queryStarting(ISearchQuery query); - + /** * Called after an <code>ISearchQuery</code> has finished. * @param query the query that has finished diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/IReplacePage.java b/org.eclipse.search/new search/org/eclipse/search/ui/IReplacePage.java index d00f95e94df..cb921611d78 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/IReplacePage.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/IReplacePage.java @@ -12,7 +12,7 @@ package org.eclipse.search.ui; /** * An extension interface to <code>ISearchPage</code>. If clients implement - * <code>IReplacePage</code> in addition to <code>ISearchPage</code>, a + * <code>IReplacePage</code> in addition to <code>ISearchPage</code>, a * "Replace" button will be shown in the search dialog. * * @since 3.0 @@ -27,5 +27,5 @@ public interface IReplacePage { * @return <code>true</code> if the dialog can be closed after execution */ public boolean performReplace(); - + } diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchPage.java b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchPage.java index 1012f536578..b308f24220e 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchPage.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchPage.java @@ -21,7 +21,7 @@ import org.eclipse.jface.dialogs.IDialogPage; * button is pressed. * </p> * <p> - * If the search page additionally implements {@link IReplacePage}, a + * If the search page additionally implements {@link IReplacePage}, a * 'Replace' button will be shown in the search dialog. * </p> * diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchPageContainer.java b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchPageContainer.java index b39adaf6a91..605269559a8 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchPageContainer.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchPageContainer.java @@ -23,37 +23,37 @@ import org.eclipse.ui.IWorkingSet; * <p> * This interface is not intended to be implemented by clients. * </p> - * + * * @noimplement This interface is not intended to be implemented by clients. */ public interface ISearchPageContainer { /** * Workspace scope (value <code>0</code>). - * + * * @since 2.0 - */ + */ public static final int WORKSPACE_SCOPE= 0; /** * Selection scope (value <code>1</code>). - * + * * @since 2.0 - */ + */ public static final int SELECTION_SCOPE= 1; /** * Working set scope (value <code>2</code>). - * + * * @since 2.0 - */ + */ public static final int WORKING_SET_SCOPE= 2; /** * Current Project scope (value <code>3</code>). - * + * * @since 3.0 - */ + */ public static final int SELECTED_PROJECTS_SCOPE= 3; /** @@ -61,7 +61,7 @@ public interface ISearchPageContainer { * * @return the selection passed to this container when it was opened */ - public ISelection getSelection(); + public ISelection getSelection(); /** * Returns the context for the search operation. @@ -82,24 +82,24 @@ public interface ISearchPageContainer { /** * Returns search container's selected scope. * The scope is WORKSPACE_SCOPE, SELECTED_PROJECTS_SCOPE, SELECTION_SCOPE or WORKING_SET_SCOPE. - * + * * @return the selected scope * @since 2.0 - */ + */ public int getSelectedScope(); /** * Sets the selected scope of this search page container. * The scope is WORKSPACE_SCOPE, SELECTED_PROJECTS_SCOPE, SELECTION_SCOPE or WORKING_SET_SCOPE. * @param scope the newly selected scope - * + * * @since 2.0 - */ + */ public void setSelectedScope(int scope); /** * Tells whether a valid scope is selected. - * + * * @return a <code>true</code> if a valid scope is selected in this search page container * @since 2.0 */ @@ -107,7 +107,7 @@ public interface ISearchPageContainer { /** * Returns the selected working sets of this container. - * + * * @return an array with the selected working sets or <code>null</code> if the scope is not {@link #WORKING_SET_SCOPE} * @since 2.0 */ @@ -115,19 +115,19 @@ public interface ISearchPageContainer { /** * Sets the selected working sets of this container. - * + * * @param workingSets an array of IWorkingSet * @since 2.0 */ public void setSelectedWorkingSets(IWorkingSet[] workingSets); - + /** * Returns the names of the enclosing projects if selected by the container or <code>null</code> * if the scope is not {@link #SELECTED_PROJECTS_SCOPE} - * + * * @return the names of the enclosing project or <code>null</code> if the scope is not {@link #SELECTED_PROJECTS_SCOPE}. * @since 3.2 */ public String[] getSelectedProjectNames(); - + } diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchPageScoreComputer.java b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchPageScoreComputer.java index 4443266c7a2..b37f8a9f900 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchPageScoreComputer.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchPageScoreComputer.java @@ -20,7 +20,7 @@ package org.eclipse.search.ui; * For example, a Java-specific search page score computer could test * if the page is a Java search page and returns high scores * for Java elements as selection input. - * + * * Intended to be implemented. * </p> */ diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchQuery.java b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchQuery.java index ffeb98c5311..8037de1fb35 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchQuery.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchQuery.java @@ -23,17 +23,17 @@ import org.eclipse.core.runtime.OperationCanceledException; * <p> * Clients may implement this interface. * </p> - * + * * @since 3.0 */ public interface ISearchQuery { /** * This is the method that actually does the work, i.e. finds the results of * the search query. - * + * * @param monitor the progress monitor to be used - * - * @return the status after completion of the search job. + * + * @return the status after completion of the search job. * @throws OperationCanceledException Thrown when the search query has been canceled. */ IStatus run(IProgressMonitor monitor) throws OperationCanceledException; @@ -43,14 +43,14 @@ public interface ISearchQuery { * the background. Note that progress notification (for example, the number * of matches found) should be done via the progress monitor passed into the * <code>run(IProgressMonitor)</code> method - * + * * @return the user readable label of this query */ String getLabel(); /** * Returns whether the query can be run more than once. Some queries may * depend on transient information and return <code>false</code>. - * + * * @return whether this query can be run more than once */ boolean canRerun(); @@ -58,14 +58,14 @@ public interface ISearchQuery { * Returns whether this query can be run in the background. Note that * queries must do proper locking when they are run in the background (e.g. * get the appropriate workspace locks). - * + * * @return whether this query can be run in the background */ boolean canRunInBackground(); /** * Returns the search result associated with this query. This method can be * called before run is called. - * + * * @return this query's search result */ ISearchResult getSearchResult(); diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResult.java b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResult.java index 603fc2a1123..e82afd97a5b 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResult.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResult.java @@ -28,7 +28,7 @@ import org.eclipse.jface.resource.ImageDescriptor; * <p> * Clients may implement this interface. * </p> - * + * * @see org.eclipse.search.ui.ISearchResultPage * @since 3.0 */ @@ -36,39 +36,39 @@ public interface ISearchResult { /** * Adds a <code>ISearchResultListener</code>. Has no effect when the * listener has already been added. - * + * * @param l the listener to be added */ void addListener(ISearchResultListener l); /** * Removes a <code>ISearchResultChangedListener</code>. Has no effect * when the listener hasn't previously been added. - * + * * @param l the listener to be removed */ void removeListener(ISearchResultListener l); /** * Returns a user readable label for this search result. The label is typically used in the result * view and should contain the search query string and number of matches. - * + * * @return the label for this search result */ String getLabel(); /** * Returns a tooltip to be used when this search result is shown in the UI. - * + * * @return a user readable String */ String getTooltip(); /** * Returns an image descriptor for the given ISearchResult. - * + * * @return an image representing this search result or <code>null</code> */ ImageDescriptor getImageDescriptor(); /** * Returns the query that produced this search result. - * + * * @return the query producing this result */ ISearchQuery getQuery(); diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultListener.java b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultListener.java index 75550e29d29..61a406a500b 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultListener.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultListener.java @@ -11,11 +11,11 @@ package org.eclipse.search.ui; /** * Listener interface for changes to an <code>ISearchResult</code>. - * Implementers of <code>ISearchResult</code> should define subclasses of + * Implementers of <code>ISearchResult</code> should define subclasses of * <code>SearchResultEvent</code> and send those to registered listeners. Implementers of - * <code>ISearchResultListener</code> will in general know the concrete class of search + * <code>ISearchResultListener</code> will in general know the concrete class of search * result they are listening to, and therefore the kind of events they - * have to handle. + * have to handle. * <p> * Clients may implement this interface. * </p> @@ -26,9 +26,9 @@ public interface ISearchResultListener { * Called to notify listeners of changes in a <code>ISearchResult</code>. * The event object <code>e</code> is only guaranteed to be valid for * the duration of the call. - * - * @param e the event object describing the change. Note that implementers - * of <code>ISearchResult</code> will be sending subclasses of + * + * @param e the event object describing the change. Note that implementers + * of <code>ISearchResult</code> will be sending subclasses of * <code>SearchResultEvent</code> */ void searchResultChanged(SearchResultEvent e); diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultPage.java b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultPage.java index 7bf76009ee0..d728cc993a7 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultPage.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultPage.java @@ -28,7 +28,7 @@ public interface ISearchResultPage extends IPageBookViewPage { * page. For example, the current selection in a viewer. The UI state will * be later passed into the <code>setInput()</code> method when the * currently shown <code>ISearchResult</code> is shown again. - * + * * @return an object representing the UI state of this page */ Object getUIState(); @@ -36,10 +36,10 @@ public interface ISearchResultPage extends IPageBookViewPage { * Sets the search result to be shown in this search results page. * Implementers should restore UI state (e.g. selection) from the previously * saved <code>uiState</code> object. - * + * * @param search the search result to be shown or <code>null</code> to clear the page. * @param uiState the previously saved UI state - * + * * @see ISearchResultPage#getUIState() */ void setInput(ISearchResult search, Object uiState); @@ -47,49 +47,49 @@ public interface ISearchResultPage extends IPageBookViewPage { /** * Sets the search view this search results page is shown in. This method will be called before * the page is shown for the first time (i.e. before the page control is created). - * + * * @param part the parent search view */ void setViewPart(ISearchResultViewPart part); /** * Restores the page state. Note that this applies only to state that is * saved across sessions. - * + * * @param memento a memento to restore the page state from or <code>null</code> * if no previous state was saved - * + * * @see #setInput(ISearchResult, Object) */ void restoreState(IMemento memento); /** * Saves the page state in a memento. Note that this applies to state that * should persist across sessions. - * + * * @param memento a memento to receive the object state - * + * * @see #getUIState() */ void saveState(IMemento memento); /** * Sets the id for this page. This method will be called before any other * initialization is done. - * + * * @param id the id for this page */ void setID(String id); /** * Returns the id set via <code>setID</code>. - * + * * @return the id of this page */ String getID(); - + /** * Returns a user readable label for this search result page. The label will be * used to describe the contents for the page to the user (for example it will be * displayed in the search view title bar). To take an example from file search, * a label might read like this: 'test' - 896 matches in workspace. - * + * * @return the user readable label for this search result page */ String getLabel(); diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultViewPart.java b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultViewPart.java index e435c88bccb..aeed4486dda 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultViewPart.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/ISearchResultViewPart.java @@ -22,30 +22,30 @@ import org.eclipse.ui.IViewPart; * <p> * This interface is not intended to be implemented by clients * </p> - * + * * @see NewSearchUI#activateSearchResultView() * @see NewSearchUI#getSearchResultView() - * + * * @since 3.0 - * + * * @noimplement This interface is not intended to be implemented by clients. */ public interface ISearchResultViewPart extends IViewPart { /** * Search result pages should call this method to have the search results view contribute to * their context menus. - * + * * @param menuManager the menu manager the search result view should contribute to */ void fillContextMenu(IMenuManager menuManager); /** * Returns the <code>ISearchResultPage</code> currently shown in this * search view. Returns <code>null</code> if no page is currently shown. - * + * * @return the active <code>ISearchResultPage</code> or <code>null</code> */ ISearchResultPage getActivePage(); - + /** * Requests that the search view updates the label it is showing for search result * pages. Typically, a search result page will call this method when the search result diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/NewSearchUI.java b/org.eclipse.search/new search/org/eclipse/search/ui/NewSearchUI.java index bfac5246116..19f32d9ac81 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/NewSearchUI.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/NewSearchUI.java @@ -26,16 +26,16 @@ import org.eclipse.search2.internal.ui.SearchMessages; /** * A facade for access to the new search UI facilities. - * + * * @since 3.0 - * + * */ public class NewSearchUI { /** * Activates a search result view in the current workbench window page. If a * search view is already open in the current workbench window page, it is * activated. Otherwise a new search view is opened and activated. - * + * * @return the activate search result view or <code>null</code> if the * search result view couldn't be activated */ @@ -44,7 +44,7 @@ public class NewSearchUI { } /** * Gets the search result view shown in the current workbench window. - * + * * @return the search result view or <code>null</code>, if none is open * in the current workbench window page */ @@ -57,7 +57,7 @@ public class NewSearchUI { * returns <code>true</code>. Running a query adds it to the set of known * queries and notifies any registered <code>IQueryListener</code>s about * the addition. - * + * * @param query * the query to execute * @deprecated deprecated in 3.1. @@ -76,22 +76,22 @@ public class NewSearchUI { if (!status.isOK()) SearchPlugin.log(status); if (status.getSeverity() == IStatus.ERROR) { - ErrorDialog.openError(SearchPlugin.getActiveWorkbenchShell(), SearchMessages.NewSearchUI_error_title, SearchMessages.NewSearchUI_error_label, status); + ErrorDialog.openError(SearchPlugin.getActiveWorkbenchShell(), SearchMessages.NewSearchUI_error_title, SearchMessages.NewSearchUI_error_label, status); } } } } - + /** * Runs the given search query. This method will execute the query in a - * background thread and not block until the search is finished. + * background thread and not block until the search is finished. * Running a query adds it to the set of known queries and notifies * any registered {@link IQueryListener}s about the addition. * <p> * The search view that shows the result will be activated. That means a call * to {@link #activateSearchResultView} is not required. * </p> - * + * * @param query * the query to execute. The query must be able to run in background, that means * {@link ISearchQuery#canRunInBackground()} must be <code>true</code> @@ -104,17 +104,17 @@ public class NewSearchUI { } runQueryInBackground(query, null); } - + /** * Runs the given search query. This method will execute the query in a - * background thread and not block until the search is finished. + * background thread and not block until the search is finished. * Running a query adds it to the set of known queries and notifies * any registered {@link IQueryListener}s about the addition. * <p> * The result will be shown in the given search result view which will be activated. A call to * to {@link #activateSearchResultView} is not required. * </p> - * + * * @param query * the query to execute. The query must be able to run in background, that means * {@link ISearchQuery#canRunInBackground()} must be <code>true</code> @@ -133,7 +133,7 @@ public class NewSearchUI { else throw new IllegalArgumentException("Query can not be run in background"); //$NON-NLS-1$ } - + /** * Runs the given search query. This method will execute the query in the * same thread as the caller. This method blocks until the query is @@ -143,7 +143,7 @@ public class NewSearchUI { * The result will be shown in a search view that will be activated. That means a call * to {@link #activateSearchResultView} is not required. * </p> - * + * * @param context * the runnable context to run the query in * @param query @@ -157,7 +157,7 @@ public class NewSearchUI { } return runQueryInForeground(context, query, null); } - + /** * Runs the given search query. This method will execute the query in the * same thread as the caller. This method blocks until the query is @@ -167,7 +167,7 @@ public class NewSearchUI { * The result will be shown in the given search result view which will be activated. A call to * to {@link #activateSearchResultView} is not required. * </p> - * + * * @param context * the runnable context to run the query in * @param query @@ -177,7 +177,7 @@ public class NewSearchUI { * mechanism is used to open a new result view or to select the view to be reused. * @return a status indicating whether the query ran correctly, including {@link IStatus#CANCEL} to signal * that the query was canceled. - * + * * @since 3.2 */ public static IStatus runQueryInForeground(IRunnableContext context, ISearchQuery query, ISearchResultViewPart view) { @@ -186,13 +186,13 @@ public class NewSearchUI { } return InternalSearchUI.getInstance().runSearchInForeground(context, query, view); } - + /** * Registers the given listener to receive notification of changes to * queries. The listener will be notified whenever a query has been added, * removed, is starting or has finished. Has no effect if an identical * listener is already registered. - * + * * @param l * the listener to be added */ @@ -202,7 +202,7 @@ public class NewSearchUI { /** * Removes the given query listener. Does nothing if the listener is not * present. - * + * * @param l * the listener to be removed. */ @@ -212,17 +212,17 @@ public class NewSearchUI { /** * Returns all search queries know to the search UI (i.e. registered via * <code>runQuery()</code> or <code>runQueryInForeground())</code>. - * + * * @return all search results */ public static ISearchQuery[] getQueries() { return InternalSearchUI.getInstance().getQueries(); } - + /** * Returns whether the given query is currently running. Queries may be run * by client request or by actions in the search UI. - * + * * @param query * the query * @return whether the given query is currently running @@ -235,11 +235,11 @@ public class NewSearchUI { } return InternalSearchUI.getInstance().isQueryRunning(query); } - + /** * Sends a 'cancel' command to the given query running in background. - * The call has no effect if the query is not running, not in background or is not cancelable. - * + * The call has no effect if the query is not running, not in background or is not cancelable. + * * @param query * the query * @since 3.1 @@ -250,25 +250,25 @@ public class NewSearchUI { } InternalSearchUI.getInstance().cancelSearch(query); } - + /** * Search Plug-in Id (value <code>"org.eclipse.search"</code>). */ public static final String PLUGIN_ID= "org.eclipse.search"; //$NON-NLS-1$ - /** + /** * Search marker type (value <code>"org.eclipse.search.searchmarker"</code>). * * @see org.eclipse.core.resources.IMarker - */ + */ public static final String SEARCH_MARKER= PLUGIN_ID + ".searchmarker"; //$NON-NLS-1$ - /** + /** * Id of the new Search view * (value <code>"org.eclipse.search.ui.views.SearchView"</code>). */ public static final String SEARCH_VIEW_ID= "org.eclipse.search.ui.views.SearchView"; //$NON-NLS-1$ - + /** * Id of the Search action set * (value <code>"org.eclipse.search.searchActionSet"</code>). @@ -287,12 +287,12 @@ public class NewSearchUI { */ public static void openSearchDialog(IWorkbenchWindow window, String pageId) { new OpenSearchDialogAction(window, pageId).run(); - } + } /** * Returns the preference whether editors should be reused * when showing search results. - * + * * The goto action can decide to use or ignore this preference. * * @return <code>true</code> if editors should be reused for showing search results diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/SearchResultEvent.java b/org.eclipse.search/new search/org/eclipse/search/ui/SearchResultEvent.java index 0faee480f31..0efb49efc69 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/SearchResultEvent.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/SearchResultEvent.java @@ -16,28 +16,28 @@ import java.util.EventObject; * The common superclass of all events sent from <code>ISearchResults</code>. * This class is supposed to be subclassed to provide more specific * notification. - * + * * @see org.eclipse.search.ui.ISearchResultListener#searchResultChanged(SearchResultEvent) - * + * * @since 3.0 */ public abstract class SearchResultEvent extends EventObject { - + private static final long serialVersionUID= -4877459368182725252L; - - + + /** * Creates a new search result event for the given search result. - * + * * @param searchResult the source of the event */ protected SearchResultEvent(ISearchResult searchResult) { super(searchResult); } - + /** * Gets the <code>ISearchResult</code> for this event. - * + * * @return the source of this event */ public ISearchResult getSearchResult() { diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/actions/TextSearchGroup.java b/org.eclipse.search/new search/org/eclipse/search/ui/actions/TextSearchGroup.java index 5b4b82c2e0e..675740a4e51 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/actions/TextSearchGroup.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/actions/TextSearchGroup.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright (c) 2006, 2007 Wind River Systems 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: - * Markus Schorn - initial API and implementation + * 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: + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.search.ui.actions; @@ -19,6 +19,7 @@ import org.eclipse.jface.action.Separator; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.actions.ActionGroup; + import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.search2.internal.ui.SearchMessages; @@ -30,11 +31,11 @@ import org.eclipse.search2.internal.ui.text2.FindInWorkspaceActionDelegate; /** * Action group that adds a sub-menu with text search actions to a context menu. - * + * * @since 3.2 */ public class TextSearchGroup extends ActionGroup { - + private static final String CTX_MENU_ID= "org.eclipse.search.text.ctxmenu"; //$NON-NLS-1$ private String fAppendToGroup= ITextEditorActionConstants.GROUP_FIND; @@ -45,17 +46,17 @@ public class TextSearchGroup extends ActionGroup { * Constructs a TextSearchGroup for adding actions to the context menu * of the editor provided. The editor will be accessed for the purpose of * determining the search string. - * - * @param editor the editor + * + * @param editor the editor */ public TextSearchGroup(IEditorPart editor) { createActions(editor); } /** - * Changes the text that is used for the submenu label. The default is + * Changes the text that is used for the submenu label. The default is * "Search Text". - * + * * @param text the text for the menu label. */ public void setMenuText(String text) { @@ -65,7 +66,7 @@ public class TextSearchGroup extends ActionGroup { /** * Changes the group where the submenu is appended to. The default is * ITextEditorActionConstants.GROUP_FIND. - * + * * @param groupID the group id to append to */ public void setAppendToGroup(String groupID) { diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java index 40cd78a0a1e..d67c5c44c8f 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchResult.java @@ -24,15 +24,15 @@ import org.eclipse.search.ui.SearchResultEvent; /** * An abstract base implementation for text-match based search results. This search - * result implementation consists of a list of {@link org.eclipse.search.ui.text.Match matches}. + * result implementation consists of a list of {@link org.eclipse.search.ui.text.Match matches}. * No assumptions are made about the kind of elements these matches are reported against. - * - * @since 3.0 + * + * @since 3.0 */ public abstract class AbstractTextSearchResult implements ISearchResult { - + private static final Match[] EMPTY_ARRAY= new Match[0]; - + private final Map fElementsToMatches; private final List fListeners; private final MatchEvent fMatchEvent; @@ -46,14 +46,14 @@ public abstract class AbstractTextSearchResult implements ISearchResult { fElementsToMatches= new HashMap(); fListeners= new ArrayList(); fMatchEvent= new MatchEvent(this); - + fMatchFilters= null; // filtering disabled by default } - + /** * Returns an array with all matches reported against the given element. * Note that all matches of the given element are returned. The filter state of the matches is not relevant. - * + * * @param element the element to report matches for * @return all matches reported for this element * @see Match#getElement() @@ -66,14 +66,14 @@ public abstract class AbstractTextSearchResult implements ISearchResult { return EMPTY_ARRAY; } } - + /** * Adds a <code>Match</code> to this search result. This method does nothing if the * match is already present. * <p> * Subclasses may extend this method. * </p> - * + * * @param match the match to add */ public void addMatch(Match match) { @@ -84,9 +84,9 @@ public abstract class AbstractTextSearchResult implements ISearchResult { if (hasAdded) fireChange(getSearchResultEvent(match, MatchEvent.ADDED)); } - + /** - * Adds a number of Matches to this search result. This method does nothing for + * Adds a number of Matches to this search result. This method does nothing for * matches that are already present. * <p> * Subclasses may extend this method. @@ -104,7 +104,7 @@ public abstract class AbstractTextSearchResult implements ISearchResult { if (!reallyAdded.isEmpty()) fireChange(getSearchResultEvent(reallyAdded, MatchEvent.ADDED)); } - + private MatchEvent getSearchResultEvent(Match match, int eventKind) { fMatchEvent.setKind(eventKind); fMatchEvent.setMatch(match); @@ -120,7 +120,7 @@ public abstract class AbstractTextSearchResult implements ISearchResult { private boolean doAddMatch(Match match) { updateFilterState(match); - + List matches= (List) fElementsToMatches.get(match.getElement()); if (matches == null) { matches= new ArrayList(); @@ -134,12 +134,12 @@ public abstract class AbstractTextSearchResult implements ISearchResult { } return false; } - + private static void insertSorted(List matches, Match match) { int insertIndex= getInsertIndex(matches, match); matches.add(insertIndex, match); } - + private static int getInsertIndex(List matches, Match match) { int count= matches.size(); int min = 0, max = count - 1; @@ -178,7 +178,7 @@ public abstract class AbstractTextSearchResult implements ISearchResult { private void doRemoveAll() { fElementsToMatches.clear(); } - + /** * Removes the given match from this search result. This method has no * effect if the match is not found. @@ -195,14 +195,14 @@ public abstract class AbstractTextSearchResult implements ISearchResult { if (existed) fireChange(getSearchResultEvent(match, MatchEvent.REMOVED)); } - + /** * Removes the given matches from this search result. This method has no * effect for matches that are not found * <p> * Subclasses may extend this method. * </p> - * + * * @param matches the matches to remove */ public void removeMatches(Match[] matches) { @@ -217,7 +217,7 @@ public abstract class AbstractTextSearchResult implements ISearchResult { fireChange(getSearchResultEvent(existing, MatchEvent.REMOVED)); } - + private boolean doRemoveMatch(Match match) { boolean existed= false; List matches= (List) fElementsToMatches.get(match.getElement()); @@ -228,7 +228,7 @@ public abstract class AbstractTextSearchResult implements ISearchResult { } return existed; } - + /** * {@inheritDoc} */ @@ -237,7 +237,7 @@ public abstract class AbstractTextSearchResult implements ISearchResult { fListeners.add(l); } } - + /** * {@inheritDoc} */ @@ -246,13 +246,13 @@ public abstract class AbstractTextSearchResult implements ISearchResult { fListeners.remove(l); } } - + /** * Send the given <code>SearchResultEvent</code> to all registered search * result listeners. - * + * * @param e the event to be sent - * + * * @see ISearchResultListener */ protected void fireChange(SearchResultEvent e) { @@ -265,7 +265,7 @@ public abstract class AbstractTextSearchResult implements ISearchResult { ((ISearchResultListener) listeners.next()).searchResultChanged(e); } } - + private void updateFilterStateForAllMatches() { boolean disableFiltering= getActiveMatchFilters() == null; ArrayList changed= new ArrayList(); @@ -281,7 +281,7 @@ public abstract class AbstractTextSearchResult implements ISearchResult { Match[] allChanges= (Match[]) changed.toArray(new Match[changed.size()]); fireChange(new FilterUpdateEvent(this, allChanges, getActiveMatchFilters())); } - + /* * Evaluates the filter for the match and updates it. Return true if the filter changed. */ @@ -290,7 +290,7 @@ public abstract class AbstractTextSearchResult implements ISearchResult { if (matchFilters == null) { return false; // do nothing, no change } - + boolean oldState= match.isFiltered(); for (int i= 0; i < matchFilters.length; i++) { if (matchFilters[i].filters(match)) { @@ -301,11 +301,11 @@ public abstract class AbstractTextSearchResult implements ISearchResult { match.setFiltered(false); return oldState; } - + /** * Returns the total number of matches contained in this search result. * The filter state of the matches is not relevant when counting matches. All matches are counted. - * + * * @return total number of matches */ public int getMatchCount() { @@ -319,12 +319,12 @@ public abstract class AbstractTextSearchResult implements ISearchResult { } return count; } - + /** * Returns the number of matches reported against a given element. This is * equivalent to calling <code>getMatches(element).length</code> * The filter state of the matches is not relevant when counting matches. All matches are counted. - * + * * @param element the element to get the match count for * @return the number of matches reported against the element */ @@ -334,12 +334,12 @@ public abstract class AbstractTextSearchResult implements ISearchResult { return matches.size(); return 0; } - + /** * Returns an array containing the set of all elements that matches are * reported against in this search result. * Note that all elements that contain matches are returned. The filter state of the matches is not relevant. - * + * * @return the set of elements in this search result */ public Object[] getElements() { @@ -347,7 +347,7 @@ public abstract class AbstractTextSearchResult implements ISearchResult { return fElementsToMatches.keySet().toArray(); } } - + /** * Sets the active match filters for this result. If set to non-null, the match filters will be used to update the filter * state ({@link Match#isFiltered()} of matches and the {@link AbstractTextSearchViewPage} will only @@ -355,63 +355,63 @@ public abstract class AbstractTextSearchResult implements ISearchResult { * the filter state of the match is ignored by the {@link AbstractTextSearchViewPage} and all matches * are shown. * Note the model contains all matches, regardless if the filter state of a match. - * + * * @param filters the match filters to set or <code>null</code> if the filter state of the match * should be ignored. - * + * * @since 3.3 */ public void setActiveMatchFilters(MatchFilter[] filters) { fMatchFilters= filters; updateFilterStateForAllMatches(); } - + /** * Returns the active match filters for this result. If not null is returned, the match filters will be used to update the filter * state ({@link Match#isFiltered()} of matches and the {@link AbstractTextSearchViewPage} will only * show non-filtered matches. If <code>null</code> is set * the filter state of the match is ignored by the {@link AbstractTextSearchViewPage} and all matches * are shown. - * + * * @return the match filters to be used or <code>null</code> if the filter state of the match * should be ignored. - * + * * @since 3.3 */ public MatchFilter[] getActiveMatchFilters() { return fMatchFilters; } - + /** * Returns all applicable filters for this result or null if match filters are not supported. If match filters are returned, * the {@link AbstractTextSearchViewPage} will contain menu entries in the view menu. - * - * @return all applicable filters for this result. - * + * + * @return all applicable filters for this result. + * * @since 3.3 */ public MatchFilter[] getAllMatchFilters() { return null; } - + /** * Returns an implementation of <code>IEditorMatchAdapter</code> appropriate * for this search result. - * + * * @return an appropriate adapter or <code>null</code> if none has been implemented - * + * * @see IEditorMatchAdapter */ public abstract IEditorMatchAdapter getEditorMatchAdapter(); - + /** * Returns an implementation of <code>IFileMatchAdapter</code> appropriate - * for this search result. - * + * for this search result. + * * @return an appropriate adapter or <code>null</code> if none has been implemented - * + * * @see IFileMatchAdapter */ public abstract IFileMatchAdapter getFileMatchAdapter(); diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java index 31dd71dc205..e9c50210de2 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java @@ -119,17 +119,17 @@ import org.eclipse.search2.internal.ui.text.PositionTracker; * provider and a content provider. <br> * Changes in the search result are handled by updating the viewer in the * <code>elementsChanged()</code> and <code>clear()</code> methods. - * + * * @since 3.0 */ public abstract class AbstractTextSearchViewPage extends Page implements ISearchResultPage { private class UpdateUIJob extends UIJob { - + public UpdateUIJob() { super(SearchMessages.AbstractTextSearchViewPage_update_job_name); setSystem(true); } - + public IStatus runInUIThread(IProgressMonitor monitor) { Control control= getControl(); if (control == null || control.isDisposed()) { @@ -155,19 +155,19 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch fViewPart.updateLabel(); return Status.OK_STATUS; } - + /* * Undocumented for testing only. Used to find UpdateUIJobs. */ public boolean belongsTo(Object family) { return family == AbstractTextSearchViewPage.this; } - + } - + private class SelectionProviderAdapter implements ISelectionProvider, ISelectionChangedListener { private ArrayList fListeners= new ArrayList(5); - + public void addSelectionChangedListener(ISelectionChangedListener listener) { fListeners.add(listener); } @@ -198,12 +198,12 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch private volatile boolean fIsUIUpdateScheduled= false; private volatile boolean fScheduleEnsureSelection= false; private static final String KEY_LAYOUT = "org.eclipse.search.resultpage.layout"; //$NON-NLS-1$ - + /** * An empty array. */ protected static final Match[] EMPTY_MATCH_ARRAY= new Match[0]; - + private StructuredViewer fViewer; private Composite fViewerContainer; private Control fBusyLabel; @@ -212,7 +212,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch private ISearchResultViewPart fViewPart; private Set fBatchedUpdates; private boolean fBatchedClearAll; - + private ISearchResultListener fListener; private IQueryListener fQueryListener; private MenuManager fMenu; @@ -224,10 +224,10 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch private Action fRemoveAllResultsAction; private Action fShowNextAction; private Action fShowPreviousAction; - + private ExpandAllAction fExpandAllAction; private CollapseAllAction fCollapseAllAction; - + private SetLayoutAction fFlatAction; private SetLayoutAction fHierarchicalAction; private int fCurrentLayout; @@ -236,10 +236,10 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch private final int fSupportedLayouts; private SelectionProviderAdapter fViewerAdapter; private SelectAllAction fSelectAllAction; - + private IAction[] fFilterActions; private Integer fElementLimit; - + /** * Flag (<code>value 1</code>) denoting flat list layout. */ @@ -249,12 +249,12 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch */ public static final int FLAG_LAYOUT_TREE = 2; - + /** * This constructor must be passed a combination of layout flags combined * with bitwise or. At least one flag must be passed in (i.e. 0 is not a * permitted value). - * + * * @param supportedLayouts * flags determining which layout options this page supports. * Must not be 0 @@ -274,12 +274,12 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch fExpandAllAction= new ExpandAllAction(); fCollapseAllAction= new CollapseAllAction(); } - + fSelectAllAction= new SelectAllAction(); createLayoutActions(); fBatchedUpdates = new HashSet(); fBatchedClearAll= false; - + fListener = new ISearchResultListener() { public void searchResultChanged(SearchResultEvent e) { handleSearchResultChanged(e); @@ -288,7 +288,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch fFilterActions= null; fElementLimit= null; } - + private void initLayout() { if (supportsTreeLayout()) fCurrentLayout = FLAG_LAYOUT_TREE; @@ -298,13 +298,13 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch /** * Constructs this page with the default layout flags. - * + * * @see AbstractTextSearchViewPage#AbstractTextSearchViewPage(int) */ protected AbstractTextSearchViewPage() { this(FLAG_LAYOUT_FLAT | FLAG_LAYOUT_TREE); } - + private void createLayoutActions() { if (countBits(fSupportedLayouts) > 1) { @@ -314,7 +314,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch SearchPluginImages.setImageDescriptors(fHierarchicalAction, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_HIERARCHICAL_LAYOUT); } } - + private int countBits(int layoutFlags) { int bitCount = 0; for (int i = 0; i < 32; i++) { @@ -332,7 +332,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch /** * Returns a dialog settings object for this search result page. There will be * one dialog settings object per search result page id. - * + * * @return the dialog settings for this search result page * @see AbstractTextSearchViewPage#getID() */ @@ -357,7 +357,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch public String getID() { return fId; } - + /** * {@inheritDoc} */ @@ -372,12 +372,12 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch * Opens an editor on the given element and selects the given range of text. If a search results * implements a <code>IFileMatchAdapter</code>, match locations will be tracked and the current * match range will be passed into this method. - * + * * @param match the match to show * @param currentOffset the current start offset of the match * @param currentLength the current length of the selection * @throws PartInitException if an editor can't be opened - * + * * @see org.eclipse.core.filebuffers.ITextFileBufferManager * @see IFileMatchAdapter * @deprecated Use {@link #showMatch(Match, int, int, boolean)} instead @@ -392,7 +392,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch * this method. * If the <code>activate</code> parameter is <code>true</code> the opened editor * should have be activated. Otherwise the focus should not be changed. - * + * * @param match * the match to show * @param currentOffset @@ -403,7 +403,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch * whether to activate the editor. * @throws PartInitException * if an editor can't be opened - * + * * @see org.eclipse.core.filebuffers.ITextFileBufferManager * @see IFileMatchAdapter */ @@ -418,7 +418,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch * occurred by the time this method is called. They will be described in a * future call. * <p>The changed elements are evaluated by {@link #evaluateChangedElements(Match[], Set)}.</p> - * + * * @param objects * array of objects that has to be refreshed */ @@ -437,7 +437,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch * Configures the given viewer. Implementers have to set at least a content * provider and a label provider. This method may be called if the page was * constructed with the flag <code>FLAG_LAYOUT_TREE</code>. - * + * * @param viewer the viewer to be configured */ protected abstract void configureTreeViewer(TreeViewer viewer); @@ -446,7 +446,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch * Configures the given viewer. Implementers have to set at least a content * provider and a label provider. This method may be called if the page was * constructed with the flag <code>FLAG_LAYOUT_FLAT</code>. - * + * * @param viewer the viewer to be configured */ protected abstract void configureTableViewer(TableViewer viewer); @@ -454,7 +454,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch /** * Fills the context menu for this page. Subclasses may override this * method. - * + * * @param mgr the menu manager representing the context menu */ protected void fillContextMenu(IMenuManager mgr) { @@ -466,7 +466,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch if (canRemoveMatchesWith(getViewer().getSelection())) mgr.appendToGroup(IContextMenuConstants.GROUP_REMOVE_MATCHES, fRemoveSelectedMatches); mgr.appendToGroup(IContextMenuConstants.GROUP_REMOVE_MATCHES, fRemoveAllResultsAction); - + if (getLayout() == FLAG_LAYOUT_TREE) { mgr.appendToGroup(IContextMenuConstants.GROUP_SHOW, fExpandAllAction); } @@ -510,7 +510,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch // Register menu getSite().registerContextMenu(fViewPart.getViewSite().getId(), fMenu, fViewerAdapter); - + createViewer(fViewerContainer, fCurrentLayout); showBusyLabel(fIsBusyShown); NewSearchUI.addQueryListener(fQueryListener); @@ -597,10 +597,10 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch /** * Determines whether a certain layout is supported by this search result * page. - * + * * @param layout the layout to test for * @return whether the given layout is supported or not - * + * * @see AbstractTextSearchViewPage#AbstractTextSearchViewPage(int) */ public boolean isLayoutSupported(int layout) { @@ -613,7 +613,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch * it must be one of the values passed during construction of this search * result page. * @param layout the new layout - * + * * @see AbstractTextSearchViewPage#isLayoutSupported(int) */ public void setLayout(int layout) { @@ -650,9 +650,9 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch /** * Return the layout this page is currently using. - * + * * @return the layout this page is currently using - * + * * @see #FLAG_LAYOUT_FLAT * @see #FLAG_LAYOUT_TREE */ @@ -672,16 +672,16 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch fCollapseAllAction.setViewer(viewer); fExpandAllAction.setViewer(viewer); } - + fCopyToClipboardAction.setViewer(fViewer); fSelectAllAction.setViewer(fViewer); - + IToolBarManager tbm = getSite().getActionBars().getToolBarManager(); tbm.removeAll(); SearchView.createToolBarGroups(tbm); fillToolbar(tbm); tbm.update(false); - + new OpenAndLinkWithEditorHelper(fViewer) { protected void activate(ISelection selection) { @@ -710,12 +710,12 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch fRemoveSelectedMatches.setEnabled(canRemoveMatchesWith(event.getSelection())); } }); - + fViewer.addSelectionChangedListener(fViewerAdapter); - + Menu menu = fMenu.createContextMenu(fViewer.getControl()); fViewer.getControl().setMenu(menu); - + updateLayoutActions(); getViewPart().updateLabel(); } @@ -723,7 +723,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch /** * Creates the tree viewer to be shown on this page. Clients may override * this method. - * + * * @param parent the parent widget * @return returns a newly created <code>TreeViewer</code>. */ @@ -734,7 +734,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch /** * Creates the table viewer to be shown on this page. Clients may override * this method. - * + * * @param parent the parent widget * @return returns a newly created <code>TableViewer</code> */ @@ -764,7 +764,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch public void setInput(ISearchResult newSearch, Object viewState) { if (newSearch != null && !(newSearch instanceof AbstractTextSearchResult)) return; // ignore - + AbstractTextSearchResult oldSearch= fInput; if (oldSearch != null) { disconnectViewer(); @@ -773,21 +773,21 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch AnnotationManagers.removeSearchResult(getSite().getWorkbenchWindow(), oldSearch); } fInput= (AbstractTextSearchResult) newSearch; - + if (fInput != null) { AnnotationManagers.addSearchResult(getSite().getWorkbenchWindow(), fInput); - + fInput.addListener(fListener); connectViewer(fInput); if (viewState instanceof ISelection) fViewer.setSelection((ISelection) viewState, true); else navigateNext(true); - + updateBusyLabel(); turnOffDecoration(); scheduleUIUpdate(); - + fFilterActions= addFilterActionsToViewMenu(); } else { getViewPart().updateLabel(); @@ -805,23 +805,23 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch } menu.remove(MatchFilterSelectionAction.ACTION_ID); } - + private IAction[] addFilterActionsToViewMenu() { AbstractTextSearchResult input= getInput(); if (input == null) { return null; } - + MatchFilter[] allMatchFilters= input.getAllMatchFilters(); if (allMatchFilters == null && getElementLimit() == null) { return null; } - + IActionBars bars= getSite().getActionBars(); IMenuManager menu= bars.getMenuManager(); - + menu.prependToGroup(IContextMenuConstants.GROUP_FILTERING, new MatchFilterSelectionAction(this)); - + if (allMatchFilters != null) { MatchFilterAction[] actions= new MatchFilterAction[allMatchFilters.length]; for (int i= allMatchFilters.length - 1; i >= 0; i--) { @@ -833,7 +833,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch } return null; } - + private void updateFilterActions(IAction[] filterActions) { if (filterActions != null) { for (int i= 0; i < filterActions.length; i++) { @@ -862,7 +862,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch /** * Returns the viewer currently used in this page. - * + * * @return the currently used viewer or <code>null</code> if none has been * created yet. */ @@ -889,9 +889,9 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch /** * Returns the currently shown result. - * + * * @return the previously set result or <code>null</code> - * + * * @see AbstractTextSearchViewPage#setInput(ISearchResult, Object) */ public AbstractTextSearchResult getInput() { @@ -935,7 +935,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch } showCurrentMatch(activateEditor); } - + private void navigateNext(boolean forward) { INavigate navigator = null; if (fViewer instanceof TableViewer) { @@ -957,7 +957,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch /** * Returns the currently selected match. - * + * * @return the selected match or <code>null</code> if none are selected */ public Match getCurrentMatch() { @@ -969,7 +969,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch } return null; } - + /** * Returns the matches that are currently displayed for the given element. * If {@link AbstractTextSearchResult#getActiveMatchFilters()} is not null, only matches are returned @@ -978,7 +978,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch * Any action operating on the visible matches in the search * result page should use this method to get the matches for a search * result (instead of asking the search result directly). - * + * * @param element * The element to get the matches for * @return The matches displayed for the given element. If the current input @@ -1002,7 +1002,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch } if (count == matches.length) return matches; - + Match[] filteredMatches= new Match[count]; for (int i= 0, k= 0; i < matches.length; i++) { if (matches[i] != null) @@ -1010,7 +1010,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch } return filteredMatches; } - + /** * Returns the current location of the match. This takes possible * modifications of the file into account. Therefore the result may @@ -1018,12 +1018,12 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch * off the match. * @param match the match to get the position for. * @return the current position of the match. - * + * * @since 3.2 */ public IRegion getCurrentMatchLocation(Match match) { PositionTracker tracker= InternalSearchUI.getInstance().getPositionTracker(); - + int offset, length; Position pos= tracker.getCurrentPosition(match); if (pos == null) { @@ -1035,7 +1035,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch } return new Region(offset, length); } - + /** * Returns the number of matches that are currently displayed for the given * element. If {@link AbstractTextSearchResult#getActiveMatchFilters()} is not null, only matches @@ -1043,7 +1043,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch * Any action operating on the visible matches in the * search result page should use this method to get the match count for a * search result (instead of asking the search result directly). - * + * * @param element * The element to get the matches for * @return The number of matches displayed for the given element. If the @@ -1109,7 +1109,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch /** * Fills the toolbar contribution for this page. Subclasses may override * this method. - * + * * @param tbm the tool bar manager representing the view's toolbar */ protected void fillToolbar(IToolBarManager tbm) { @@ -1149,7 +1149,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch /** * Returns the view part set with * <code>setViewPart(ISearchResultViewPart)</code>. - * + * * @return The view part or <code>null</code> if the view part hasn't been * set yet (or set to null). */ @@ -1158,11 +1158,11 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch } // multi-threaded update handling. - + /** * Handles a search result event for the current search result. * @param e the event to handle - * + * * @since 3.2 */ protected void handleSearchResultChanged(final SearchResultEvent e) { @@ -1175,12 +1175,12 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch updateFilterActions(fFilterActions); } } - + /** * Evaluates the elements to that are later passed to {@link #elementsChanged(Object[])}. By default * the element to change are the elements received by ({@link Match#getElement()}). Client implementations * can modify this behavior. - * + * * @param matches the matches that were added or removed * @param changedElements the set that collects the elements to change. Clients should only add elements to the set. * @since 3.4 @@ -1190,7 +1190,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch changedElements.add(matches[i].getElement()); } } - + private synchronized void postUpdate(Match[] matches) { evaluateChangedElements(matches, fBatchedUpdates); scheduleUIUpdate(); @@ -1302,7 +1302,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch * Removes the currently selected match. Does nothing if no match is * selected. * </p> - * + * * @noreference This method is not intended to be referenced by clients. */ public void internalRemoveSelected() { @@ -1311,7 +1311,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch return; StructuredViewer viewer = getViewer(); IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); - + HashSet set = new HashSet(); if (viewer instanceof TreeViewer) { ITreeContentProvider cp = (ITreeContentProvider) viewer.getContentProvider(); @@ -1320,7 +1320,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch collectAllMatches(set, selection.toArray()); } navigateNext(true); - + Match[] matches = new Match[set.size()]; set.toArray(matches); result.removeMatches(matches); @@ -1345,7 +1345,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch collectAllMatchesBelow(result, set, cp, children); } } - + private void turnOffDecoration() { IBaseLabelProvider lp= fViewer.getLabelProvider(); if (lp instanceof DecoratingLabelProvider) { @@ -1357,7 +1357,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch IBaseLabelProvider lp= fViewer.getLabelProvider(); if (lp instanceof DecoratingLabelProvider) { ((DecoratingLabelProvider)lp).setLabelDecorator(PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()); - + } } @@ -1371,7 +1371,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch * </p> * @param event * the event sent for the currently shown viewer - * + * * @see IOpenListener */ protected void handleOpen(OpenEvent event) { @@ -1393,7 +1393,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch gotoNextMatch(OpenStrategy.activateOnOpen()); } } - + /** * Sets the maximal number of top level elements to be shown in a viewer. * If <code>null</code> is set, the view page does not support to limit the elements and will not provide @@ -1408,12 +1408,12 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch * <li><code>-1</code> to not limit and provide configuration UI</li> * <li><code>positive integer</code> to limit by the given value and provide configuration UI</li> * </dl> - * + * * @since 3.3 */ public void setElementLimit(Integer limit) { fElementLimit= limit; - + if (fViewer != null) { fViewer.refresh(); } @@ -1421,7 +1421,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch fViewPart.updateLabel(); } } - + /** * Gets the maximal number of top level elements to be shown in a viewer. * <code>null</code> means the view page does not limit the elements and will not provide @@ -1434,12 +1434,12 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch * <li><code>-1</code> to not limit and provide configuration UI</li> * <li><code>positive integer</code> to limit by the given value and provide configuration UI</li> * </dl> - * + * * @since 3.3 */ public Integer getElementLimit() { return fElementLimit; } - - + + } diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java index 23b6e706276..20aee64f64a 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java @@ -43,26 +43,26 @@ import org.eclipse.search.internal.ui.util.FileTypeEditor; * Clients should not instantiate or subclass this class. * </p> * @since 3.2 - * + * * @noinstantiate This class is not intended to be instantiated by clients. */ public final class FileTextSearchScope extends TextSearchScope { - + private static final boolean IS_CASE_SENSITIVE_FILESYSTEM = !new File("Temp").equals(new File("temp")); //$NON-NLS-1$ //$NON-NLS-2$ /** * Returns a scope for the workspace. The created scope contains all resources in the workspace * that match the given file name patterns. Depending on <code>includeDerived</code>, derived resources or * resources inside a derived container are part of the scope or not. - * - * @param fileNamePatterns file name pattern that all files have to match <code>null</code> to include all file names. + * + * @param fileNamePatterns file name pattern that all files have to match <code>null</code> to include all file names. * @param includeDerived defines if derived files and files inside derived containers are included in the scope. * @return a scope containing all files in the workspace that match the given file name patterns. */ public static FileTextSearchScope newWorkspaceScope(String[] fileNamePatterns, boolean includeDerived) { - return new FileTextSearchScope(SearchMessages.WorkspaceScope, new IResource[] { ResourcesPlugin.getWorkspace().getRoot() }, null, fileNamePatterns, includeDerived); + return new FileTextSearchScope(SearchMessages.WorkspaceScope, new IResource[] { ResourcesPlugin.getWorkspace().getRoot() }, null, fileNamePatterns, includeDerived); } - + /** * Returns a scope for the given root resources. The created scope contains all root resources and their * children that match the given file name patterns. Depending on <code>includeDerived</code>, derived resources or @@ -75,7 +75,7 @@ public final class FileTextSearchScope extends TextSearchScope { */ public static FileTextSearchScope newSearchScope(IResource[] roots, String[] fileNamePatterns, boolean includeDerived) { roots= removeRedundantEntries(roots, includeDerived); - + String description; if (roots.length == 0) { description= SearchMessages.FileTextSearchScope_scope_empty; @@ -90,14 +90,14 @@ public final class FileTextSearchScope extends TextSearchScope { description= Messages.format(label, new String[] { roots[0].getName(), roots[1].getName()}); } return new FileTextSearchScope(description, roots, null, fileNamePatterns, includeDerived); - } + } /** * Returns a scope for the given working sets. The created scope contains all resources in the * working sets that match the given file name patterns. Depending on <code>includeDerived</code>, derived resources or * resources inside a derived container are part of the scope or not. - * - * @param workingSets the working sets defining the scope. + * + * @param workingSets the working sets defining the scope. * @param fileNamePatterns file name pattern that all files have to match <code>null</code> to include all file names. * @param includeDerived defines if derived files and files inside derived containers are included in the scope. * @return a scope containing the resources in the working set if they match the given file name patterns. @@ -126,7 +126,7 @@ public final class FileTextSearchScope extends TextSearchScope { private final String[] fFileNamePatterns; private final Matcher fPositiveFileNameMatcher; private final Matcher fNegativeFileNameMatcher; - + private boolean fVisitDerived; private IWorkingSet[] fWorkingSets; @@ -139,10 +139,10 @@ public final class FileTextSearchScope extends TextSearchScope { fPositiveFileNameMatcher= createMatcher(fileNamePatterns, false); fNegativeFileNameMatcher= createMatcher(fileNamePatterns, true); } - + /** * Returns the description of the scope - * + * * @return the description of the scope */ public String getDescription() { @@ -152,17 +152,17 @@ public final class FileTextSearchScope extends TextSearchScope { /** * Returns the file name pattern configured for this scope or <code>null</code> to match * all file names. - * + * * @return the file name pattern starings */ public String[] getFileNamePatterns() { return fFileNamePatterns; } - + /** - * Returns the working-sets that were used to configure this scope or <code>null</code> + * Returns the working-sets that were used to configure this scope or <code>null</code> * if the scope was not created off working sets. - * + * * @return the working-sets the scope is based on. */ public IWorkingSet[] getWorkingSets() { @@ -172,16 +172,16 @@ public final class FileTextSearchScope extends TextSearchScope { /** * Returns the content types configured for this scope or <code>null</code> to match * all content types. - * + * * @return the file name pattern starings */ public IContentType[] getContentTypes() { return null; // to be implemented in the future } - + /** * Returns a description describing the file name patterns and content types. - * + * * @return the description of the scope */ public String getFilterDescription() { @@ -199,16 +199,16 @@ public final class FileTextSearchScope extends TextSearchScope { } return BasicElementLabels.getFilePattern(buf.toString()); } - + /** * Returns whether derived resources are included in this search scope. - * + * * @return whether derived resources are included in this search scope. */ public boolean includeDerived() { return fVisitDerived; } - + /* (non-Javadoc) * @see org.eclipse.search.core.text.FileSearchScope#getRoots() */ @@ -223,13 +223,13 @@ public final class FileTextSearchScope extends TextSearchScope { if (!fVisitDerived && proxy.isDerived()) { return false; // all resources in a derived folder are considered to be derived, see bug 103576 } - + if (proxy.getType() == IResource.FILE) { return matchesFileName(proxy.getName()); } return true; } - + private boolean matchesFileName(String fileName) { if (fPositiveFileNameMatcher != null && !fPositiveFileNameMatcher.reset(fileName).matches()) { return false; @@ -239,7 +239,7 @@ public final class FileTextSearchScope extends TextSearchScope { } return true; } - + private Matcher createMatcher(String[] fileNamePatterns, boolean negativeMatcher) { if (fileNamePatterns == null || fileNamePatterns.length == 0) { return null; @@ -263,7 +263,7 @@ public final class FileTextSearchScope extends TextSearchScope { } return null; } - + private static IResource[] removeRedundantEntries(IResource[] elements, boolean includeDerived) { ArrayList res= new ArrayList(); for (int i= 0; i < elements.length; i++) { @@ -290,7 +290,7 @@ public final class FileTextSearchScope extends TextSearchScope { } return (IResource[]) res.toArray(new IResource[res.size()]); } - + private static void addToList(ArrayList res, IResource curr, boolean includeDerived) { if (!includeDerived && isDerived(curr)) { return; diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/FilterUpdateEvent.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/FilterUpdateEvent.java index 4cc01c8f139..3e0ef9b3fb7 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/text/FilterUpdateEvent.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/FilterUpdateEvent.java @@ -27,10 +27,10 @@ public class FilterUpdateEvent extends SearchResultEvent { private final Match[] fMatches; private final MatchFilter[] fFilters; - + /** * Constructs a new {@link FilterUpdateEvent}. - * + * * @param searchResult the search result concerned * @param matches the matches updated by the filter change * @param filters the currently activated filters @@ -40,19 +40,19 @@ public class FilterUpdateEvent extends SearchResultEvent { fMatches= matches; fFilters= filters; } - + /** * Returns the matches updated by the filter update. - * + * * @return the matches updated by the filter update */ public Match[] getUpdatedMatches() { return fMatches; } - + /** * Returns the the filters currently set, or <code>null</code> if filters have been disabled. - * + * * @return the filters currently set */ public MatchFilter[] getActiveFilters() { diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/IEditorMatchAdapter.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/IEditorMatchAdapter.java index f15d2c4a76f..18269a88f7d 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/text/IEditorMatchAdapter.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/IEditorMatchAdapter.java @@ -13,7 +13,7 @@ package org.eclipse.search.ui.text; import org.eclipse.ui.IEditorPart; /** - * This interface serves as an adapter between matches and editors. It is used to + * This interface serves as an adapter between matches and editors. It is used to * highlight matches in editors. Search implementors who want their matches highlighted * must return an implementation of <code>IEditorMatchAdapter</code> from the <code>getEditorMatchAdapter()</code> * method in their search result subclass. @@ -23,15 +23,15 @@ import org.eclipse.ui.IEditorPart; * Clients may implement this interface. * </p> * @see org.eclipse.search.ui.text.AbstractTextSearchResult - * + * * @since 3.0 */ public interface IEditorMatchAdapter { /** * Determines whether a match should be displayed in the given editor. - * For example, if a match is reported in a file, This method should return - * <code>true</code>, if the given editor displays the file. - * + * For example, if a match is reported in a file, This method should return + * <code>true</code>, if the given editor displays the file. + * * @param match The match * @param editor The editor that possibly contains the matches element * @return whether the given match should be displayed in the editor @@ -43,11 +43,11 @@ public interface IEditorMatchAdapter { * For example, if the editor shows a particular file, all matches in that file should * be returned. * @param result the result to search for matches - * + * * @param editor The editor. * @return All matches that are contained in the element that is shown in * the given editor. */ public abstract Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor); - + } diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/IFileMatchAdapter.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/IFileMatchAdapter.java index c4d50154872..f634e610b7d 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/text/IFileMatchAdapter.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/IFileMatchAdapter.java @@ -22,7 +22,7 @@ import org.eclipse.core.resources.IFile; * Clients may implement this interface. * </p> * @see org.eclipse.search.ui.text.AbstractTextSearchResult - * + * * @since 3.0 */ public interface IFileMatchAdapter { @@ -30,10 +30,10 @@ public interface IFileMatchAdapter { * Returns an array with all matches contained in the given file in the * given search result. If the matches are not contained within an * <code>IFile</code>, this method must return an empty array. - * + * * @param result the search result to find matches in * @param file the file to find matches in - * + * * @return an array of matches (possibly empty) */ public abstract Match[] computeContainedMatches(AbstractTextSearchResult result, IFile file); @@ -41,9 +41,9 @@ public interface IFileMatchAdapter { * Returns the file associated with the given element (usually the file the * element is contained in). If the element is not associated with a file, * this method should return <code>null</code>. - * + * * @param element an element associated with a match - * + * * @return the file associated with the element or <code>null</code> */ public abstract IFile getFile(Object element); diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/ISearchEditorAccess.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/ISearchEditorAccess.java index 4f12f467ce3..1785df18777 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/text/ISearchEditorAccess.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/ISearchEditorAccess.java @@ -15,14 +15,14 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.source.IAnnotationModel; /** - * <p>This interface allows editors to provide customized access to editor internals for the - * search implementation to highlight matches. The search system will use the document to - * do line/character offset conversion if needed and it will add annotations to the annotation + * <p>This interface allows editors to provide customized access to editor internals for the + * search implementation to highlight matches. The search system will use the document to + * do line/character offset conversion if needed and it will add annotations to the annotation * model.</p> - * <p> The search system will ask an editor for an adapter of this class whenever it needs - * access to the document or the annotation model of the editor. Since an editor might use - * multiple documents and/or annotation models, the match is passed in when asking the editor. - * The editor is then expected to return the proper annotation model or document for the given + * <p> The search system will ask an editor for an adapter of this class whenever it needs + * access to the document or the annotation model of the editor. Since an editor might use + * multiple documents and/or annotation models, the match is passed in when asking the editor. + * The editor is then expected to return the proper annotation model or document for the given * match.</p> * <p> * This interface is intended to be implemented by clients. diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/Match.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/Match.java index 2b31033abe9..4bf70e38498 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/text/Match.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/Match.java @@ -18,17 +18,17 @@ import org.eclipse.core.runtime.Assert; * against is assumed to contain the match, and the UI will group matches * against the same element together. A match has an offset and a length which * may be specified in characters or in lines. - * + * * @since 3.0 */ public class Match { - + /** * A constant expressing that offset and length of this match are specified * in lines */ public static final int UNIT_LINE= 1; - + /** * A constant expressing that offset and length of this match are specified * in characters @@ -36,7 +36,7 @@ public class Match { public static final int UNIT_CHARACTER= 2; private static final int IS_FILTERED= 1 << 2; - + private Object fElement; private int fOffset; private int fLength; @@ -44,7 +44,7 @@ public class Match { /** * Constructs a new Match object. - * + * * @param element * the element that contains the match * @param unit @@ -65,7 +65,7 @@ public class Match { /** * Constructs a new Match object. The offset and length will be based on * characters. - * + * * @param element * the element that contains the match * @param offset @@ -79,7 +79,7 @@ public class Match { /** * Returns the offset of this match. - * + * * @return the offset */ public int getOffset() { @@ -88,7 +88,7 @@ public class Match { /** * Sets the offset of this match. - * + * * @param offset * the offset to set */ @@ -98,7 +98,7 @@ public class Match { /** * Returns the length of this match. - * + * * @return the length */ public int getLength() { @@ -107,7 +107,7 @@ public class Match { /** * Sets the length. - * + * * @param length * the length to set */ @@ -117,7 +117,7 @@ public class Match { /** * Returns the element that contains this match. The element is used to group the match. - * + * * @return the element that contains this match */ public Object getElement() { @@ -127,7 +127,7 @@ public class Match { /** * Returns whether match length and offset are expressed in lines or * characters. - * + * * @return either UNIT_LINE or UNIT_CHARACTER; */ public int getBaseUnit() { @@ -135,13 +135,13 @@ public class Match { return UNIT_LINE; return UNIT_CHARACTER; } - + /** * Marks this match as filtered or not. - * + * * @param value <code>true</code> if the match is filtered; * otherwise <code>false</code> - * + * * @since 3.1 */ public void setFiltered(boolean value) { @@ -151,13 +151,13 @@ public class Match { fFlags &= (~IS_FILTERED); } } - + /** * Returns whether this match is filtered or not. - * + * * @return <code>true<code> if the match is filtered; * otherwise <code>false</code> - * + * * @since 3.1 */ public boolean isFiltered() { diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/MatchEvent.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/MatchEvent.java index 4f7052722d2..0bdde79062c 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/text/MatchEvent.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/MatchEvent.java @@ -27,31 +27,31 @@ public class MatchEvent extends SearchResultEvent { private Match[] fMatchContainer = new Match[1]; /** * Constant for a matches being added. - * + * * @see MatchEvent#getKind() */ public static final int ADDED = 1; /** * Constant for a matches being removed. - * + * * @see MatchEvent#getKind() */ public static final int REMOVED = 2; - + private static final Match[] fgEmtpyMatches = new Match[0]; - + /** * Constructs a new <code>MatchEvent</code>. - * + * * @param searchResult the search result concerned */ public MatchEvent(ISearchResult searchResult) { super(searchResult); } - + /** * Tells whether this is a remove or an add. - * + * * @return one of <code>ADDED</code> or <code>REMOVED</code> */ public int getKind() { @@ -59,7 +59,7 @@ public class MatchEvent extends SearchResultEvent { } /** * Returns the concerned matches. - * + * * @return the matches this event is about */ public Match[] getMatches() { @@ -70,10 +70,10 @@ public class MatchEvent extends SearchResultEvent { else return fgEmtpyMatches; } - + /** * Sets the kind of event this is. - * + * * @param kind the kind to set; either <code>ADDED</code> or <code>REMOVED</code> */ protected void setKind(int kind) { @@ -81,17 +81,17 @@ public class MatchEvent extends SearchResultEvent { } /** * Sets the match for the change this event reports. - * + * * @param match the match to set */ protected void setMatch(Match match) { fMatchContainer[0] = match; fMatches = null; } - + /** * Sets the matches for the change this event reports. - * + * * @param matches the matches to set */ protected void setMatches(Match[] matches) { diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/MatchFilter.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/MatchFilter.java index eb98e31d622..451a760db1e 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/text/MatchFilter.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/MatchFilter.java @@ -17,7 +17,7 @@ package org.eclipse.search.ui.text; * @since 3.3 */ public abstract class MatchFilter { - + /** * Returns whether the given match is filtered by this filter. * @@ -25,21 +25,21 @@ public abstract class MatchFilter { * @return returns <code>true</code> if the given match should be filtered or <code>false</code> if not. */ public abstract boolean filters(Match match); - + /** * Returns the name of the filter as shown in the match filter selection dialog. * * @return the name of the filter as shown in the match filter selection dialog. */ public abstract String getName(); - + /** * Returns the description of the filter as shown in the match filter selection dialog. * * @return the description of the filter as shown in the match filter selection dialog. */ public abstract String getDescription(); - + /** * Returns the label of the filter as shown by the filter action. * @@ -48,10 +48,10 @@ public abstract class MatchFilter { public abstract String getActionLabel(); /** - * Returns an ID of this filter. + * Returns an ID of this filter. * * @return the id of the filter to be used when persisting this filter. */ public abstract String getID(); - + } diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/RemoveAllEvent.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/RemoveAllEvent.java index 6b1ba519b3e..850b0178a5c 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/text/RemoveAllEvent.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/RemoveAllEvent.java @@ -13,11 +13,11 @@ import org.eclipse.search.ui.ISearchResult; import org.eclipse.search.ui.SearchResultEvent; /** * An event indicating that all matches have been removed from a <code>AbstractTextSearchResult</code>. - * + * * <p> * Clients may instantiate or subclass this class. * </p> - * + * * @since 3.0 */ public class RemoveAllEvent extends SearchResultEvent { diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/TextSearchQueryProvider.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/TextSearchQueryProvider.java index e676e0dd3b6..73475f7c83c 100644 --- a/org.eclipse.search/new search/org/eclipse/search/ui/text/TextSearchQueryProvider.java +++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/TextSearchQueryProvider.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright (c) 2006 Wind River Systems 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: - * Markus Schorn - initial API and implementation + * 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: + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.search.ui.text; @@ -17,14 +17,13 @@ import org.eclipse.core.resources.IResource; import org.eclipse.ui.IWorkingSet; -import org.eclipse.search.ui.ISearchQuery; - import org.eclipse.search.internal.ui.SearchPlugin; +import org.eclipse.search.ui.ISearchQuery; /** * Abstract base class for text search query providers supplied via the <code>org.eclipse.search.textSearchQueryProvider</code> * extension point. The plug-in preference <code>org.eclipse.search.textSearchQueryProvider<code> defines the preferred - * query provider. It is intended that only products choose a preferred query provider. + * query provider. It is intended that only products choose a preferred query provider. * * @since 3.2 */ @@ -37,44 +36,44 @@ public abstract class TextSearchQueryProvider { * </p> */ public static abstract class TextSearchInput { - + /** * Returns the search text to search for. - * + * * @return the search text, depending on {@link #isRegExSearch()} the search text represents a regular expression * or a pattern using '*' and '?' as wildcards. The empty search text signals a file name search. */ public abstract String getSearchText(); - + /** * Returns whether the search is a case sensitive search or not. - * + * * @return whether the pattern is to be used case sensitive or not. */ public abstract boolean isCaseSensitiveSearch(); - + /** * Returns whether the search text denotes a regular expression or not. - * + * * @return whether the pattern denotes a regular expression. */ public abstract boolean isRegExSearch(); - + /** * Returns the scope for the search - * + * * @return the scope for the search */ public abstract FileTextSearchScope getScope(); } - + /** * Returns the preferred query provider. The preferred query provider is typically configured by the product * and defined by the search plug-in preference 'org.eclipse.search.textSearchQueryProvider'. * It is not intended that query providers change at runtime, but clients should always use this method to access * the query provider. - * + * * @return the preferred {@link TextSearchQueryProvider}. */ public static TextSearchQueryProvider getPreferred() { @@ -83,17 +82,17 @@ public abstract class TextSearchQueryProvider { /** * Create a query for the input with the given information. - * + * * @param textSearchInput the search input * @return returns the created search query * @throws CoreException a {@link CoreException} can be thrown when the query provider can not * create a query for the given input. */ public abstract ISearchQuery createQuery(TextSearchInput textSearchInput) throws CoreException; - + /** * Create a query to search for the selected text in the workspace. - * + * * @param selectedText the text to search for * @return returns the created search query * @throws CoreException a {@link CoreException} can be thrown when the query provider can not @@ -103,7 +102,7 @@ public abstract class TextSearchQueryProvider { /** * Create a query to search for the selected text in the given resources. - * + * * @param selectedText the text to search for * @param resources the resources to search in * @return returns the created search query @@ -111,10 +110,10 @@ public abstract class TextSearchQueryProvider { * create a query for the given input. */ public abstract ISearchQuery createQuery(String selectedText, IResource[] resources) throws CoreException; - + /** * Create a query to search for the selected text in the given working sets. - * + * * @param selectedText the text to search for * @param ws the working sets to search in * @return returns the created search query diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/CancelSearchAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/CancelSearchAction.java index c5a1b16b410..32c6568625a 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/CancelSearchAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/CancelSearchAction.java @@ -12,21 +12,20 @@ package org.eclipse.search2.internal.ui; import org.eclipse.jface.action.Action; -import org.eclipse.search.ui.ISearchResult; - import org.eclipse.search.internal.ui.SearchPluginImages; +import org.eclipse.search.ui.ISearchResult; public class CancelSearchAction extends Action { private SearchView fView; public CancelSearchAction(SearchView view) { - super(SearchMessages.CancelSearchAction_label); + super(SearchMessages.CancelSearchAction_label); fView= view; - setToolTipText(SearchMessages.CancelSearchAction_tooltip); + setToolTipText(SearchMessages.CancelSearchAction_tooltip); SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_CANCEL); } - + public void run() { ISearchResult result= fView.getCurrentSearchResult(); if (result != null) { diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java index a9e759bb08b..cfea4dbc1e9 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java @@ -30,28 +30,27 @@ import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.progress.IWorkbenchSiteProgressService; +import org.eclipse.search.internal.ui.SearchPlugin; +import org.eclipse.search.internal.ui.SearchPluginImages; +import org.eclipse.search.internal.ui.SearchPreferencePage; import org.eclipse.search.ui.IQueryListener; import org.eclipse.search.ui.ISearchQuery; import org.eclipse.search.ui.ISearchResult; import org.eclipse.search.ui.ISearchResultViewPart; -import org.eclipse.search.internal.ui.SearchPlugin; -import org.eclipse.search.internal.ui.SearchPluginImages; -import org.eclipse.search.internal.ui.SearchPreferencePage; - import org.eclipse.search2.internal.ui.text.PositionTracker; public class InternalSearchUI { - + //The shared instance. private static InternalSearchUI fgInstance; - + // contains all running jobs private HashMap fSearchJobs; - + private QueryManager fSearchResultsManager; private PositionTracker fPositionTracker; - + private SearchViewManager fSearchViewManager; public static final Object FAMILY_SEARCH = new Object(); @@ -69,18 +68,18 @@ public class InternalSearchUI { this.job= null; } } - + private class InternalSearchJob extends Job { - + private SearchJobRecord fSearchJobRecord; - + public InternalSearchJob(SearchJobRecord sjr) { super(sjr.query.getLabel()); - + fSearchJobRecord= sjr; } - + protected IStatus run(IProgressMonitor monitor) { fSearchJobRecord.job= this; searchJobStarted(fSearchJobRecord); @@ -91,7 +90,7 @@ public class InternalSearchUI { } catch (SecurityException e) {} try{ - status= fSearchJobRecord.query.run(monitor); + status= fSearchJobRecord.query.run(monitor); } finally { try { Thread.currentThread().setPriority(origPriority); @@ -112,13 +111,13 @@ public class InternalSearchUI { record.isRunning= true; getSearchManager().queryStarting(record.query); } - + private void searchJobFinished(SearchJobRecord record) { record.isRunning= false; fSearchJobs.remove(record); getSearchManager().queryFinished(record.query); } - + /** * The constructor. */ @@ -127,9 +126,9 @@ public class InternalSearchUI { fSearchJobs= new HashMap(); fSearchResultsManager= new QueryManager(); fPositionTracker= new PositionTracker(); - + fSearchViewManager= new SearchViewManager(fSearchResultsManager); - + PlatformUI.getWorkbench().getProgressService().registerIconForFamily(SearchPluginImages.DESC_VIEW_SEARCHRES, FAMILY_SEARCH); } @@ -155,25 +154,25 @@ public class InternalSearchUI { } return null; } - + public boolean runSearchInBackground(ISearchQuery query, ISearchResultViewPart view) { if (isQueryRunning(query)) return false; - + // prepare view if (view == null) { getSearchViewManager().activateSearchView(true); } else { getSearchViewManager().activateSearchView(view); } - + addQuery(query); SearchJobRecord sjr= new SearchJobRecord(query, true); fSearchJobs.put(query, sjr); - + Job job= new InternalSearchJob(sjr); - job.setPriority(Job.BUILD); + job.setPriority(Job.BUILD); job.setUser(true); IWorkbenchSiteProgressService service= getProgressService(); @@ -182,7 +181,7 @@ public class InternalSearchUI { } else { job.schedule(); } - + return true; } @@ -195,7 +194,7 @@ public class InternalSearchUI { if (isQueryRunning(query)) { return Status.CANCEL_STATUS; } - + // prepare view if (view == null) { getSearchViewManager().activateSearchView(true); @@ -204,22 +203,22 @@ public class InternalSearchUI { } addQuery(query); - + SearchJobRecord sjr= new SearchJobRecord(query, false); fSearchJobs.put(query, sjr); - + if (context == null) context= new ProgressMonitorDialog(null); - + return doRunSearchInForeground(sjr, context); } - + private IStatus doRunSearchInForeground(final SearchJobRecord rec, IRunnableContext context) { try { context.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { searchJobStarted(rec); - try { + try { IStatus status= rec.query.run(monitor); if (status.matches(IStatus.CANCEL)) { throw new InterruptedException(); @@ -239,7 +238,7 @@ public class InternalSearchUI { if (innerException instanceof CoreException) { return ((CoreException) innerException).getStatus(); } - return new Status(IStatus.ERROR, SearchPlugin.getID(), 0, SearchMessages.InternalSearchUI_error_unexpected, innerException); + return new Status(IStatus.ERROR, SearchPlugin.getID(), 0, SearchMessages.InternalSearchUI_error_unexpected, innerException); } catch (InterruptedException e) { return Status.CANCEL_STATUS; } @@ -248,10 +247,10 @@ public class InternalSearchUI { public static void shutdown() { InternalSearchUI instance= fgInstance; - if (instance != null) + if (instance != null) instance.doShutdown(); } - + private void doShutdown() { Iterator jobRecs= fSearchJobs.values().iterator(); while (jobRecs.hasNext()) { @@ -260,9 +259,9 @@ public class InternalSearchUI { element.job.cancel(); } fPositionTracker.dispose(); - + fSearchViewManager.dispose(fSearchResultsManager); - + } public void cancelSearch(ISearchQuery job) { @@ -276,7 +275,7 @@ public class InternalSearchUI { public QueryManager getSearchManager() { return fSearchResultsManager; } - + public SearchViewManager getSearchViewManager() { return fSearchViewManager; } @@ -284,7 +283,7 @@ public class InternalSearchUI { public PositionTracker getPositionTracker() { return fPositionTracker; } - + public void addQueryListener(IQueryListener l) { getSearchManager().addQueryListener(l); } @@ -311,7 +310,7 @@ public class InternalSearchUI { establishHistoryLimit(); getSearchManager().addQuery(query); } - + private void establishHistoryLimit() { int historyLimit= SearchPreferencePage.getHistoryLimit(); QueryManager searchManager= getSearchManager(); @@ -330,7 +329,7 @@ public class InternalSearchUI { } } } - + public void removeAllQueries() { for (Iterator queries= fSearchJobs.keySet().iterator(); queries.hasNext();) { ISearchQuery query= (ISearchQuery) queries.next(); @@ -339,7 +338,7 @@ public class InternalSearchUI { fSearchJobs.clear(); getSearchManager().removeAll(); } - + public void showSearchResult(SearchView searchView, ISearchResult result, boolean openInNew) { if (openInNew) { boolean isPinned= searchView.isPinned(); @@ -354,11 +353,11 @@ public class InternalSearchUI { showSearchResult(searchView, result); } } - + private void showSearchResult(SearchView searchView, ISearchResult result) { getSearchManager().touch(result.getQuery()); searchView.showSearchResult(result); } - - + + } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterAction.java index 202e55ccb86..6048505d711 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterAction.java @@ -23,10 +23,10 @@ import org.eclipse.search.ui.text.MatchFilter; public class MatchFilterAction extends Action implements IUpdate { - + private MatchFilter fFilter; private AbstractTextSearchViewPage fPage; - + public MatchFilterAction(AbstractTextSearchViewPage page, MatchFilter filter) { super(filter.getActionLabel(), IAction.AS_CHECK_BOX); fPage= page; @@ -45,7 +45,7 @@ public class MatchFilterAction extends Action implements IUpdate { if (activeMatchFilters == null) { return; } - + for (int i= 0; i < activeMatchFilters.length; i++) { if (!activeMatchFilters[i].equals(fFilter)) { newFilters.add(activeMatchFilters[i]); @@ -61,7 +61,7 @@ public class MatchFilterAction extends Action implements IUpdate { public MatchFilter getFilter() { return fFilter; } - + private boolean isActiveMatchFilter() { AbstractTextSearchResult input= fPage.getInput(); if (input != null) { diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterSelectionAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterSelectionAction.java index a5f19254441..a9750b02ce1 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterSelectionAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterSelectionAction.java @@ -15,21 +15,20 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.action.Action; import org.eclipse.jface.window.Window; +import org.eclipse.search.internal.ui.SearchPluginImages; import org.eclipse.search.ui.text.AbstractTextSearchResult; import org.eclipse.search.ui.text.AbstractTextSearchViewPage; import org.eclipse.search.ui.text.MatchFilter; -import org.eclipse.search.internal.ui.SearchPluginImages; - public class MatchFilterSelectionAction extends Action { - + public static final String ACTION_ID= "MatchFilterSelectionAction"; //$NON-NLS-1$ - + private AbstractTextSearchViewPage fPage; - + public MatchFilterSelectionAction(AbstractTextSearchViewPage page) { - super(SearchMessages.MatchFilterSelectionAction_label); + super(SearchMessages.MatchFilterSelectionAction_label); setId(ACTION_ID); SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_FILTER); fPage= page; @@ -37,21 +36,21 @@ public class MatchFilterSelectionAction extends Action { public void run() { Shell shell= fPage.getSite().getShell(); - + AbstractTextSearchResult input= fPage.getInput(); if (input == null) { return; } - + MatchFilter[] allFilters= input.getAllMatchFilters(); MatchFilter[] checkedFilters= input.getActiveMatchFilters(); Integer limit= fPage.getElementLimit(); - + boolean enableMatchFilterConfiguration= checkedFilters != null; boolean enableLimitConfiguration= limit != null; int elementLimit= limit != null ? limit.intValue() : -1; - - MatchFilterSelectionDialog dialog = new MatchFilterSelectionDialog(shell, enableMatchFilterConfiguration, allFilters, checkedFilters, enableLimitConfiguration, elementLimit); + + MatchFilterSelectionDialog dialog = new MatchFilterSelectionDialog(shell, enableMatchFilterConfiguration, allFilters, checkedFilters, enableLimitConfiguration, elementLimit); if (dialog.open() == Window.OK) { if (enableMatchFilterConfiguration) { input.setActiveMatchFilters(dialog.getMatchFilters()); diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterSelectionDialog.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterSelectionDialog.java index b7f34d944b5..4ce2f7240cc 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterSelectionDialog.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/MatchFilterSelectionDialog.java @@ -10,9 +10,6 @@ *******************************************************************************/ package org.eclipse.search2.internal.ui; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -28,6 +25,9 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Text; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; + import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.StatusDialog; import org.eclipse.jface.viewers.ArrayContentProvider; @@ -39,30 +39,29 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.search.internal.ui.SearchPlugin; import org.eclipse.search.ui.NewSearchUI; import org.eclipse.search.ui.text.MatchFilter; -import org.eclipse.search.internal.ui.SearchPlugin; - /** * A dialog that lets users configure the active {@link MatchFilter match filters} and (optionally) the * maximal number of top level elements. - * + * * @since 3.3 */ public class MatchFilterSelectionDialog extends StatusDialog { private final boolean fShowLimitConfigurationControls; private final MatchFilter[] fAllFilters; - + private MatchFilter[] fEnabledFilters; - + private CheckboxTableViewer fListViewer; private Button fLimitElementsCheckbox; private Text fLimitElementsField; private Text fDescription; - + private int fLimitElementCount; private int fLastLimit; private final boolean fEnableMatchFilterConfiguration; @@ -70,7 +69,7 @@ public class MatchFilterSelectionDialog extends StatusDialog { /** * Creates a {@link MatchFilterSelectionDialog}. - * + * * @param shell the parent shell * @param enableMatchFilterConfiguration * @param allFilters all filters available for selection @@ -84,13 +83,13 @@ public class MatchFilterSelectionDialog extends StatusDialog { setTitle(SearchMessages.MatchFilterSelectionDialog_label); setStatusLineAboveButtons(true); - + fShowLimitConfigurationControls= enableLimitConfiguration; fEnableMatchFilterConfiguration= enableMatchFilterConfiguration; fAllFilters= allFilters; fEnabledFilters= selectedFilters; - + fLimitElementCount= limit; fLastLimit= limit != -1 ? limit : 1000; } @@ -110,10 +109,10 @@ public class MatchFilterSelectionDialog extends StatusDialog { String name= "MatchFilterSelectionDialog_" + String.valueOf(fShowLimitConfigurationControls) + '.' + String.valueOf(fEnableMatchFilterConfiguration); //$NON-NLS-1$ return SearchPlugin.getDefault().getDialogSettingsSection(name); } - + /** * Returns the currently selected match filters. - * + * * @return the currently selected match filters. */ public MatchFilter[] getMatchFilters() { @@ -123,13 +122,13 @@ public class MatchFilterSelectionDialog extends StatusDialog { /** * Returns the currently configured limit for top level elements. <code>-1</code> is returned if * no limit should be applied. - * + * * @return the currently configured limit for top level elements or -1 if no limit should be used. */ public int getLimit() { return fLimitElementCount; } - + /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) */ @@ -151,11 +150,11 @@ public class MatchFilterSelectionDialog extends StatusDialog { Label l= new Label(parent, SWT.NONE); l.setFont(parent.getFont()); l.setText(SearchMessages.MatchFilterSelectionDialog_filter_description); - + Table table = new Table(parent, SWT.CHECK | SWT.BORDER); table.setFont(parent.getFont()); fListViewer = new CheckboxTableViewer(table); - + GridData data = new GridData(GridData.FILL_BOTH); data.minimumHeight= convertHeightInCharsToPixels(8); table.setLayoutData(data); @@ -168,13 +167,13 @@ public class MatchFilterSelectionDialog extends StatusDialog { public void checkStateChanged(CheckStateChangedEvent event) { performFilterListCheckStateChanged(); } - + public String getText(Object element) { return ((MatchFilter) element).getName(); } } ListenerAndLabelProvider listenerAndLP= new ListenerAndLabelProvider(); - + fListViewer.setLabelProvider(listenerAndLP); fListViewer.setContentProvider(new ArrayContentProvider()); fListViewer.addSelectionChangedListener(listenerAndLP); @@ -208,7 +207,7 @@ public class MatchFilterSelectionDialog extends StatusDialog { fLimitElementsCheckbox.setText(SearchMessages.MatchFilterSelectionDialog_limit_description); fLimitElementsCheckbox.setLayoutData(new GridData()); fLimitElementsCheckbox.setFont(parent.getFont()); - + fLimitElementsField = new Text(parent, SWT.BORDER); fLimitElementsField.setFont(parent.getFont()); gd = new GridData(); @@ -238,13 +237,13 @@ public class MatchFilterSelectionDialog extends StatusDialog { else fDescription.setText(new String()); } - + private void performFilterListCheckStateChanged() { Object[] checked= fListViewer.getCheckedElements(); fEnabledFilters= new MatchFilter[checked.length]; System.arraycopy(checked, 0, fEnabledFilters, 0, checked.length); } - + private void performLimitCheckboxChanged() { boolean isEnabled= fLimitElementsCheckbox.getSelection(); fLimitElementsField.setEnabled(isEnabled); @@ -269,7 +268,7 @@ public class MatchFilterSelectionDialog extends StatusDialog { else updateStatus(createStatus(IStatus.OK, "")); //$NON-NLS-1$ } - + private IStatus createStatus(int severity, String message) { return new Status(severity, NewSearchUI.PLUGIN_ID, severity, message, null); } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/Messages.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/Messages.java index 4dfea96553e..df63b840064 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/Messages.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/Messages.java @@ -14,7 +14,7 @@ import com.ibm.icu.text.MessageFormat; /** * Helper class to format message strings. - * + * * @since 3.1 */ public class Messages { diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/OpenSearchPreferencesAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/OpenSearchPreferencesAction.java index f4af673e994..c449a5bc318 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/OpenSearchPreferencesAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/OpenSearchPreferencesAction.java @@ -25,8 +25,8 @@ import org.eclipse.search.internal.ui.SearchPreferencePage; */ public class OpenSearchPreferencesAction extends Action { public OpenSearchPreferencesAction() { - super(SearchMessages.OpenSearchPreferencesAction_label); - setToolTipText(SearchMessages.OpenSearchPreferencesAction_tooltip); + super(SearchMessages.OpenSearchPreferencesAction_label); + setToolTipText(SearchMessages.OpenSearchPreferencesAction_tooltip); //PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IWorkbenchHelpContextIds.OPEN_PREFERENCES_ACTION); } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/PinSearchViewAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/PinSearchViewAction.java index 2ac9cefba88..dc5b01eac34 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/PinSearchViewAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/PinSearchViewAction.java @@ -21,7 +21,7 @@ import org.eclipse.search.internal.ui.SearchPluginImages; * Pins the currently visible search view */ public class PinSearchViewAction extends Action implements IUpdate { - + private SearchView fView = null; /** @@ -29,13 +29,13 @@ public class PinSearchViewAction extends Action implements IUpdate { * @param view the search view */ public PinSearchViewAction(SearchView view) { - super(SearchMessages.PinSearchViewAction_label, IAction.AS_CHECK_BOX); - setToolTipText(SearchMessages.PinSearchViewAction_tooltip); + super(SearchMessages.PinSearchViewAction_label, IAction.AS_CHECK_BOX); + setToolTipText(SearchMessages.PinSearchViewAction_tooltip); SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_PIN_VIEW); fView = view; update(); } - + /* (non-Javadoc) * @see org.eclipse.jface.action.IAction#run() */ @@ -43,7 +43,7 @@ public class PinSearchViewAction extends Action implements IUpdate { fView.setPinned(isChecked()); fView.updatePartName(); } - + /* (non-Javadoc) * @see org.eclipse.ui.texteditor.IUpdate#update() */ diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java index eef2f8b388c..84b2795db91 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java @@ -23,29 +23,29 @@ import org.eclipse.search.ui.ISearchQuery; class QueryManager { private List fQueries; private List fListeners; - + public QueryManager() { super(); // an ArrayList should be plenty fast enough (few searches). fListeners= new ArrayList(); fQueries= new LinkedList(); } - + public boolean hasQueries() { synchronized (this) { return !fQueries.isEmpty(); } } - + public int getSize() { synchronized (this) { return fQueries.size(); } } - + /** - * Returns the queries in LRU order. Smaller index means more recently used. - * + * Returns the queries in LRU order. Smaller index means more recently used. + * * @return all queries */ public ISearchQuery[] getQueries() { @@ -69,7 +69,7 @@ class QueryManager { } fireAdded(query); } - + public void addQueryListener(IQueryListener l) { synchronized (fListeners) { fListeners.add(l); @@ -81,7 +81,7 @@ class QueryManager { fListeners.remove(l); } } - + public void fireAdded(ISearchQuery query) { Set copiedListeners= new HashSet(); synchronized (fListeners) { @@ -105,7 +105,7 @@ class QueryManager { l.queryRemoved(query); } } - + public void fireStarting(ISearchQuery query) { Set copiedListeners= new HashSet(); synchronized (fListeners) { @@ -149,7 +149,7 @@ class QueryManager { public void queryStarting(ISearchQuery query) { fireStarting(query); } - + public void touch(ISearchQuery query) { synchronized (this) { if (fQueries.contains(query)) { @@ -158,5 +158,5 @@ class QueryManager { } } } - + } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java index 468b42f323c..f5f96291d78 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/RemoveAllSearchesAction.java @@ -11,6 +11,7 @@ package org.eclipse.search2.internal.ui; import org.eclipse.jface.action.Action; + import org.eclipse.search.ui.ISearchQuery; import org.eclipse.search.ui.NewSearchUI; @@ -18,10 +19,10 @@ import org.eclipse.search.ui.NewSearchUI; class RemoveAllSearchesAction extends Action { public RemoveAllSearchesAction() { - super(SearchMessages.RemoveAllSearchesAction_label); - setToolTipText(SearchMessages.RemoveAllSearchesAction_tooltip); - } - + super(SearchMessages.RemoveAllSearchesAction_label); + setToolTipText(SearchMessages.RemoveAllSearchesAction_tooltip); + } + public void run() { ISearchQuery[] queries= NewSearchUI.getQueries(); for (int i = 0; i < queries.length; i++) { diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchAgainAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchAgainAction.java index 64b74273afe..6efe82c1d54 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchAgainAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchAgainAction.java @@ -10,28 +10,27 @@ *******************************************************************************/ package org.eclipse.search2.internal.ui; -import org.eclipse.core.runtime.IStatus; - import org.eclipse.swt.widgets.Shell; +import org.eclipse.core.runtime.IStatus; + import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.search.internal.ui.SearchPluginImages; import org.eclipse.search.ui.ISearchQuery; import org.eclipse.search.ui.ISearchResult; import org.eclipse.search.ui.NewSearchUI; -import org.eclipse.search.internal.ui.SearchPluginImages; - class SearchAgainAction extends Action { private SearchView fView; - + public SearchAgainAction(SearchView view) { - setText(SearchMessages.SearchAgainAction_label); - setToolTipText(SearchMessages.SearchAgainAction_tooltip); + setText(SearchMessages.SearchAgainAction_label); + setToolTipText(SearchMessages.SearchAgainAction_tooltip); SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_AGAIN); - fView= view; + fView= view; } public void run() { @@ -47,7 +46,7 @@ class SearchAgainAction extends Action { ProgressMonitorDialog pmd= new ProgressMonitorDialog(shell); IStatus status= NewSearchUI.runQueryInForeground(pmd, query, fView); if (!status.isOK() && status.getSeverity() != IStatus.CANCEL) { - ErrorDialog.openError(shell, SearchMessages.SearchAgainAction_Error_title, SearchMessages.SearchAgainAction_Error_message, status); + ErrorDialog.openError(shell, SearchMessages.SearchAgainAction_Error_title, SearchMessages.SearchAgainAction_Error_message, status); } } } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistoryDropDownAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistoryDropDownAction.java index 69f4870bcd5..aa7003ca2b7 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistoryDropDownAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistoryDropDownAction.java @@ -22,12 +22,11 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.IMenuCreator; +import org.eclipse.search.internal.ui.SearchPluginImages; import org.eclipse.search.ui.ISearchQuery; import org.eclipse.search.ui.ISearchResult; import org.eclipse.search.ui.NewSearchUI; -import org.eclipse.search.internal.ui.SearchPluginImages; - class SearchHistoryDropDownAction extends Action implements IMenuCreator { private class ShowSearchFromHistoryAction extends Action { @@ -36,10 +35,10 @@ class SearchHistoryDropDownAction extends Action implements IMenuCreator { public ShowSearchFromHistoryAction(ISearchResult search) { super("", AS_RADIO_BUTTON); //$NON-NLS-1$ fSearch= search; - + String label= escapeAmp(search.getLabel()); if (InternalSearchUI.getInstance().isQueryRunning(search.getQuery())) - label= MessageFormat.format(SearchMessages.SearchDropDownAction_running_message, new String[] { label }); + label= MessageFormat.format(SearchMessages.SearchDropDownAction_running_message, new String[] { label }); // fix for bug 38049 if (label.indexOf('@') >= 0) label+= '@'; @@ -47,7 +46,7 @@ class SearchHistoryDropDownAction extends Action implements IMenuCreator { setImageDescriptor(search.getImageDescriptor()); setToolTipText(search.getTooltip()); } - + private String escapeAmp(String label) { StringBuffer buf= new StringBuffer(); for (int i= 0; i < label.length(); i++) { @@ -59,11 +58,11 @@ class SearchHistoryDropDownAction extends Action implements IMenuCreator { } return buf.toString(); } - + public void runWithEvent(Event event) { runIfChecked(event.stateMask == SWT.CTRL); } - + public void run() { runIfChecked(false); } @@ -78,15 +77,15 @@ class SearchHistoryDropDownAction extends Action implements IMenuCreator { private Menu fMenu; private SearchView fSearchView; - + public SearchHistoryDropDownAction(SearchView searchView) { - setText(SearchMessages.SearchDropDownAction_label); - setToolTipText(SearchMessages.SearchDropDownAction_tooltip); + setText(SearchMessages.SearchDropDownAction_label); + setToolTipText(SearchMessages.SearchDropDownAction_tooltip); SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_HISTORY); fSearchView= searchView; setMenuCreator(this); } - + public void updateEnablement() { boolean hasQueries= InternalSearchUI.getInstance().getSearchManager().hasQueries(); setEnabled(hasQueries); @@ -108,11 +107,11 @@ class SearchHistoryDropDownAction extends Action implements IMenuCreator { public Menu getMenu(Control parent) { ISearchResult currentSearch= fSearchView.getCurrentSearchResult(); disposeMenu(); - + fMenu= new Menu(parent); - + ISearchQuery[] searches= NewSearchUI.getQueries(); - if (searches.length > 0) { + if (searches.length > 0) { for (int i= 0; i < searches.length; i++) { ISearchResult search= searches[i].getSearchResult(); ShowSearchFromHistoryAction action= new ShowSearchFromHistoryAction(search); @@ -130,7 +129,7 @@ class SearchHistoryDropDownAction extends Action implements IMenuCreator { ActionContributionItem item= new ActionContributionItem(action); item.fill(parent, -1); } - + public void run() { new ShowSearchHistoryDialogAction(fSearchView).run(); } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistorySelectionDialog.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistorySelectionDialog.java index e13ddb5ccae..25d0f2a82de 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistorySelectionDialog.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchHistorySelectionDialog.java @@ -14,9 +14,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -36,6 +33,9 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Text; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; + import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.StatusDialog; @@ -53,44 +53,43 @@ import org.eclipse.jface.window.Window; import org.eclipse.ui.dialogs.SelectionDialog; -import org.eclipse.search.ui.ISearchQuery; -import org.eclipse.search.ui.ISearchResult; - import org.eclipse.search.internal.ui.SearchPlugin; import org.eclipse.search.internal.ui.SearchPreferencePage; import org.eclipse.search.internal.ui.util.SWTUtil; +import org.eclipse.search.ui.ISearchQuery; +import org.eclipse.search.ui.ISearchResult; /** * Dialog that shows a list of items with icon and label. */ public class SearchHistorySelectionDialog extends SelectionDialog { - + private static final int REMOVE_ID= IDialogConstants.CLIENT_ID+1; private static final int WIDTH_IN_CHARACTERS= 55; - + private List fInput; private final List fRemovedEntries; - + private TableViewer fViewer; private Button fRemoveButton; - + private boolean fIsOpenInNewView; private Link fLink; - + private static class HistoryConfigurationDialog extends StatusDialog { - + private static final int DEFAULT_ID= 100; - + private int fHistorySize; private Text fHistorySizeTextField; private final List fCurrentList; private final List fCurrentRemoves; - + public HistoryConfigurationDialog(Shell parent, List currentList, List removedEntries) { super(parent); fCurrentList= currentList; fCurrentRemoves= removedEntries; - setTitle(SearchMessages.SearchHistorySelectionDialog_history_size_title); + setTitle(SearchMessages.SearchHistorySelectionDialog_history_size_title); fHistorySize= SearchPreferencePage.getHistoryLimit(); setHelpAvailable(false); } @@ -111,11 +110,11 @@ public class SearchHistorySelectionDialog extends SelectionDialog { GridLayout layout= (GridLayout) ancestor.getLayout(); layout.numColumns= 2; ancestor.setLayout(layout); - + Label limitText= new Label(ancestor, SWT.NONE); limitText.setText(SearchMessages.SearchHistorySelectionDialog_history_size_description); limitText.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); - + fHistorySizeTextField= new Text(ancestor, SWT.BORDER | SWT.RIGHT); fHistorySizeTextField.setTextLimit(2); fHistorySizeTextField.setText(String.valueOf(fHistorySize)); @@ -124,7 +123,7 @@ public class SearchHistorySelectionDialog extends SelectionDialog { validateDialogState(); } }); - + GridData gridData= new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); gridData.widthHint= convertWidthInCharsToPixels(6); fHistorySizeTextField.setLayoutData(gridData); @@ -133,7 +132,7 @@ public class SearchHistorySelectionDialog extends SelectionDialog { return ancestor; } - + /* (non-Javadoc) * @see org.eclipse.jface.dialogs.StatusDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ @@ -141,7 +140,7 @@ public class SearchHistorySelectionDialog extends SelectionDialog { createButton(parent, DEFAULT_ID, SearchMessages.SearchHistorySelectionDialog_restore_default_button, false); super.createButtonsForButtonBar(parent); } - + /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) */ @@ -153,7 +152,7 @@ public class SearchHistorySelectionDialog extends SelectionDialog { } super.buttonPressed(buttonId); } - + protected final boolean validateDialogState() { IStatus status= null; @@ -174,14 +173,14 @@ public class SearchHistorySelectionDialog extends SelectionDialog { updateStatus(status); return !status.matches(IStatus.ERROR); } - + /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#okPressed() */ protected void okPressed() { IPreferenceStore store= SearchPlugin.getDefault().getPreferenceStore(); store.setValue(SearchPreferencePage.LIMIT_HISTORY, fHistorySize); - + // establish history size for (int i= fCurrentList.size() - 1; i >= fHistorySize; i--) { fCurrentRemoves.add(fCurrentList.get(i)); @@ -189,42 +188,42 @@ public class SearchHistorySelectionDialog extends SelectionDialog { } super.okPressed(); } - + } - + private static final class SearchesLabelProvider extends LabelProvider { - + private ArrayList fImages= new ArrayList(); - + public String getText(Object element) { return ((ISearchResult)element).getLabel(); } - + public Image getImage(Object element) { - ImageDescriptor imageDescriptor= ((ISearchResult)element).getImageDescriptor(); + ImageDescriptor imageDescriptor= ((ISearchResult)element).getImageDescriptor(); if (imageDescriptor == null) return null; - + Image image= imageDescriptor.createImage(); fImages.add(image); return image; } - + public void dispose() { Iterator iter= fImages.iterator(); while (iter.hasNext()) ((Image)iter.next()).dispose(); - + fImages= null; } } public SearchHistorySelectionDialog(Shell parent, List input) { super(parent); - setTitle(SearchMessages.SearchesDialog_title); - setMessage(SearchMessages.SearchesDialog_message); + setTitle(SearchMessages.SearchesDialog_title); + setMessage(SearchMessages.SearchesDialog_message); fInput= input; fRemovedEntries= new ArrayList(); setHelpAvailable(false); @@ -236,22 +235,22 @@ public class SearchHistorySelectionDialog extends SelectionDialog { public boolean isOpenInNewView() { return fIsOpenInNewView; } - + /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings() */ protected IDialogSettings getDialogBoundsSettings() { return SearchPlugin.getDefault().getDialogSettingsSection("DialogBounds_SearchHistorySelectionDialog"); //$NON-NLS-1$ } - + /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsStrategy() */ protected int getDialogBoundsStrategy() { return DIALOG_PERSISTSIZE; } - - + + /* * Overrides method from Dialog */ @@ -263,43 +262,43 @@ public class SearchHistorySelectionDialog extends SelectionDialog { layout.marginWidth= 0; parent.setLayout(layout); parent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - + Label label = new Label(parent,SWT.WRAP); - label.setText(getMessage()); + label.setText(getMessage()); GridData gd= new GridData(GridData.FILL_HORIZONTAL); //gd.widthHint= convertWidthInCharsToPixels(WIDTH_IN_CHARACTERS); label.setLayoutData(gd); - + applyDialogFont(label); return label; } - - - + + + /* (non-Javadoc) * @see org.eclipse.jface.window.Window#create() */ public void create() { super.create(); - + List initialSelection= getInitialElementSelections(); if (initialSelection != null) fViewer.setSelection(new StructuredSelection(initialSelection)); validateDialogState(); } - + /* * Overrides method from Dialog */ protected Control createDialogArea(Composite container) { Composite ancestor= (Composite) super.createDialogArea(container); - + createMessageArea(ancestor); - + Composite parent= new Composite(ancestor, SWT.NONE); - + GridLayout layout= new GridLayout(); layout.numColumns= 2; layout.marginHeight= 0; @@ -309,7 +308,7 @@ public class SearchHistorySelectionDialog extends SelectionDialog { fViewer= new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION); fViewer.setContentProvider(new ArrayContentProvider()); - + final Table table= fViewer.getTable(); table.addMouseListener(new MouseAdapter() { public void mouseDoubleClick(MouseEvent e) { @@ -321,10 +320,10 @@ public class SearchHistorySelectionDialog extends SelectionDialog { gd.heightHint= convertHeightInCharsToPixels(15); gd.widthHint= convertWidthInCharsToPixels(WIDTH_IN_CHARACTERS); table.setLayoutData(gd); - - + + fRemoveButton= new Button(parent, SWT.PUSH); - fRemoveButton.setText(SearchMessages.SearchesDialog_remove_label); + fRemoveButton.setText(SearchMessages.SearchesDialog_remove_label); fRemoveButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { buttonPressed(REMOVE_ID); @@ -332,13 +331,13 @@ public class SearchHistorySelectionDialog extends SelectionDialog { }); fRemoveButton.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false)); SWTUtil.setButtonDimensionHint(fRemoveButton); - + fViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { validateDialogState(); } - }); - + }); + fLink= new Link(parent, SWT.NONE); configureHistoryLink(); fLink.addSelectionListener(new SelectionAdapter() { @@ -351,8 +350,8 @@ public class SearchHistorySelectionDialog extends SelectionDialog { } }); fLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); - - + + applyDialogFont(ancestor); // set input & selections last, so all the widgets are created. @@ -365,11 +364,11 @@ public class SearchHistorySelectionDialog extends SelectionDialog { int historyLimit= SearchPreferencePage.getHistoryLimit(); fLink.setText(Messages.format(SearchMessages.SearchHistorySelectionDialog_configure_link_label, new Integer(historyLimit))); } - + protected final void validateDialogState() { IStructuredSelection sel= (IStructuredSelection) fViewer.getSelection(); int elementsSelected= sel.toList().size(); - + fRemoveButton.setEnabled(elementsSelected > 0); Button okButton= getOkButton(); if (okButton != null) { @@ -380,7 +379,7 @@ public class SearchHistorySelectionDialog extends SelectionDialog { openInNewButton.setEnabled(elementsSelected == 1); } } - + /* (non-Javadoc) * @see org.eclipse.ui.dialogs.SelectionDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ @@ -389,8 +388,8 @@ public class SearchHistorySelectionDialog extends SelectionDialog { createButton(parent, IDialogConstants.OPEN_ID, SearchMessages.SearchHistorySelectionDialog_open_in_new_button, false); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); } - - + + protected void buttonPressed(int buttonId) { if (buttonId == REMOVE_ID) { IStructuredSelection selection= (IStructuredSelection) fViewer.getSelection(); @@ -412,7 +411,7 @@ public class SearchHistorySelectionDialog extends SelectionDialog { } super.buttonPressed(buttonId); } - + /* * Overrides method from Dialog */ @@ -421,7 +420,7 @@ public class SearchHistorySelectionDialog extends SelectionDialog { ISelection selection= fViewer.getSelection(); if (selection instanceof IStructuredSelection) setResult(((IStructuredSelection) fViewer.getSelection()).toList()); - + // remove queries for (Iterator iter= fRemovedEntries.iterator(); iter.hasNext();) { ISearchResult result= (ISearchResult) iter.next(); diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.java index 4ab503a00dd..0f2f3a01df4 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchMessages.java @@ -19,7 +19,7 @@ public final class SearchMessages extends NLS { private SearchMessages() { // Do not instantiate } - + static { NLS.initializeMessages(BUNDLE_NAME, SearchMessages.class); } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java index 62d9f49dfc4..519ffec5db4 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchPageRegistry.java @@ -20,26 +20,25 @@ import org.eclipse.core.runtime.SafeRunner; import org.eclipse.jface.util.SafeRunnable; +import org.eclipse.search.internal.ui.SearchPlugin; import org.eclipse.search.ui.ISearchResult; import org.eclipse.search.ui.ISearchResultPage; -import org.eclipse.search.internal.ui.SearchPlugin; - public class SearchPageRegistry { - + public static final String ID_EXTENSION_POINT= "org.eclipse.search.searchResultViewPages"; //$NON-NLS-1$ public static final String ATTRIB_SEARCH_RESULT_CLASS= "searchResultClass"; //$NON-NLS-1$ public static final String ATTRIB_ID= "id"; //$NON-NLS-1$ public static final String ATTRIB_LABEL= "label"; //$NON-NLS-1$ public static final String ATTRIB_ICON= "icon"; //$NON-NLS-1$ - + public static final String ATTRIB_HELP_CONTEXT= "helpContextId"; //$NON-NLS-1$ - + private final Map fResultClassNameToExtension; private final Map fExtensionToInstance; private final IConfigurationElement[] fExtensions; - + public SearchPageRegistry() { fExtensionToInstance= new HashMap(); fResultClassNameToExtension= new HashMap(); @@ -57,7 +56,7 @@ public class SearchPageRegistry { } return null; } - + public ISearchResultPage findPageForPageId(String pageId, boolean create) { IConfigurationElement configElement= findConfigurationElement(pageId); if (configElement != null) { @@ -105,7 +104,7 @@ public class SearchPageRegistry { } return instance; } - + private IConfigurationElement findConfigurationElement(String pageId) { for (int i= 0; i < fExtensions.length; i++) { IConfigurationElement curr= fExtensions[i]; @@ -115,7 +114,7 @@ public class SearchPageRegistry { } return null; } - + private IConfigurationElement findConfigurationElement(Class resultClass) { String className= resultClass.getName(); IConfigurationElement configElement= (IConfigurationElement) fResultClassNameToExtension.get(className); @@ -130,7 +129,7 @@ public class SearchPageRegistry { return foundExtension; } } - + Class[] interfaces= resultClass.getInterfaces(); for (int i= 0; i < interfaces.length; i++) { IConfigurationElement foundExtension= findConfigurationElement(interfaces[i]); diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java index be3c28791b7..783df2c639a 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java @@ -13,18 +13,11 @@ *******************************************************************************/ package org.eclipse.search2.internal.ui; -import com.ibm.icu.text.MessageFormat; - import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import org.eclipse.core.commands.operations.IUndoContext; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -import org.eclipse.core.resources.ResourcesPlugin; +import com.ibm.icu.text.MessageFormat; import org.eclipse.osgi.util.NLS; @@ -40,6 +33,13 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Link; +import org.eclipse.core.commands.operations.IUndoContext; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; + +import org.eclipse.core.resources.ResourcesPlugin; + import org.eclipse.jface.action.GroupMarker; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; @@ -72,6 +72,9 @@ import org.eclipse.ui.part.PageSwitcher; import org.eclipse.ui.part.ShowInContext; import org.eclipse.ui.progress.IWorkbenchSiteProgressService; +import org.eclipse.search.internal.ui.ISearchHelpContextIds; +import org.eclipse.search.internal.ui.OpenSearchDialogAction; +import org.eclipse.search.internal.ui.SearchPlugin; import org.eclipse.search.ui.IContextMenuConstants; import org.eclipse.search.ui.IQueryListener; import org.eclipse.search.ui.ISearchQuery; @@ -80,12 +83,8 @@ import org.eclipse.search.ui.ISearchResultPage; import org.eclipse.search.ui.ISearchResultViewPart; import org.eclipse.search.ui.NewSearchUI; -import org.eclipse.search.internal.ui.ISearchHelpContextIds; -import org.eclipse.search.internal.ui.OpenSearchDialogAction; -import org.eclipse.search.internal.ui.SearchPlugin; - public class SearchView extends PageBookView implements ISearchResultViewPart, IQueryListener { - + private static final String MEMENTO_TYPE= "view"; //$NON-NLS-1$ private static final String MEMENTO_KEY_IS_PINNED= "isPinned"; //$NON-NLS-1$ private static final String MEMENTO_KEY_LAST_ACTIVATION= "org.eclipse.search.lastActivation"; //$NON-NLS-1$ @@ -101,19 +100,19 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I private CancelSearchAction fCancelAction; private PinSearchViewAction fPinSearchViewAction; private UndoRedoActionGroup fUndoRedoActionGroup; - + private IMemento fPageState; private boolean fIsPinned; private int fActivationCount= 0; private String fDefaultPartName; - + private Composite fPageContent; private Link fDescription; private Composite fDescriptionComposite; - + /** * Creates the groups and separators for the search view's context menu - * + * * @param menu the context menu */ public static void createContextMenuGroups(IMenuManager menu) { @@ -131,10 +130,10 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP)); menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES)); } - + /** * Creates the groups and separators for the search view's context menu - * + * * @param menu the context menu */ private static void createViewMenuGroups(IMenuManager menu) { @@ -155,9 +154,9 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I } /** - * Creates the groups and separators for the search view's + * Creates the groups and separators for the search view's * tool bar - * + * * @param toolbar the toolbar */ public static void createToolBarGroups(IToolBarManager toolbar) { @@ -176,7 +175,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I toolbar.add(new Separator(IContextMenuConstants.GROUP_SEARCH)); } - static class DummyPart implements IWorkbenchPart { + static class DummyPart implements IWorkbenchPart { private int fLastActivation= 0; public void setLastActivation(int lastActivation) { fLastActivation= lastActivation; @@ -202,12 +201,12 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I public void createControl(Composite parent) { Color background= parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND); - + Composite composite= new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, false)); - + composite.setBackground(background); - + Link link= new Link(composite, SWT.NONE); link.setText(SearchMessages.SearchView_empty_search_label); link.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false)); @@ -217,9 +216,9 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I new OpenSearchDialogAction().run(); } }); - + fControl= composite; - } + } public Control getControl() { return fControl; @@ -249,7 +248,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I return null; } - + public void init(IPageSite pageSite) { super.init(pageSite); getSite().setSelectionProvider(null); @@ -263,7 +262,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I */ public void saveState(IMemento memento) { // do nothing - + } /* (non-Javadoc) @@ -303,14 +302,14 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I fSearchViewStates= new HashMap(); fIsPinned= false; } - + /** * @return the search result page registry */ public SearchPageRegistry getSearchPageRegistry() { return fSearchViewPageService; } - + /* (non-Javadoc) * @see org.eclipse.ui.part.PageBookView#partActivated(org.eclipse.ui.IWorkbenchPart) */ @@ -320,8 +319,8 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I InternalSearchUI.getInstance().getSearchViewManager().searchViewActivated(this); } } - - + + protected IPage createDefaultPage(PageBook book) { IPageBookViewPage page= new EmptySearchView(); page.createControl(book); @@ -345,7 +344,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I IPage page = pageRecord.page; page.dispose(); pageRecord.dispose(); - + // empty cross-reference cache fPartsToPages.remove(part); } @@ -357,14 +356,14 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I protected boolean isImportant(IWorkbenchPart part) { return part instanceof DummyPart; } - - + + public void showSearchResult(ISearchResult search) { ISearchResultPage newPage= null; if (search != null) { newPage= fSearchViewPageService.findPageForSearchResult(search, true); if (newPage == null) { - String format= SearchMessages.SearchView_error_noResultPage; + String format= SearchMessages.SearchView_error_noResultPage; String message= MessageFormat.format(format, new Object[] { search.getClass().getName() }); SearchPlugin.log(new Status(IStatus.ERROR, SearchPlugin.getID(), 0, message, null)); return; @@ -372,13 +371,13 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I } internalShowSearchPage(newPage, search); } - + public void showEmptySearchPage(String pageId) { ISearchResultPage newPage= fSearchViewPageService.findPageForPageId(pageId, true); internalShowSearchPage(newPage, null); } - - + + private void internalShowSearchPage(ISearchResultPage page, ISearchResult search) { // detach the previous page. ISearchResultPage currentPage= (ISearchResultPage) getCurrentPage(); @@ -386,7 +385,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I fSearchViewStates.put(fCurrentSearch, currentPage.getUIState()); currentPage.setInput(null, null); } - + fCurrentSearch= search; if (page != null) { @@ -401,7 +400,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I part.setLastActivation(++fActivationCount); partActivated(part); } - + // connect to the new pages Object uiState= search != null ? fSearchViewStates.get(search) : null; page.setInput(search, uiState); @@ -409,21 +408,21 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I updatePartName(); updateLabel(); updateCancelAction(); - + updateHelpContextID(page); } - + private void updateHelpContextID(ISearchResultPage page) { String helpContextId= null; String pageId= null; - + if (page != null) pageId= page.getID(); - + if (pageId != null) helpContextId= fSearchViewPageService.getHelpContextId(pageId); - + if (helpContextId == null) helpContextId= ISearchHelpContextIds.New_SEARCH_VIEW; @@ -447,20 +446,20 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I if (fDescriptionComposite == null) { fDescriptionComposite= new Composite(fPageContent, SWT.NONE); fDescriptionComposite.moveAbove(null); - + GridLayout layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; layout.verticalSpacing= 0; fDescriptionComposite.setLayout(layout); fDescriptionComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - + fDescription= new Link(fDescriptionComposite, SWT.NONE); GridData gridData= new GridData(SWT.FILL, SWT.CENTER, true, false); gridData.horizontalIndent= 5; fDescription.setLayoutData(gridData); fDescription.setText(label); - + Label separator= new Label(fDescriptionComposite, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); fPageContent.layout(); @@ -470,14 +469,14 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I } } } - + public ISearchResult getCurrentSearchResult() { return fCurrentSearch; } public void createPartControl(Composite parent) { createActions(); - + fPageContent= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); layout.marginHeight= 0; @@ -485,17 +484,17 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I layout.horizontalSpacing= 0; layout.verticalSpacing= 0; fPageContent.setLayout(layout); - + fDescriptionComposite= null; - + super.createPartControl(fPageContent); getPageBook().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - + fDefaultPartName= getPartName(); initializeToolBar(); InternalSearchUI.getInstance().getSearchManager().addQueryListener(this); initializePageSwitcher(); - + PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ISearchHelpContextIds.New_SEARCH_VIEW); restorePageFromMemento(); } @@ -558,7 +557,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I tbm.appendToGroup(IContextMenuConstants.GROUP_SEARCH, fPinSearchViewAction); getViewSite().getActionBars().updateActionBars(); } - + private void createActions() { fSearchesDropDownAction= new SearchHistoryDropDownAction(this); fSearchesDropDownAction.updateEnablement(); @@ -569,7 +568,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I fCancelAction= new CancelSearchAction(this); fCancelAction.setEnabled(false); fPinSearchViewAction= new PinSearchViewAction(this); - + IUndoContext workspaceContext= (IUndoContext)ResourcesPlugin.getWorkspace().getAdapter(IUndoContext.class); fUndoRedoActionGroup= new UndoRedoActionGroup(getViewSite(), workspaceContext, true); } @@ -642,21 +641,21 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I } } } - + private String getShowInMenuLabel() { String keyBinding= null; - + IBindingService bindingService= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class); if (bindingService != null) keyBinding= bindingService.getBestActiveBindingFormattedFor("org.eclipse.ui.navigate.showInQuickMenu"); //$NON-NLS-1$ - + if (keyBinding == null) keyBinding= ""; //$NON-NLS-1$ - + return NLS.bind(SearchMessages.SearchView_showIn_menu, keyBinding); } - + // Methods related to saving page state. ------------------------------------------- public void saveState(IMemento memento) { @@ -671,7 +670,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I } memento.putString(MEMENTO_KEY_IS_PINNED, String.valueOf(isPinned())); } - + public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); @@ -682,16 +681,16 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I if (progressService != null) progressService.showBusyForFamily(InternalSearchUI.FAMILY_SEARCH); } - + protected void initPage(IPageBookViewPage page) { super.initPage(page); IActionBars actionBars= page.getSite().getActionBars(); actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fSearchAgainAction); actionBars.updateActionBars(); - + fUndoRedoActionGroup.fillActionBars(actionBars); - + ISearchResultPage srPage= (ISearchResultPage) page; IMemento memento= null; if (fPageState != null) { @@ -705,7 +704,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I } srPage.restoreState(memento); } - + /* * TODO workaround for focus problem. Clarify focus behavior. * @see org.eclipse.ui.IWorkbenchPart#setFocus() @@ -714,17 +713,17 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I IPage currentPage= getCurrentPage(); if (currentPage != null) currentPage.setFocus(); - else + else super.setFocus(); } - + public ISearchResultPage getActivePage() { IPage page= getCurrentPage(); if (page instanceof ISearchResultPage) return (ISearchResultPage) page; return null; } - + public IWorkbenchSiteProgressService getProgressService() { IWorkbenchSiteProgressService service = null; Object siteService = @@ -738,7 +737,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I super.showBusy(busy); getProgressService().warnOfContentChange(); } - + public Object getAdapter(Class adapter) { Object superAdapter= super.getAdapter(adapter); if (superAdapter != null) @@ -754,21 +753,21 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I } /** - * Marks the view as pinned. - * - * @param pinned if <code>true</code> the view is marked as pinned + * Marks the view as pinned. + * + * @param pinned if <code>true</code> the view is marked as pinned */ public void setPinned(boolean pinned) { fIsPinned= pinned; } /** - * @return returns <code>true</code> the view is marked as pinned + * @return returns <code>true</code> the view is marked as pinned */ public boolean isPinned() { return fIsPinned; } - + public void updatePartName() { if (fDefaultPartName != null) { // mstodo not yet enabled. diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchViewManager.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchViewManager.java index 5e21347fe3d..4869e2e22f9 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchViewManager.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchViewManager.java @@ -21,26 +21,25 @@ import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.WorkbenchException; +import org.eclipse.search.internal.ui.SearchPlugin; +import org.eclipse.search.internal.ui.util.ExceptionHandler; import org.eclipse.search.ui.IQueryListener; import org.eclipse.search.ui.ISearchQuery; import org.eclipse.search.ui.ISearchResult; import org.eclipse.search.ui.ISearchResultViewPart; import org.eclipse.search.ui.NewSearchUI; -import org.eclipse.search.internal.ui.SearchPlugin; -import org.eclipse.search.internal.ui.util.ExceptionHandler; - /** - * + * */ public class SearchViewManager { - + private IQueryListener fNewQueryListener; private int fViewCount= 0; - + private LinkedList fLRUSearchViews; - - + + public SearchViewManager(QueryManager queryManager) { fNewQueryListener= new IQueryListener() { @@ -51,20 +50,20 @@ public class SearchViewManager { public void queryRemoved(ISearchQuery query) {} public void queryStarting(ISearchQuery query) {} public void queryFinished(ISearchQuery query) {} - + }; - + queryManager.addQueryListener(fNewQueryListener); - + fLRUSearchViews= new LinkedList(); - + } - + public void dispose(QueryManager queryManager) { queryManager.removeQueryListener(fNewQueryListener); } - - + + protected boolean showNewSearchQuery(ISearchQuery query) { if (!fLRUSearchViews.isEmpty()) { SearchView view= (SearchView) fLRUSearchViews.getFirst(); @@ -76,7 +75,7 @@ public class SearchViewManager { public ISearchResultViewPart activateSearchView(boolean useForNewSearch) { IWorkbenchPage activePage= SearchPlugin.getActivePage(); - + String defaultPerspectiveId= NewSearchUI.getDefaultPerspectiveId(); if (defaultPerspectiveId != null) { IWorkbenchWindow window= activePage.getWorkbenchWindow(); @@ -101,12 +100,12 @@ public class SearchViewManager { } return (ISearchResultViewPart) activePage.showView(NewSearchUI.SEARCH_VIEW_ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE); } catch (PartInitException ex) { - ExceptionHandler.handle(ex, SearchMessages.Search_Error_openResultView_title, SearchMessages.Search_Error_openResultView_message); - } + ExceptionHandler.handle(ex, SearchMessages.Search_Error_openResultView_title, SearchMessages.Search_Error_openResultView_message); + } } return null; } - + public boolean isShown(ISearchQuery query) { for (Iterator iter= fLRUSearchViews.iterator(); iter.hasNext();) { SearchView view= (SearchView) iter.next(); @@ -117,15 +116,15 @@ public class SearchViewManager { } return false; } - + public void activateSearchView(ISearchResultViewPart viewPart) { try { IWorkbenchPage activePage= viewPart.getSite().getPage(); String secondaryId= viewPart.getViewSite().getSecondaryId(); activePage.showView(NewSearchUI.SEARCH_VIEW_ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE); } catch (PartInitException ex) { - ExceptionHandler.handle(ex, SearchMessages.Search_Error_openResultView_title, SearchMessages.Search_Error_openResultView_message); - } + ExceptionHandler.handle(ex, SearchMessages.Search_Error_openResultView_title, SearchMessages.Search_Error_openResultView_message); + } } private ISearchResultViewPart findLRUSearchResultView(IWorkbenchPage page, boolean avoidPinnedViews) { @@ -149,14 +148,14 @@ public class SearchViewManager { if (view != null && (!avoidPinnedViews || !view.isPinned())) { return view; } - + } } } return null; } - - + + public void searchViewActivated(SearchView view) { fLRUSearchViews.remove(view); fLRUSearchViews.addFirst(view); @@ -175,7 +174,7 @@ public class SearchViewManager { } - - - + + + } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchHistoryDialogAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchHistoryDialogAction.java index e721b8a4b5c..2efe0511fbc 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchHistoryDialogAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/ShowSearchHistoryDialogAction.java @@ -15,12 +15,11 @@ import java.util.ArrayList; import org.eclipse.jface.action.Action; import org.eclipse.jface.window.Window; +import org.eclipse.search.internal.ui.SearchPlugin; import org.eclipse.search.ui.ISearchQuery; import org.eclipse.search.ui.ISearchResult; import org.eclipse.search.ui.NewSearchUI; -import org.eclipse.search.internal.ui.SearchPlugin; - /** @@ -35,11 +34,11 @@ class ShowSearchHistoryDialogAction extends Action { * Create a new instance of this class */ public ShowSearchHistoryDialogAction(SearchView searchView) { - super(SearchMessages.ShowSearchesAction_label); - setToolTipText(SearchMessages.ShowSearchesAction_tooltip); + super(SearchMessages.ShowSearchesAction_label); + setToolTipText(SearchMessages.ShowSearchesAction_tooltip); fSearchView= searchView; } - + public void run() { ISearchQuery[] queries= NewSearchUI.getQueries(); @@ -48,9 +47,9 @@ class ShowSearchHistoryDialogAction extends Action { ISearchResult search= queries[j].getSearchResult(); input.add(search); } - + SearchHistorySelectionDialog dlg= new SearchHistorySelectionDialog(SearchPlugin.getActiveWorkbenchShell(),input); - + ISearchResult current= fSearchView.getCurrentSearchResult(); if (current != null) { Object[] selected= new Object[1]; diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/CollapseAllAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/CollapseAllAction.java index 3c320865bc3..4bcb61a3620 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/CollapseAllAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/CollapseAllAction.java @@ -22,15 +22,15 @@ public class CollapseAllAction extends Action { private TreeViewer fViewer; public CollapseAllAction() { - super(SearchMessages.CollapseAllAction_0); - setToolTipText(SearchMessages.CollapseAllAction_1); + super(SearchMessages.CollapseAllAction_0); + setToolTipText(SearchMessages.CollapseAllAction_1); SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_COLLAPSE_ALL); } - + public void setViewer(TreeViewer viewer) { fViewer= viewer; } - + public void run() { if (fViewer != null) { fViewer.collapseAll(); diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ExpandAllAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ExpandAllAction.java index c5240a17a20..c797fad8615 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ExpandAllAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ExpandAllAction.java @@ -22,15 +22,15 @@ public class ExpandAllAction extends Action { private TreeViewer fViewer; public ExpandAllAction() { - super(SearchMessages.ExpandAllAction_label); - setToolTipText(SearchMessages.ExpandAllAction_tooltip); + super(SearchMessages.ExpandAllAction_label); + setToolTipText(SearchMessages.ExpandAllAction_tooltip); SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_EXPAND_ALL); } - + public void setViewer(TreeViewer viewer) { fViewer= viewer; } - + public void run() { if (fViewer != null) { fViewer.expandAll(); diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveAllMatchesAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveAllMatchesAction.java index 059ab342cdd..aefa27e345f 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveAllMatchesAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveAllMatchesAction.java @@ -12,10 +12,9 @@ package org.eclipse.search2.internal.ui.basic.views; import org.eclipse.jface.action.Action; -import org.eclipse.search.ui.text.*; -import org.eclipse.search.ui.text.AbstractTextSearchResult; - import org.eclipse.search.internal.ui.SearchPluginImages; +import org.eclipse.search.ui.text.AbstractTextSearchResult; +import org.eclipse.search.ui.text.AbstractTextSearchViewPage; import org.eclipse.search2.internal.ui.SearchMessages; @@ -23,12 +22,12 @@ public class RemoveAllMatchesAction extends Action { AbstractTextSearchViewPage fPage; public RemoveAllMatchesAction(AbstractTextSearchViewPage page) { - super(SearchMessages.RemoveAllMatchesAction_label); - SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_REM_ALL); - setToolTipText(SearchMessages.RemoveAllMatchesAction_tooltip); + super(SearchMessages.RemoveAllMatchesAction_label); + SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_REM_ALL); + setToolTipText(SearchMessages.RemoveAllMatchesAction_tooltip); fPage= page; } - + public void run() { AbstractTextSearchResult search= fPage.getInput(); if (search != null) diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveMatchAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveMatchAction.java index ac7b6e30fa2..de5b1afada1 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveMatchAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveMatchAction.java @@ -12,9 +12,10 @@ package org.eclipse.search2.internal.ui.basic.views; import org.eclipse.jface.action.Action; -import org.eclipse.search.ui.text.*; - import org.eclipse.search.internal.ui.SearchPluginImages; +import org.eclipse.search.ui.text.AbstractTextSearchResult; +import org.eclipse.search.ui.text.AbstractTextSearchViewPage; +import org.eclipse.search.ui.text.Match; import org.eclipse.search2.internal.ui.SearchMessages; @@ -24,16 +25,16 @@ public class RemoveMatchAction extends Action { public RemoveMatchAction(AbstractTextSearchViewPage page) { fPage= page; - setText(SearchMessages.RemoveMatchAction_label); - setToolTipText(SearchMessages.RemoveMatchAction_tooltip); + setText(SearchMessages.RemoveMatchAction_label); + setToolTipText(SearchMessages.RemoveMatchAction_tooltip); SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_REM); } - + public void run() { Match match= fPage.getCurrentMatch(); AbstractTextSearchResult result= fPage.getInput(); if (match != null && result != null) result.removeMatch(match); } - + } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveSelectedMatchesAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveSelectedMatchesAction.java index 48be45f5c26..f4b7e698671 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveSelectedMatchesAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/RemoveSelectedMatchesAction.java @@ -11,8 +11,10 @@ package org.eclipse.search2.internal.ui.basic.views; import org.eclipse.jface.action.Action; + import org.eclipse.search.internal.ui.SearchPluginImages; import org.eclipse.search.ui.text.AbstractTextSearchViewPage; + import org.eclipse.search2.internal.ui.SearchMessages; public class RemoveSelectedMatchesAction extends Action { @@ -21,11 +23,11 @@ public class RemoveSelectedMatchesAction extends Action { public RemoveSelectedMatchesAction(AbstractTextSearchViewPage page) { fPage= page; - setText(SearchMessages.RemoveSelectedMatchesAction_label); - setToolTipText(SearchMessages.RemoveSelectedMatchesAction_tooltip); + setText(SearchMessages.RemoveSelectedMatchesAction_label); + setToolTipText(SearchMessages.RemoveSelectedMatchesAction_tooltip); SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_REM); } - + public void run() { fPage.internalRemoveSelected(); } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/SetLayoutAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/SetLayoutAction.java index 4d7756282b5..a8fa3b61266 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/SetLayoutAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/SetLayoutAction.java @@ -12,6 +12,7 @@ package org.eclipse.search2.internal.ui.basic.views; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; + import org.eclipse.search.ui.text.AbstractTextSearchViewPage; public class SetLayoutAction extends Action { @@ -25,11 +26,11 @@ public class SetLayoutAction extends Action { setToolTipText(tooltip); fLayout= layout; } - + public void run() { fPage.setLayout(fLayout); } - + public int getLayout() { return fLayout; } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ShowNextResultAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ShowNextResultAction.java index 37cd383200a..df4eae3ca9a 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ShowNextResultAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ShowNextResultAction.java @@ -12,23 +12,22 @@ package org.eclipse.search2.internal.ui.basic.views; import org.eclipse.jface.action.Action; -import org.eclipse.search.ui.text.*; - import org.eclipse.search.internal.ui.SearchPluginImages; +import org.eclipse.search.ui.text.AbstractTextSearchViewPage; import org.eclipse.search2.internal.ui.SearchMessages; public class ShowNextResultAction extends Action { - + private AbstractTextSearchViewPage fPage; public ShowNextResultAction(AbstractTextSearchViewPage page) { - super(SearchMessages.ShowNextResultAction_label); + super(SearchMessages.ShowNextResultAction_label); SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_NEXT); - setToolTipText(SearchMessages.ShowNextResultAction_tooltip); + setToolTipText(SearchMessages.ShowNextResultAction_tooltip); fPage= page; } - + public void run() { fPage.gotoNextMatch(); } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ShowPreviousResultAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ShowPreviousResultAction.java index c433eaa9ab8..fad52bbe8e2 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ShowPreviousResultAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/ShowPreviousResultAction.java @@ -12,23 +12,22 @@ package org.eclipse.search2.internal.ui.basic.views; import org.eclipse.jface.action.Action; -import org.eclipse.search.ui.text.*; - import org.eclipse.search.internal.ui.SearchPluginImages; +import org.eclipse.search.ui.text.AbstractTextSearchViewPage; import org.eclipse.search2.internal.ui.SearchMessages; public class ShowPreviousResultAction extends Action { - + private AbstractTextSearchViewPage fPage; public ShowPreviousResultAction(AbstractTextSearchViewPage page) { - super(SearchMessages.ShowPreviousResultAction_label); + super(SearchMessages.ShowPreviousResultAction_label); SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_PREV); - setToolTipText(SearchMessages.ShowPreviousResultAction_tooltip); + setToolTipText(SearchMessages.ShowPreviousResultAction_tooltip); fPage= page; } - + public void run() { fPage.gotoPreviousMatch(); } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/TreeViewerNavigator.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/TreeViewerNavigator.java index 2f646165df0..6ebd84af56a 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/TreeViewerNavigator.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/basic/views/TreeViewerNavigator.java @@ -10,8 +10,6 @@ *******************************************************************************/ package org.eclipse.search2.internal.ui.basic.views; -import org.eclipse.search.ui.text.AbstractTextSearchViewPage; - import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; @@ -19,15 +17,17 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.search.ui.text.AbstractTextSearchViewPage; + public class TreeViewerNavigator implements INavigate { private TreeViewer fViewer; private AbstractTextSearchViewPage fPage; - + public TreeViewerNavigator(AbstractTextSearchViewPage page, TreeViewer viewer) { fViewer= viewer; fPage= page; } - + public void navigateNext(boolean forward) { TreeItem currentItem= getCurrentItem(forward); if (currentItem == null) @@ -46,7 +46,7 @@ public class TreeViewerNavigator implements INavigate { internalSetSelection(nextItem); } } - + private TreeItem getFirstItem() { TreeItem[] roots= fViewer.getTree().getItems(); if (roots.length == 0) @@ -60,7 +60,7 @@ public class TreeViewerNavigator implements INavigate { } return null; } - + private TreeItem getLastItem() { TreeItem[] roots= fViewer.getTree().getItems(); if (roots.length == 0) @@ -131,7 +131,7 @@ public class TreeViewerNavigator implements INavigate { return child; return getFirstChildWithMatches(child); } - + private TreeItem[] getChildren(TreeItem item) { fViewer.setExpandedState(item.getData(), true); return item.getItems(); diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java index 6ead01db158..eecadbed188 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationHighlighter.java @@ -18,12 +18,12 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; -import org.eclipse.core.filebuffers.IFileBuffer; -import org.eclipse.core.filebuffers.ITextFileBuffer; - import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.core.filebuffers.IFileBuffer; +import org.eclipse.core.filebuffers.ITextFileBuffer; + import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.Position; @@ -31,9 +31,8 @@ import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.IAnnotationModelExtension; -import org.eclipse.search.ui.text.Match; - import org.eclipse.search.internal.ui.SearchPlugin; +import org.eclipse.search.ui.text.Match; import org.eclipse.search2.internal.ui.InternalSearchUI; import org.eclipse.search2.internal.ui.SearchMessages; @@ -43,7 +42,7 @@ public class AnnotationHighlighter extends Highlighter { private IAnnotationModel fModel; private IDocument fDocument; private Map fMatchesToAnnotations; - + public AnnotationHighlighter(IAnnotationModel model, IDocument document) { fModel= model; fDocument= document; @@ -58,7 +57,7 @@ public class AnnotationHighlighter extends Highlighter { if (offset >= 0 && length >= 0) { Position position= createPosition(matches[i]); if (position != null) { - Annotation annotation= matches[i].isFiltered() + Annotation annotation= matches[i].isFiltered() ? new Annotation(SearchPlugin.FILTERED_SEARCH_ANNOTATION_TYPE, true, null) : new Annotation(SearchPlugin.SEARCH_ANNOTATION_TYPE, true, null); fMatchesToAnnotations.put(matches[i], annotation); @@ -67,14 +66,14 @@ public class AnnotationHighlighter extends Highlighter { } } addAnnotations(map); - + } - + private Position createPosition(Match match) { Position position= InternalSearchUI.getInstance().getPositionTracker().getCurrentPosition(match); if (position == null) position= new Position(match.getOffset(), match.getLength()); - else + else // need to clone position, can't have it twice in a document. position= new Position(position.getOffset(), position.getLength()); if (match.getBaseUnit() == Match.UNIT_LINE) { @@ -82,11 +81,11 @@ public class AnnotationHighlighter extends Highlighter { try { position= PositionTracker.convertToCharacterPosition(position, fDocument); } catch (BadLocationException e) { - // ignore, match must be outdated + // ignore, match must be outdated return null; } } else { - SearchPlugin.log(new Status(IStatus.ERROR, SearchPlugin.getID(), 0, SearchMessages.AnnotationHighlighter_error_noDocument, null)); + SearchPlugin.log(new Status(IStatus.ERROR, SearchPlugin.getID(), 0, SearchMessages.AnnotationHighlighter_error_noDocument, null)); return null; } } @@ -103,13 +102,13 @@ public class AnnotationHighlighter extends Highlighter { } removeAnnotations(annotations); } - + public void removeAll() { Collection matchSet= fMatchesToAnnotations.values(); removeAnnotations(matchSet); fMatchesToAnnotations.clear(); } - + private void addAnnotations(Map annotationToPositionMap) { if (fModel instanceof IAnnotationModelExtension) { IAnnotationModelExtension ame= (IAnnotationModelExtension) fModel; @@ -122,11 +121,11 @@ public class AnnotationHighlighter extends Highlighter { } } } - + /** * Removes annotations from the given annotation model. The default implementation works for editors that * implement <code>ITextEditor</code>. - * Subclasses may override this method. + * Subclasses may override this method. * @param annotations A set containing the annotations to be removed. * @see Annotation */ @@ -146,7 +145,7 @@ public class AnnotationHighlighter extends Highlighter { protected void handleContentReplaced(IFileBuffer buffer) { if (!(buffer instanceof ITextFileBuffer)) return; - + ITextFileBuffer textBuffer= (ITextFileBuffer) buffer; if (fDocument != null && fDocument.equals(textBuffer.getDocument())) { Set allMatches= fMatchesToAnnotations.keySet(); diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationManagers.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationManagers.java index 586fd434f4e..975ea6f20c4 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationManagers.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/AnnotationManagers.java @@ -13,11 +13,12 @@ package org.eclipse.search2.internal.ui.text; import java.util.HashMap; -import org.eclipse.search.ui.text.AbstractTextSearchResult; import org.eclipse.ui.IWindowListener; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; +import org.eclipse.search.ui.text.AbstractTextSearchResult; + public class AnnotationManagers { static { fgManagerMap = new HashMap(); @@ -53,11 +54,11 @@ public class AnnotationManagers { public static void addSearchResult(IWorkbenchWindow window, AbstractTextSearchResult newResult) { getWindowAnnotationManager(window).addSearchResult(newResult); } - + public static void removeSearchResult(IWorkbenchWindow window, AbstractTextSearchResult result) { getWindowAnnotationManager(window).removeSearchResult(result); } - + private static WindowAnnotationManager getWindowAnnotationManager(IWorkbenchWindow window) { WindowAnnotationManager mgr= (WindowAnnotationManager) fgManagerMap.get(window); if (mgr == null) { @@ -66,6 +67,6 @@ public class AnnotationManagers { } return mgr; } - + } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAccessHighlighter.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAccessHighlighter.java index ba8342d37ca..d3ef848d49b 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAccessHighlighter.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAccessHighlighter.java @@ -17,12 +17,12 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; -import org.eclipse.core.filebuffers.IFileBuffer; -import org.eclipse.core.filebuffers.ITextFileBuffer; - import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.core.filebuffers.IFileBuffer; +import org.eclipse.core.filebuffers.ITextFileBuffer; + import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.Position; @@ -30,11 +30,10 @@ import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.IAnnotationModelExtension; +import org.eclipse.search.internal.ui.SearchPlugin; import org.eclipse.search.ui.text.ISearchEditorAccess; import org.eclipse.search.ui.text.Match; -import org.eclipse.search.internal.ui.SearchPlugin; - import org.eclipse.search2.internal.ui.InternalSearchUI; import org.eclipse.search2.internal.ui.SearchMessages; @@ -42,7 +41,7 @@ import org.eclipse.search2.internal.ui.SearchMessages; public class EditorAccessHighlighter extends Highlighter { private ISearchEditorAccess fEditorAcess; private Map fMatchesToAnnotations; - + public EditorAccessHighlighter(ISearchEditorAccess editorAccess) { fEditorAcess= editorAccess; fMatchesToAnnotations= new HashMap(); @@ -59,7 +58,7 @@ public class EditorAccessHighlighter extends Highlighter { if (position != null) { Map map= getMap(mapsByAnnotationModel, matches[i]); if (map != null) { - Annotation annotation= matches[i].isFiltered() + Annotation annotation= matches[i].isFiltered() ? new Annotation(SearchPlugin.FILTERED_SEARCH_ANNOTATION_TYPE, true, null) : new Annotation(SearchPlugin.SEARCH_ANNOTATION_TYPE, true, null); fMatchesToAnnotations.put(matches[i], annotation); @@ -67,7 +66,7 @@ public class EditorAccessHighlighter extends Highlighter { } } } catch (BadLocationException e) { - SearchPlugin.log(new Status(IStatus.ERROR, SearchPlugin.getID(), 0, SearchMessages.EditorAccessHighlighter_error_badLocation, e)); + SearchPlugin.log(new Status(IStatus.ERROR, SearchPlugin.getID(), 0, SearchMessages.EditorAccessHighlighter_error_badLocation, e)); } } } @@ -76,7 +75,7 @@ public class EditorAccessHighlighter extends Highlighter { Map positionMap= (Map) mapsByAnnotationModel.get(model); addAnnotations(model, positionMap); } - + } private Position createPosition(Match match) throws BadLocationException { @@ -91,7 +90,7 @@ public class EditorAccessHighlighter extends Highlighter { if (doc != null) { position= PositionTracker.convertToCharacterPosition(position, doc); } else { - SearchPlugin.log(new Status(IStatus.ERROR, SearchPlugin.getID(), 0, SearchMessages.AnnotationHighlighter_error_noDocument, null)); + SearchPlugin.log(new Status(IStatus.ERROR, SearchPlugin.getID(), 0, SearchMessages.AnnotationHighlighter_error_noDocument, null)); return null; } } @@ -140,7 +139,7 @@ public class EditorAccessHighlighter extends Highlighter { } } - + private void addAnnotations(IAnnotationModel model, Map annotationToPositionMap) { if (model instanceof IAnnotationModelExtension) { IAnnotationModelExtension ame= (IAnnotationModelExtension) model; @@ -153,11 +152,11 @@ public class EditorAccessHighlighter extends Highlighter { } } } - + /* * Removes annotations from the given annotation model. The default implementation works for editors that * implement <code>ITextEditor</code>. - * Subclasses may override this method. + * Subclasses may override this method. * @param annotations A set containing the annotations to be removed. * @see Annotation */ @@ -191,12 +190,12 @@ public class EditorAccessHighlighter extends Highlighter { if (document != null) break; } - + if (document != null && document.equals(textBuffer.getDocument())) { Match[] matches= new Match[fMatchesToAnnotations.keySet().size()]; fMatchesToAnnotations.keySet().toArray(matches); removeAll(); - addHighlights(matches); + addHighlights(matches); } } } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java index a0bb42dd5a4..ad41643a2cd 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/EditorAnnotationManager.java @@ -25,6 +25,7 @@ import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IWorkbenchPart; + import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; @@ -40,25 +41,25 @@ import org.eclipse.search.ui.text.MatchEvent; import org.eclipse.search.ui.text.RemoveAllEvent; public class EditorAnnotationManager implements ISearchResultListener { - + private ArrayList fResults; private IEditorPart fEditor; private Highlighter fHighlighter; // initialized lazy - + public static final int HIGHLLIGHTER_ANY= 0; public static final int HIGHLIGHTER_MARKER= 1; public static final int HIGHLIGHTER_ANNOTATION= 2; public static final int HIGHLIGHTER_EDITOR_ACCESS= 3; private static int fgHighlighterType= HIGHLLIGHTER_ANY; - - + + public EditorAnnotationManager(IEditorPart editorPart) { Assert.isNotNull(editorPart); fEditor= editorPart; fHighlighter= null; // lazy initialization fResults= new ArrayList(3); } - + public static final void debugSetHighlighterType(int type) { fgHighlighterType= type; @@ -69,21 +70,21 @@ public class EditorAnnotationManager implements ISearchResultListener { removeAllAnnotations(); if (fHighlighter != null) fHighlighter.dispose(); - + for (int i= 0; i < fResults.size(); i++) { ((AbstractTextSearchResult) fResults.get(i)).removeListener(this); } fResults.clear(); } - + public synchronized void doEditorInputChanged() { removeAllAnnotations(); - + if (fHighlighter != null) { fHighlighter.dispose(); fHighlighter= null; } - + for (int i= 0; i < fResults.size(); i++) { AbstractTextSearchResult curr= (AbstractTextSearchResult) fResults.get(i); addAnnotations(curr); @@ -96,24 +97,24 @@ public class EditorAnnotationManager implements ISearchResultListener { ((AbstractTextSearchResult) fResults.get(i)).removeListener(this); } fResults.clear(); - + for (int i= 0; i < results.size(); i++) { addSearchResult((AbstractTextSearchResult) results.get(i)); } } - + public synchronized void addSearchResult(AbstractTextSearchResult result) { fResults.add(result); result.addListener(this); addAnnotations(result); } - + public synchronized void removeSearchResult(AbstractTextSearchResult result) { fResults.remove(result); result.removeListener(this); removeAnnotations(result); } - + public synchronized void searchResultChanged(SearchResultEvent e) { ISearchResult searchResult= e.getSearchResult(); @@ -146,12 +147,12 @@ public class EditorAnnotationManager implements ISearchResultListener { if (adapter == null) { return null; } - + // optimize the array-length == 1 case (most common) if (matches.length == 1) { return adapter.isShownInEditor(matches[0], fEditor) ? matches : null; } - + ArrayList matchesInEditor= null; // lazy initialization for (int i= 0; i < matches.length; i++) { Match curr= matches[i]; @@ -197,7 +198,7 @@ public class EditorAnnotationManager implements ISearchResultListener { if (fgHighlighterType == HIGHLIGHTER_ANNOTATION) { IAnnotationModel model= getAnnotationModel(editor); if (model != null) - return new AnnotationHighlighter(model, getDocument(editor)); + return new AnnotationHighlighter(model, getDocument(editor)); } else if (fgHighlighterType == HIGHLIGHTER_MARKER) { IEditorInput input= editor.getEditorInput(); if (input instanceof IFileEditorInput) { @@ -205,7 +206,7 @@ public class EditorAnnotationManager implements ISearchResultListener { if (file != null) return new MarkerHighlighter(file); } - + } else if (fgHighlighterType == HIGHLIGHTER_EDITOR_ACCESS) { ISearchEditorAccess access= (ISearchEditorAccess) editor.getAdapter(ISearchEditorAccess.class); if (access != null) @@ -223,10 +224,10 @@ public class EditorAnnotationManager implements ISearchResultListener { return; addAnnotations(matches); } - + private void removeAnnotations(AbstractTextSearchResult result) { removeAllAnnotations(); - + for (int i= 0; i < fResults.size(); i++) { AbstractTextSearchResult curr= (AbstractTextSearchResult) fResults.get(i); if (curr != result) { @@ -249,11 +250,11 @@ public class EditorAnnotationManager implements ISearchResultListener { private static IAnnotationModel getAnnotationModel(IWorkbenchPart part) { IAnnotationModel model= null; - model= (IAnnotationModel) part.getAdapter(IAnnotationModel.class); + model= (IAnnotationModel) part.getAdapter(IAnnotationModel.class); if (model == null) { ITextEditor textEditor= null; if (part instanceof ITextEditor) { - textEditor= (ITextEditor) part; + textEditor= (ITextEditor) part; } if (textEditor != null) { IDocumentProvider dp= textEditor.getDocumentProvider(); @@ -266,11 +267,11 @@ public class EditorAnnotationManager implements ISearchResultListener { private static IDocument getDocument(IWorkbenchPart part) { IDocument doc= null; - doc= (IDocument) part.getAdapter(IDocument.class); + doc= (IDocument) part.getAdapter(IDocument.class); if (doc == null) { ITextEditor textEditor= null; if (part instanceof ITextEditor) { - textEditor= (ITextEditor) part; + textEditor= (ITextEditor) part; } if (textEditor != null) { IDocumentProvider dp= textEditor.getDocumentProvider(); diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/Highlighter.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/Highlighter.java index 7a743873aee..15f61589c9d 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/Highlighter.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/Highlighter.java @@ -10,10 +10,12 @@ *******************************************************************************/ package org.eclipse.search2.internal.ui.text; +import org.eclipse.core.runtime.IPath; + import org.eclipse.core.filebuffers.FileBuffers; import org.eclipse.core.filebuffers.IFileBuffer; import org.eclipse.core.filebuffers.IFileBufferListener; -import org.eclipse.core.runtime.IPath; + import org.eclipse.search.ui.text.Match; public class Highlighter { @@ -54,39 +56,39 @@ public class Highlighter { }; FileBuffers.getTextFileBufferManager().addFileBufferListener(fBufferListener); } - + /** * Adds highlighting for the given matches - * + * * @param matches the matches to add highlighting */ public void addHighlights(Match[] matches) { } - + /** * Removes highlighting for the given matches - * + * * @param matches the matches to remove the highlighting */ public void removeHighlights(Match[] matches) { } - + /** * Removes all highlighting */ public void removeAll() { } - + /** * Called when the highlighter is disposed. */ public void dispose() { FileBuffers.getTextFileBufferManager().removeFileBufferListener(fBufferListener); } - + /** * Notifies that a buffer has its content changed - * + * * @param buffer the buffer */ protected void handleContentReplaced(IFileBuffer buffer) { diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/MarkerHighlighter.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/MarkerHighlighter.java index 47108441f80..b3e2236a178 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/MarkerHighlighter.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/MarkerHighlighter.java @@ -13,24 +13,29 @@ package org.eclipse.search2.internal.ui.text; import java.util.HashMap; import java.util.Map; -import org.eclipse.core.filebuffers.IFileBuffer; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; + +import org.eclipse.core.filebuffers.IFileBuffer; + import org.eclipse.jface.text.Position; + import org.eclipse.search.internal.ui.SearchPlugin; import org.eclipse.search.ui.NewSearchUI; import org.eclipse.search.ui.text.Match; + import org.eclipse.search2.internal.ui.InternalSearchUI; public class MarkerHighlighter extends Highlighter { private IFile fFile; private Map fMatchesToAnnotations; - + public MarkerHighlighter(IFile file) { fFile= file; fMatchesToAnnotations= new HashMap(); @@ -53,7 +58,7 @@ public class MarkerHighlighter extends Highlighter { SearchPlugin.log(e.getStatus()); } } - + private IMarker createMarker(Match match) throws CoreException { Position position= InternalSearchUI.getInstance().getPositionTracker().getCurrentPosition(match); if (position == null) { @@ -64,7 +69,7 @@ public class MarkerHighlighter extends Highlighter { // need to clone position, can't have it twice in a document. position= new Position(position.getOffset(), position.getLength()); } - IMarker marker= match.isFiltered() + IMarker marker= match.isFiltered() ? fFile.createMarker(SearchPlugin.FILTERED_SEARCH_MARKER) : fFile.createMarker(NewSearchUI.SEARCH_MARKER); HashMap attributes= new HashMap(4); @@ -77,7 +82,7 @@ public class MarkerHighlighter extends Highlighter { marker.setAttributes(attributes); return marker; } - + public void removeHighlights(Match[] matches) { for (int i= 0; i < matches.length; i++) { IMarker marker= (IMarker) fMatchesToAnnotations.remove(matches[i]); diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java index 7359e2d0a0b..76a301bae63 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/PositionTracker.java @@ -16,6 +16,22 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; + +import org.eclipse.core.resources.IFile; + +import org.eclipse.core.filebuffers.FileBuffers; +import org.eclipse.core.filebuffers.IFileBuffer; +import org.eclipse.core.filebuffers.IFileBufferListener; +import org.eclipse.core.filebuffers.ITextFileBuffer; +import org.eclipse.core.filebuffers.LocationKind; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.Position; + import org.eclipse.search.internal.ui.SearchPlugin; import org.eclipse.search.ui.IQueryListener; import org.eclipse.search.ui.ISearchQuery; @@ -29,44 +45,29 @@ import org.eclipse.search.ui.text.Match; import org.eclipse.search.ui.text.MatchEvent; import org.eclipse.search.ui.text.RemoveAllEvent; -import org.eclipse.core.filebuffers.FileBuffers; -import org.eclipse.core.filebuffers.IFileBuffer; -import org.eclipse.core.filebuffers.IFileBufferListener; -import org.eclipse.core.filebuffers.ITextFileBuffer; -import org.eclipse.core.filebuffers.LocationKind; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.Position; - public class PositionTracker implements IQueryListener, ISearchResultListener, IFileBufferListener { private Map fMatchesToPositions= new HashMap(); private Map fMatchesToSearchResults= new HashMap(); private Map fFileBuffersToMatches= new HashMap(); - + private interface IFileBufferMatchOperation { void run(ITextFileBuffer buffer, Match match); } - + public PositionTracker() { NewSearchUI.addQueryListener(this); FileBuffers.getTextFileBufferManager().addFileBufferListener(this); } - + // tracking search results -------------------------------------------------------------- public void queryAdded(ISearchQuery query) { if (query.getSearchResult() instanceof AbstractTextSearchResult) { query.getSearchResult().addListener(this); } } - + public void queryRemoved(ISearchQuery query) { ISearchResult result= query.getSearchResult(); if (result instanceof AbstractTextSearchResult) { @@ -132,7 +133,7 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I int length = match.getLength(); if (offset < 0 || length < 0) return; - + try { IDocument doc= fb.getDocument(); Position position= new Position(offset, length); @@ -152,7 +153,7 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I public static Position convertToCharacterPosition(Position linePosition, IDocument doc) throws BadLocationException { int lineOffset= linePosition.getOffset(); int lineLength= linePosition.getLength(); - + int charOffset= doc.getLineOffset(lineOffset); int charLength= 0; if (lineLength > 0) { @@ -180,7 +181,7 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I fFileBuffersToMatches.remove(fb); } } - + private ITextFileBuffer getTrackedFileBuffer(AbstractTextSearchResult result, Object element) { IFileMatchAdapter adapter= result.getFileMatchAdapter(); if (adapter == null) @@ -192,7 +193,7 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I return null; return FileBuffers.getTextFileBufferManager().getTextFileBuffer(file.getFullPath(), LocationKind.IFILE); } - + public Position getCurrentPosition(Match match) { Position pos= (Position)fMatchesToPositions.get(match); if (pos == null) @@ -205,14 +206,14 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I try { pos= convertToLinePosition(pos, doc); } catch (BadLocationException e) { - + } } } - + return pos; } - + public static Position convertToLinePosition(Position pos, IDocument doc) throws BadLocationException { int offset= doc.getLineOfOffset(pos.getOffset()); int end= doc.getLineOfOffset(pos.getOffset()+pos.getLength()); @@ -237,7 +238,7 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I final int[] trackCount= new int[1]; if (!(buffer instanceof ITextFileBuffer)) return; - + IFile file= FileBuffers.getWorkspaceFileAtLocation(buffer.getLocation()); if (file == null) return; @@ -258,7 +259,7 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I } } } - + private void doForExistingMatchesIn(IFileBuffer buffer, IFileBufferMatchOperation operation) { if (!(buffer instanceof ITextFileBuffer)) return; @@ -271,7 +272,7 @@ public class PositionTracker implements IQueryListener, ISearchResultListener, I } } } - + /* (non-Javadoc) * @see org.eclipse.core.filebuffers.IFileBufferListener#bufferDisposed(org.eclipse.core.filebuffers.IFileBuffer) diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/WindowAnnotationManager.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/WindowAnnotationManager.java index d747ea3d355..8546012f855 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/WindowAnnotationManager.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text/WindowAnnotationManager.java @@ -29,13 +29,13 @@ public class WindowAnnotationManager { private Map fAnnotationManagers; private IPartListener2 fPartListener; private ArrayList fSearchResults; - + public WindowAnnotationManager(IWorkbenchWindow window) { fWindow = window; fAnnotationManagers = new HashMap(); - + fSearchResults= new ArrayList(); - + initEditors(); fPartListener= new IPartListener2() { public void partActivated(IWorkbenchPartReference partRef) { @@ -69,9 +69,9 @@ public class WindowAnnotationManager { } }; fWindow.getPartService().addPartListener(fPartListener); - + } - + private void startHighlighting(IEditorPart editor) { if (editor == null) return; @@ -82,7 +82,7 @@ public class WindowAnnotationManager { mgr.setSearchResults(fSearchResults); } } - + private void updateHighlighting(IEditorPart editor) { if (editor == null) return; @@ -91,7 +91,7 @@ public class WindowAnnotationManager { mgr.doEditorInputChanged(); } } - + private void initEditors() { IWorkbenchPage[] pages= fWindow.getPages(); @@ -140,7 +140,7 @@ public class WindowAnnotationManager { } } } - + void removeSearchResult(AbstractTextSearchResult result) { fSearchResults.remove(result); boolean stillShown= fSearchResults.contains(result); @@ -151,5 +151,5 @@ public class WindowAnnotationManager { } } } - + } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/DefaultTextSearchQueryProvider.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/DefaultTextSearchQueryProvider.java index 3d1df24d7a4..ef6c1f4b296 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/DefaultTextSearchQueryProvider.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/DefaultTextSearchQueryProvider.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright (c) 2006 Wind River Systems 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: - * Markus Schorn - initial API and implementation + * 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: + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.search2.internal.ui.text2; @@ -15,12 +15,11 @@ import org.eclipse.core.resources.IResource; import org.eclipse.ui.IWorkingSet; +import org.eclipse.search.internal.ui.text.FileSearchQuery; import org.eclipse.search.ui.ISearchQuery; import org.eclipse.search.ui.text.FileTextSearchScope; import org.eclipse.search.ui.text.TextSearchQueryProvider; -import org.eclipse.search.internal.ui.text.FileSearchQuery; - public class DefaultTextSearchQueryProvider extends TextSearchQueryProvider { /* (non-Javadoc) @@ -41,7 +40,7 @@ public class DefaultTextSearchQueryProvider extends TextSearchQueryProvider { FileTextSearchScope scope= FileTextSearchScope.newWorkspaceScope(getPreviousFileNamePatterns(), false); return new FileSearchQuery(searchForString, false, true, scope); } - + /* (non-Javadoc) * @see org.eclipse.search.ui.text.TextSearchQueryProvider#createQuery(java.lang.String, org.eclipse.core.resources.IResource[]) */ @@ -57,9 +56,9 @@ public class DefaultTextSearchQueryProvider extends TextSearchQueryProvider { FileTextSearchScope scope= FileTextSearchScope.newSearchScope(ws, getPreviousFileNamePatterns(), false); return new FileSearchQuery(selectedText, false, true, scope); } - + private String[] getPreviousFileNamePatterns() { return new String[] { "*" }; //$NON-NLS-1$ } - + } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInFileActionDelegate.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInFileActionDelegate.java index 0a34f616042..4376bb04f7a 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInFileActionDelegate.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInFileActionDelegate.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright (c) 2006 Wind River Systems 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: - * Markus Schorn - initial API and implementation + * 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: + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.search2.internal.ui.text2; @@ -33,7 +33,7 @@ import org.eclipse.search2.internal.ui.SearchMessages; public class FindInFileActionDelegate extends FindInRecentScopeActionDelegate { private IEditorPart fEditor= null; - + public FindInFileActionDelegate() { super(SearchMessages.FindInFileActionDelegate_text); setActionDefinitionId("org.eclipse.search.ui.performTextSearchFile"); //$NON-NLS-1$ @@ -63,7 +63,7 @@ public class FindInFileActionDelegate extends FindInRecentScopeActionDelegate { super.setActiveEditor(action, editor); } - + private IFile getFile() { if (fEditor != null) { IEditorInput ei= fEditor.getEditorInput(); @@ -77,5 +77,5 @@ public class FindInFileActionDelegate extends FindInRecentScopeActionDelegate { protected ISearchQuery createQuery(TextSearchQueryProvider provider, String searchForString) throws CoreException { return provider.createQuery(searchForString, new IResource[] { getFile() }); } - + } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInProjectActionDelegate.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInProjectActionDelegate.java index fe786afeb6f..50723529886 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInProjectActionDelegate.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInProjectActionDelegate.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright (c) 2006 Wind River Systems 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: - * Markus Schorn - initial API and implementation + * 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: + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.search2.internal.ui.text2; @@ -78,5 +78,5 @@ public class FindInProjectActionDelegate extends FindInRecentScopeActionDelegate return provider.createQuery(searchForString, new IResource[] { getCurrentProject() }); } return provider.createQuery(searchForString); - } + } } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInRecentScopeActionDelegate.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInRecentScopeActionDelegate.java index 991f01e96aa..8c4f17675d6 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInRecentScopeActionDelegate.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInRecentScopeActionDelegate.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright (c) 2006 Wind River Systems 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: - * Markus Schorn - initial API and implementation + * 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: + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.search2.internal.ui.text2; diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInWorkingSetActionDelegate.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInWorkingSetActionDelegate.java index eb6f5527276..3d0c305338a 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInWorkingSetActionDelegate.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInWorkingSetActionDelegate.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright (c) 2006 Wind River Systems 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: - * Markus Schorn - initial API and implementation + * 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: + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.search2.internal.ui.text2; @@ -33,7 +33,7 @@ public class FindInWorkingSetActionDelegate extends FindInRecentScopeActionDeleg super(SearchMessages.FindInWorkingSetActionDelegate_text); setActionDefinitionId("org.eclipse.search.ui.performTextSearchWorkingSet"); //$NON-NLS-1$ } - + protected ISearchQuery createQuery(TextSearchQueryProvider provider, String searchForString) throws CoreException { IWorkbenchPage page= getWorkbenchPage(); if (page != null) { diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInWorkspaceActionDelegate.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInWorkspaceActionDelegate.java index 82fcf31a3a5..9da18c7e120 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInWorkspaceActionDelegate.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/FindInWorkspaceActionDelegate.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright (c) 2006 Wind River Systems 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: - * Markus Schorn - initial API and implementation + * 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: + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.search2.internal.ui.text2; diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/RetrieverAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/RetrieverAction.java index 5f28538a14d..405677cebf2 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/RetrieverAction.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/RetrieverAction.java @@ -1,20 +1,16 @@ /******************************************************************************* * Copyright (c) 2006 Wind River Systems 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: - * Markus Schorn - initial API and implementation + * 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: + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.search2.internal.ui.text2; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.OperationCanceledException; - import org.eclipse.swt.custom.CCombo; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.graphics.Point; @@ -28,6 +24,10 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.OperationCanceledException; + import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.MessageDialog; @@ -46,14 +46,14 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.forms.editor.FormEditor; import org.eclipse.ui.forms.widgets.FormText; import org.eclipse.ui.model.IWorkbenchAdapter; + import org.eclipse.ui.texteditor.ITextEditor; +import org.eclipse.search.internal.ui.SearchPlugin; import org.eclipse.search.ui.ISearchQuery; import org.eclipse.search.ui.NewSearchUI; import org.eclipse.search.ui.text.TextSearchQueryProvider; -import org.eclipse.search.internal.ui.SearchPlugin; - import org.eclipse.search2.internal.ui.SearchMessages; abstract public class RetrieverAction extends Action { @@ -75,7 +75,7 @@ abstract public class RetrieverAction extends Action { ISearchQuery query= createQuery(provider, searchForString); if (query != null) { NewSearchUI.runQueryInBackground(query); - } + } } catch (OperationCanceledException ex) { // action cancelled } catch (CoreException e) { @@ -90,7 +90,7 @@ abstract public class RetrieverAction extends Action { } return null; } - + private Shell getShell() { IWorkbenchPart part= getActivePart(); if (part != null) { @@ -155,13 +155,13 @@ abstract public class RetrieverAction extends Action { sel= combo.getText(); Point selection= combo.getSelection(); sel= sel.substring(selection.x, selection.y); - } + } if (control instanceof CCombo) { CCombo combo= (CCombo) control; sel= combo.getText(); Point selection= combo.getSelection(); sel= sel.substring(selection.x, selection.y); - } + } else if (control instanceof Text) { Text text= (Text) control; sel= text.getSelectionText(); @@ -195,7 +195,7 @@ abstract public class RetrieverAction extends Action { sel= s[0]; } } - + if (sel != null) { sel= trimSearchString(sel); } @@ -319,5 +319,5 @@ abstract public class RetrieverAction extends Action { } return searchFor == null ? "" : searchFor; //$NON-NLS-1$ } - + } diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java index 4e79a78fb16..3ade7252bfe 100644 --- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java +++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright (c) 2006 Wind River Systems 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: - * Markus Schorn - initial API and implementation + * 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: + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.search2.internal.ui.text2; @@ -19,10 +19,9 @@ import org.eclipse.core.runtime.Preferences; import org.eclipse.jface.util.SafeRunnable; -import org.eclipse.search.ui.text.TextSearchQueryProvider; - import org.eclipse.search.internal.ui.SearchPlugin; import org.eclipse.search.internal.ui.SearchPreferencePage; +import org.eclipse.search.ui.text.TextSearchQueryProvider; import org.eclipse.search2.internal.ui.SearchMessages; |