KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > typehierarchy > FocusOnTypeAction


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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.typehierarchy;
12
13 import org.eclipse.swt.widgets.Shell;
14
15 import org.eclipse.jface.action.Action;
16 import org.eclipse.jface.dialogs.IDialogConstants;
17
18 import org.eclipse.ui.PlatformUI;
19
20 import org.eclipse.jdt.core.IType;
21 import org.eclipse.jdt.core.search.IJavaSearchConstants;
22 import org.eclipse.jdt.core.search.SearchEngine;
23
24 import org.eclipse.jdt.ui.ITypeHierarchyViewPart;
25
26 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
27 import org.eclipse.jdt.internal.ui.dialogs.FilteredTypesSelectionDialog;
28
29 /**
30  * Refocuses the type hierarchy on a type selection from a all types dialog.
31  */

32 public class FocusOnTypeAction extends Action {
33             
34     private ITypeHierarchyViewPart fViewPart;
35     
36     public FocusOnTypeAction(ITypeHierarchyViewPart part) {
37         super(TypeHierarchyMessages.FocusOnTypeAction_label);
38         setDescription(TypeHierarchyMessages.FocusOnTypeAction_description);
39         setToolTipText(TypeHierarchyMessages.FocusOnTypeAction_tooltip);
40         
41         fViewPart= part;
42         PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.FOCUS_ON_TYPE_ACTION);
43     }
44
45     /*
46      * @see Action#run
47      */

48     public void run() {
49         Shell parent= fViewPart.getSite().getShell();
50         FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(parent, false,
51             PlatformUI.getWorkbench().getProgressService(),
52             SearchEngine.createWorkspaceScope(), IJavaSearchConstants.TYPE);
53     
54         dialog.setTitle(TypeHierarchyMessages.FocusOnTypeAction_dialog_title);
55         dialog.setMessage(TypeHierarchyMessages.FocusOnTypeAction_dialog_message);
56         if (dialog.open() != IDialogConstants.OK_ID) {
57             return;
58         }
59         
60         Object JavaDoc[] types= dialog.getResult();
61         if (types != null && types.length > 0) {
62             IType type= (IType)types[0];
63             fViewPart.setInputElement(type);
64         }
65     }
66 }
67
Popular Tags