/** * Returns the text regions covered by the given selection in the given viewer. * * @param viewer the viewer * @param selection the selection * @return the text regions corresponding to <code>selection</code> * @throws BadLocationException if accessing the document failed * @since 3.5 */ public static IRegion[] getCoveredRanges(ITextViewer viewer, ITextSelection selection) throws BadLocationException { return new SelectionProcessor(viewer).getRanges(selection); }
/** * Returns the text regions covered by the given selection in the given viewer. * * @param viewer the viewer * @param selection the selection * @return the text regions corresponding to <code>selection</code> * @throws BadLocationException if accessing the document failed * @since 3.5 */ public static IRegion[] getCoveredRanges(ITextViewer viewer, ITextSelection selection) throws BadLocationException { return new SelectionProcessor(viewer).getRanges(selection); }
/** * Deletes the selection and sets the caret before the deleted range. * * @param selection the selection to delete * @param textWidget the widget * @throws BadLocationException on document access failure * @since 3.5 */ private void deleteSelection(ITextSelection selection, StyledText textWidget) throws BadLocationException { new SelectionProcessor(this).doDelete(selection); }
/** * Deletes the selection and sets the caret before the deleted range. * * @param selection the selection to delete * @param textWidget the widget * @throws BadLocationException on document access failure * @since 3.5 */ private void deleteSelection(ITextSelection selection, StyledText textWidget) throws BadLocationException { new SelectionProcessor(this).doDelete(selection); }
/** * Returns <code>true</code> if the text covered by <code>selection</code> does not contain any * characters in the given viewer. Note the difference to {@link ITextSelection#isEmpty()}, * which returns <code>true</code> only for invalid selections. * * @param viewer the viewer * @param selection the selection * @return <code>true</code> if <code>selection</code> does not contain any text, * <code>false</code> otherwise * @throws BadLocationException if accessing the document failed * @since 3.5 */ public static boolean isEmpty(ITextViewer viewer, ITextSelection selection) throws BadLocationException { return new SelectionProcessor(viewer).isEmpty(selection); }
/** * Returns <code>true</code> if the text covered by <code>selection</code> does not contain any * characters in the given viewer. Note the difference to {@link ITextSelection#isEmpty()}, * which returns <code>true</code> only for invalid selections. * * @param viewer the viewer * @param selection the selection * @return <code>true</code> if <code>selection</code> does not contain any text, * <code>false</code> otherwise * @throws BadLocationException if accessing the document failed * @since 3.5 */ public static boolean isEmpty(ITextViewer viewer, ITextSelection selection) throws BadLocationException { return new SelectionProcessor(viewer).isEmpty(selection); }
@Override public void run() { try { new SelectionProcessor(TextViewer.this).doDelete(getSelection()); } catch (BadLocationException e) { if (TRACE_ERRORS) System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.delete")); //$NON-NLS-1$ } } });
@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 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 public void run() { SelectionProcessor processor= new SelectionProcessor(TextViewer.this); try { /* Use the selection instead of the event's coordinates. Is this dangerous? */ ISelection selection= getSelection(); int length= e.text.length(); if (length == 0 && e.character == '\0') { // backspace in StyledText block selection mode... TextEdit edit= processor.backspace(selection); edit.apply(fDocument, TextEdit.UPDATE_REGIONS); ISelection empty= processor.makeEmpty(selection, true); setSelection(empty); } else { int lines= processor.getCoveredLines(selection); String delim= fDocument.getLegalLineDelimiters()[0]; StringBuffer text= new StringBuffer(lines * length + (lines - 1) * delim.length()); text.append(e.text); for (int i= 0; i < lines - 1; i++) { text.append(delim); text.append(e.text); } processor.doReplace(selection, text.toString()); } } catch (BadLocationException x) { if (TRACE_ERRORS) System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.verifyText")); //$NON-NLS-1$ } } });
@Override public IRegion[] getRegions() { IDocument document= getDocument(); if (document != null) { try { return new SelectionProcessor(document, fTabWidth).getRanges(this); } catch (BadLocationException x) { // default to single region behavior } } return new IRegion[] {new Region(getOffset(), getLength())}; } }
@Override public IRegion[] getRegions() { IDocument document= getDocument(); if (document != null) { try { return new SelectionProcessor(document, fTabWidth).getRanges(this); } catch (BadLocationException x) { // default to single region behavior } } return new IRegion[] {new Region(getOffset(), getLength())}; } }
if (isFirst) { wrapCompoundChange(() -> { SelectionProcessor processor= new SelectionProcessor(TextViewer.this); try {
@Override public void run() { SelectionProcessor processor= new SelectionProcessor(TextViewer.this); Clipboard clipboard= new Clipboard(getDisplay()); try {
} else { wrapCompoundChange(() -> { SelectionProcessor processor= new SelectionProcessor(TextViewer.this); Clipboard clipboard= new Clipboard(getDisplay()); try {
private void delete() { if (!fTextWidget.getBlockSelection()) { fTextWidget.invokeAction(ST.DELETE_NEXT); } else { wrapCompoundChange(() -> { try { new SelectionProcessor(TextViewer.this).doDelete(getSelection()); } catch (BadLocationException e) { if (TRACE_ERRORS) System.out.println(JFaceTextMessages.getString("TextViewer.error.bad_location.delete")); //$NON-NLS-1$ } }); } Point selection= fTextWidget.getSelectionRange(); fireSelectionChanged(selection.x, selection.y); }