1 package net.sourceforge.phpeclipse.xdebug.ui.php.model;
3 import net.sourceforge.phpeclipse.xdebug.php.launching.IXDebugConstants;
4 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugLineBreakpoint;
6 import org.eclipse.core.resources.IResource;
7 import org.eclipse.core.runtime.CoreException;
8 import org.eclipse.debug.core.DebugPlugin;
9 import org.eclipse.debug.core.model.IBreakpoint;
10 import org.eclipse.debug.core.model.ILineBreakpoint;
11 import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
12 import org.eclipse.jface.text.ITextSelection;
13 import org.eclipse.jface.viewers.ISelection;
14 import org.eclipse.ui.IEditorPart;
15 import org.eclipse.ui.IWorkbenchPart;
17 public class PHPLineBreakpointAdapter implements IToggleBreakpointsTarget {
19 public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection)
20 throws CoreException {
21 IEditorPart editorPart = (IEditorPart)part;
23 IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class);
24 ITextSelection textSelection = (ITextSelection) selection;
25 int lineNumber = textSelection.getStartLine()+1;
26 IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IXDebugConstants.ID_PHP_DEBUG_MODEL);
27 for (int i = 0; i < breakpoints.length; i++) {
28 IBreakpoint breakpoint = breakpoints[i];
29 if (resource.equals(breakpoint.getMarker().getResource())) {
30 if (((ILineBreakpoint)breakpoint).getLineNumber() == (lineNumber )) {
37 // create line breakpoint (doc line numbers start at 0)
38 XDebugLineBreakpoint lineBreakpoint = new XDebugLineBreakpoint(resource, lineNumber);
39 DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint);
43 public boolean canToggleLineBreakpoints(IWorkbenchPart part,
44 ISelection selection) {
45 // TODO Auto-generated method stub
49 public void toggleMethodBreakpoints(IWorkbenchPart part,
50 ISelection selection) throws CoreException {
51 // TODO Auto-generated method stub
55 public boolean canToggleMethodBreakpoints(IWorkbenchPart part,
56 ISelection selection) {
57 // TODO Auto-generated method stub
61 public void toggleWatchpoints(IWorkbenchPart part, ISelection selection)
62 throws CoreException {
63 // TODO Auto-generated method stub
67 public boolean canToggleWatchpoints(IWorkbenchPart part,
68 ISelection selection) {
69 // TODO Auto-generated method stub