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


Java IDocumentProvider.getDocument方法代码示例

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


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

示例1: moveTo

import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
public void moveTo(String handlerName) {
	
	IEditorPart editor =  PlatformUI
								.getWorkbench()
								.getActiveWorkbenchWindow()
								.getActivePage()
								.getActiveEditor();
	
	if (editor instanceof JscriptTransactionEditor) {
		JscriptTransactionEditor myEditor = (JscriptTransactionEditor) editor;
		MyJScriptEditor jsEditor = myEditor.getEditor();
		IDocumentProvider provider = jsEditor.getDocumentProvider();
		IDocument document = provider.getDocument(editor.getEditorInput());
		String content = document.get();
		int index = content.indexOf(handlerName);
		jsEditor.selectAndReveal(index, handlerName.length());
	}
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:19,代码来源:HandlersDeclarationTreeObject.java

示例2: attach

import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的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

示例3: initializeSourceViewer

import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
private void initializeSourceViewer(final IEditorInput input) {

        final IDocumentProvider documentProvider = getDocumentProvider();
        final IAnnotationModel model = documentProvider.getAnnotationModel(input);
        final IDocument document = documentProvider.getDocument(input);

        if (document != null) {
            fSourceViewer.setDocument(document, model);
            fSourceViewer.setEditable(isEditable());
            fSourceViewer.showAnnotations(model != null);
        }

        if (fElementStateListener instanceof IElementStateListenerExtension) {
            boolean isStateValidated = false;
            if (documentProvider instanceof IDocumentProviderExtension)
                isStateValidated = ((IDocumentProviderExtension) documentProvider).isStateValidated(input);

            final IElementStateListenerExtension extension = (IElementStateListenerExtension) fElementStateListener;
            extension.elementStateValidationChanged(input, isStateValidated);
        }

    }
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:23,代码来源:TestEditor.java

示例4: initializeSourceViewer

import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
private void initializeSourceViewer(IEditorInput input) {

		IDocumentProvider documentProvider = getDocumentProvider();
		IAnnotationModel model = documentProvider.getAnnotationModel(input);
		IDocument document = documentProvider.getDocument(input);

		if (document != null) {
			fSourceViewer.setDocument(document, model);
			fSourceViewer.setEditable(isEditable());
			fSourceViewer.showAnnotations(model != null);
		}

		if (fElementStateListener instanceof IElementStateListenerExtension) {
			boolean isStateValidated = false;
			if (documentProvider instanceof IDocumentProviderExtension)
				isStateValidated = ((IDocumentProviderExtension) documentProvider)
						.isStateValidated(input);

			IElementStateListenerExtension extension = (IElementStateListenerExtension) fElementStateListener;
			extension.elementStateValidationChanged(input, isStateValidated);
		}

	}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:24,代码来源:TestEditor.java

示例5: getPosition

import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
public static Position getPosition(IFile file, TextSpan textSpan) throws BadLocationException {
	ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
	ITextFileBuffer buffer = bufferManager.getTextFileBuffer(file.getLocation(), LocationKind.IFILE);
	if (buffer != null) {
		return getPosition(buffer.getDocument(), textSpan);
	}
	IDocumentProvider provider = new TextFileDocumentProvider();
	try {
		provider.connect(file);
		IDocument document = provider.getDocument(file);
		if (document != null) {
			return getPosition(document, textSpan);
		}
	} catch (CoreException e) {
	} finally {
		provider.disconnect(file);
	}
	return null;
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:20,代码来源:EditorUtils.java

示例6: model2xml

import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
protected String model2xml() {
	try {
		if (model != null) {
			String xml = doModel2xml();
			IDocumentProvider dp = xmlEditor.getDocumentProvider();
			IDocument doc = dp.getDocument(xmlEditor.getEditorInput());
			if (xml != null && !Arrays.equals(doc.get().getBytes(), xml.getBytes()))
				doc.set(xml);
			xmlFresh = true;
			return xml;
		}
	} catch (final Exception e) {
		UIUtils.showError(e);
	}
	return null;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:17,代码来源:AMultiEditor.java

示例7: xml2model

import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
/**
 * Xml2model.
 * 
 * @throws JRException
 *           the jR exception
 */
private void xml2model() throws Exception {
	InputStream in = null;
	try {
		IDocumentProvider dp = xmlEditor.getDocumentProvider();
		IDocument doc = dp.getDocument(xmlEditor.getEditorInput());
		in = new ByteArrayInputStream(doc.get().getBytes("UTF-8"));

		JasperDesign jd = new JRXmlLoader(jrContext, JasperReportsConfiguration.getJRXMLDigester()).loadXML(in);
		jrContext.setJasperDesign(jd);
		JaspersoftStudioPlugin.getExtensionManager().onLoad(jd, this);
		setModel(ReportFactory.createReport(jrContext));
	} finally {
		FileUtils.closeStream(in);
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:22,代码来源:JrxmlEditor.java

示例8: validate

import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
@Override
public ValidationResult validate(IResource resource, int kind,
		ValidationState state, IProgressMonitor monitor) {
	IDocument document = null;
	// get document
	try {
		final IDocumentProvider provider = new TextFileDocumentProvider();
		provider.connect(resource);
		document = provider.getDocument(resource);
		provider.disconnect(resource);
	} catch (CoreException e) {
		e.printStackTrace();
	}

	ValidationResult result = new ValidationResult();
	if (document != null) {
		// validate definitions names
		List<ElementRegion> definitionNameRegions = tilesXmlParser
				.getDefinitionNameRegions(document);
		validateRegions(resource, document, result, definitionNameRegions,
				DUP_DEFINITION_MESSAGE_TEXT, IMarker.SEVERITY_WARNING);
	}

	return result;
}
 
开发者ID:aleksandr-m,项目名称:strutsclipse,代码行数:26,代码来源:TilesXmlValidator.java

示例9: getScript

import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
public String getScript( )
{
	IDocumentProvider provider = getDocumentProvider( );
	String script = ""; //$NON-NLS-1$

	if ( provider != null )
	{
		IDocument document = provider.getDocument( getEditorInput( ) );

		if ( document != null )
		{
			script = document.get( );
		}
	}
	return script;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:17,代码来源:ScriptEditor.java

示例10: gotoLine

import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
private void gotoLine(ITextEditor editor, int line) {

			IDocumentProvider provider = editor.getDocumentProvider();
			IDocument document = provider.getDocument(editor.getEditorInput());
			try {

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

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

			} catch (BadLocationException x) {
				// ignore
			}
		}
 
开发者ID:blackdogit,项目名称:connectiq-monkeyc,代码行数:17,代码来源:PCMatcher.java

示例11: execute

import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的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

示例12: gotoLine

import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的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

示例13: getOffsetOfFirstNonWhitespaceCharAtLine

import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的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

示例14: getLineContent

import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的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

示例15: gotoLine

import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的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


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