use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class HandleFactory method getPkgFragmentRoot.
/**
* Returns the package fragment root that contains the given resource path.
*/
private PackageFragmentRoot getPkgFragmentRoot(String pathString) {
IPath path = new Path(pathString);
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (int i = 0, max = projects.length; i < max; i++) {
try {
IProject project = projects[i];
if (!project.isAccessible() || !project.hasNature(JavaCore.NATURE_ID))
continue;
IJavaProject javaProject = this.javaModel.getJavaProject(project);
IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
for (int j = 0, rootCount = roots.length; j < rootCount; j++) {
PackageFragmentRoot root = (PackageFragmentRoot) roots[j];
if (root.internalPath().isPrefixOf(path) && !Util.isExcluded(path, root.fullInclusionPatternChars(), root.fullExclusionPatternChars(), false)) {
return root;
}
}
} catch (CoreException e) {
// CoreException from hasNature - should not happen since we check that the project is accessible
// JavaModelException from getPackageFragmentRoots - a problem occured while accessing project: nothing we can do, ignore
}
}
return null;
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class RenamePackageProcessor method getRefactoredResource.
//---- IResourceMapper ----------------------------------
public IResource getRefactoredResource(IResource element) {
IFolder packageFolder = (IFolder) fPackage.getResource();
if (packageFolder == null)
return element;
IContainer newPackageFolder = (IContainer) getNewPackage().getResource();
if (packageFolder.equals(element))
return newPackageFolder;
IPath packagePath = packageFolder.getProjectRelativePath();
IPath elementPath = element.getProjectRelativePath();
if (packagePath.isPrefixOf(elementPath)) {
if (fRenameSubpackages || (element instanceof IFile && packageFolder.equals(element.getParent()))) {
IPath pathInPackage = elementPath.removeFirstSegments(packagePath.segmentCount());
if (element instanceof IFile)
return newPackageFolder.getFile(pathInPackage);
else
return newPackageFolder.getFolder(pathInPackage);
}
}
return element;
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class ResourceModifications method addCopyDelta.
public void addCopyDelta(IResource copy, CopyArguments arguments) {
if (fIgnoreCount == 0) {
IPath destination = ((IResource) arguments.getDestination()).getFullPath().append(copy.getName());
internalAdd(new CopyDescription(copy, destination));
}
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class ResourceModifications method buildMoveDelta.
public static void buildMoveDelta(IResourceChangeDescriptionFactory builder, IResource resource, MoveArguments args) {
IPath destination = ((IResource) args.getDestination()).getFullPath().append(resource.getName());
new MoveDescription(resource, destination).buildDelta(builder);
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class ImportOperation method collectExistingReadonlyFiles.
/**
* Prompts if existing resources should be overwritten. Recursively collects
* existing read-only files to overwrite and resources that should not be
* overwritten.
*
* @param sourceStart destination path to check for existing files
* @param sources file system objects that may exist in the destination
* @param noOverwrite files that were selected to be skipped (don't overwrite).
* object type IPath
* @param overwriteReadonly the collected existing read-only files to overwrite.
* object type IPath
* @param policy on of the POLICY constants defined in the
* class.
*/
void collectExistingReadonlyFiles(IPath sourceStart, List sources, ArrayList noOverwrite, ArrayList overwriteReadonly, int policy) {
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
Iterator sourceIter = sources.iterator();
IPath sourceRootPath = null;
if (this.source != null) {
sourceRootPath = new Path(provider.getFullPath(this.source));
}
while (sourceIter.hasNext()) {
Object nextSource = sourceIter.next();
IPath sourcePath = new Path(provider.getFullPath(nextSource));
IPath newDestinationPath;
IResource newDestination;
if (sourceRootPath == null) {
newDestinationPath = sourceStart.append(provider.getLabel(nextSource));
} else {
int prefixLength = sourcePath.matchingFirstSegments(sourceRootPath);
IPath relativeSourcePath = sourcePath.removeFirstSegments(prefixLength);
newDestinationPath = this.destinationPath.append(relativeSourcePath);
}
newDestination = workspaceRoot.findMember(newDestinationPath);
if (newDestination == null) {
continue;
}
IFolder folder = getFolder(newDestination);
if (folder != null) {
if (policy != POLICY_FORCE_OVERWRITE) {
if (this.overwriteState == OVERWRITE_NONE || !queryOverwrite(newDestinationPath)) {
noOverwrite.add(folder);
continue;
}
}
if (provider.isFolder(nextSource)) {
collectExistingReadonlyFiles(newDestinationPath, provider.getChildren(nextSource), noOverwrite, overwriteReadonly, POLICY_FORCE_OVERWRITE);
}
} else {
IFile file = getFile(newDestination);
if (file != null) {
if (!queryOverwriteFile(file, policy)) {
noOverwrite.add(file.getFullPath());
} else if (file.isReadOnly()) {
overwriteReadonly.add(file);
}
}
}
}
}
Aggregations