本文整理汇总了Java中org.eclipse.jdt.internal.corext.refactoring.util.ResourceUtil.getResource方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceUtil.getResource方法的具体用法?Java ResourceUtil.getResource怎么用?Java ResourceUtil.getResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.corext.refactoring.util.ResourceUtil
的用法示例。
在下文中一共展示了ResourceUtil.getResource方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: confirmFileOverwritting
import org.eclipse.jdt.internal.corext.refactoring.util.ResourceUtil; //导入方法依赖的package包/类
private void confirmFileOverwritting(IConfirmQuery overwriteQuery, IConfirmQuery skipQuery) {
List<IFile> filesToNotOverwrite = new ArrayList<IFile>(1);
for (int i = 0; i < fFiles.length; i++) {
IFile file = fFiles[i];
if (willOverwrite(file)) {
IContainer destination = (IContainer) ResourceUtil.getResource(fDestination);
if (ParentChecker.isDescendantOf(file, destination.findMember(file.getName()))) {
if (!skip(BasicElementLabels.getResourceName(file), skipQuery)) {
filesToNotOverwrite.add(file);
}
} else if (!overwrite(file, overwriteQuery)) {
filesToNotOverwrite.add(file);
}
}
}
IFile[] files = filesToNotOverwrite.toArray(new IFile[filesToNotOverwrite.size()]);
fFiles = ArrayTypeConverter.toFileArray(ReorgUtils.setMinus(fFiles, files));
}
示例2: confirmFileOverwritting
import org.eclipse.jdt.internal.corext.refactoring.util.ResourceUtil; //导入方法依赖的package包/类
private void confirmFileOverwritting(IConfirmQuery overwriteQuery, IConfirmQuery skipQuery) {
List<IFile> filesToNotOverwrite= new ArrayList<IFile>(1);
for (int i= 0; i < fFiles.length; i++) {
IFile file= fFiles[i];
if (willOverwrite(file)) {
IContainer destination= (IContainer) ResourceUtil.getResource(fDestination);
if (ParentChecker.isDescendantOf(file, destination.findMember(file.getName()))) {
if (!skip(BasicElementLabels.getResourceName(file), skipQuery)) {
filesToNotOverwrite.add(file);
}
} else if (!overwrite(file, overwriteQuery)) {
filesToNotOverwrite.add(file);
}
}
}
IFile[] files= filesToNotOverwrite.toArray(new IFile[filesToNotOverwrite.size()]);
fFiles= ArrayTypeConverter.toFileArray(ReorgUtils.setMinus(fFiles, files));
}
示例3: willOverwrite
import org.eclipse.jdt.internal.corext.refactoring.util.ResourceUtil; //导入方法依赖的package包/类
private boolean willOverwrite(IResource resource) {
if (resource == null)
return false;
IResource destinationResource= ResourceUtil.getResource(fDestination);
if (destinationResource.equals(resource.getParent()))
return false;
if (destinationResource instanceof IContainer) {
IContainer container= (IContainer)destinationResource;
IResource member= container.findMember(resource.getName());
if (member == null || !member.exists())
return false;
return true;
}
return false;
}
示例4: copyCuToPackage
import org.eclipse.jdt.internal.corext.refactoring.util.ResourceUtil; //导入方法依赖的package包/类
private static Change copyCuToPackage(ICompilationUnit cu, IPackageFragment dest, NewNameProposer nameProposer, INewNameQueries copyQueries) {
// XXX workaround for bug 31998 we will have to disable renaming of
// linked packages (and cus)
IResource res= ReorgUtils.getResource(cu);
if (res != null && res.isLinked()) {
if (ResourceUtil.getResource(dest) instanceof IContainer)
return copyFileToContainer(cu, (IContainer) ResourceUtil.getResource(dest), nameProposer, copyQueries);
}
String newName= nameProposer.createNewName(cu, dest);
Change simpleCopy= new CopyCompilationUnitChange(cu, dest, copyQueries.createStaticQuery(newName));
if (newName == null || newName.equals(cu.getElementName()))
return simpleCopy;
try {
IPath newPath= cu.getResource().getParent().getFullPath().append(JavaModelUtil.getRenamedCUName(cu, newName));
INewNameQuery nameQuery= copyQueries.createNewCompilationUnitNameQuery(cu, newName);
return new CreateCopyOfCompilationUnitChange(newPath, cu.getSource(), cu, nameQuery);
} catch (CoreException e) {
// Using inferred change
return simpleCopy;
}
}
示例5: isParentInWorkspaceOrOnDisk
import org.eclipse.jdt.internal.corext.refactoring.util.ResourceUtil; //导入方法依赖的package包/类
public static boolean isParentInWorkspaceOrOnDisk(
IPackageFragment pack, IPackageFragmentRoot root) {
if (pack == null) return false;
IJavaElement packParent = pack.getParent();
if (packParent == null) return false;
if (packParent.equals(root)) return true;
IResource packageResource = ResourceUtil.getResource(pack);
IResource packageRootResource = ResourceUtil.getResource(root);
return isParentInWorkspaceOrOnDisk(packageResource, packageRootResource);
}
示例6: willOverwrite
import org.eclipse.jdt.internal.corext.refactoring.util.ResourceUtil; //导入方法依赖的package包/类
private boolean willOverwrite(IResource resource) {
if (resource == null) return false;
IResource destinationResource = ResourceUtil.getResource(fDestination);
if (destinationResource.equals(resource.getParent())) return false;
if (destinationResource instanceof IContainer) {
IContainer container = (IContainer) destinationResource;
IResource member = container.findMember(resource.getName());
if (member == null || !member.exists()) return false;
return true;
}
return false;
}
示例7: copyCuToPackage
import org.eclipse.jdt.internal.corext.refactoring.util.ResourceUtil; //导入方法依赖的package包/类
private static Change copyCuToPackage(
ICompilationUnit cu,
IPackageFragment dest,
NewNameProposer nameProposer,
INewNameQueries copyQueries) {
// XXX workaround for bug 31998 we will have to disable renaming of
// linked packages (and cus)
IResource res = ReorgUtils.getResource(cu);
if (res != null && res.isLinked()) {
if (ResourceUtil.getResource(dest) instanceof IContainer)
return copyFileToContainer(
cu, (IContainer) ResourceUtil.getResource(dest), nameProposer, copyQueries);
}
String newName = nameProposer.createNewName(cu, dest);
Change simpleCopy =
new CopyCompilationUnitChange(cu, dest, copyQueries.createStaticQuery(newName));
if (newName == null || newName.equals(cu.getElementName())) return simpleCopy;
try {
IPath newPath =
cu.getResource()
.getParent()
.getFullPath()
.append(JavaModelUtil.getRenamedCUName(cu, newName));
INewNameQuery nameQuery = copyQueries.createNewCompilationUnitNameQuery(cu, newName);
return new CreateCopyOfCompilationUnitChange(newPath, cu.getSource(), cu, nameQuery);
} catch (CoreException e) {
// Using inferred change
return simpleCopy;
}
}
示例8: moveCuToPackage
import org.eclipse.jdt.internal.corext.refactoring.util.ResourceUtil; //导入方法依赖的package包/类
private static Change moveCuToPackage(ICompilationUnit cu, IPackageFragment dest) {
// XXX workaround for bug 31998 we will have to disable renaming of
// linked packages (and cus)
IResource resource = cu.getResource();
if (resource != null && resource.isLinked()) {
if (ResourceUtil.getResource(dest) instanceof IContainer)
return moveFileToContainer(cu, (IContainer) ResourceUtil.getResource(dest));
}
return new MoveCompilationUnitChange(cu, dest);
}
示例9: isParentInWorkspaceOrOnDisk
import org.eclipse.jdt.internal.corext.refactoring.util.ResourceUtil; //导入方法依赖的package包/类
public static boolean isParentInWorkspaceOrOnDisk(IPackageFragment pack, IPackageFragmentRoot root){
if (pack == null)
return false;
IJavaElement packParent= pack.getParent();
if (packParent == null)
return false;
if (packParent.equals(root))
return true;
IResource packageResource= ResourceUtil.getResource(pack);
IResource packageRootResource= ResourceUtil.getResource(root);
return isParentInWorkspaceOrOnDisk(packageResource, packageRootResource);
}
示例10: moveCuToPackage
import org.eclipse.jdt.internal.corext.refactoring.util.ResourceUtil; //导入方法依赖的package包/类
private static Change moveCuToPackage(ICompilationUnit cu, IPackageFragment dest) {
// XXX workaround for bug 31998 we will have to disable renaming of
// linked packages (and cus)
IResource resource= cu.getResource();
if (resource != null && resource.isLinked()) {
if (ResourceUtil.getResource(dest) instanceof IContainer)
return moveFileToContainer(cu, (IContainer) ResourceUtil.getResource(dest));
}
return new MoveCompilationUnitChange(cu, dest);
}
示例11: mustDisableJavaModelAction
import org.eclipse.jdt.internal.corext.refactoring.util.ResourceUtil; //导入方法依赖的package包/类
public static boolean mustDisableJavaModelAction(Shell shell, Object element) {
if (!(element instanceof IPackageFragment) && !(element instanceof IPackageFragmentRoot))
return false;
IResource resource= ResourceUtil.getResource(element);
if ((resource == null) || (! (resource instanceof IFolder)) || (! resource.isLinked()))
return false;
MessageDialog.openInformation(shell, ActionMessages.ActionUtil_not_possible, ActionMessages.ActionUtil_no_linked);
return true;
}