Java Code Examples for org.eclipse.core.resources.IFile#getResourceAttributes()

The following examples show how to use org.eclipse.core.resources.IFile#getResourceAttributes() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test public void testBug342875() throws Exception {

		IJavaProject project = createJavaProject("foo");
		addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
		IFile file = createFile("foo/src/foo" + F_EXT, "objekt Foo ");
		ResourceAttributes resourceAttributes = file.getResourceAttributes();
		resourceAttributes.setReadOnly(true);
		file.setResourceAttributes(resourceAttributes);
		try {
			build();
			assertTrue(file.isReadOnly());
			assertEquals(1, countMarkers(file));
		} finally {
			resourceAttributes.setReadOnly(false);
			file.setResourceAttributes(resourceAttributes);
		}
	}
 
Example 2
private void addExecutableFlag(IFile file) {
	ResourceAttributes attributes = file.getResourceAttributes();
	if (attributes != null) {
		attributes.setExecutable(true);
		try {
			file.setResourceAttributes(attributes);
		} catch (CoreException e) {
			LOG.warn("Failed to set executable flag for " + file.getFullPath().toOSString(), e);
		}
	}
}
 
Example 3
@Test public void testBug342875() throws Exception {
	IFile file = createFile("sample/first" + F_EXT, "Hello A");
	ResourceAttributes resourceAttributes = file.getResourceAttributes();
	resourceAttributes.setReadOnly(true);
	file.setResourceAttributes(resourceAttributes);
	try {
		build();
		assertTrue(file.isReadOnly());
		assertEquals(1, countMarkers(file));
	} finally {
		resourceAttributes.setReadOnly(false);
		file.setResourceAttributes(resourceAttributes);
	}
}