Examples of IContentDescription


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

    }
    return NLS.bind(XMLUIMessages.Open, path);
  }

  private String getEditorLabel() throws CoreException {
    final IContentDescription description = fFile.getContentDescription();
    final IEditorDescriptor defaultEditor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(fFile.getName(), description != null ? description.getContentType() : null);
    return defaultEditor != null ? defaultEditor.getLabel() : null;
  }
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)))
        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

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

   * This implementation delegates to the platform's content description support,
   */
  @Override
  public Map<String, Object> contentDescription(URI uri, InputStream inputStream, Map<?, ?> options, Map<Object, Object> context) throws IOException
  {
    IContentDescription contentDescription;
    if (uri.isPlatformResource() && PlatformResourceURIHandlerImpl.workspaceRoot != null)
    {
      contentDescription = PlatformResourceURIHandlerImpl.WorkbenchHelper.getContentDescription(uri.toPlatformString(true), options);
    }
    else
    {
      contentDescription = Platform.getContentTypeManager().getDescriptionFor(inputStream, uri.lastSegment(), IContentDescription.ALL);
    }
    if (contentDescription == null)
    {
      return INVALID_CONTENT_DESCRIPTION;
    }
    else
    {
      Map<String, Object> result = createContentDescription(ContentHandler.Validity.VALID);
      result.put(ContentHandler.CONTENT_TYPE_PROPERTY, contentDescription.getContentType().getId());
      Set<String> requestedProperties = getRequestedProperties(options);
      if (requestedProperties != null)
      {
        for (String property : requestedProperties)
        {
          QualifiedName qualifiedName = getQualifiedName(property);
          if (qualifiedName != null)
          {
            Object value = getDescriptionValue(qualifiedName, contentDescription.getProperty(qualifiedName));
            if (value != null)
            {
              result.put(property, value);
            }
          }
View Full Code Here

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

    IFile file = input.getFile();
    if (file == null) {
      return null;
    }

    IContentDescription description = file.getContentDescription();
    if (description == null || description.getContentType() == null || !description.getContentType().isKindOf(WOD_FILE_CONTENT_TYPE)) {
      return null;
    }

    return super.createFileInfo(element);
  }
View Full Code Here

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

      : stringContents.getBytes(encoding);

    // Special case for UTF-8 BOM files
    // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=110576
    if (encoding != null && encoding.equals(org.eclipse.jdt.internal.compiler.util.Util.UTF_8)) {
      IContentDescription description;
      try {
        description = this.file.getContentDescription();
      } catch (CoreException e) {
        if (e.getStatus().getCode() != IResourceStatus.RESOURCE_NOT_FOUND)
          throw e;
        // file no longer exist (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=234307 )
        description = null;
      }
      if (description != null && description.getProperty(IContentDescription.BYTE_ORDER_MARK) != null) {
        int bomLength= IContentDescription.BOM_UTF_8.length;
        byte[] bytesWithBOM= new byte[bytes.length + bomLength];
        System.arraycopy(IContentDescription.BOM_UTF_8, 0, bytesWithBOM, 0, bomLength);
        System.arraycopy(bytes, 0, bytesWithBOM, bomLength, bytes.length);
        bytes= bytesWithBOM;
View Full Code Here

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

          + " as a Message. ", e);
    }
  }

  public static IMessage fileToMessage(IFile resource) throws CoreException, JAXBException {
    IContentDescription contentDescription = resource.getContentDescription();
    String fileExtension = resource.getFileExtension();

    IMessage message;
    if (MessagesNamespaceXmlContentDescriber.isXmlFormat(resource)) {
      message = Exchanges.loadMessage(resource, resource.getContents());
    } else {

      // TODO deal with binary....
      File file = IFiles.toFile(resource);
      if (file != null) {
        Message m = new Message();
        message = m;

        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 {
View Full Code Here

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

    protected String getContentType() {
        String contentTypeName = null;

        if (getFileResource() != null) {
            try {
                IContentDescription contentDescription = getFileResource().getContentDescription();
                if (contentDescription != null) {
                    IContentType contentType = contentDescription.getContentType();
                    contentTypeName = contentType.getName();
                } else {
                    logger.warn("No content type found for file '"
                            + getFileResource().getProjectRelativePath().toPortableString() + "'");
                }
View Full Code Here

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

      : stringContents.getBytes(encoding);

    // Special case for UTF-8 BOM files
    // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=110576
    if (encoding != null && encoding.equals(org.eclipse.jdt.internal.compiler.util.Util.UTF_8)) {
      IContentDescription description;
      try {
        description = this.file.getContentDescription();
      } catch (CoreException e) {
        if (e.getStatus().getCode() != IResourceStatus.RESOURCE_NOT_FOUND)
          throw e;
        // file no longer exist (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=234307 )
        description = null;
      }
      if (description != null && description.getProperty(IContentDescription.BYTE_ORDER_MARK) != null) {
        int bomLength= IContentDescription.BOM_UTF_8.length;
        byte[] bytesWithBOM= new byte[bytes.length + bomLength];
        System.arraycopy(IContentDescription.BOM_UTF_8, 0, bytesWithBOM, 0, bomLength);
        System.arraycopy(bytes, 0, bytesWithBOM, bomLength, bytes.length);
        bytes= bytesWithBOM;
View Full Code Here

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

      IResource resource = sourceModule.getCorrespondingResource();
      if (resource instanceof IFile) {
        if (isPhar(resource)) {
          return true;
        }
        IContentDescription contentDescription = ((IFile) resource)
            .getContentDescription();
        if (contentDescription != null) {
          return ContentTypeIdForPHP.ContentTypeID_PHP
              .equals(contentDescription.getContentType().getId());
        }
      }
    } catch (CoreException e) {
    }
    return hasPhpExtention(sourceModule.getElementName());
View Full Code Here

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

    String extension = getExtention(fileName);
    return extension != null && isPharExtention(extension);
  }

  public static boolean isPhpFile(final IFile file) {
    IContentDescription contentDescription = null;
    if (!file.exists()) {
      return hasPhpExtention(file);
    }
    try {
      contentDescription = file.getContentDescription();
    } catch (final CoreException e) {
      return hasPhpExtention(file);
    }

    if (contentDescription == null) {
      return hasPhpExtention(file);
    }

    return ContentTypeIdForPHP.ContentTypeID_PHP.equals(contentDescription
        .getContentType().getId());
  }
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.