use of org.eclipse.core.resources.ResourceAttributes in project che by eclipse.
the class RenamePackageTest method testReadOnly.
@Test
public void testReadOnly() throws Exception {
if (BUG_6054) {
printTestDisabledMessage("see bug#6054 (renaming a read-only package resets the read-only flag)");
return;
}
fIsPreDeltaTest = true;
String[] packageNames = new String[] { "r" };
String[][] packageFileNames = new String[][] { { "A" } };
String newPackageName = "p1";
IPackageFragment[] packages = new IPackageFragment[packageNames.length];
ICompilationUnit[][] cus = new ICompilationUnit[packageFileNames.length][packageFileNames[0].length];
for (int i = 0; i < packageNames.length; i++) {
packages[i] = getRoot().createPackageFragment(packageNames[i], true, null);
for (int j = 0; j < packageFileNames[i].length; j++) {
cus[i][j] = createCUfromTestFile(packages[i], packageFileNames[i][j], packageNames[i].replace('.', '/') + "/");
}
}
IPackageFragment thisPackage = packages[0];
final IResource resource = thisPackage.getCorrespondingResource();
final ResourceAttributes attributes = resource.getResourceAttributes();
if (attributes != null)
attributes.setReadOnly(true);
RefactoringStatus result = performRefactoring(createRefactoringDescriptor(thisPackage, newPackageName));
TestCase.assertEquals("preconditions were supposed to pass", null, result);
assertTrue("package not renamed", !getRoot().getPackageFragment(packageNames[0]).exists());
IPackageFragment newPackage = getRoot().getPackageFragment(newPackageName);
assertTrue("new package does not exist", newPackage.exists());
assertTrue("new package should be read-only", attributes == null || attributes.isReadOnly());
}
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);
}
}
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();
}
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);
}
}
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);
}
}
Aggregations