Java Code Examples for org.eclipse.jface.text.TextSelection#getStartLine()

The following examples show how to use org.eclipse.jface.text.TextSelection#getStartLine() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PyToggleTargetAdapter.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void toggleBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
    if (part instanceof ITextEditor && selection instanceof TextSelection
            && PyToggleTargetAdapter.canToggleFor((ITextEditor) part)) {
        TextSelection textSelection = (TextSelection) selection;
        BaseEditor pyEdit = (BaseEditor) part;
        int startLine = textSelection.getStartLine();

        List<IMarker> markersFromCurrentFile = PyBreakpointRulerAction.getMarkersFromCurrentFile(pyEdit, startLine);
        if (markersFromCurrentFile.size() > 0) {
            PyBreakpointRulerAction.removeMarkers(markersFromCurrentFile);
        } else {
            PyBreakpointRulerAction.addBreakpointMarker(pyEdit.getDocument(), startLine + 1, pyEdit,
                    PyBreakpoint.PY_BREAK_TYPE_DJANGO);
        }
    }
}
 
Example 2
Source File: PyToggleBreakpointsTarget.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void toggleBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
    if (part instanceof PyEdit && selection instanceof TextSelection) {
        TextSelection textSelection = (TextSelection) selection;
        PyEdit pyEdit = (PyEdit) part;
        int startLine = textSelection.getStartLine();

        List<IMarker> markersFromCurrentFile = PyBreakpointRulerAction.getMarkersFromCurrentFile(pyEdit, startLine);
        if (markersFromCurrentFile.size() > 0) {
            PyBreakpointRulerAction.removeMarkers(markersFromCurrentFile);
        } else {
            PyBreakpointRulerAction.addBreakpointMarker(pyEdit.getDocument(), startLine + 1, pyEdit,
                    PyBreakpoint.PY_BREAK_TYPE_PYTHON);
        }

    }

}