当前位置: 首页>>代码示例>>Java>>正文


Java ResourceUtil.getResource方法代码示例

本文整理汇总了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));
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:OverwriteHelper.java

示例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));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:OverwriteHelper.java

示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:OverwriteHelper.java

示例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;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:ReorgPolicyFactory.java

示例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);
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:ReorgUtils.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:OverwriteHelper.java

示例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;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:33,代码来源:ReorgPolicyFactory.java

示例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);
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:ReorgPolicyFactory.java

示例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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:ReorgUtils.java

示例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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:ReorgPolicyFactory.java

示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:12,代码来源:ActionUtil.java


注:本文中的org.eclipse.jdt.internal.corext.refactoring.util.ResourceUtil.getResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。