コード例 #1
0
  public void toggleLineBreakpoints(final IWorkbenchPart part, ISelection selection)
      throws CoreException {
    final QvtEditor qvtEditor = getEditor(part);
    if (qvtEditor == null) {
      return;
    }

    IFile unitFile = (IFile) qvtEditor.getEditorInput().getAdapter(IResource.class);
    ITextSelection textSelection = (ITextSelection) selection;
    int lineNumber = textSelection.getStartLine() + 1;

    List<ILineBreakpoint> breakpoints = QVTODebugCore.getQVTOBreakpoints(ILineBreakpoint.class);
    for (ILineBreakpoint next : breakpoints) {
      if (!unitFile.equals(next.getMarker().getResource())) {
        continue;
      }

      if (next.getLineNumber() == lineNumber) {
        try {
          // a breakpoint already exists at this line =>toggle again means remove
          DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint(next, true);
        } catch (CoreException e) {
          QVTODebugUIPlugin.log(e.getStatus());
        }
        next.delete();
        return;
      }
    }

    URI sourceURI = URIUtils.getResourceURI(unitFile);
    final QVTOBreakpoint lineBreakpoint = new QVTOBreakpoint(sourceURI, lineNumber);
    lineBreakpoint.register(true);

    Job job =
        new Job(DebugUIMessages.QVTOToggleBreakpointAdapter_VerifyBreakpointJob) {
          @Override
          protected IStatus run(IProgressMonitor monitor) {
            return new BreakpointLocationVerifier(
                    qvtEditor,
                    lineBreakpoint,
                    DebugUIMessages.QVTOToggleBreakpointAdapter_CannotSetBreakpoint)
                .run();
          }

          @Override
          public boolean belongsTo(Object family) {
            return QVTOBreakpoint.QVTO_BREAKPOINT_JOBFAMILY == family;
          }
        };

    job.setPriority(Job.INTERACTIVE);
    job.setSystem(true);
    job.schedule();
  }
コード例 #2
0
 protected StringBuilder appendFileName(ILineBreakpoint breakpoint, StringBuilder label)
     throws CoreException {
   label.append(breakpoint.getMarker().getResource().getName());
   return label;
 }