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.actions; 12 13 14 import java.util.Iterator; 15 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.jdt.debug.core.IJavaBreakpoint; 18 import org.eclipse.jdt.debug.core.IJavaExceptionBreakpoint; 19 import org.eclipse.jface.viewers.IStructuredSelection; 20 21 /** 22 * Toggles the uncaught state of an exception breakpoint 23 */ 24 public class ExceptionUncaughtToggleAction extends BreakpointToggleAction { 25 26 /** 27 * @see BreakpointToggleAction#getToggleState(IJavaBreakpoint) 28 */ 29 protected boolean getToggleState(IJavaBreakpoint breakpoint) throws CoreException { 30 //will only be called after isEnabledFor so cast is safe 31 IJavaExceptionBreakpoint exception= (IJavaExceptionBreakpoint)breakpoint; 32 return exception.isUncaught(); 33 } 34 35 /** 36 * @see BreakpointToggleAction#doAction(IJavaBreakpoint) 37 */ 38 public void doAction(IJavaBreakpoint breakpoint) throws CoreException { 39 //will only be called after isEnabledFor so cast is safe 40 IJavaExceptionBreakpoint exception= (IJavaExceptionBreakpoint)breakpoint; 41 exception.setUncaught(!exception.isUncaught()); 42 } 43 44 /** 45 * @see BreakpointToggleAction#isEnabledFor(IStructuredSelection) 46 */ 47 public boolean isEnabledFor(IStructuredSelection selection) { 48 Iterator iter= selection.iterator(); 49 while (iter.hasNext()) { 50 Object element = iter.next(); 51 if (!(element instanceof IJavaExceptionBreakpoint)) { 52 return false; 53 } 54 55 } 56 return true; 57 } 58 } 59