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);
}
}
}
}
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class ImportOperation method createFromRoot.
/**
* Creates the folders that appear in the specified resource path
* assuming that the destinationContainer begins at the root. Do not create projects.
*
* @param path the relative path of the resource
* @return the container resource coresponding to the given path
* @exception CoreException if this method failed
*/
private IContainer createFromRoot(IPath path) throws CoreException {
int segmentCount = path.segmentCount();
//Assume the project exists
IContainer currentFolder = ((IWorkspaceRoot) destinationContainer).getProject(path.segment(0));
for (int i = 1; i < segmentCount; i++) {
currentFolder = currentFolder.getFolder(new Path(path.segment(i)));
if (!currentFolder.exists()) {
((IFolder) currentFolder).create(false, true, null);
}
}
return currentFolder;
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class FileNamePatternSearchScope method addToList.
private static void addToList(ArrayList res, IResource curr, boolean includeDerived) {
// if (!includeDerived && curr.isDerived(IResource.CHECK_ANCESTORS)) {
// return;
// }
IPath currPath = curr.getFullPath();
for (int k = res.size() - 1; k >= 0; k--) {
IResource other = (IResource) res.get(k);
IPath otherPath = other.getFullPath();
if (otherPath.isPrefixOf(currPath)) {
return;
}
if (currPath.isPrefixOf(otherPath)) {
res.remove(k);
}
}
res.add(curr);
}
use of org.eclipse.core.runtime.IPath in project che by eclipse.
the class ContainerDescription method recordStateFromHistory.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.internal.ide.undo.ResourceDescription#recordStateFromHistory(org.eclipse.core.resources.IResource,
* org.eclipse.core.runtime.IProgressMonitor)
*/
public void recordStateFromHistory(IResource resource, IProgressMonitor monitor) throws CoreException {
monitor.beginTask(UndoMessages.FolderDescription_SavingUndoInfoProgress, 100);
if (members != null) {
for (int i = 0; i < members.length; i++) {
if (members[i] instanceof FileDescription) {
IPath path = resource.getFullPath().append(((FileDescription) members[i]).name);
IFile fileHandle = resource.getWorkspace().getRoot().getFile(path);
members[i].recordStateFromHistory(fileHandle, new SubProgressMonitor(monitor, 100 / members.length));
} else if (members[i] instanceof FolderDescription) {
IPath path = resource.getFullPath().append(((FolderDescription) members[i]).name);
IFolder folderHandle = resource.getWorkspace().getRoot().getFolder(path);
members[i].recordStateFromHistory(folderHandle, new SubProgressMonitor(monitor, 100 / members.length));
}
}
}
monitor.done();
}
Aggregations