当前位置: 首页>>代码示例>>Java>>正文


Java DocumentEvent.getDocument方法代码示例

本文整理汇总了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();
	}
}
 
开发者ID:eclipse,项目名称:tm4e,代码行数:26,代码来源:DocumentLineList.java

示例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);
            }
        });
    }
}
 
开发者ID:RepreZen,项目名称:KaiZen-OpenAPI-Editor,代码行数:18,代码来源:JsonEditor.java

示例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;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:27,代码来源:KillRing.java

示例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;
	}
}
 
开发者ID:ctreude,项目名称:nlp2code,代码行数:10,代码来源:CycleDocListener.java

示例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;
			}
		}
	}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:41,代码来源:SadlConsoleListener.java

示例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();
    }
}
 
开发者ID:anb0s,项目名称:LogViewer,代码行数:47,代码来源:LogViewer.java

示例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;
			}
		}
	}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:43,代码来源:SadlConsoleListener.java


注:本文中的org.eclipse.jface.text.DocumentEvent.getDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。