KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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  *******************************************************************************/

12 package org.eclipse.jdt.internal.ui.callhierarchy;
13
14 import org.eclipse.jdt.core.JavaModelException;
15
16 import org.eclipse.jface.action.Action;
17
18 import org.eclipse.ui.IWorkingSet;
19 import org.eclipse.ui.PlatformUI;
20
21 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
22 import org.eclipse.jdt.internal.ui.JavaPlugin;
23 import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory;
24 import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
25
26 class SelectWorkingSetAction extends Action {
27     private final SearchScopeActionGroup fGroup;
28     
29     public SelectWorkingSetAction(SearchScopeActionGroup group) {
30         super(CallHierarchyMessages.SearchScopeActionGroup_workingset_select_text);
31         this.fGroup = group;
32         setToolTipText(CallHierarchyMessages.SearchScopeActionGroup_workingset_select_tooltip);
33         PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION);
34     }
35     /*
36      * (non-Javadoc)
37      *
38      * @see org.eclipse.jface.action.Action#run()
39      */

40     public void run() {
41         try {
42             IWorkingSet[] workingSets;
43             workingSets = JavaSearchScopeFactory.getInstance().queryWorkingSets();
44             if (workingSets != null) {
45                 this.fGroup.setActiveWorkingSets(workingSets);
46                 SearchUtil.updateLRUWorkingSets(workingSets);
47             } else {
48                 this.fGroup.setActiveWorkingSets(null);
49             }
50         } catch (JavaModelException e) {
51             ExceptionHandler.handle(e, JavaPlugin.getActiveWorkbenchShell(),
52                     CallHierarchyMessages.SelectWorkingSetAction_error_title,
53                     CallHierarchyMessages.SelectWorkingSetAction_error_message);
54         } catch (InterruptedException JavaDoc e) {
55             // cancel pressed
56
}
57     }
58 }
59
Popular Tags