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


Java ITextEditor.getDocumentProvider方法代码示例

本文整理汇总了Java中org.eclipse.ui.texteditor.ITextEditor.getDocumentProvider方法的典型用法代码示例。如果您正苦于以下问题:Java ITextEditor.getDocumentProvider方法的具体用法?Java ITextEditor.getDocumentProvider怎么用?Java ITextEditor.getDocumentProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.ui.texteditor.ITextEditor的用法示例。


在下文中一共展示了ITextEditor.getDocumentProvider方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: attach

import org.eclipse.ui.texteditor.ITextEditor; //导入方法依赖的package包/类
/**
 * Attaches a coverage annotation model for the given editor if the editor can
 * be annotated. Does nothing if the model is already attached.
 *
 * @param editor
 *          Editor to attach a annotation model to
 */
public static void attach(ITextEditor editor) {
  IDocumentProvider provider = editor.getDocumentProvider();
  // there may be text editors without document providers (SF #1725100)
  if (provider == null)
    return;
  IAnnotationModel model = provider.getAnnotationModel(editor
      .getEditorInput());
  if (!(model instanceof IAnnotationModelExtension))
    return;
  IAnnotationModelExtension modelex = (IAnnotationModelExtension) model;

  IDocument document = provider.getDocument(editor.getEditorInput());

  CoverageAnnotationModel coveragemodel = (CoverageAnnotationModel) modelex
      .getAnnotationModel(KEY);
  if (coveragemodel == null) {
    coveragemodel = new CoverageAnnotationModel(editor, document);
    modelex.addAnnotationModel(KEY, coveragemodel);
  }
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:28,代码来源:CoverageAnnotationModel.java

示例2: execute

import org.eclipse.ui.texteditor.ITextEditor; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
	IFileEditorInput input = (IFileEditorInput) part.getEditorInput();
	IFile file = input.getFile();
	if (part instanceof ITextEditor) {
		final ITextEditor editor = (ITextEditor) part;
		IVerticalRulerInfo ruleInfo = editor.getAdapter(IVerticalRulerInfo.class);
		IDocumentProvider provider = editor.getDocumentProvider();
		IDocument document = provider.getDocument(editor.getEditorInput());
		int lineNumber = ruleInfo.getLineOfLastMouseButtonActivity();
		String className = file.getName().substring(0, file.getName().lastIndexOf('.'));
		HashMap<VFUnit, VFMethod> resultantUnit = getSelectedUnit(className, document, lineNumber);
		List<VFNode> unit = new ArrayList<>();
		if (resultantUnit.size() > 0) {
			if (event.getCommand().getId().equals("JavaHandler.NavigateToJimple")) {
				NavigationHandler handler = new NavigationHandler();
				handler.highlightJimpleSource(new ArrayList<>(resultantUnit.keySet()));
			} else {
				for (VFUnit vfUnit : resultantUnit.keySet()) {
					unit.add(new VFNode(vfUnit, 0));
				}
				try {
					ServiceUtil.getService(DataModel.class).filterGraph(unit, true, true, null);

				} catch (Exception e) {
					e.printStackTrace();
				}
			}

		}

		// call graph highlighting code here
	} else {
		logger.error("Editor not a  Text Editor");
	}
	return null;
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:39,代码来源:JavaToCFGHandler.java

示例3: detach

import org.eclipse.ui.texteditor.ITextEditor; //导入方法依赖的package包/类
/**
 * Detaches the coverage annotation model from the given editor. If the editor
 * does not have a model attached, this method does nothing.
 *
 * @param editor
 *          Editor to detach the annotation model from
 */
public static void detach(ITextEditor editor) {
  IDocumentProvider provider = editor.getDocumentProvider();
  // there may be text editors without document providers (SF #1725100)
  if (provider == null)
    return;
  IAnnotationModel model = provider.getAnnotationModel(editor
      .getEditorInput());
  if (!(model instanceof IAnnotationModelExtension))
    return;
  IAnnotationModelExtension modelex = (IAnnotationModelExtension) model;
  modelex.removeAnnotationModel(KEY);
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:20,代码来源:CoverageAnnotationModel.java

示例4: gotoLine

import org.eclipse.ui.texteditor.ITextEditor; //导入方法依赖的package包/类
public static void gotoLine(ITextEditor textEditor, int line) throws BadLocationException {
	IDocumentProvider provider = textEditor.getDocumentProvider();
	IDocument document = provider.getDocument(textEditor.getEditorInput());

	int start = document.getLineOffset(line);
	textEditor.selectAndReveal(start, 0);

	IWorkbenchPage page = textEditor.getSite().getPage();
	page.activate(textEditor);

}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:12,代码来源:TextEditorUtils.java

示例5: getOffsetOfFirstNonWhitespaceCharAtLine

import org.eclipse.ui.texteditor.ITextEditor; //导入方法依赖的package包/类
public static int getOffsetOfFirstNonWhitespaceCharAtLine(ITextEditor textEditor, int lineNumber)
		throws BadLocationException {
	IDocumentProvider provider = textEditor.getDocumentProvider();
	IDocument document = provider.getDocument(textEditor.getEditorInput());
	IRegion region = document.getLineInformation(lineNumber);
	int offset = region.getOffset();
	int lastOffset = offset + region.getLength() - 1;
	while ((offset <= lastOffset) && (document.getChar(offset) <= ' ')) {
		offset++;
	}
	return offset;
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:13,代码来源:TextEditorUtils.java

示例6: getLineContent

import org.eclipse.ui.texteditor.ITextEditor; //导入方法依赖的package包/类
public static String getLineContent(ITextEditor textEditor, int lineNumber) {
	try {
		IDocumentProvider provider = textEditor.getDocumentProvider();
		IDocument document = provider.getDocument(textEditor.getEditorInput());
		IRegion region = document.getLineInformation(lineNumber);
		return document.get(region.getOffset(), region.getLength());
	} catch (BadLocationException e) {
		return null;
	}
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:11,代码来源:TextEditorUtils.java

示例7: getAnnotationModel

import org.eclipse.ui.texteditor.ITextEditor; //导入方法依赖的package包/类
private AbstractMarkerAnnotationModel getAnnotationModel(ITextEditor editor) {
	IDocumentProvider provider = editor.getDocumentProvider();
	IAnnotationModel model = provider.getAnnotationModel(editor.getEditorInput());
	if (model instanceof AbstractMarkerAnnotationModel)
		return (AbstractMarkerAnnotationModel) model;
	return null;
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:8,代码来源:GetLinkedBookmarksOperation.java

示例8: gotoLine

import org.eclipse.ui.texteditor.ITextEditor; //导入方法依赖的package包/类
public static void gotoLine(ITextEditor textEditor, int line)
		throws BadLocationException {
	IDocumentProvider provider = textEditor.getDocumentProvider();
	IDocument document = provider.getDocument(textEditor.getEditorInput());

	int start = document.getLineOffset(line);
	textEditor.selectAndReveal(start, 0);

	IWorkbenchPage page = textEditor.getSite().getPage();
	page.activate(textEditor);

}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:13,代码来源:JavaEditorUtils.java

示例9: getCurrentSelection

import org.eclipse.ui.texteditor.ITextEditor; //导入方法依赖的package包/类
private static String getCurrentSelection() {
	IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
	if (part instanceof ITextEditor) {
		final ITextEditor editor = (ITextEditor) part;
		IDocumentProvider prov = editor.getDocumentProvider();
		IDocument doc = prov.getDocument(editor.getEditorInput());
		ISelection sel = editor.getSelectionProvider().getSelection();
		if (sel instanceof TextSelection) {
			ITextSelection textSel = (ITextSelection) sel;
			return textSel.getText();
		}
	}
	return null;
}
 
开发者ID:aroog,项目名称:code,代码行数:15,代码来源:TraceToCodeUIAction.java

示例10: showAnnotations

import org.eclipse.ui.texteditor.ITextEditor; //导入方法依赖的package包/类
/**
 * Show the annotation view.
 * @param svnFile
 * @param svnAnnotateBlocks
 * @param contents
 * @param useHistoryView
 * @throws PartInitException
 */
public void showAnnotations(ISVNRemoteFile svnFile, Collection svnAnnotateBlocks, InputStream contents, boolean useHistoryView) throws PartInitException {

	// Disconnect from old annotation editor
	disconnect();
	
	// Remove old viewer
	Control[] oldChildren = top.getChildren();
	if (oldChildren != null) {
		for (int i = 0; i < oldChildren.length; i++) {
			oldChildren[i].dispose();
		}
	}

	viewer = new ListViewer(top, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
	viewer.setContentProvider(new ArrayContentProvider());
	viewer.setLabelProvider(new LabelProvider());
	viewer.addSelectionChangedListener(this);
	viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));

	PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), IHelpContextIds.ANNOTATIONS_VIEW);

	top.layout();
	
	this.svnFile = svnFile;
	this.contents = contents;
	this.svnAnnotateBlocks = svnAnnotateBlocks;
	page = SVNUIPlugin.getActivePage();
	viewer.setInput(svnAnnotateBlocks);
	editor = (ITextEditor) openEditor();
	IDocumentProvider provider = editor.getDocumentProvider();
	document = provider.getDocument(editor.getEditorInput());

	setPartName(Policy.bind("SVNAnnotateView.showFileAnnotation", new Object[] {svnFile.getName()})); //$NON-NLS-1$
	setTitleToolTip(svnFile.getName());
	
	if (!useHistoryView) {
		return;
	}

	// Get hook to the HistoryView
	historyView = (IHistoryView)page.showView(ISVNUIConstants.HISTORY_VIEW_ID);
	if (historyView != null) {
		historyView.showHistoryFor(svnFile);
	}
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:54,代码来源:AnnotateView.java

示例11: execute

import org.eclipse.ui.texteditor.ITextEditor; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent arg0) {
	// After the document has been edited (after cycling through snippets), disable cycling functionality.
	if (changed_doc == true) {
		changed_doc = false;
		InputHandler.previous_length = 0;
		InputHandler.previous_offset = 0;
		return null;
	}
	try {
		// Get the current active editor.
	    IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
	    
	    // If the current active editor is a text editor (i.e. not any other workbench component)
	    if ( part instanceof ITextEditor ) {
	    	// Use text editor context to locate the document of the editor and get the input stream to that editor.
	        ITextEditor editor = (ITextEditor)part;
	        IDocumentProvider prov = editor.getDocumentProvider();
	        IDocument doc = prov.getDocument( editor.getEditorInput() );
	        int offset = InputHandler.previous_offset;
	        int length = InputHandler.previous_length;
	        if (offset + length > doc.getLength()) return null;
	        String text = doc.get(offset, length);
			if (InputHandler.previous_search.contains(text)) {
	        	int index = InputHandler.previous_search.indexOf(text);
	        	index++;
	        	if (index >= InputHandler.previous_search.size() || index < 0) index = 0;
	        	// Replace old snippet with new snippet.
	        	doc.replace(offset, length, InputHandler.previous_search.get(index));
	            InputHandler.previous_length = InputHandler.previous_search.get(index).length();
	            previous_index = index;
	            if (InputHandler.previous_offset + InputHandler.previous_length > doc.getLength()) return null;
	            editor.selectAndReveal(InputHandler.previous_offset + InputHandler.previous_length, 0);
	            return null;
	        }
	    }
	} catch (Exception ex) {
		ex.printStackTrace();
	}
	return null;
}
 
开发者ID:ctreude,项目名称:nlp2code,代码行数:42,代码来源:CycleAnswersHandler.java

示例12: execute

import org.eclipse.ui.texteditor.ITextEditor; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	ITextEditor current_editor = (ITextEditor)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
	IDocument current_doc = current_editor.getDocumentProvider().getDocument(current_editor.getEditorInput());
	if (!InputHandler.documents.contains(current_doc)) {
		current_doc.addDocumentListener(InputHandler.qdl);
	}

	// Get the current active editor.
    IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    
    // If the current active editor is a text editor (i.e. not any other workbench component)
    if ( part instanceof ITextEditor ) {
    	// Use text editor context to locate the document of the editor and get the input stream to that editor.
        ITextEditor editor = (ITextEditor)part;
        IDocumentProvider prov = editor.getDocumentProvider();
        IDocument doc = prov.getDocument( editor.getEditorInput() );
        
        // Get the current selection to query on. 
        ISelection sel = editor.getSelectionProvider().getSelection();
        
        if (sel instanceof ITextSelection) {
	        ITextSelection textSelection = (ITextSelection)sel;
	        try {
	        	// Get the line number we are currently on.
	        	if (textSelection.equals(null)) return null;
	        	int offset = textSelection.getOffset();
	        	// Get the string on the current line and use that as the query line to be auto-completed.
	        	if (offset > doc.getLength() || offset < 0) return null;
				String text = doc.get(doc.getLineOffset(doc.getLineOfOffset(offset)), doc.getLineLength(doc.getLineOfOffset(offset)));
				if (text.equals("") || text.equals(null)) return null;
				boolean eol = false;
				if (text.endsWith("\n")) eol = true;
				String whitespace_before = text.substring(0, text.indexOf(text.trim()));
	            text = text.trim();
	            
	            // Get the vector of URLS from the getPosts query.		            
	            Vector<String> results = Searcher.getThreads(text);
	            if (results.size() == 0) return null;
	            Vector<String> url = new Vector<String>();
	            for (int i=0; i<results.size(); i++) {
       		    	url.add(results.get(i));
       		    }
	            
	            // Get the accepted answer code snippet.
	            Vector<String> code = Searcher.getCodeSnippets(url);
	            if (code.size() == 0) return null;
	            Vector<String> fixed_code = fixSpacing(code,whitespace_before);
       		    previous_search.clear();
       		    previous_search = fixed_code;
       		    previous_query = text;
       		    
       		    // Find line length and offset to replace.
       		    int line_num = doc.getLineOfOffset(offset);
       		    int line_length = 0;
       			int line_offset = 0;
       			try {
       				line_length = doc.getLineLength(line_num);
       				line_offset = doc.getLineOffset(line_num);
       				if (eol) line_length -= 1;
       			} catch (BadLocationException e1) {
       				e1.printStackTrace();
       			}
	            // Replace the code snippet back into the document.
	            doc.replace(line_offset, line_length, fixed_code.get(0));
	            previous_offset = line_offset;
	            previous_length = fixed_code.get(0).length();
	            
	            //Move cursor to the end of the inserted snippet.
	            editor.selectAndReveal(previous_offset + previous_length, 0);
	            doc.addDocumentListener(InputHandler.doclistener);
	        } catch (BadLocationException e) {
				System.out.println("Error with getting input query.");
				e.printStackTrace();
				return null;
			}
	    }
    }
	return null;
}
 
开发者ID:ctreude,项目名称:nlp2code,代码行数:81,代码来源:InputHandler.java

示例13: getDocument

import org.eclipse.ui.texteditor.ITextEditor; //导入方法依赖的package包/类
private IDocument getDocument(ITextEditor editor) {
	IDocumentProvider provider = editor.getDocumentProvider();
	return provider.getDocument(editor.getEditorInput());
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:5,代码来源:GetLinkedBookmarksOperation.java

示例14: getOffset

import org.eclipse.ui.texteditor.ITextEditor; //导入方法依赖的package包/类
private int getOffset(ITextEditor editor, int lineNumber) throws BadLocationException {
	IDocumentProvider provider = editor.getDocumentProvider();
	IDocument document = provider.getDocument(editor.getEditorInput());
	return document.getLineOffset(lineNumber);
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:6,代码来源:GetLinkedBookmarksOperationTest.java


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