1 11 package org.eclipse.search2.internal.ui.text2; 12 13 14 import org.eclipse.core.runtime.CoreException; 15 16 import org.eclipse.jface.action.IAction; 17 import org.eclipse.jface.viewers.ISelection; 18 19 import org.eclipse.ui.IEditorActionDelegate; 20 import org.eclipse.ui.IEditorPart; 21 import org.eclipse.ui.IWorkbenchPage; 22 import org.eclipse.ui.IWorkbenchWindow; 23 import org.eclipse.ui.IWorkbenchWindowActionDelegate; 24 25 import org.eclipse.search.ui.ISearchQuery; 26 import org.eclipse.search.ui.text.TextSearchQueryProvider; 27 28 29 32 abstract public class FindInRecentScopeActionDelegate extends RetrieverAction implements IWorkbenchWindowActionDelegate, IEditorActionDelegate { 33 private IWorkbenchWindow fWindow; 34 35 public FindInRecentScopeActionDelegate(String text) { 36 setText(text); 37 } 38 39 public void dispose() { 41 fWindow= null; 42 } 43 44 public void init(IWorkbenchWindow window) { 46 fWindow= window; 47 } 48 49 public void setActiveEditor(IAction action, IEditorPart targetEditor) { 51 fWindow= null; 52 if (targetEditor != null) { 53 fWindow= targetEditor.getSite().getWorkbenchWindow(); 54 } 55 } 56 57 public void selectionChanged(IAction action, ISelection selection) { 59 } 60 61 final public void run(IAction action) { 63 run(); 64 } 65 66 protected IWorkbenchPage getWorkbenchPage() { 68 if (fWindow != null) { 69 return fWindow.getActivePage(); 70 } 71 return null; 72 } 73 74 abstract protected ISearchQuery createQuery(TextSearchQueryProvider provider, String searchForString) throws CoreException; 75 } 76 | Popular Tags |