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

The following examples show how to use org.eclipse.jdt.internal.core.util.Util#isReadOnly() . 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 5 votes vote down vote up
/**
 * Creates any destination package fragment(s) which do not exists yet.
 * Return true if a read-only package fragment has been found among package fragments, false otherwise
 */
private boolean createNeededPackageFragments(IContainer sourceFolder, PackageFragmentRoot root, String[] newFragName, boolean moveFolder) throws JavaModelException {
	boolean containsReadOnlyPackageFragment = false;
	IContainer parentFolder = (IContainer) root.resource();
	JavaElementDelta projectDelta = null;
	String[] sideEffectPackageName = null;
	char[][] inclusionPatterns = root.fullInclusionPatternChars();
	char[][] exclusionPatterns = root.fullExclusionPatternChars();
	for (int i = 0; i < newFragName.length; i++) {
		String subFolderName = newFragName[i];
		sideEffectPackageName = Util.arrayConcat(sideEffectPackageName, subFolderName);
		IResource subFolder = parentFolder.findMember(subFolderName);
		if (subFolder == null) {
			// create deepest folder only if not a move (folder will be moved in processPackageFragmentResource)
			if (!(moveFolder && i == newFragName.length-1)) {
				createFolder(parentFolder, subFolderName, this.force);
			}
			parentFolder = parentFolder.getFolder(new Path(subFolderName));
			sourceFolder = sourceFolder.getFolder(new Path(subFolderName));
			if (Util.isReadOnly(sourceFolder)) {
				containsReadOnlyPackageFragment = true;
			}
			IPackageFragment sideEffectPackage = root.getPackageFragment(sideEffectPackageName);
			if (i < newFragName.length - 1 // all but the last one are side effect packages
					&& !Util.isExcluded(parentFolder, inclusionPatterns, exclusionPatterns)) {
				if (projectDelta == null) {
					projectDelta = getDeltaFor(root.getJavaProject());
				}
				projectDelta.added(sideEffectPackage);
			}
			this.createdElements.add(sideEffectPackage);
		} else {
			parentFolder = (IContainer) subFolder;
		}
	}
	return containsReadOnlyPackageFragment;
}
 
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);
		}
	}
}