本文整理汇总了Java中org.eclipse.core.resources.ResourceAttributes类的典型用法代码示例。如果您正苦于以下问题:Java ResourceAttributes类的具体用法?Java ResourceAttributes怎么用?Java ResourceAttributes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResourceAttributes类属于org.eclipse.core.resources包,在下文中一共展示了ResourceAttributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: disableRunningGraphResource
import org.eclipse.core.resources.ResourceAttributes; //导入依赖的package包/类
private void disableRunningGraphResource(IEditorInput editorInput,String partName){
if(editorInput instanceof IFileEditorInput){
IFileEditorInput input = (IFileEditorInput)editorInput ;
IFile fileJob = input.getFile();
IPath xmlFileIPath =new Path(input.getFile().getFullPath().toOSString().replace(".job", ".xml"));
IFile fileXml = ResourcesPlugin.getWorkspace().getRoot().getFile(xmlFileIPath);
ResourceAttributes attributes = new ResourceAttributes();
attributes.setReadOnly(true);
attributes.setExecutable(true);
try {
fileJob.setResourceAttributes(attributes);
fileXml.setResourceAttributes(attributes);
} catch (CoreException e) {
logger.error("Unable to disable running job resources", e);
}
}
}
示例2: enableRunningGraphResource
import org.eclipse.core.resources.ResourceAttributes; //导入依赖的package包/类
private void enableRunningGraphResource(IEditorInput editorInput,
String partName) {
IFileEditorInput input = (IFileEditorInput)editorInput ;
IFile fileJob = input.getFile();
IPath xmlFileIPath =new Path(input.getFile().getFullPath().toOSString().replace(".job", ".xml"));
IFile fileXml = ResourcesPlugin.getWorkspace().getRoot().getFile(xmlFileIPath);
ResourceAttributes attributes = new ResourceAttributes();
attributes.setReadOnly(false);
attributes.setExecutable(true);
try {
if(fileJob.exists()){
fileJob.setResourceAttributes(attributes);
}
if(fileXml.exists()){
fileXml.setResourceAttributes(attributes);
}
} catch (CoreException e) {
logger.error("Unable to enable locked job resources",e);
}
}
示例3: checkReadOnlyAndNull
import org.eclipse.core.resources.ResourceAttributes; //导入依赖的package包/类
/**
* Check if the supplied resource is read only or null. If it is then ask
* the user if they want to continue. Return true if the resource is not
* read only or if the user has given permission.
*
* @return boolean
*/
private boolean checkReadOnlyAndNull(IResource currentResource) {
// Do a quick read only and null check
if (currentResource == null) {
return false;
}
// Do a quick read only check
final ResourceAttributes attributes = currentResource
.getResourceAttributes();
if (attributes != null && attributes.isReadOnly()) {
return MessageDialog.openQuestion(shellProvider.getShell(), CHECK_RENAME_TITLE,
MessageFormat.format(CHECK_RENAME_MESSAGE,
new Object[] { currentResource.getName() }));
}
return true;
}
示例4: setFileAccess
import org.eclipse.core.resources.ResourceAttributes; //导入依赖的package包/类
private void setFileAccess(IFile file) {
if (file != null && isInstalled()) {
ResourceAttributes resourceAttributes = new ResourceAttributes();
resourceAttributes.setReadOnly(true);
try {
file.setResourceAttributes(resourceAttributes);
} catch (CoreException e) {
String logMessage = Utils.generateCoreExceptionLog(e);
logger.warn("Unable to set read-only on file " + resource.getName() + ": " + logMessage);
}
if (logger.isDebugEnabled()) {
logger.debug("Set read-only access on " + file.getName());
}
}
}
示例5: isReadOnly
import org.eclipse.core.resources.ResourceAttributes; //导入依赖的package包/类
@Override
public boolean isReadOnly() {
if (fTextFileBuffer != null) {
return fTextFileBuffer.isCommitable();
}
ResourceAttributes attributes = fFile.getResourceAttributes();
return attributes != null ? attributes.isReadOnly() : false;
}
示例6: testReadOnly
import org.eclipse.core.resources.ResourceAttributes; //导入依赖的package包/类
@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());
}
示例7: setReadOnly
import org.eclipse.core.resources.ResourceAttributes; //导入依赖的package包/类
static void setReadOnly(IResource resource, boolean readOnly) {
ResourceAttributes resourceAttributes = resource.getResourceAttributes();
if (resourceAttributes == null) // not supported on this platform for this resource
return;
resourceAttributes.setReadOnly(readOnly);
try {
resource.setResourceAttributes(resourceAttributes);
} catch (CoreException e) {
JavaPlugin.log(e);
}
}
示例8: canEnable
import org.eclipse.core.resources.ResourceAttributes; //导入依赖的package包/类
@Override
public boolean canEnable() throws JavaModelException {
if (!super.canEnable()) return false;
IPackageFragmentRoot[] roots = getPackageFragmentRoots();
for (int i = 0; i < roots.length; i++) {
IPackageFragmentRoot root = roots[i];
if (root.isReadOnly() && !root.isArchive() && !root.isExternal()) {
final ResourceAttributes attributes = roots[i].getResource().getResourceAttributes();
if (attributes == null || attributes.isReadOnly()) return false;
}
}
return roots.length > 0;
}
示例9: isReadOnly
import org.eclipse.core.resources.ResourceAttributes; //导入依赖的package包/类
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();
}
示例10: setReadOnly
import org.eclipse.core.resources.ResourceAttributes; //导入依赖的package包/类
static void setReadOnly(IResource resource, boolean readOnly) {
ResourceAttributes resourceAttributes = resource.getResourceAttributes();
if (resourceAttributes == null) // not supported on this platform for this resource
return;
resourceAttributes.setReadOnly(readOnly);
try {
resource.setResourceAttributes(resourceAttributes);
} catch (CoreException e) {
RefactoringCorePlugin.log(e);
}
}
示例11: checkReadOnlyAndNull
import org.eclipse.core.resources.ResourceAttributes; //导入依赖的package包/类
/**
* Check if the supplied resource is read only or null. If it is then ask the user if they want to continue. Return
* true if the resource is not read only or if the user has given permission.
*
* @return boolean
*/
private boolean checkReadOnlyAndNull(final IResource currentResource) {
// Do a quick read only and null check
if (currentResource == null) { return false; }
// Do a quick read only check
final ResourceAttributes attributes = currentResource.getResourceAttributes();
if (attributes != null && attributes
.isReadOnly()) { return MessageDialog.openQuestion(WorkbenchHelper.getShell(), CHECK_RENAME_TITLE,
MessageFormat.format(CHECK_RENAME_MESSAGE, new Object[] { currentResource.getName() })); }
return true;
}
示例12: writeFile
import org.eclipse.core.resources.ResourceAttributes; //导入依赖的package包/类
/**
* Writes data into a resource with the given resourceName residing in the
* source folder of the given project. The previous file content is lost.
* Temporarily resets the "read-only" file attribute if one is present.
*
* @param file to set contents for
* @param data to write into the file
* @throws CoreException
*/
public static void writeFile(IFile file, String data) throws CoreException {
if (file != null && file.exists()) {
ResourceAttributes resourceAttributes = file.getResourceAttributes();
if (resourceAttributes.isReadOnly()) {
resourceAttributes.setReadOnly(false);
file.setResourceAttributes(resourceAttributes);
}
file.setContents(new ByteArrayInputStream(data.getBytes()), IFile.FORCE, null);
resourceAttributes.setReadOnly(true);
file.setResourceAttributes(resourceAttributes);
}
}
示例13: canEnable
import org.eclipse.core.resources.ResourceAttributes; //导入依赖的package包/类
@Override
public boolean canEnable() throws JavaModelException {
if (!super.canEnable())
return false;
IPackageFragmentRoot[] roots= getPackageFragmentRoots();
for (int i= 0; i < roots.length; i++) {
IPackageFragmentRoot root= roots[i];
if (root.isReadOnly() && !root.isArchive() && !root.isExternal()) {
final ResourceAttributes attributes= roots[i].getResource().getResourceAttributes();
if (attributes == null || attributes.isReadOnly())
return false;
}
}
return roots.length > 0;
}
示例14: setReadOnly
import org.eclipse.core.resources.ResourceAttributes; //导入依赖的package包/类
static void setReadOnly(IResource resource, boolean readOnly) {
ResourceAttributes resourceAttributes = resource.getResourceAttributes();
if (resourceAttributes == null) // not supported on this platform for this resource
return;
resourceAttributes.setReadOnly(readOnly);
try {
resource.setResourceAttributes(resourceAttributes);
} catch (CoreException e) {
JavaPlugin.log(e);
}
}
示例15: isReadOnly
import org.eclipse.core.resources.ResourceAttributes; //导入依赖的package包/类
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();
}