Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.IStorage


  {
    for (int i = 0; i < roots.length; i++) {
      if (roots[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY ||
          roots[i].getEntryKind() == IClasspathEntry.CPE_CONTAINER)
      {
        IStorage storage = getResourceFromLibrary(
            javaProject, baseName, roots[i]);
        if (storage != null)
        {
          return storage;
        }
View Full Code Here


      }

      if (resources != null && resources.length > 0) {
        for (int k = 0; k < resources.length; k++) {
          if (resources[k] instanceof IStorage) {
            IStorage storage = (IStorage) resources[k];
            if (getFileName(baseName).equalsIgnoreCase(
                storage.getName())) {
              return storage;
            }
          }
        }
      }
View Full Code Here

    private static IFile createCachedBundleFile(final IProject project,
                                                   final String  resourcePathStr)
                      throws IOException, CoreException
    {
        final IStorage storage =
            LoadBundleUtil.getLoadBundleResource(project, resourcePathStr);

        IFile bundleRes = null;

        if (storage != null
                && storage.getAdapter(IFile.class) != null)
        {
            bundleRes = (IFile) storage.getAdapter(IFile.class);
            // if file is removed, clear the bundle from the store.
            final LifecycleListener listener = new LifecycleListener(bundleRes, ResourcesPlugin.getWorkspace());
            listener.addListener(new IResourceLifecycleListener()
            {
                public EventResult acceptEvent(final ResourceLifecycleEvent event)
View Full Code Here

        if (vars != null) {
          for (int i = 0; i < vars.length; i++) {
            if (varName.equals(vars[i].getName())) {
              if (vars[i].getMode() == IVariableInfo.RESOURCEBUNDLE) {
                String resourceName = vars[i].getTypeInfoString();
                IStorage storage = null;
                try {
                  storage = LoadBundleUtil.getLoadBundleResource(_prj, resourceName);
                } catch (CoreException cex) {
                  _log.info("PageExpressionContext.Info.0", cex); //$NON-NLS-1$
                }
                if (storage != null) {
                  InputStream input = null;
                  try {
                    input = new BufferedInputStream(storage.getContents());
                    Properties properties = new Properties();
                    properties.load(input);
                    ret = properties;
                  } catch (Exception ignored) {
                    //ignore - we'll return null
View Full Code Here

        location = path.toString();
      }
    }
    if (location == null) {
      try {
        IStorage storage = input.getStorage();
        if (storage != null) {
          IPath storagePath = storage.getFullPath();
          String name = storage.getName();
          if (storagePath != null) {
            // If they are different, the IStorage contract is not
            // being honored
            // (https://bugs.eclipse.org/bugs/show_bug.cgi?id=73098).
            // Favor the name.
View Full Code Here

        path = ipath.toString();
      }
    }
    if (path == null) {
      try {
        IStorage storage = input.getStorage();
        if (storage != null) {
          IPath storagePath = storage.getFullPath();
          String name = storage.getName();
          if (storagePath != null) {
            // If they are different, the IStorage contract is not
            // being honored
            // (https://bugs.eclipse.org/bugs/show_bug.cgi?id=73098).
            // Favor the name.
View Full Code Here

   * @see org.eclipse.ui.editors.text.StorageDocumentProvider#getPersistedEncoding(java.lang.Object)
   */
  protected String getPersistedEncoding(Object element) {
    String charset = super.getPersistedEncoding(element);
    if (charset == null && element instanceof IStorageEditorInput) {
      IStorage storage;
      try {
        storage = ((IStorageEditorInput) element).getStorage();
        if (storage != null && !(storage instanceof IEncodedStorage)) {
          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();
              }
            }

View Full Code Here

  protected void setDocumentContent(IDocument document, IEditorInput element)
      throws CoreException {
    IDiagramDocument diagramDocument = (IDiagramDocument) document;
    TransactionalEditingDomain domain = diagramDocument.getEditingDomain();
    if (element instanceof FileEditorInput) {
      IStorage storage = ((FileEditorInput) element).getStorage();
      Diagram diagram = DiagramIOUtil.load(domain, storage, true,
          getProgressMonitor());
      document.setContent(diagram);
    } else if (element instanceof URIEditorInput) {
      URI uri = ((URIEditorInput) element).getURI();
View Full Code Here

  protected void setDocumentContent(IDocument document, IEditorInput element)
      throws CoreException {
    IDiagramDocument diagramDocument = (IDiagramDocument) document;
    TransactionalEditingDomain domain = diagramDocument.getEditingDomain();
    if (element instanceof FileEditorInput) {
      IStorage storage = ((FileEditorInput) element).getStorage();
      Diagram diagram = DiagramIOUtil.load(domain, storage, true,
          getProgressMonitor());
      document.setContent(diagram);
    } else if (element instanceof URIEditorInput) {
      URI uri = ((URIEditorInput) element).getURI();
View Full Code Here

  }

  private InputStream openStream(IEditorInput input) throws CoreException,
      IOException {
    if (input instanceof IStorageEditorInput) {
      final IStorage storage = ((IStorageEditorInput) input).getStorage();
      return storage.getContents();
    }
    if (input instanceof IURIEditorInput) {
      final URI uri = ((IURIEditorInput) input).getURI();
      return uri.toURL().openStream();
    }
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.