Package org.eclipse.core.runtime.content

Examples of org.eclipse.core.runtime.content.IContentType


   

   
   
    IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
    IContentType type = contentTypeManager.getContentType("at.ssw.cocoE.editor.CocoEContentType");
   
   
   
    boolean isNew = true;
   
    if(type.isAssociatedWith("."+editorSuffix)){
      isNew = false;
    }
   
    else{
      try {
        type.addFileSpec(editorSuffix, IContentType.FILE_EXTENSION_SPEC);
      } catch (CoreException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
    }
View Full Code Here


   * @return the language type if found or ELanguageTypes.Unknown otherwise
   * @throws IOException thrown if analysis has problems with the input stream
   */
  private ELanguageTypes findContentTypeInternal(InputStream content, String fileName) throws IOException {
    IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
    IContentType contentType = contentTypeManager.findContentTypeFor(content, fileName);
    ELanguageTypes matchedLanguageType = ELanguageTypes.Unknown;

    if (contentType != null) {
      matchedLanguageType = ELanguageTypes.getLanguageTypeFromContentType(contentType.getId());
    }

    if (matchedLanguageType == ELanguageTypes.Unknown) {
      IContentType[] contentTypes = contentTypeManager.findContentTypesFor(content, fileName);
      if (contentTypes != null) {
View Full Code Here

      return true;

    if (target.matchesClass(editor.getClass()))
      return true;

    IContentType contentType= getContentType(editor);
    return contentType != null && target.matchesContentType(contentType);

  }
View Full Code Here

  public static boolean isContentType(IContentType contentType, String id) {
    if (contentType != null) {
      if (Objects.equal(contentType.getId(), id)) {
        return true;
      }
      IContentType baseType = contentType.getBaseType();
      if (baseType != null) {
        return isContentType(baseType, id);
      }
    }
    return false;
View Full Code Here

        setMessageBody(m, file, !IFiles.isTextContentType(resource));
        // TODO should we add MIME type and whatnot headers...

       
        if (contentDescription != null) {
          IContentType contentType = contentDescription.getContentType();
          if (contentType != null) {
            m.setHeader("EclipseContentType", contentType.getId());
          }
        }
      } else {
        message = null;
      }
View Full Code Here

  private boolean isTextFile(IFile file) throws CoreException {
   
    if( !file.isSynchronized(IResource.DEPTH_ZERO) )
      return false;
   
    IContentType contentType = IDE.getContentType(file);
    if( contentType == null ) contentType = IDE.guessContentType(file);
    if( contentType == null ) return false;
   
    if( TEXT_CONTENT_TYPE != null && contentType.isKindOf(TEXT_CONTENT_TYPE) )
      return true;
   
    return false;
  }
View Full Code Here

  /**
   * Returns the registered Java like extensions.
   */
  public static char[][] getJavaLikeExtensions() {
    if (JAVA_LIKE_EXTENSIONS == null) {
      IContentType javaContentType = Platform.getContentTypeManager().getContentType(JavaCore.JAVA_SOURCE_CONTENT_TYPE);
      HashSet fileExtensions = new HashSet();
      // content types derived from java content type should be included (https://bugs.eclipse.org/bugs/show_bug.cgi?id=121715)
      IContentType[] contentTypes = Platform.getContentTypeManager().getAllContentTypes();
      for (int i = 0, length = contentTypes.length; i < length; i++) {
        if (contentTypes[i].isKindOf(javaContentType)) { // note that javaContentType.isKindOf(javaContentType) == true
View Full Code Here

    return id;
  }

  private static IContentType getContentType(
      FileRevisionEditorInput editorInput) {
    IContentType type = null;
    try {
      InputStream contents = editorInput.getStorage().getContents();
      try {
        type = getContentType(editorInput.getFileRevision().getName(),
            contents);
View Full Code Here

    return type;
  }

  private static IContentType getContentType(String fileName,
      InputStream contents) {
    IContentType type = null;
    if (contents != null) {
      try {
        type = Platform.getContentTypeManager().findContentTypeFor(
            contents, fileName);
      } catch (IOException e) {
View Full Code Here

    // make initial commit
    new Git(repo).commit().setAuthor("JUnit", "junit@jgit.org")
        .setMessage("Initial commit").call();

    IContentType textType = Platform.getContentTypeManager()
        .getContentType("org.eclipse.core.runtime.text");
    textType.addFileSpec(SAMPLE_FILE_EXTENSION,
        IContentType.FILE_EXTENSION_SPEC);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.core.runtime.content.IContentType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.