KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > ui > actions > WorkingSetFindAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation 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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.ui.actions;
12
13 import org.eclipse.core.runtime.Assert;
14
15 import org.eclipse.ui.IWorkbenchSite;
16 import org.eclipse.ui.PlatformUI;
17
18 import org.eclipse.jdt.core.IJavaElement;
19
20 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
21 import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
22
23 /**
24  * Wraps a <code>JavaElementSearchActions</code> to find its results
25  * in the specified working set.
26  * <p>
27  * The action is applicable to selections and Search view entries
28  * representing a Java element.
29  *
30  * <p>
31  * Note: This class is for internal use only. Clients should not use this class.
32  * </p>
33  *
34  * @since 2.0
35  */

36 public class WorkingSetFindAction extends FindAction {
37
38     private FindAction fAction;
39
40     /**
41      * Note: This constructor is for internal use only. Clients should not call this constructor.
42      */

43     public WorkingSetFindAction(IWorkbenchSite site, FindAction action, String JavaDoc workingSetName) {
44         super(site);
45         init(action, workingSetName);
46     }
47
48     /**
49      * Note: This constructor is for internal use only. Clients should not call this constructor.
50      */

51     public WorkingSetFindAction(JavaEditor editor, FindAction action, String JavaDoc workingSetName) {
52         super(editor);
53         init(action, workingSetName);
54     }
55
56     Class JavaDoc[] getValidTypes() {
57         return null; // ignore, we override canOperateOn
58
}
59     
60     void init() {
61         // ignore: do our own init in 'init(FindAction, String)'
62
}
63     
64     private void init(FindAction action, String JavaDoc workingSetName) {
65         Assert.isNotNull(action);
66         fAction= action;
67         setText(workingSetName);
68         setImageDescriptor(action.getImageDescriptor());
69         setToolTipText(action.getToolTipText());
70         PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.WORKING_SET_FIND_ACTION);
71     }
72     
73     public void run(IJavaElement element) {
74         fAction.run(element);
75     }
76
77     boolean canOperateOn(IJavaElement element) {
78         return fAction.canOperateOn(element);
79     }
80
81     int getLimitTo() {
82         return -1;
83     }
84
85     String JavaDoc getOperationUnavailableMessage() {
86         return fAction.getOperationUnavailableMessage();
87     }
88
89 }
90
Popular Tags