Examples of IContentDescription


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

        }       
      }
     
      // all other textual resources should be validated
      try {
        IContentDescription desc = file.getContentDescription();
        if (desc != null) {       
          IContentType type = desc.getContentType();
          if (type != null && desc.getContentType().isKindOf(Platform.getContentTypeManager().getContentType("org.eclipse.core.runtime.text"))) {
            return true;
          }
        }
      } catch (CoreException e) {
      }
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.aspectj.org.eclipse.jdt.internal.compiler.util.Util.UTF_8)) {
      IContentDescription description = this.file.getContentDescription();
      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

            IFile f = project.getProject().getFile(p.getLocalFile());
            if (f.exists())
            {
                try
                {
                    IContentDescription desc = f.getContentDescription();
                    if (desc != null)
                    {
                        IContentType type = desc.getContentType();
                        if (type != null)
                        {
                            if (type.isKindOf(txt))
                            {
                                parseText(f, imports);
View Full Code Here

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

    init(file);
  }

  private void init(IFile file) {
    try {
      IContentDescription desc = file.getContentDescription();
      if (desc != null) {
        componentType = (String) desc
            .getProperty(NonameContentType.COMPONENT_TYPE);
      }
    } catch (CoreException e) {
      e.printStackTrace();
    }
View Full Code Here

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

   *       - byte order mark is not valid for UTF-8
   */
  private static boolean isUTF8BOM(String encoding, IStorage storage) throws CoreException {
    if (storage instanceof IFile && "UTF-8".equals(encoding)) { //$NON-NLS-1$
      IFile file= (IFile) storage;
      IContentDescription description= file.getContentDescription();
      if (description != null) {
        byte[] bom= (byte[]) description.getProperty(IContentDescription.BYTE_ORDER_MARK);
        if (bom != null) {
          if (bom != IContentDescription.BOM_UTF_8)
            throw new CoreException(new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, IStatus.OK, QuickDiffMessages.getString("LastSaveReferenceProvider.LastSaveReferenceProvider.error.wrongByteOrderMark"), null)); //$NON-NLS-1$
          return true;
        }
View Full Code Here

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

    if (element instanceof IStorageEditorInput) {
      IStorage storage= ((IStorageEditorInput) element).getStorage();
      Reader reader= null;
      InputStream stream= null;
      try {
        IContentDescription desc;
        IDocument document= getDocument(element);
        if (document != null) {
          reader= new DocumentReader(document);
          desc= Platform.getContentTypeManager().getDescriptionFor(reader, storage.getName(), NO_PROPERTIES);
        } else {
          stream= storage.getContents();
          desc= Platform.getContentTypeManager().getDescriptionFor(stream, storage.getName(), NO_PROPERTIES);
        }
        if (desc != null && desc.getContentType() != null)
          return desc.getContentType();
      } catch (IOException x) {
        IPath path= storage.getFullPath();
        String name;
        if (path != null)
          name= path.toOSString();
View Full Code Here

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

    // Probe content
    Reader reader= new DocumentReader(document);
    try {
      QualifiedName[] options= new QualifiedName[] { IContentDescription.CHARSET, IContentDescription.BYTE_ORDER_MARK };
      IContentDescription description= Platform.getContentTypeManager().getDescriptionFor(reader, targetFile.getName(), options);
      if (description != null) {
        encoding= description.getCharset();
        if (encoding != null)
          return encoding;
      }
    } catch (IOException ex) {
      // continue with next strategy
View Full Code Here

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

   * @throws CoreException if reading or accessing the underlying store
   *                 fails
   * @since 3.1
   */
  private IContentType getContentType(IFileEditorInput input) throws CoreException {
    IContentDescription desc= input.getFile().getContentDescription();
    if (desc != null)
      return desc.getContentType();
    return null;
  }
View Full Code Here

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

  private boolean hasBOM(Object element) {
    if (element instanceof IFileEditorInput) {
      IFile file= ((IFileEditorInput)element).getFile();
      if (file != null) {
        try {
          IContentDescription description= file.getContentDescription();
          return  description != null && description.getProperty(IContentDescription.BYTE_ORDER_MARK) != null;
        } catch (CoreException ex) {
          return false;
        }
      }
    }
View Full Code Here

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

  /*
   * @since 3.0
   */
  private static String getEncodingFromContent(IFile file) throws CoreException {
    IContentDescription description = file.getContentDescription();
    if (description != null) {
      byte[] bom= (byte[])description.getProperty(IContentDescription.BYTE_ORDER_MARK);
      if (bom == null)
        return (String)description.getProperty(IContentDescription.CHARSET);
      if (bom == IContentDescription.BOM_UTF_8)
        return TextEditorMessages.WorkbenchPreference_encoding_BOM_UTF_8;
      if (bom == IContentDescription.BOM_UTF_16BE)
        return TextEditorMessages.WorkbenchPreference_encoding_BOM_UTF_16BE;
      if (bom == IContentDescription.BOM_UTF_16LE)
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.