KickJava   Java API By Example, From Geeks To Geeks.

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


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
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.debug.core.model.IBreakpoint;
16 import org.eclipse.jdt.debug.core.IJavaExceptionBreakpoint;
17 import org.eclipse.jdt.debug.core.IJavaThread;
18 import org.eclipse.ui.IActionFilter;
19
20 /**
21  * Filter which determines if actions relevant to an IJavaThread should
22  * be displayed. This filter is provided to the platform by JDIDebugUIAdapterFactory.
23  */

24 public class JavaThreadActionFilter implements IActionFilter {
25
26     public boolean testAttribute(Object JavaDoc target, String JavaDoc name, String JavaDoc value) {
27         if (target instanceof IJavaThread) {
28             if (name.equals("TerminateEvaluationActionFilter") //$NON-NLS-1$
29
&& value.equals("supportsTerminateEvaluation")) { //$NON-NLS-1$
30
IJavaThread thread = (IJavaThread) target;
31                 return thread.isPerformingEvaluation();
32             } else if (name.equals("ExcludeExceptionLocationFilter") //$NON-NLS-1$
33
&& value.equals("suspendedAtException")) { //$NON-NLS-1$
34
IJavaThread thread = (IJavaThread) target;
35                 IBreakpoint[] breakpoints= thread.getBreakpoints();
36                 for (int i = 0; i < breakpoints.length; i++) {
37                     IBreakpoint breakpoint= breakpoints[i];
38                     try {
39                         if (breakpoint.isRegistered() && breakpoint instanceof IJavaExceptionBreakpoint) {
40                             return true;
41                         }
42                     } catch (CoreException e) {
43                     }
44                 }
45             }
46                 
47         }
48         return false;
49     }
50 }
51
Popular Tags