本文整理了Java中org.eclipse.jdt.internal.core.util.Util.setReadOnly()
方法的一些代码示例,展示了Util.setReadOnly()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.setReadOnly()
方法的具体详情如下:
包路径:org.eclipse.jdt.internal.core.util.Util
类名称:Util
方法名:setReadOnly
[英]Sets or unsets the given resource as read-only in the file system. It's a no-op if the file system does not support the read-only attribute.
[中]将给定资源设置为或取消设置为文件系统中的只读资源。如果文件系统不支持只读属性,则为no-op。
代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core
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);
}
}
}
/**
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core
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);
}
}
}
/**
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core
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);
}
}
}
/**
代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core
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);
}
}
}
/**
代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion
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);
}
}
}
/**
代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core
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);
}
}
}
/**
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core
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);
}
}
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core
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);
}
}
}
代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core
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);
}
}
}
代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion
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);
}
}
}
代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core
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);
}
}
}
代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core
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);
}
}
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core
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
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core
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
}
代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core
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
}
代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core
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
}
代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core
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
}
代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion
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
}
代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core
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);
}
/**
代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core
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);
}
/**
内容来源于网络,如有侵权,请联系作者删除!