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()
24 .getAdapter(IResource.class);
25 ITextSelection textSelection = (ITextSelection) selection;
26 int lineNumber = textSelection.getStartLine() + 1;
27 IBreakpoint[] breakpoints = DebugPlugin.getDefault()
28 .getBreakpointManager().getBreakpoints(
29 IXDebugConstants.ID_PHP_DEBUG_MODEL);
30 for (int i = 0; i < breakpoints.length; i++) {
31 IBreakpoint breakpoint = breakpoints[i];
32 if (resource.equals(breakpoint.getMarker().getResource())) {
33 if (((ILineBreakpoint) breakpoint).getLineNumber() == (lineNumber)) {
40 // create line breakpoint (doc line numbers start at 0)
41 XDebugLineBreakpoint lineBreakpoint = new XDebugLineBreakpoint(
42 resource, lineNumber);
43 // DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint);
47 public boolean canToggleLineBreakpoints(IWorkbenchPart part,
48 ISelection selection) {
49 // TODO Auto-generated method stub
53 public void toggleMethodBreakpoints(IWorkbenchPart part,
54 ISelection selection) throws CoreException {
55 // TODO Auto-generated method stub
59 public boolean canToggleMethodBreakpoints(IWorkbenchPart part,
60 ISelection selection) {
61 // TODO Auto-generated method stub
65 public void toggleWatchpoints(IWorkbenchPart part, ISelection selection)
66 throws CoreException {
67 // TODO Auto-generated method stub
71 public boolean canToggleWatchpoints(IWorkbenchPart part,
72 ISelection selection) {
73 // TODO Auto-generated method stub