Search in sources :

Example 21 with ResourceAttributes

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

the class FileStoreFileBuffersForWorkspaceFiles 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)

Example 22 with ResourceAttributes

use of org.eclipse.core.resources.ResourceAttributes in project polymap4-core by Polymap4.

the class FileUtil method fileInfoToAttributes.

/**
 * Converts an IFileInfo object into a ResourceAttributes object.
 * @param fileInfo The file info
 * @return The resource attributes
 */
public static ResourceAttributes fileInfoToAttributes(IFileInfo fileInfo) {
    ResourceAttributes attributes = new ResourceAttributes();
    attributes.setReadOnly(fileInfo.getAttribute(EFS.ATTRIBUTE_READ_ONLY));
    attributes.setArchive(fileInfo.getAttribute(EFS.ATTRIBUTE_ARCHIVE));
    attributes.setExecutable(fileInfo.getAttribute(EFS.ATTRIBUTE_EXECUTABLE));
    attributes.setHidden(fileInfo.getAttribute(EFS.ATTRIBUTE_HIDDEN));
    attributes.setSymbolicLink(fileInfo.getAttribute(EFS.ATTRIBUTE_SYMLINK));
    return attributes;
}
Also used : ResourceAttributes(org.eclipse.core.resources.ResourceAttributes)

Example 23 with ResourceAttributes

use of org.eclipse.core.resources.ResourceAttributes in project mdw-designer by CenturyLinkCloud.

the class PluginUtil method setReadOnly.

public static void setReadOnly(IResource resource, boolean readonly) throws CoreException {
    ResourceAttributes attributes = resource.getResourceAttributes();
    if (attributes == null)
        return;
    attributes.setReadOnly(readonly);
    resource.setResourceAttributes(attributes);
}
Also used : ResourceAttributes(org.eclipse.core.resources.ResourceAttributes)

Example 24 with ResourceAttributes

use of org.eclipse.core.resources.ResourceAttributes in project tdq-studio-se by Talend.

the class FolderObjFilter method select.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object,
     * java.lang.Object)
     */
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
    if (element instanceof IResource) {
        IResource res = (IResource) element;
        if (IResource.FOLDER == res.getType()) {
            IFolder folder = (IFolder) element;
            // MOD mzhao 2010-08-12 14891: use same repository API with TOS to persistent metadata
            if (folder.getProjectRelativePath().toString().startsWith(EResourceConstant.METADATA.getPath())) {
                String folderName = folder.getName();
                if (folderName.equals("bin")) {
                    // $NON-NLS-1$
                    return false;
                }
                if (folderName.equals(EResourceConstant.METADATA.getPath())) {
                    return true;
                } else if (ResourceManager.getConnectionFolder().getFullPath().isPrefixOf(folder.getFullPath())) {
                    return true;
                }
                return false;
            } else // MOD zshen 2011-1-16 18724: Java UDI enhancements to hide lib folder.
            if (folder.getProjectRelativePath().toString().startsWith(EResourceConstant.USER_DEFINED_INDICATORS.getPath()) && (folder.getName().equals("lib"))) {
                // $NON-NLS-1$
                return false;
            }
            // ~18724
            ResourceAttributes resourceAttributes = folder.getResourceAttributes();
            if (resourceAttributes == null) {
                return true;
            }
            if (resourceAttributes.isHidden()) {
                return false;
            }
        } else {
            return true;
        }
    } else if (element instanceof UserDefIndicatorSubFolderRepNode) {
        if (EResourceConstant.USER_DEFINED_INDICATORS_LIB.getName().equalsIgnoreCase(((UserDefIndicatorSubFolderRepNode) element).getObject().getLabel())) {
            return false;
        }
    }
    return true;
}
Also used : UserDefIndicatorSubFolderRepNode(org.talend.dq.nodes.UserDefIndicatorSubFolderRepNode) IResource(org.eclipse.core.resources.IResource) ResourceAttributes(org.eclipse.core.resources.ResourceAttributes) IFolder(org.eclipse.core.resources.IFolder)

Example 25 with ResourceAttributes

use of org.eclipse.core.resources.ResourceAttributes in project eclipse-cs by checkstyle.

the class WriteProtectedFilter method accept.

/**
 * {@inheritDoc}
 */
@Override
public boolean accept(Object element) {
    boolean goesThrough = true;
    if (element instanceof IResource) {
        ResourceAttributes attrs = ((IResource) element).getResourceAttributes();
        goesThrough = attrs != null && !attrs.isReadOnly();
    }
    return goesThrough;
}
Also used : IResource(org.eclipse.core.resources.IResource) 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