Package org.eclipse.core.runtime.content

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


   * @param fileName file name (if available) where the content resides - can be null
   * @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) {
        for (int i=0; i<contentTypes.length; i++) {
          if (ELanguageTypes.getLanguageTypeFromContentType(contentTypes[i].getId()) != ELanguageTypes.Unknown) {
            matchedLanguageType = ELanguageTypes.getLanguageTypeFromContentType(contentTypes[i].getId());
            break;
View Full Code Here


    return new String[] { org.eclipse.php.internal.core.project.PHPNature.ID };
  }

  public static String[] getFileExtensions() {
    ArrayList extensions = new ArrayList();
    IContentTypeManager typeManager = Platform.getContentTypeManager();

    IContentType type = typeManager
        .getContentType(ContentTypeIdForPHP.ContentTypeID_PHP);
    String[] phpExtensions = type
        .getFileSpecs(IContentType.FILE_EXTENSION_SPEC);

    IContentType htmlContentType = typeManager
        .getContentType(ORG_ECLIPSE_WST_HTML_CORE_HTMLSOURCE);
    String[] htmlExtensions = htmlContentType
        .getFileSpecs(IContentType.FILE_EXTENSION_SPEC);

    if (phpExtensions != null)
View Full Code Here

  protected boolean canHandle(IFile file) {
    boolean result = false;
    if (file != null) {
      try {
        IContentTypeManager contentTypeManager = Platform
            .getContentTypeManager();

        IContentDescription contentDescription = file
            .getContentDescription();
        IContentType phpContentType = contentTypeManager
            .getContentType(ContentTypeIdForPHP.ContentTypeID_PHP);
        if (contentDescription != null) {
          IContentType fileContentType = contentDescription
              .getContentType();
View Full Code Here

    IResource file = workspace.getRoot().findMember(fullPath);
    if (file != null && file.getType() == IResource.FILE)
      return ((IFile)file).getCharset();
   
    // tries to obtain a description for the file contents
    IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
    InputStream contents = new BufferedInputStream(getContents());
    boolean failed = false;
    try {
      IContentDescription description = contentTypeManager.getDescriptionFor(contents, getName(), new QualifiedName[] {IContentDescription.CHARSET});
      return description == null ? null : description.getCharset();
    } catch (IOException e) {
      failed = true;
      String message = NLS.bind(Messages.history_errorContentDescription, getFullPath());   
      throw new ResourceException(IResourceStatus.FAILED_DESCRIBING_CONTENTS, getFullPath(), message, e);
View Full Code Here

        return charset;
    // tries to obtain a description from the contents provided
    IContentDescription description;
    try {
      // TODO need to take project specific settings into account
      IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
      description = contentTypeManager.getDescriptionFor(contents, getName(), new QualifiedName[] {IContentDescription.CHARSET});
    } catch (IOException e) {
      String message = NLS.bind(Messages.resources_errorContentDescription, getFullPath());
      throw new ResourceException(IResourceStatus.FAILED_DESCRIBING_CONTENTS, getFullPath(), message, e);
    }
    if (description != null)
View Full Code Here

              @Override
              public synchronized void add(Object item, ItemsFilter filter) {
                if (filter.matchItem(item)) {
                  if (item instanceof IFile) {
                    IFile ifile = (IFile) item;
                    IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
                    InputStream stream = null;
                    try {
                      stream = ifile.getContents(true);
                      IContentType t = contentTypeManager.findContentTypeFor(stream, ifile.getName());
                      if (t.getId().equals("org.fusesource.ide.camel.editor.camelContentType")) {
                        contentProvider.add(item, filter);
                      }
                    } catch (Exception ex) {
                      Activator.getLogger().error(ex);
View Full Code Here

public class TwigModelUtils
{
   
    public static boolean isTwigTemplate(String filename)
    {
        IContentTypeManager manager = Platform.getContentTypeManager();
        IContentType[] contentTypes = manager.findContentTypesFor(filename);
       
        for (IContentType type : contentTypes) {
            if (ContentTypeIdForTwig.CONTENT_TYPE_ID_TWIG.equals(type.getId())) {
                return true;
            }
View Full Code Here

 
  /**
   * @since 3.3.0
   */
  public static boolean isBeansConfigContentType(IFile file) {
    IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
    InputStream contents = null;
    try {
      contents = file.getContents();
      IContentType contentType = contentTypeManager.findContentTypeFor(contents, file.getName());
      if (contentType != null && contentType.isKindOf(contentTypeManager.getContentType("com.springsource.sts.config.ui.beanConfigFile"))) {
        return true;
      }
    } catch (CoreException e) {
      // if something goes wrong, treats the file as non spring content type
    } catch (IOException e) {
View Full Code Here

TOP

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

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.