Search in sources :

Example 16 with ResourceAttributes

use of org.eclipse.core.resources.ResourceAttributes in project che by eclipse.

the class Resources method setReadOnly.

static void setReadOnly(IResource resource, boolean readOnly) {
    ResourceAttributes resourceAttributes = resource.getResourceAttributes();
    if (// not supported on this platform for this resource
    resourceAttributes == null)
        return;
    resourceAttributes.setReadOnly(readOnly);
    try {
        resource.setResourceAttributes(resourceAttributes);
    } catch (CoreException e) {
        RefactoringCorePlugin.log(e);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ResourceAttributes(org.eclipse.core.resources.ResourceAttributes)

Example 17 with ResourceAttributes

use of org.eclipse.core.resources.ResourceAttributes in project che by eclipse.

the class DocumentAdapter method isReadOnly.

/*
	 * @see IBuffer#isReadOnly()
	 */
public boolean isReadOnly() {
    //		if (fTextFileBuffer != null)
    //			return !fTextFileBuffer.isCommitable();
    IResource resource = getUnderlyingResource();
    if (resource == null)
        return true;
    final ResourceAttributes attributes = resource.getResourceAttributes();
    return attributes == null ? false : attributes.isReadOnly();
}
Also used : IResource(org.eclipse.core.resources.IResource) ResourceAttributes(org.eclipse.core.resources.ResourceAttributes)

Example 18 with ResourceAttributes

use of org.eclipse.core.resources.ResourceAttributes in project che by eclipse.

the class Checks method isReadOnly.

public static boolean isReadOnly(IResource res) throws JavaModelException {
    ResourceAttributes attributes = res.getResourceAttributes();
    if (attributes != null && attributes.isReadOnly())
        return true;
    if (!(res instanceof IContainer))
        return false;
    IContainer container = (IContainer) res;
    try {
        IResource[] children = container.members();
        for (int i = 0; i < children.length; i++) {
            if (isReadOnly(children[i]))
                return true;
        }
        return false;
    } catch (JavaModelException e) {
        throw e;
    } catch (CoreException e) {
        throw new JavaModelException(e);
    }
}
Also used : JavaModelException(org.eclipse.jdt.core.JavaModelException) CoreException(org.eclipse.core.runtime.CoreException) IContainer(org.eclipse.core.resources.IContainer) ResourceAttributes(org.eclipse.core.resources.ResourceAttributes) IResource(org.eclipse.core.resources.IResource)

Example 19 with ResourceAttributes

use of org.eclipse.core.resources.ResourceAttributes in project che by eclipse.

the class Resources method setReadOnly.

static void setReadOnly(IResource resource, boolean readOnly) {
    ResourceAttributes resourceAttributes = resource.getResourceAttributes();
    if (// not supported on this platform for this resource
    resourceAttributes == null)
        return;
    resourceAttributes.setReadOnly(readOnly);
    try {
        resource.setResourceAttributes(resourceAttributes);
    } catch (CoreException e) {
        JavaPlugin.log(e);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ResourceAttributes(org.eclipse.core.resources.ResourceAttributes)

Example 20 with ResourceAttributes

use of org.eclipse.core.resources.ResourceAttributes in project eclipse.platform.text by eclipse.

the class FileBuffersForWorkspaceFiles method setReadOnly.

/*
	 * @see org.eclipse.core.filebuffers.tests.FileBufferFunctions#markReadOnly()
	 */
@Override
protected void setReadOnly(boolean state) throws Exception {
    IFile file = FileBuffers.getWorkspaceFileAtLocation(getPath());
    ResourceAttributes attributes = new ResourceAttributes();
    attributes.setReadOnly(state);
    file.setResourceAttributes(attributes);
}
Also used : IFile(org.eclipse.core.resources.IFile) ResourceAttributes(org.eclipse.core.resources.ResourceAttributes)

Aggregations

ResourceAttributes (org.eclipse.core.resources.ResourceAttributes)26 IFile (org.eclipse.core.resources.IFile)10 CoreException (org.eclipse.core.runtime.CoreException)9 IResource (org.eclipse.core.resources.IResource)7 ByteArrayInputStream (java.io.ByteArrayInputStream)4 IFolder (org.eclipse.core.resources.IFolder)4 InputStream (java.io.InputStream)3 IProject (org.eclipse.core.resources.IProject)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)2 IPath (org.eclipse.core.runtime.IPath)2 IJavaProject (org.eclipse.jdt.core.IJavaProject)2 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)2 JavaModelException (org.eclipse.jdt.core.JavaModelException)2 Activity (com.centurylink.mdw.plugin.designer.model.Activity)1 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)1 ArtifactResourceListener (com.centurylink.mdw.plugin.workspace.ArtifactResourceListener)1 TempFileRemover (com.centurylink.mdw.plugin.workspace.TempFileRemover)1 BufferedInputStream (java.io.BufferedInputStream)1