KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > sourcelookup > StackFrameShowInSourceAdapter


1 /*******************************************************************************
2  * Copyright (c) 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.debug.ui.sourcelookup;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.jdt.core.IType;
15 import org.eclipse.jdt.debug.core.IJavaStackFrame;
16 import org.eclipse.jdt.internal.debug.core.JavaDebugUtils;
17 import org.eclipse.jface.viewers.StructuredSelection;
18 import org.eclipse.ui.part.IShowInSource;
19 import org.eclipse.ui.part.ShowInContext;
20
21 /**
22  * @since 3.2
23  *
24  */

25 public class StackFrameShowInSourceAdapter implements IShowInSource {
26     
27     private IJavaStackFrame fFrame;
28
29     /**
30      * Constructs a new adapter on the given frame.
31      *
32      * @param frame
33      */

34     public StackFrameShowInSourceAdapter(IJavaStackFrame frame) {
35         fFrame = frame;
36     }
37     
38     /* (non-Javadoc)
39      * @see org.eclipse.ui.part.IShowInSource#getShowInContext()
40      */

41     public ShowInContext getShowInContext() {
42         try {
43             IType type = JavaDebugUtils.resolveDeclaringType(fFrame);
44             if (type != null) {
45                 return new ShowInContext(null, new StructuredSelection(type));
46             }
47         } catch (CoreException e) {
48         }
49         return null;
50     }
51
52 }
53
Popular Tags