/** * {@inheritDoc} */ public ISelection getSelection() { return new TextSelection(0, 0); }
/** * 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); } }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("TextSelection [offset: ").append(fOffset); //$NON-NLS-1$ int startLine = getStartLine(); sb.append(", startLine: ").append(startLine); //$NON-NLS-1$ int endLine = getEndLine(); if (endLine != startLine) { sb.append(", endLine: ").append(endLine); //$NON-NLS-1$ } sb.append(", length: ").append(fLength); //$NON-NLS-1$ if (fLength != 0) { sb.append(", text: ").append(getText()); //$NON-NLS-1$ } if (fDocument != null) { sb.append(", document: ").append(fDocument); //$NON-NLS-1$ } sb.append("]"); //$NON-NLS-1$ return sb.toString(); } }
@Override public ISelection getSelection() { if (fViewerInFocus != null) { return fViewerInFocus.getSelection(); } return TextSelection.emptySelection(); }
private void initSelections() { ISelection selection = container.getSelection(); if (selection instanceof TextSelection) { patternCombo.setText(((TextSelection) selection).getText()); } }
final IResource res = breakpointUtil.getBreakpointResource(xtextEditor.getEditorInput()); final URI uri = breakpointUtil.getBreakpointURI(xtextEditor.getEditorInput()); final int offset = ((TextSelection) selection).getOffset(); final int line = xtextEditor.getDocument().getLineOfOffset(offset) + 1;
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(); }
@Override public String getText() { IDocument document= getDocument(); if (document != null) { try { return new SelectionProcessor(document, fTabWidth).getText(this); } catch (BadLocationException x) { // ignore and default to super implementation } } return super.getText(); }
int offset1 = ((TextSelection) viewer.getSelectionProvider().getSelection()).getOffset(); if (variables != null)
@Override ISelection makeReplaceSelection(ISelection selection, String replacement) { ITextSelection ts= (ITextSelection)selection; return new TextSelection(fDocument, ts.getOffset() + replacement.length(), 0); } };
/** * 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); } } }
/** * To see whether the textSelection start and end are on the same. * * @param model * @param textSelection * @param lookForChildren * @return */ public static boolean isSame(IStructuredModel model, TextSelection textSelection) { if (model != null && textSelection != null) { int t1 = textSelection.getOffset(); int t2 = textSelection.getLength() + t1; return model.getIndexedRegion(t1) == model.getIndexedRegion(t2); } return false; }
/** * 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(); }
@Override public String getText() { IDocument document= getDocument(); if (document != null) { try { return new SelectionProcessor(document, fTabWidth).getText(this); } catch (BadLocationException x) { // ignore and default to super implementation } } return super.getText(); }
@Override ISelection makeReplaceSelection(ISelection selection, String replacement) { ITextSelection ts= (ITextSelection)selection; return new TextSelection(fDocument, ts.getOffset() + replacement.length(), 0); } };
/** * 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); } }
public void selectionChanged( SelectionChangedEvent event) { if (event.getSelection() instanceof TextSelection) { TextSelection textSelection = ((TextSelection) event .getSelection()); _designViewer .getSynchronizer() .textSelectionChanged( textSelection.getOffset(), textSelection.getOffset() + textSelection .getLength()); } } });
/** * 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(); }
String selection = ((TextSelection) container.getSelection()).getText(); searchText.setText(selection);