KickJava   Java API By Example, From Geeks To Geeks.

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


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.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-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.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 JavaDoc iter= selection.iterator();
42         while (iter.hasNext()) {
43             Object JavaDoc element = iter.next();
44             if (!(element instanceof IJavaWatchpoint)) {
45                 return false;
46             }
47             
48         }
49         return true;
50     }
51 }
52
53
Popular Tags