KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > callhierarchy > SearchScopeHierarchyAction


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  * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
10  * (report 36180: Callers/Callees view)
11  * Michael Fraenkel (fraenkel@us.ibm.com) - patch
12  * (report 60714: Call Hierarchy: display search scope in view title)
13  *******************************************************************************/

14 package org.eclipse.jdt.internal.ui.callhierarchy;
15
16 import org.eclipse.ui.PlatformUI;
17
18 import org.eclipse.jdt.core.IMethod;
19 import org.eclipse.jdt.core.JavaModelException;
20 import org.eclipse.jdt.core.search.IJavaSearchScope;
21 import org.eclipse.jdt.core.search.SearchEngine;
22
23 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
24 import org.eclipse.jdt.internal.ui.JavaPlugin;
25 import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory;
26
27
28 class SearchScopeHierarchyAction extends SearchScopeAction {
29     private final SearchScopeActionGroup fGroup;
30     
31     public SearchScopeHierarchyAction(SearchScopeActionGroup group) {
32         super(group, CallHierarchyMessages.SearchScopeActionGroup_hierarchy_text);
33         this.fGroup = group;
34         setToolTipText(CallHierarchyMessages.SearchScopeActionGroup_hierarchy_tooltip);
35         PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION);
36     }
37     
38     public IJavaSearchScope getSearchScope() {
39         try {
40             IMethod method = this.fGroup.getView().getMethod();
41             
42             if (method != null) {
43                 return SearchEngine.createHierarchyScope(method.getDeclaringType());
44             } else {
45                 return null;
46             }
47         } catch (JavaModelException e) {
48             JavaPlugin.log(e);
49         }
50         
51         return null;
52     }
53     
54     /* (non-Javadoc)
55      * @see org.eclipse.jdt.internal.ui.callhierarchy.SearchScopeActionGroup.SearchScopeAction#getSearchScopeType()
56      */

57     public int getSearchScopeType() {
58         return SearchScopeActionGroup.SEARCH_SCOPE_TYPE_HIERARCHY;
59     }
60     
61     /* (non-Javadoc)
62      * @see org.eclipse.jdt.internal.ui.callhierarchy.SearchScopeAction#getFullDescription()
63      */

64     public String JavaDoc getFullDescription() {
65         IMethod method = this.fGroup.getView().getMethod();
66         return JavaSearchScopeFactory.getInstance().getHierarchyScopeDescription(method.getDeclaringType());
67     }
68
69 }
70
Popular Tags