@Override public int toDocumentLineNumber(int y_coordinate) { if (fTextViewer == null || y_coordinate == -1) return -1; int[] lineNumbers= toLineNumbers(y_coordinate, true); if (lineNumbers[0] == -1) lineNumbers= toLineNumbers(y_coordinate, false); int bestLine= findBestMatchingLineNumber(lineNumbers); if (bestLine == -1 && lineNumbers.length > 0) return lineNumbers[0]; return bestLine; }
@Override public int toDocumentLineNumber(int y_coordinate) { if (fTextViewer == null || y_coordinate == -1) return -1; int[] lineNumbers= toLineNumbers(y_coordinate, true); if (lineNumbers[0] == -1) lineNumbers= toLineNumbers(y_coordinate, false); int bestLine= findBestMatchingLineNumber(lineNumbers); if (bestLine == -1 && lineNumbers.length > 0) return lineNumbers[0]; return bestLine; }
@Override public boolean hasAnnotation(int y) { return findBestMatchingLineNumber(toLineNumbers(y, true)) != -1; }
@Override public boolean hasAnnotation(int y) { return findBestMatchingLineNumber(toLineNumbers(y, true)) != -1; }
/** * Handles mouse moves. * * @param event the mouse move event */ private void handleMouseMove(MouseEvent event) { if (fTextViewer != null) { int[] lines= toLineNumbers(event.y, true); Position p= getAnnotationPosition(lines); Cursor cursor= (p != null ? fHitDetectionCursor : null); if (cursor != fLastCursor) { fCanvas.setCursor(cursor); fLastCursor= cursor; } } }
/** * Handles mouse moves. * * @param event the mouse move event */ private void handleMouseMove(MouseEvent event) { if (fTextViewer != null) { int[] lines= toLineNumbers(event.y, true); Position p= getAnnotationPosition(lines); Cursor cursor= (p != null ? fHitDetectionCursor : null); if (cursor != fLastCursor) { fCanvas.setCursor(cursor); fLastCursor= cursor; } } }
/** * Handles mouse clicks. * * @param event the mouse button down event */ private void handleMouseDown(MouseEvent event) { if (fTextViewer != null) { int[] lines= toLineNumbers(event.y, true); if (lines[0] == -1) lines= toLineNumbers(event.y, false); Position p= getAnnotationPosition(lines); if (p == null && event.button == 1) { try { p= new Position(fTextViewer.getDocument().getLineInformation(lines[0]).getOffset(), 0); } catch (BadLocationException e) { // do nothing } } if (p != null) { fTextViewer.revealRange(p.getOffset(), p.getLength()); fTextViewer.setSelectedRange(p.getOffset(), p.getLength()); } fTextViewer.getTextWidget().setFocus(); } fLastMouseButtonActivityLine= toDocumentLineNumber(event.y); }
/** * Handles mouse clicks. * * @param event the mouse button down event */ private void handleMouseDown(MouseEvent event) { if (fTextViewer != null) { int[] lines= toLineNumbers(event.y, true); if (lines[0] == -1) lines= toLineNumbers(event.y, false); Position p= getAnnotationPosition(lines); if (p == null && event.button == 1) { try { p= new Position(fTextViewer.getDocument().getLineInformation(lines[0]).getOffset(), 0); } catch (BadLocationException e) { // do nothing } } if (p != null) { fTextViewer.revealRange(p.getOffset(), p.getLength()); fTextViewer.setSelectedRange(p.getOffset(), p.getLength()); } fTextViewer.getTextWidget().setFocus(); } fLastMouseButtonActivityLine= toDocumentLineNumber(event.y); }