public ISelection getSelection() { return txtViewer.getSelection(); }
@Override public ISelection getSelection() { if (fViewerInFocus != null) { return fViewerInFocus.getSelection(); } return TextSelection.emptySelection(); }
public void focusGained(FocusEvent e) { if (selectionChangedListener != null) { selectionChangedListener.selectionChanged(new SelectionChangedEvent(viewer, viewer.getSelection())); } activateHandlers(viewer, spellCheck); }
@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$ } } });
public void historyNotification(OperationHistoryEvent event) { if (viewer != null && selectionChangedListener != null && Display.getCurrent() != null) { selectionChangedListener.selectionChanged(new SelectionChangedEvent(viewer, viewer.getSelection())); } }
@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$ } } });
try { ISelection selection= getSelection(); int length= e.text.length(); if (length == 0 && e.character == '\0') {
ISelection selection= getSelection(); TextTransfer plainTextTransfer = TextTransfer.getInstance(); String contents= (String)clipboard.getContents(plainTextTransfer, DND.CLIPBOARD);
/** * Opens the hyperlink at the caret location or opens a chooser * if more than one hyperlink is available. * * @return <code>true</code> if at least one hyperlink has been found at the caret location, <code>false</code> otherwise * @see #OPEN_HYPERLINK * @since 3.6 */ public boolean openHyperlink() { fActiveHyperlinkStateMask= fHyperlinkStateMask; if (fHyperlinkPresenter instanceof IHyperlinkPresenterExtension) { if (!((IHyperlinkPresenterExtension)fHyperlinkPresenter).canHideHyperlinks()) return false; } ITextSelection sel= (ITextSelection)((TextViewer)fTextViewer).getSelection(); int offset= sel.getOffset(); if (offset == -1) return false; IRegion region= new Region(offset, 0); fActiveHyperlinks= findHyperlinks(region); return showHyperlinks(true); } }
/** * Opens the hyperlink at the caret location or opens a chooser * if more than one hyperlink is available. * * @return <code>true</code> if at least one hyperlink has been found at the caret location, <code>false</code> otherwise * @see #OPEN_HYPERLINK * @since 3.6 */ public boolean openHyperlink() { fActiveHyperlinkStateMask= fHyperlinkStateMask; if (fHyperlinkPresenter instanceof IHyperlinkPresenterExtension) { if (!((IHyperlinkPresenterExtension)fHyperlinkPresenter).canHideHyperlinks()) return false; } ITextSelection sel= (ITextSelection)((TextViewer)fTextViewer).getSelection(); int offset= sel.getOffset(); if (offset == -1) return false; IRegion region= new Region(offset, 0); fActiveHyperlinks= findHyperlinks(region); return showHyperlinks(true); } }
ISelection selection= getSelection(); TextTransfer plainTextTransfer= TextTransfer.getInstance(); String contents= (String) clipboard.getContents(plainTextTransfer, DND.CLIPBOARD);
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); }
fUpdaterDocument.addPositionUpdater(fUpdater); ISelection selection= TextViewer.this.getSelection(); if (selection instanceof IBlockTextSelection) { IBlockTextSelection bts= (IBlockTextSelection) selection;
fUpdaterDocument.addPositionUpdater(fUpdater); ISelection selection= TextViewer.this.getSelection(); if (selection instanceof IBlockTextSelection) { IBlockTextSelection bts= (IBlockTextSelection) selection;
DocumentRewriteSession rewriteSession= null; try { ITextSelection selection= (ITextSelection) getSelection(); IRegion block= getTextBlockFromSelection(selection); ITypedRegion[] regions= TextUtilities.computePartitioning(d, getDocumentPartitioning(), block.getOffset(), block.getLength(), false);
DocumentRewriteSession rewriteSession= null; try { ITextSelection selection= (ITextSelection) getSelection(); IRegion block= getTextBlockFromSelection(selection); ITypedRegion[] regions= TextUtilities.computePartitioning(d, getDocumentPartitioning(), block.getOffset(), block.getLength(), false);