use of org.eclipse.core.resources.IResource 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.resources.IResource 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.resources.IResource in project che by eclipse.
the class AbstractResourceDescription method createResource.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.ide.undo.ResourceDescription#createResource(org.eclipse
* .core.runtime.IProgressMonitor)
*/
public IResource createResource(IProgressMonitor monitor) throws CoreException {
IResource resource = createResourceHandle();
createExistentResourceFromHandle(resource, monitor);
restoreResourceAttributes(resource);
return resource;
}
use of org.eclipse.core.resources.IResource in project che by eclipse.
the class AbstractResourceDescription method verifyExistence.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.ide.undo.ResourceDescription#verifyExistence(boolean)
*/
public boolean verifyExistence(boolean checkMembers) {
IContainer p = parent;
if (p == null) {
p = getWorkspace().getRoot();
}
IResource handle = p.findMember(getName());
return handle != null;
}
use of org.eclipse.core.resources.IResource in project che by eclipse.
the class RenameResourceProcessor method createDescriptor.
protected RenameResourceDescriptor createDescriptor() {
IResource resource = getResource();
RenameResourceDescriptor descriptor = new RenameResourceDescriptor();
descriptor.setProject(resource instanceof IProject ? null : resource.getProject().getName());
descriptor.setDescription(Messages.format(RefactoringCoreMessages.RenameResourceProcessor_description, BasicElementLabels.getResourceName(resource)));
descriptor.setComment(Messages.format(RefactoringCoreMessages.RenameResourceProcessor_comment, new String[] { BasicElementLabels.getPathLabel(resource.getFullPath(), false), BasicElementLabels.getResourceName(getNewResourceName()) }));
descriptor.setFlags(RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE | RefactoringDescriptor.BREAKING_CHANGE);
descriptor.setResourcePath(resource.getFullPath());
descriptor.setNewName(getNewResourceName());
descriptor.setUpdateReferences(isUpdateReferences());
return descriptor;
}
Aggregations