org.eclipse.ui.editors.text.TextFileDocumentProvider源码实例Demo

类org.eclipse.ui.editors.text.TextFileDocumentProvider源码实例Demo

下面列出了org.eclipse.ui.editors.text.TextFileDocumentProvider 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ContentAssist   文件: EditorUtilities.java
/**
 * Obtains the document of a file.
 * @param file the file
 * @return the document of the file, or <code>null</code> if none
 */
public static IDocument getDocument(IFile file) {
    if (file == null) {
        return null;
    }
    
    try {
        TextFileDocumentProvider provider = new TextFileDocumentProvider();
        provider.connect(file);
        IDocument doc = provider.getDocument(file);
        provider.disconnect(file);
        return doc;
    } catch (CoreException e) {
        e.printStackTrace();
    }
    return null;
}
 
源代码2 项目: typescript.java   文件: EditorUtils.java
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;
}
 
源代码3 项目: APICloud-Studio   文件: XMLEditor.java
@Override
public String getContentType()
{
	try
	{
		IContentType contentType = ((TextFileDocumentProvider) getDocumentProvider())
				.getContentType(getEditorInput());
		if (contentType != null)
		{
			IContentType baseType = contentType.getBaseType();
			if (baseType != null && IXMLConstants.CONTENT_TYPE_XML.equals(baseType.getId()))
			{
				return contentType.getId();
			}
		}
	}
	catch (Exception e)
	{
	}
	return IXMLConstants.CONTENT_TYPE_XML;
}
 
源代码4 项目: APICloud-Studio   文件: AbstractThemeableEditor.java
public String getContentType()
{
	try
	{
		IContentType contentType = ((TextFileDocumentProvider) getDocumentProvider())
				.getContentType(getEditorInput());
		if (contentType != null)
		{
			return contentType.getId();
		}
	}
	catch (Exception e)
	{
		IdeLog.logError(CommonEditorPlugin.getDefault(), e);
	}
	return null;
}
 
private static boolean mustSaveDirtyEditor(IEditorPart ep, IEditorInput input, boolean saveUnknownEditors) {
	/*
	 * Goal: save all editors that could interfere with refactoring operations.
	 *
	 * Always save all editors for compilation units that are not working copies.
	 * (Leaving them dirty would cause problems, since the file buffer could have been
	 * modified but the Java model is not reconciled.)
	 *
	 * If <code>saveUnknownEditors</code> is <code>true</code>, save all editors
	 * whose implementation is probably not based on file buffers.
	 */
	IResource resource= (IResource) input.getAdapter(IResource.class);
	if (resource == null)
		return saveUnknownEditors;

	IJavaElement javaElement= JavaCore.create(resource);
	if (javaElement instanceof ICompilationUnit) {
		ICompilationUnit cu= (ICompilationUnit) javaElement;
		if (!cu.isWorkingCopy()) {
			return true;
		}
	}

	if (! (ep instanceof ITextEditor))
		return saveUnknownEditors;

	ITextEditor textEditor= (ITextEditor) ep;
	IDocumentProvider documentProvider= textEditor.getDocumentProvider();
	if (! (documentProvider instanceof TextFileDocumentProvider))
		return saveUnknownEditors;

	return false;
}
 
源代码6 项目: saros   文件: EditorPool.java
private static void findAndLogDocumentProviderIssues(final IEditorPart editorPart) {

    final IDocumentProvider defaultDocumentProvider =
        EditorAPI.getDocumentProvider(editorPart.getEditorInput());

    if (!(defaultDocumentProvider instanceof TextFileDocumentProvider)) {
      log.warn(
          "The default document provider "
              + defaultDocumentProvider
              + " for editor with title '"
              + editorPart.getTitle()
              + "' might not support shared access. It is likely that the editor content is not properly synchronized!");

      return;
    }

    final ITextEditor textEditor = editorPart.getAdapter(ITextEditor.class);

    if (textEditor == null) return;

    final IDocumentProvider editorDocumentProvider = textEditor.getDocumentProvider();

    if (!(editorDocumentProvider instanceof TextFileDocumentProvider)) {
      log.warn(
          "The document provider "
              + editorDocumentProvider
              + " for editor with title '"
              + editorPart.getTitle()
              + "' might not support shared access. It is likely that the editor content is not properly synchronized!");
    }
  }
 
源代码7 项目: xds-ide   文件: OberonDocumentProvider.java
/**
 * Creates a new Oberon-2 source file document provider and sets up the parent chain.
 */
public OberonDocumentProvider() {
    super( IModulaPartitions.M2_PARTITIONING
         , new OberonDocumentSetupParticipant()
         , new TextFileDocumentProvider() );
}
 
源代码8 项目: xds-ide   文件: ModulaDocumentProvider.java
/**
 * Creates a new Modula-2 source file document provider and sets up the parent chain.
 */
public ModulaDocumentProvider() {
    super( IModulaPartitions.M2_PARTITIONING
         , new ModulaDocumentSetupParticipant()
         , new TextFileDocumentProvider() );
}
 
源代码评论
动弹
沙发等你来抢
 类所在包
 类方法
 同包方法