本文整理汇总了Java中org.eclipse.jface.text.DocumentEvent.getDocument方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentEvent.getDocument方法的具体用法?Java DocumentEvent.getDocument怎么用?Java DocumentEvent.getDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.DocumentEvent
的用法示例。
在下文中一共展示了DocumentEvent.getDocument方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: documentChanged
import org.eclipse.jface.text.DocumentEvent; //导入方法依赖的package包/类
@Override
public void documentChanged(DocumentEvent event) {
IDocument document = event.getDocument();
try {
int startLine = DocumentHelper.getStartLine(event);
if (!DocumentHelper.isRemove(event)) {
if (DocumentLineList.this.getSize() != DocumentHelper.getNumberOfLines(document)) {
int endLine = DocumentHelper.getEndLine(event, false);
// Insert new lines
for (int i = startLine; i < endLine; i++) {
DocumentLineList.this.addLine(i + 1);
}
} else {
// Update line
DocumentLineList.this.updateLine(startLine);
}
} else {
// Update line
DocumentLineList.this.updateLine(startLine);
}
invalidateLine(startLine);
} catch (BadLocationException e) {
e.printStackTrace();
}
}
示例2: documentChanged
import org.eclipse.jface.text.DocumentEvent; //导入方法依赖的package包/类
@Override
public void documentChanged(DocumentEvent event) {
if (event.getDocument() instanceof JsonDocument) {
final JsonDocument document = (JsonDocument) event.getDocument();
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
document.onChange();
if (contentOutline != null) {
contentOutline.setInput(getEditorInput());
}
runValidate(false);
}
});
}
}
示例3: isSelectionReplace
import org.eclipse.jface.text.DocumentEvent; //导入方法依赖的package包/类
/**
* 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;
}
示例4: documentChanged
import org.eclipse.jface.text.DocumentEvent; //导入方法依赖的package包/类
@Override
public void documentChanged(DocumentEvent event) {
String text = event.getText();
if (!InputHandler.previous_search.contains(text)) {
IDocument doc = event.getDocument();
doc.removeDocumentListener(InputHandler.doclistener);
CycleAnswersHandler.changed_doc = true;
}
}
示例5: documentChanged
import org.eclipse.jface.text.DocumentEvent; //导入方法依赖的package包/类
@Override
public void documentChanged(DocumentEvent event) {
if (hyperlinks != null) {
try {
IDocument doc = event.getDocument();
Iterator<String> itr = hyperlinks.keySet().iterator();
int lastOffset = startingOffset;
while (itr.hasNext()) {
String txt = itr.next();
FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(doc);
IRegion region = frda.find(lastOffset, txt, true, true, false, false);
if (region != null) {
HyperlinkInfo info = hyperlinks.get(txt);
int linkOffset = region.getOffset();
int linkLength = region.getLength();
if (info.getOffsetInLink() > 0) {
linkOffset += info.getOffsetInLink();
linkLength -= info.getOffsetInLink();
}
if (info.getLinkLength() > 0) {
linkLength = info.getLinkLength();
}
if (linkOffset >= 0 && linkLength > 0 && info.getFileOffset() >= 0 && info.getFileLength() > 0) {
FileLink fileLink = new FileLink(info.getFile(), null, info.getFileOffset(), info.getFileLength(), info.getFileLineNumber());
mc.addHyperlink(fileLink, linkOffset, linkLength);
}
// if (linkOffset > lastOffset) {
// lastOffset = linkOffset;
// }
}
}
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
hyperlinks = null;
}
}
}
示例6: documentChanged
import org.eclipse.jface.text.DocumentEvent; //导入方法依赖的package包/类
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 = (LogFileTab)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();
}
}
示例7: documentChanged
import org.eclipse.jface.text.DocumentEvent; //导入方法依赖的package包/类
@Override
public void documentChanged(DocumentEvent event) {
if (hyperlinks != null) {
try {
IDocument doc = event.getDocument();
Iterator<String> itr = hyperlinks.keySet().iterator();
int lastOffset = startingOffset;
while (itr.hasNext()) {
String txt = itr.next();
FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(doc);
IRegion region = frda.find(lastOffset, txt, true, true, false, false);
if (region != null) {
HyperlinkInfo info = hyperlinks.get(txt);
int linkOffset = region.getOffset();
int linkLength = region.getLength();
if (info.getOffsetInLink() > 0) {
linkOffset += info.getOffsetInLink();
linkLength -= info.getOffsetInLink();
}
if (info.getLinkLength() > 0) {
linkLength = info.getLinkLength();
}
if (linkOffset >= 0 && linkLength > 0 && info.getFileOffset() >= 0 && info.getFileLength() > 0) {
IPath path = new Path(info.getLinkResource().toString());
IFile file = null; //project.getFile(path);
// FileLink fileLink = new FileLink(file, null, info.getFileOffset(), info.getFileLength(), info.getFileLineNumber());
// mc.addHyperlink(fileLink, linkOffset, linkLength);
}
// if (linkOffset > lastOffset) {
// lastOffset = linkOffset;
// }
}
}
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally {
hyperlinks = null;
}
}
}