@Override public ISelection getSelection() { if (fViewerInFocus != null) { return fViewerInFocus.getSelection(); } return TextSelection.emptySelection(); }
private ITextSelection getCurrentSelection() { if (fEditor instanceof ITextEditor) { ISelectionProvider provider = ((ITextEditor) fEditor).getSelectionProvider(); if (provider != null) { ISelection selection = provider.getSelection(); if (selection instanceof ITextSelection) { return (ITextSelection) selection; } } } return TextSelection.emptySelection(); }
/** * Returns the selection on the editor or an invalid selection if none can be obtained. Returns * never <code>null</code>. * * @return the current selection, never <code>null</code> */ private ITextSelection getSelection() { ISelectionProvider provider= getSelectionProvider(); if (provider != null) { ISelection selection= provider.getSelection(); if (selection instanceof ITextSelection) return (ITextSelection) selection; } // null object return TextSelection.emptySelection(); }
/** * Returns the selection on the editor or an invalid selection if none can be obtained. Returns * never <code>null</code>. * * @return the current selection, never <code>null</code> */ private ITextSelection getSelection() { ISelectionProvider provider= getSelectionProvider(); if (provider != null) { ISelection selection= provider.getSelection(); if (selection instanceof ITextSelection) return (ITextSelection) selection; } // null object return TextSelection.emptySelection(); }
/** * Returns the selection on the editor or an invalid selection if none can be obtained. Returns * never <code>null</code>. * * @return the current selection, never <code>null</code> */ private ITextSelection getSelection() { ISelectionProvider provider= getSelectionProvider(); if (provider != null) { ISelection selection= provider.getSelection(); if (selection instanceof ITextSelection) return (ITextSelection) selection; } // null object return TextSelection.emptySelection(); }
Point modelSelection= widgetSelection2ModelSelection(new Point(startOffset, endOffset - startOffset)); if (modelSelection == null) return TextSelection.emptySelection(); startOffset= modelSelection.x; endOffset= modelSelection.x + modelSelection.y; int endColumn= endOffset - document.getLineOffset(endLine) + endVirtuals; if (startLine == -1 || endLine == -1) return TextSelection.emptySelection(); return new BlockTextSelection(document, startLine, startColumn, endLine, endColumn, fTextWidget.getTabs()); } catch (BadLocationException e) { return TextSelection.emptySelection(); return TextSelection.emptySelection();
Point modelSelection= widgetSelection2ModelSelection(new Point(startOffset, endOffset - startOffset)); if (modelSelection == null) return TextSelection.emptySelection(); startOffset= modelSelection.x; endOffset= modelSelection.x + modelSelection.y; int endColumn= endOffset - document.getLineOffset(endLine) + endVirtuals; if (startLine == -1 || endLine == -1) return TextSelection.emptySelection(); return new BlockTextSelection(document, startLine, startColumn, endLine, endColumn, fTextWidget.getTabs()); } catch (BadLocationException e) { return TextSelection.emptySelection(); return TextSelection.emptySelection();
/** * Sends out a text selection changed event to all registered listeners. * * @param offset the offset of the newly selected range in the visible document * @param length the length of the newly selected range in the visible document * @since 3.0 */ protected void fireSelectionChanged(int offset, int length) { if (redraws()) { if (length < 0) { length= -length; offset= offset + length; } IRegion r= widgetRange2ModelRange(new Region(offset, length)); if ((r != null && !r.equals(fLastSentSelectionChange)) || r == null) { fLastSentSelectionChange= r; ISelection selection= r != null ? new TextSelection(getDocument(), r.getOffset(), r.getLength()) : TextSelection.emptySelection(); SelectionChangedEvent event= new SelectionChangedEvent(this, selection); fireSelectionChanged(event); } } }
/** * Sends out a text selection changed event to all registered listeners. * * @param offset the offset of the newly selected range in the visible document * @param length the length of the newly selected range in the visible document * @since 3.0 */ protected void fireSelectionChanged(int offset, int length) { if (redraws()) { if (length < 0) { length= -length; offset= offset + length; } IRegion r= widgetRange2ModelRange(new Region(offset, length)); if ((r != null && !r.equals(fLastSentSelectionChange)) || r == null) { fLastSentSelectionChange= r; ISelection selection= r != null ? new TextSelection(getDocument(), r.getOffset(), r.getLength()) : TextSelection.emptySelection(); SelectionChangedEvent event= new SelectionChangedEvent(this, selection); fireSelectionChanged(event); } } }
/** * Sends out a text selection changed event to all registered post selection changed listeners. * * @param offset the offset of the newly selected range in the visible document * @param length the length of the newly selected range in the visible document * @since 3.0 */ protected void firePostSelectionChanged(int offset, int length) { if (redraws()) { IRegion r= widgetRange2ModelRange(new Region(offset, length)); ISelection selection= r != null ? new TextSelection(getDocument(), r.getOffset(), r.getLength()) : TextSelection.emptySelection(); SelectionChangedEvent event= new SelectionChangedEvent(this, selection); firePostSelectionChanged(event); } }
/** * Sends out a text selection changed event to all registered post selection changed listeners. * * @param offset the offset of the newly selected range in the visible document * @param length the length of the newly selected range in the visible document * @since 3.0 */ protected void firePostSelectionChanged(int offset, int length) { if (redraws()) { IRegion r= widgetRange2ModelRange(new Region(offset, length)); ISelection selection= r != null ? new TextSelection(getDocument(), r.getOffset(), r.getLength()) : TextSelection.emptySelection(); SelectionChangedEvent event= new SelectionChangedEvent(this, selection); firePostSelectionChanged(event); } }