Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.IStorage


  }

  public Object text(IResourceDescription element) {
    Iterator<Pair<IStorage, IProject>> storages = storage2UriMapper.getStorages(element.getURI()).iterator();
    if(storages.hasNext()) {
      IStorage storage = storages.next().getFirst();
      return storage.getFullPath().toString();
    }
    return null;
  }
View Full Code Here


        }
      }

      else {
        for (IPackageFragmentRoot root : roots) {
          IStorage storage = null;

          // Look in the root of the package fragment root
          if ("".equals(packageName) && root.exists()) {
            storage = contains(root.getNonJavaResources(), fileName);
          }
View Full Code Here

        Object resource = nonJavaResources[i];
        if (resource instanceof IFile) {
          nonJavaResources[i] = resource;
        }
        else if (resource instanceof IStorage && root.getResource() instanceof IFile) {
          IStorage storage = (IStorage) resource;
          nonJavaResources[i] = new ZipEntryStorage((IFile) root.getResource(), storage
              .getFullPath().toString());
        }
      }
    }
    return nonJavaResources;
View Full Code Here

    // Replace JAR entries with our own wrapper
    if (root.getKind() == IPackageFragmentRoot.K_BINARY && root.getResource() instanceof IFile) {
      for (int i = 0; i < nonJavaResources.length; i++) {
        Object resource = nonJavaResources[i];
        if (resource instanceof IStorage) {
          IStorage storage = (IStorage) resource;
          nonJavaResources[i] = new ZipEntryStorage((IFile) root.getResource(), storage
              .getFullPath().toString());
        }
      }
    }
    return nonJavaResources;
View Full Code Here

   * @throws CoreException if the given editor input cannot be accessed
   * @since 2.0
   */
  protected boolean setDocumentContent(IDocument document, IEditorInput editorInput, String encoding) throws CoreException {
    if (editorInput instanceof IStorageEditorInput) {
      IStorage storage= ((IStorageEditorInput) editorInput).getStorage();
      InputStream stream= storage.getContents();
      try {
        setDocumentContent(document, stream, encoding);
      } finally {
        try {
          stream.close();
View Full Code Here

   */
  protected void updateCache(IStorageEditorInput input) throws CoreException {
    StorageInfo info= (StorageInfo) getElementInfo(input);
    if (info != null) {
      try {
        IStorage storage= input.getStorage();
        if (storage != null) {
          boolean readOnly= storage.isReadOnly();
          info.fIsReadOnly=  readOnly;
          info.fIsModifiable= !readOnly;
        }
      } catch (CoreException x) {
        handleCoreException(x, EditorMessages.StorageDocumentProvider_updateCache);
View Full Code Here

   * @see org.eclipse.ui.texteditor.IDocumentProviderExtension4#getContentType(java.lang.Object)
   * @since 3.1
   */
  public IContentType getContentType(Object element) throws CoreException {
    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();
        else
          name= storage.getName();
        String message;
        if (name != null)
          message= MessageFormat.format(EditorMessages.StorageDocumentProvider_getContentDescriptionFor, name);
        else
          message= EditorMessages.StorageDocumentProvider_getContentDescription;
View Full Code Here

   * @return the persisted encoding
   * @since 2.1
   */
  protected String getPersistedEncoding(Object element) {
    if (element instanceof IStorageEditorInput) {
      IStorage storage;
      try {
        storage= ((IStorageEditorInput)element).getStorage();
        if (storage instanceof IEncodedStorage)
          return ((IEncodedStorage)storage).getCharset();
      } catch (CoreException e) {
View Full Code Here

TOP

Related Classes of org.eclipse.core.resources.IStorage

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.