/** * 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; } } }
/** * Returns the line which corresponds best to one of * the underlying annotations at the given y-coordinate. * * @param lineNumbers the line numbers * @return the best matching line or <code>-1</code> if no such line can be found */ private int findBestMatchingLineNumber(int[] lineNumbers) { if (lineNumbers == null || lineNumbers.length < 1) return -1; try { Position pos= getAnnotationPosition(lineNumbers); if (pos == null) return -1; return fTextViewer.getDocument().getLineOfOffset(pos.getOffset()); } catch (BadLocationException ex) { return -1; } }
/** * Returns the line which corresponds best to one of * the underlying annotations at the given y-coordinate. * * @param lineNumbers the line numbers * @return the best matching line or <code>-1</code> if no such line can be found */ private int findBestMatchingLineNumber(int[] lineNumbers) { if (lineNumbers == null || lineNumbers.length < 1) return -1; try { Position pos= getAnnotationPosition(lineNumbers); if (pos == null) return -1; return fTextViewer.getDocument().getLineOfOffset(pos.getOffset()); } catch (BadLocationException ex) { return -1; } }
/** * 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); }