1 /*******************************************************************************2 * Copyright (c) 2000, 2003 IBM Corporation and others.3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Common Public License v1.05 * which accompanies this distribution, and is available at6 * http://www.eclipse.org/legal/cpl-v10.html7 * 8 * Contributors:9 * IBM Corporation - initial API and implementation10 *******************************************************************************/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.IJavaWatchpoint;19 import org.eclipse.jface.viewers.IStructuredSelection;20 21 public class ModificationWatchpointToggleAction extends BreakpointToggleAction {22 23 /**24 * @see BreakpointToggleAction#getToggleState(IJavaBreakpoint)25 */26 protected boolean getToggleState(IJavaBreakpoint watchpoint) throws CoreException {27 return ((IJavaWatchpoint)watchpoint).isModification();28 }29 30 /**31 * @see BreakpointToggleAction#doAction(IJavaBreakpoint)32 */33 public void doAction(IJavaBreakpoint watchpoint) throws CoreException {34 ((IJavaWatchpoint)watchpoint).setModification(!((IJavaWatchpoint)watchpoint).isModification());35 }36 37 /**38 * @see BreakpointToggleAction#isEnabledFor(IStructuredSelection)39 */40 public boolean isEnabledFor(IStructuredSelection selection) {41 Iterator iter= selection.iterator();42 while (iter.hasNext()) {43 Object element = iter.next();44 if (!(element instanceof IJavaWatchpoint)) {45 return false;46 }47 48 }49 return true;50 }51 }52 53