Changeset 3776 for devel-tools


Ignore:
Timestamp:
Apr 23, 2008, 8:46:43 PM (13 years ago)
Author:
yura
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel-tools/trunk/eclipse/org.refal.rfpdt.ui/src/org/refal/rfpdt/ui/actions/ToggleBreakpointAdapter.java

    r3523 r3776  
    44
    55import org.eclipse.core.resources.IFile;
     6import org.eclipse.core.resources.IMarker;
    67import org.eclipse.core.runtime.CoreException;
    78import org.eclipse.core.runtime.IProgressMonitor;
     
    1011import org.eclipse.core.runtime.jobs.Job;
    1112import org.eclipse.debug.core.DebugPlugin;
     13import org.eclipse.debug.core.IBreakpointManager;
     14import org.eclipse.debug.core.model.IBreakpoint;
     15import org.eclipse.debug.core.model.ILineBreakpoint;
    1216import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension;
    13 import org.eclipse.jdt.debug.core.IJavaLineBreakpoint;
    1417import org.eclipse.jdt.debug.core.JDIDebugModel;
    1518import org.eclipse.jface.text.ITextSelection;
     
    4043    }
    4144
     45    private static boolean removeLineBreakpoint (IBreakpointManager breakpointManager, IFile file, int lnumber)
     46            throws CoreException {
     47        for (IBreakpoint breakpoint : breakpointManager.getBreakpoints(JDIDebugModel.getPluginIdentifier())) {
     48            if (!(breakpoint instanceof ILineBreakpoint))
     49                continue;
     50            IMarker marker = breakpoint.getMarker();
     51            if (marker != null && marker.exists() && marker.getResource().equals(file)
     52                    && ((ILineBreakpoint) breakpoint).getLineNumber() == lnumber) {
     53                breakpointManager.removeBreakpoint(breakpoint, true);
     54                return true;
     55            }
     56        }
     57        return false;
     58    }
     59
    4260    public void toggleLineBreakpoints (final IWorkbenchPart part, final ISelection selection) throws CoreException {
    4361        Job job = new Job("Toggle Line Breakpoint") { //$NON-NLS-1$
    4462            protected IStatus run (IProgressMonitor monitor) {
    45                 // JDIDebugModel.createLineBreakpoint(resource, typeName, lineNumber, charStart, charEnd, hitCount,
    46                 // register, attributes);
    47                 ITextEditor editor = getTextEditor(part);
    48                 if (editor != null && selection instanceof ITextSelection) {
    49                     if (monitor.isCanceled()) {
     63                if (getTextEditor(part) != null && selection instanceof ITextSelection) {
     64                    if (monitor.isCanceled())
    5065                        return Status.CANCEL_STATUS;
    51                     }
    5266                    try {
    5367                        IFile file = getFile(part);
    54                         String className = RfpProject.staticGetModuleName(file);
    5568                        int lnumber = ((ITextSelection) selection).getStartLine() + 1;
    56                         IJavaLineBreakpoint existingBreakpoint = JDIDebugModel.lineBreakpointExists(file,
    57                                 className, lnumber);
    58                         if (existingBreakpoint != null) {
    59                             DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(existingBreakpoint, true);
    60                             return Status.OK_STATUS;
    61                         }
    62                         IJavaLineBreakpoint javaLineBreakpoint = JDIDebugModel.createLineBreakpoint(file,
    63                                 className, lnumber, -1, -1, 0, true, new HashMap<Object, Object>(10));
    64                         DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(javaLineBreakpoint);
     69                        IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
     70                        if (!removeLineBreakpoint(breakpointManager, file, lnumber))
     71                            breakpointManager.addBreakpoint(JDIDebugModel.createStratumBreakpoint(file, null, null,
     72                                    null, RfpProject.staticGetModuleName(file), lnumber, -1, -1, 0, true,
     73                                    new HashMap<Object, Object>(10)));
    6574                    } catch (CoreException ce) {
    6675                        return ce.getStatus();
Note: See TracChangeset for help on using the changeset viewer.