KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > EvaluationContextStatusHandler


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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;
12
13 import org.eclipse.core.runtime.IStatus;
14 import org.eclipse.debug.core.IStatusHandler;
15 import org.eclipse.debug.core.model.IDebugElement;
16 import org.eclipse.jdt.debug.core.IJavaDebugTarget;
17 import org.eclipse.jdt.debug.core.IJavaStackFrame;
18 import org.eclipse.ui.IWorkbenchWindow;
19
20 /**
21  * Supplies a thread that can be used for an evaluation, given an element
22  * from a java debug model. Currently use for logical object structure
23  * computations.
24  *
25  * @since 3.0
26  */

27 public class EvaluationContextStatusHandler implements IStatusHandler {
28
29     /* (non-Javadoc)
30      * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object)
31      */

32     public Object JavaDoc handleStatus(IStatus status, Object JavaDoc source) {
33         if (source instanceof IDebugElement) {
34             IDebugElement element = (IDebugElement) source;
35             IJavaDebugTarget target = (IJavaDebugTarget) element.getDebugTarget().getAdapter(IJavaDebugTarget.class);
36             if (target != null) {
37                 IJavaStackFrame frame = EvaluationContextManager.getEvaluationContext((IWorkbenchWindow)null);
38                 if (frame != null && frame.getDebugTarget().equals(target)) {
39                     return frame.getThread();
40                 }
41             }
42         }
43         return null;
44     }
45
46 }
47
Popular Tags