KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > search2 > internal > ui > text2 > FindInRecentScopeActionDelegate


1 /*******************************************************************************
2  * Copyright (c) 2006 Wind River Systems and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * Markus Schorn - initial API and implementation
10  *******************************************************************************/

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 /**
30  * @author markus.schorn@windriver.com
31  */

32 abstract public class FindInRecentScopeActionDelegate extends RetrieverAction implements IWorkbenchWindowActionDelegate, IEditorActionDelegate {
33     private IWorkbenchWindow fWindow;
34
35     public FindInRecentScopeActionDelegate(String JavaDoc text) {
36         setText(text);
37     }
38
39     // IWorkbenchWindowActionDelegate
40
public void dispose() {
41         fWindow= null;
42     }
43
44     // IWorkbenchWindowActionDelegate
45
public void init(IWorkbenchWindow window) {
46         fWindow= window;
47     }
48
49     // IEditorActionDelegate
50
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
51         fWindow= null;
52         if (targetEditor != null) {
53             fWindow= targetEditor.getSite().getWorkbenchWindow();
54         }
55     }
56
57     // IActionDelegate
58
public void selectionChanged(IAction action, ISelection selection) {
59     }
60
61     // IActionDelegate
62
final public void run(IAction action) {
63         run();
64     }
65
66     // RetrieverAction
67
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 JavaDoc searchForString) throws CoreException;
75 }
76
Popular Tags