Examples of IContentDescription


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

      Logger.log(Logger.ERROR, "model should never be null in PageDirective Adapter");
      return;
    }

    EmbeddedTypeHandler potentialNewandler = null;
    IContentDescription contentDescription = getContentDescription(model.getStructuredDocument());
    Object prop = contentDescription.getProperty(IContentDescriptionForJSP.CONTENT_FAMILY_ATTRIBUTE);
    if (prop != null) {
      if (ContentTypeFamilyForHTML.HTML_FAMILY.equals(prop)) {
        potentialNewandler = EmbeddedTypeRegistryImpl.getInstance().getTypeFor("text/html");
      }
    }
View Full Code Here

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

  private IContentDescription getContentDescription(Reader in) {

    if (in == null)
      return null;

    IContentDescription desc = null;
    try {

      IContentType contentTypeJSP = Platform.getContentTypeManager().getContentType(ContentTypeIdForJSP.ContentTypeID_JSP);
      desc = contentTypeJSP.getDescriptionFor(in, IContentDescription.ALL);
    }
View Full Code Here

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

   */
  private boolean isFragment(IFile file) {
    boolean isFragment = false;
    InputStream is = null;
    try {
      IContentDescription contentDescription = file.getContentDescription();
      // it can be null
      if (contentDescription == null) {
        is = file.getContents();
        contentDescription = Platform.getContentTypeManager().getDescriptionFor(is, file.getName(), new QualifiedName[]{IContentDescription.CHARSET});
      }
      if (contentDescription != null) {
        String fileCtId = contentDescription.getContentType().getId();
        isFragment = (fileCtId != null && ContentTypeIdForJSP.ContentTypeID_JSPFRAGMENT.equals(fileCtId));
      }
    }
    catch (IOException e) {
      // ignore, assume it's invalid JSP
View Full Code Here

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

  private boolean isFragment(IFile file) {
    // copied from JSPValidator
    boolean isFragment = false;
    InputStream is = null;
    try {
      IContentDescription contentDescription = file.getContentDescription();
      // it can be null
      if (contentDescription == null) {
        is = file.getContents();
        contentDescription = Platform.getContentTypeManager().getDescriptionFor(is, file.getName(), new QualifiedName[]{IContentDescription.CHARSET});
      }
      if (contentDescription != null) {
        String fileCtId = contentDescription.getContentType().getId();
        isFragment = (fileCtId != null && ContentTypeIdForJSP.ContentTypeID_JSPFRAGMENT.equals(fileCtId));
      }
    }
    catch (IOException e) {
      // ignore, assume it's invalid JSP
View Full Code Here

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

      }
      else if (fData instanceof Map && resource.isAccessible() && resource.getType() == IResource.FILE) {
        IContentType[] types = Platform.getContentTypeManager().findContentTypesFor(resource.getName());
        if (types.length == 0) {
          // if failed to find quickly, be more aggressive
          IContentDescription d = null;
          try {
            // optimized description lookup, might not succeed
            d = ((IFile) resource).getContentDescription();
            if (d != null) {
              types = new IContentType[]{d.getContentType()};
            }
          }
          catch (CoreException e) {
            /*
             * should not be possible given the accessible and
View Full Code Here

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

  private boolean isFragment(IFile file) {
    // copied from JSPValidator
    boolean isFragment = false;
    InputStream is = null;
    try {
      IContentDescription contentDescription = file.getContentDescription();
      // it can be null
      if (contentDescription == null) {
        is = file.getContents();
        contentDescription = Platform.getContentTypeManager().getDescriptionFor(is, file.getName(), new QualifiedName[]{IContentDescription.CHARSET});
      }
      if (contentDescription != null) {
        String fileCtId = contentDescription.getContentType().getId();
        isFragment = (fileCtId != null && ContentTypeIdForJSP.ContentTypeID_JSPFRAGMENT.equals(fileCtId));
      }
    }
    catch (IOException e) {
      // ignore, assume it's invalid JSP
View Full Code Here

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

          InputStream contents = null;
          try {
            contents = storage.getContents();
            if (contents != null) {
              QualifiedName[] detectionOptions = new QualifiedName[]{IContentDescription.BYTE_ORDER_MARK, IContentDescription.CHARSET};
              IContentDescription description = Platform.getContentTypeManager().getDescriptionFor(contents, storage.getName(), detectionOptions);
              if (description != null) {
                charset = description.getCharset();
              }
            }

          }
          catch (IOException e) {
View Full Code Here

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

      return newStamp > modificationStamp;
    }

    private String detectCharset(IFile file) {
      if (file.getType() == IResource.FILE && file.isAccessible()) {
        IContentDescription d = null;
        try {
          // optimized description lookup, might not succeed
          d = file.getContentDescription();
          if (d != null)
            return d.getCharset();
        }
        catch (CoreException e) {
          // should not be possible given the accessible and file
          // type
          // check above
        }
        InputStream contents = null;
        try {
          contents = file.getContents();
          IContentDescription description = Platform.getContentTypeManager().getDescriptionFor(contents, file.getName(), new QualifiedName[]{IContentDescription.CHARSET});
          if (description != null) {
            return description.getCharset();
          }
        }
        catch (IOException e) {
          // will try to cleanup in finally
        }
View Full Code Here

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

    String contentTypeId = null;

    IContentType ct = null;
    try {
      IContentDescription desc = Platform.getContentTypeManager().getDescriptionFor(new StringReader(doc.get()), null, IContentDescription.ALL);
      if (desc != null) {
        ct = desc.getContentType();
        if (ct != null)
          contentTypeId = ct.getId();
      }
    }
    catch (IOException e) {
View Full Code Here

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

      String extension = file.getFileExtension();
      if (extension != null && "xml".endsWith(extension.toLowerCase(Locale.US))) //$NON-NLS-1$
        return true;
    }

    IContentDescription contentDescription = null;
    try {
      contentDescription = ((IFile) file).getContentDescription();
      if (contentDescription != null) {
        IContentType contentType = contentDescription.getContentType();
        return contentDescription != null && contentType.isKindOf(getXMLContentType());
      }
    }
    catch (CoreException e) {
      Logger.logException(e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.