KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > actions > ExcludeExceptionLocationAction


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.debug.ui.actions;
12
13
14 import java.util.Iterator JavaDoc;
15
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.debug.core.model.IBreakpoint;
18 import org.eclipse.jdt.core.Signature;
19 import org.eclipse.jdt.debug.core.IJavaExceptionBreakpoint;
20 import org.eclipse.jdt.debug.core.IJavaStackFrame;
21 import org.eclipse.jdt.debug.core.IJavaThread;
22 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
23 import org.eclipse.jface.action.IAction;
24 import org.eclipse.jface.viewers.IStructuredSelection;
25
26 public class ExcludeExceptionLocationAction extends ObjectActionDelegate {
27
28     /**
29      * @see IActionDelegate#run(IAction)
30      */

31     public void run(IAction action) {
32         IStructuredSelection selection= getCurrentSelection();
33         if (selection == null) {
34             return;
35         }
36         Iterator JavaDoc itr= selection.iterator();
37         
38         while (itr.hasNext()) {
39             IJavaThread thread= (IJavaThread)itr.next();
40             try {
41                 IBreakpoint[] breakpoints= thread.getBreakpoints();
42                 IJavaStackFrame frame= (IJavaStackFrame)thread.getTopStackFrame();
43                 String JavaDoc newFilter= frame.getDeclaringTypeName();
44                 int index = newFilter.indexOf(Signature.C_GENERIC_START);
45                 if (index > 0) {
46                     newFilter = newFilter.substring(0, index);
47                 }
48                 for (int i = 0; i < breakpoints.length; i++) {
49                     IBreakpoint breakpoint = breakpoints[i];
50                     if (breakpoint instanceof IJavaExceptionBreakpoint) {
51                         IJavaExceptionBreakpoint exBreakpoint= (IJavaExceptionBreakpoint)breakpoint;
52                         String JavaDoc[] current= exBreakpoint.getExclusionFilters();
53                         String JavaDoc[] newFilters= new String JavaDoc[current.length+1];
54                         System.arraycopy(current, 0, newFilters, 0, current.length);
55                         newFilters[current.length]= newFilter;
56                         exBreakpoint.setExclusionFilters(newFilters);
57                         action.setEnabled(false);
58                     }
59                 }
60             } catch (CoreException de) {
61                 JDIDebugUIPlugin.log(de);
62             }
63         }
64     }
65 }
66
Popular Tags