KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > commands > ShowElementInTypeHierarchyViewHandler


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.internal.ui.commands;
12
13 import org.eclipse.core.commands.AbstractHandler;
14 import org.eclipse.core.commands.ExecutionEvent;
15 import org.eclipse.core.commands.ExecutionException;
16
17 import org.eclipse.ui.IWorkbenchWindow;
18
19 import org.eclipse.jdt.core.IJavaElement;
20
21 import org.eclipse.jdt.internal.ui.JavaPlugin;
22 import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil;
23
24 /**
25  * A command handler to show a java element in the type hierarchy view.
26  *
27  * @since 3.2
28  */

29 public class ShowElementInTypeHierarchyViewHandler extends AbstractHandler {
30
31     private static final String JavaDoc PARAM_ID_ELEMENT_REF= "elementRef"; //$NON-NLS-1$
32

33     public Object JavaDoc execute(ExecutionEvent event) throws ExecutionException {
34
35         IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow();
36         if (window == null)
37             return null;
38
39         IJavaElement javaElement= (IJavaElement) event.getObjectParameterForExecution(PARAM_ID_ELEMENT_REF);
40
41         OpenTypeHierarchyUtil.open(javaElement, window);
42
43         return null;
44     }
45 }
46
Popular Tags