Java Code Examples for org.eclipse.jdt.internal.core.util.Util#setReadOnly()

The following examples show how to use org.eclipse.jdt.internal.core.util.Util#setReadOnly() . 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
Source File: CopyResourceElementsOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void saveContent(PackageFragment dest, String destName, TextEdit edits, String sourceEncoding, IFile destFile) throws JavaModelException {
	try {
		// TODO (frederic) remove when bug 67606 will be fixed (bug 67823)
		// fix bug 66898
		if (sourceEncoding != null) destFile.setCharset(sourceEncoding, this.progressMonitor);
		// end todo
	}
	catch (CoreException ce) {
		// use no encoding
	}
	// when the file was copied, its read-only flag was preserved -> temporary set it to false
	// note this doesn't interfere with repository providers as this is a new resource that cannot be under
	// version control yet
	Util.setReadOnly(destFile, false);
	ICompilationUnit destCU = dest.getCompilationUnit(destName);
	applyTextEdit(destCU, edits);
	destCU.save(getSubProgressMonitor(1), this.force);
}
 
Example 2
Source File: CopyResourceElementsOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void updateReadOnlyPackageFragmentsForCopy(IContainer sourceFolder, PackageFragmentRoot root, String[] newFragName) {
	IContainer parentFolder = (IContainer) root.resource();
	for (int i = 0, length = newFragName.length; i <length; i++) {
		String subFolderName = newFragName[i];
		parentFolder = parentFolder.getFolder(new Path(subFolderName));
		sourceFolder = sourceFolder.getFolder(new Path(subFolderName));
		if (sourceFolder.exists() && Util.isReadOnly(sourceFolder)) {
			Util.setReadOnly(parentFolder, true);
		}
	}
}
 
Example 3
Source File: CopyResourceElementsOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void updateReadOnlyPackageFragmentsForMove(IContainer sourceFolder, PackageFragmentRoot root, String[] newFragName, boolean sourceFolderIsReadOnly) {
	IContainer parentFolder = (IContainer) root.resource();
	for (int i = 0, length = newFragName.length; i < length; i++) {
		String subFolderName = newFragName[i];
		parentFolder = parentFolder.getFolder(new Path(subFolderName));
		sourceFolder = sourceFolder.getFolder(new Path(subFolderName));
		if ((sourceFolder.exists() && Util.isReadOnly(sourceFolder)) || (i == length - 1 && sourceFolderIsReadOnly)) {
			Util.setReadOnly(parentFolder, true);
			// the source folder will be deleted anyway (move operation)
			Util.setReadOnly(sourceFolder, false);
		}
	}
}
 
Example 4
Source File: AbstractImageBuilder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected void copyResource(IResource source, IResource destination) throws CoreException {
	IPath destPath = destination.getFullPath();
	try {
		source.copy(destPath, IResource.FORCE | IResource.DERIVED, null);
	} catch (CoreException e) {
		// handle the case when the source resource is deleted
		source.refreshLocal(0, null);
		if (!source.exists()) return; // source resource was deleted so skip it
		throw e;
	}
	Util.setReadOnly(destination, false); // just in case the original was read only
}