* Calls the move/delete hook to perform the move. Since this method calls
* client code, it is run "unprotected", so the workspace lock is not held.
* Returns true if resources were actually moved, and false otherwise.
*/
private boolean unprotectedMove(ResourceTree tree, final IResource destination, int updateFlags, IProgressMonitor monitor) throws CoreException, ResourceException {
IMoveDeleteHook hook = workspace.getMoveDeleteHook();
switch (getType()) {
case IResource.FILE :
if (isLinked())
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_LINK_MOVE, this, destination, updateFlags));
if (!hook.moveFile(tree, (IFile) this, (IFile) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2)))
tree.standardMoveFile((IFile) this, (IFile) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork));
break;
case IResource.FOLDER :
if (isLinked())
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_LINK_MOVE, this, destination, updateFlags));
if (!hook.moveFolder(tree, (IFolder) this, (IFolder) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2)))
tree.standardMoveFolder((IFolder) this, (IFolder) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork));
break;
case IResource.PROJECT :
IProject project = (IProject) this;
// if there is no change in name, there is nothing to do so return.
if (getName().equals(destination.getName()))
return false;
//we are deleting the source project so notify.
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_MOVE, this, destination, updateFlags));
IProjectDescription description = project.getDescription();
description.setName(destination.getName());
if (!hook.moveProject(tree, project, description, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2)))
tree.standardMoveProject(project, description, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork));
break;
case IResource.ROOT :
String msg = Messages.resources_moveRoot;
throw new ResourceException(new ResourceStatus(IResourceStatus.INVALID_VALUE, getFullPath(), msg));