下面列出了org.eclipse.jface.text.DocumentEvent#getDocument ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void documentChanged(DocumentEvent event) {
IDocument document = event.getDocument();
try {
int startLine = DocumentHelper.getStartLine(event);
if (!DocumentHelper.isRemove(event)) {
int endLine = DocumentHelper.getEndLine(event, false);
// Insert new lines
for (int i = startLine; i < endLine; i++) {
DocumentLineList.this.addLine(i + 1);
}
if (startLine == endLine) {
DocumentLineList.this.updateLine(startLine);
}
} else {
// Update line
DocumentLineList.this.updateLine(startLine);
}
invalidateLine(startLine);
} catch (BadLocationException e) {
TMUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TMUIPlugin.PLUGIN_ID, e.getMessage(), e));
}
}
@Override
public void documentChanged(DocumentEvent event) {
if (event.getDocument() instanceof JsonDocument) {
final JsonDocument document = (JsonDocument) event.getDocument();
document.onChange();
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
if (contentOutline != null) {
// depends on the results of document.onChange()
contentOutline.setInput(getEditorInput());
}
}
});
// depends on the results of document.onChange()
runValidate(false);
}
}
/**
* Determine if a selection is being replaced by non-emacs+ behavior (or YANK), and save the
* replaced content in the kill ring. This captures the Eclipse (but not emacs) behavior where
* typing/pasting into a selection replaces the old with the new, so it is appropriate to save
* the old text to the kill ring.
*
* @param event the DocumentEvent containing the IDocument, offset, and length
* @return true if the non-zero length region matches the current selection in the editor
*/
private boolean isSelectionReplace(DocumentEvent event) {
int len = event.getLength();
// ignore plain insertion or any emacs+ (except YANK) command invocation
if (selectionReplace && len > 0 && shouldSave()) {
ITextEditor editor = EmacsPlusUtils.getCurrentEditor();
// otherwise, if we can get the selection, see if it matches the replace region
if (editor != null && editor.getDocumentProvider().getDocument(editor.getEditorInput()) == event.getDocument()) {
ISelection isel = editor.getSelectionProvider().getSelection();
if (isel instanceof ITextSelection) {
ITextSelection selection = (ITextSelection)isel;
boolean result = selection.getOffset() == event.getOffset() && selection.getLength() == len;
return result;
}
}
}
return false;
}
@Override
public void documentChanged(DocumentEvent event) {
final IDocument document = event.getDocument();
if (shouldBuild()) {
doBuild(document, allGroovyPartitions(document));
}
}
public void documentChanged(DocumentEvent event) {
if(!isAvailable()) {
return;
}
LogFileTab tab = getSelectedTab();
// activate / show the view and tab
if (viewer.isShowWhenUpdated()) {
//LogViewer view = null;
try {
//view = (LogViewer)
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("de.anbos.eclipse.logviewer.plugin.LogViewer");
} catch (PartInitException e) {
e.printStackTrace();
}
// change selection
if (event.getDocument() != tab.getDocument()) {
// show active document
Iterator<String> keyIterator = logTab.keySet().iterator();
while(keyIterator.hasNext()) {
Object key = keyIterator.next();
LogFileTab newTab = logTab.get(key);
if (event.getDocument() == newTab.getDocument()) {
showDocument(newTab.getDocument(),null,0,true);
tabfolder.setSelection(new TabItem[] {newTab.getItem()});
// send event to refresh encoding
Event newEvent = new Event();
newEvent.item = newTab.getItem();
tabfolder.notifyListeners(SWT.Selection, newEvent);
break;
}
}
}
}
if(logTab != null && event.getDocument() == tab.getDocument() && viewer.getDocument() != null) {
viewer.refresh();
viewer.showBottomOfFile();
}
if (stopAfterChange) {
stopAfterChange = false;
stopTail();
}
}