Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.ResourceAttributes


          if (timeStamp != null)
          {
            resource.setLocalTimeStamp(timeStamp);
          }

          ResourceAttributes resourceAttributes = null;
          Boolean readOnly = (Boolean)attributes.get(URIConverter.ATTRIBUTE_READ_ONLY);
          if (readOnly != null)
          {
            resourceAttributes = resource.getResourceAttributes();
            resourceAttributes.setReadOnly(readOnly);
          }
          Boolean archive = (Boolean)attributes.get(URIConverter.ATTRIBUTE_ARCHIVE);
          if (archive != null)
          {
            if (resourceAttributes == null)
            {
              resourceAttributes = resource.getResourceAttributes();
            }
            resourceAttributes.setArchive(archive);
          }
          Boolean executable =  (Boolean)attributes.get(URIConverter.ATTRIBUTE_EXECUTABLE);
          if (executable != null)
          {
            if (resourceAttributes == null)
            {
              resourceAttributes = resource.getResourceAttributes();
            }
            resourceAttributes.setExecutable(executable);
          }
          Boolean hidden = (Boolean)attributes.get(URIConverter.ATTRIBUTE_HIDDEN);
          if (hidden != null)
          {
            if (resourceAttributes == null)
            {
              resourceAttributes = resource.getResourceAttributes();
            }
            resourceAttributes.setHidden(hidden);
          }

          if (resourceAttributes != null)
          {
            resource.setResourceAttributes(resourceAttributes);
View Full Code Here


        if (requestedAttributes == null || requestedAttributes.contains(URIConverter.ATTRIBUTE_TIME_STAMP))
        {
          result.put(URIConverter.ATTRIBUTE_TIME_STAMP,  resource.getLocalTimeStamp());
        }
        ResourceAttributes resourceAttributes = null;
        if (requestedAttributes == null || requestedAttributes.contains(URIConverter.ATTRIBUTE_READ_ONLY))
        {
          resourceAttributes = resource.getResourceAttributes();
          result.put(URIConverter.ATTRIBUTE_READ_ONLY,  resourceAttributes.isReadOnly());
        }
        if (requestedAttributes == null || requestedAttributes.contains(URIConverter.ATTRIBUTE_ARCHIVE))
        {
          if (resourceAttributes == null)
          {
            resourceAttributes = resource.getResourceAttributes();
          }
          result.put(URIConverter.ATTRIBUTE_ARCHIVE,  resourceAttributes.isArchive());
        }
        if (requestedAttributes == null || requestedAttributes.contains(URIConverter.ATTRIBUTE_EXECUTABLE))
        {
          if (resourceAttributes == null)
          {
            resourceAttributes = resource.getResourceAttributes();
          }
          result.put(URIConverter.ATTRIBUTE_EXECUTABLE,  resourceAttributes.isExecutable());
        }
        if (requestedAttributes == null || requestedAttributes.contains(URIConverter.ATTRIBUTE_HIDDEN))
        {
          if (resourceAttributes == null)
          {
            resourceAttributes = resource.getResourceAttributes();
          }
          result.put(URIConverter.ATTRIBUTE_HIDDEN,  resourceAttributes.isHidden());
        }
        if (requestedAttributes == null || requestedAttributes.contains(URIConverter.ATTRIBUTE_DIRECTORY))
        {
          if (resourceAttributes == null)
          {
View Full Code Here

          if (timeStamp != null)
          {
            resource.setLocalTimeStamp(timeStamp);
          }

          ResourceAttributes resourceAttributes = null;
          Boolean readOnly = (Boolean)attributes.get(URIConverter.ATTRIBUTE_READ_ONLY);
          if (readOnly != null)
          {
            resourceAttributes = resource.getResourceAttributes();
            resourceAttributes.setReadOnly(readOnly);
          }
          Boolean archive = (Boolean)attributes.get(URIConverter.ATTRIBUTE_ARCHIVE);
          if (archive != null)
          {
            if (resourceAttributes == null)
            {
              resourceAttributes = resource.getResourceAttributes();
            }
            resourceAttributes.setArchive(archive);
          }
          Boolean executable =  (Boolean)attributes.get(URIConverter.ATTRIBUTE_EXECUTABLE);
          if (executable != null)
          {
            if (resourceAttributes == null)
            {
              resourceAttributes = resource.getResourceAttributes();
            }
            resourceAttributes.setExecutable(executable);
          }
          Boolean hidden = (Boolean)attributes.get(URIConverter.ATTRIBUTE_HIDDEN);
          if (hidden != null)
          {
            if (resourceAttributes == null)
            {
              resourceAttributes = resource.getResourceAttributes();
            }
            resourceAttributes.setHidden(hidden);
          }

          if (resourceAttributes != null)
          {
            resource.setResourceAttributes(resourceAttributes);
View Full Code Here

   * @param data to write into the file
   * @throws CoreException
   */
  public static void writeFile(IFile file, String data) throws CoreException {
    if (file != null && file.exists()) {
      ResourceAttributes resourceAttributes = file.getResourceAttributes();
      if (resourceAttributes.isReadOnly()) {
        resourceAttributes.setReadOnly(false);
        file.setResourceAttributes(resourceAttributes);
      }
      file.setContents(new ByteArrayInputStream(data.getBytes()), IFile.FORCE, null);
      resourceAttributes.setReadOnly(true);
      file.setResourceAttributes(resourceAttributes);
    }
  }
View Full Code Here

            fModificationStamp = resource.getModificationStamp();
        }
    }

    public static boolean isReadOnly(IResource resource) {
        ResourceAttributes resourceAttributes = resource.getResourceAttributes();
        if (resourceAttributes == null) // not supported on this platform for this resource
            return false;
        return resourceAttributes.isReadOnly();
    }
View Full Code Here

    public void setResourceAttributes(IFile file) {
        try {
            Component component = getComponentFactory().getComponentFromFile(file, false);
            if (component.isInstalled()) {
                ResourceAttributes resourceAttributes = new ResourceAttributes();
                resourceAttributes.setReadOnly(true);
            }
        } catch (Exception e) {
            logger.error("Unable to set read-only access son file " + file.getName(), e);
        }
    }
View Full Code Here

    protected abstract void loadComponentProperties(IFile file);

    protected void setFileAccess(IFile file) {
        if (file != null && isInstalled()) {
            ResourceAttributes resourceAttributes = new ResourceAttributes();
            resourceAttributes.setReadOnly(true);
            try {
                file.setResourceAttributes(resourceAttributes);
            } catch (CoreException e) {
                String logMessage = Utils.generateCoreExceptionLog(e);
                logger.warn("Unable to set read-only on file " + resource.getName() + ": " + logMessage);
View Full Code Here

   *
   * @param element
   * @return the attributes of the file
   */
  public ResourceAttributes getResourceAttributes(Object element) {
    ResourceAttributes attributes = new ResourceAttributes();
    TarEntry entry = (TarEntry) element;
    attributes.setExecutable((entry.getMode() & 0100) != 0);
    attributes.setReadOnly((entry.getMode() & 0200) == 0);
    return attributes;
  }
View Full Code Here

  /*
   * @see IBuffer#isReadOnly()
   */
  public boolean isReadOnly() {
    IResource resource = getUnderlyingResource();
    ResourceAttributes resourceAttributes = resource
        .getResourceAttributes();
    return resource == null ? true : resourceAttributes.isReadOnly();
  }
View Full Code Here

    // no need to set read-only if resource is already set to desired
    // read-only setting
    if (resource.getResourceAttributes() != null
        && resource.getResourceAttributes().isReadOnly() != readyOnly) {
      ResourceAttributes resourceAttributes = new ResourceAttributes();
      resourceAttributes.setReadOnly(readyOnly);
      try {
        resource.setResourceAttributes(resourceAttributes);
        if (logger.isDebugEnabled()) {
          logger.debug("Set resource '"
              + resource.getProjectRelativePath()
View Full Code Here

TOP

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

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.