Search in sources :

Example 1 with FMLineBreakpoint

use of com.liferay.ide.portal.core.debug.fm.FMLineBreakpoint in project liferay-ide by liferay.

the class FMBreakpointProvider method addBreakpoint.

public IStatus addBreakpoint(IDocument document, IEditorInput input, int lineNumber, int offset) throws CoreException {
    IStatus retval = Status.OK_STATUS;
    if (fSourceEditingTextTools instanceof IDebugEditor) {
        IDebugEditor debugEditor = (IDebugEditor) fSourceEditingTextTools;
        IStatus status = debugEditor.validateBreakpointPosition(lineNumber, offset);
        if (status.isOK()) {
            if (input instanceof IFileEditorInput) {
                final IFileEditorInput fileEditorInput = (IFileEditorInput) input;
                final IFile file = fileEditorInput.getFile();
                final FMLineBreakpoint bp = new FMLineBreakpoint(file, lineNumber);
                DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(bp);
            }
        } else {
            retval = status;
        }
    }
    return retval;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) IFileEditorInput(org.eclipse.ui.IFileEditorInput) IDebugEditor(com.liferay.ide.portal.ui.debug.IDebugEditor) FMLineBreakpoint(com.liferay.ide.portal.core.debug.fm.FMLineBreakpoint)

Example 2 with FMLineBreakpoint

use of com.liferay.ide.portal.core.debug.fm.FMLineBreakpoint in project liferay-ide by liferay.

the class FMLineBreakpointAdapter method toggleLineBreakpoints.

public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
    ITextEditor textEditor = getEditor(part);
    if (textEditor != null) {
        IResource resource = (IResource) textEditor.getEditorInput().getAdapter(IResource.class);
        ITextSelection textSelection = (ITextSelection) selection;
        int lineNumber = textSelection.getStartLine();
        IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(ILRDebugConstants.ID_FM_DEBUG_MODEL);
        for (int i = 0; i < breakpoints.length; i++) {
            IBreakpoint breakpoint = breakpoints[i];
            if (resource.equals(breakpoint.getMarker().getResource())) {
                if (((ILineBreakpoint) breakpoint).getLineNumber() == (lineNumber + 1)) {
                    // remove
                    breakpoint.delete();
                    return;
                }
            }
        }
        // create line breakpoint (doc line numbers start at 0)
        FMLineBreakpoint lineBreakpoint = new FMLineBreakpoint(resource, lineNumber + 1);
        DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint);
    }
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) FMLineBreakpoint(com.liferay.ide.portal.core.debug.fm.FMLineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IResource(org.eclipse.core.resources.IResource) ITextSelection(org.eclipse.jface.text.ITextSelection) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) FMLineBreakpoint(com.liferay.ide.portal.core.debug.fm.FMLineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Aggregations

FMLineBreakpoint (com.liferay.ide.portal.core.debug.fm.FMLineBreakpoint)2 IDebugEditor (com.liferay.ide.portal.ui.debug.IDebugEditor)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 IStatus (org.eclipse.core.runtime.IStatus)1 IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)1 ILineBreakpoint (org.eclipse.debug.core.model.ILineBreakpoint)1 ITextSelection (org.eclipse.jface.text.ITextSelection)1 IFileEditorInput (org.eclipse.ui.IFileEditorInput)1 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)1