Lines 686-695
Link Here
|
686 |
workspace.prepareOperation(rule, monitor); |
686 |
workspace.prepareOperation(rule, monitor); |
687 |
// if there is no resource then there is nothing to delete so just return |
687 |
// if there is no resource then there is nothing to delete so just return |
688 |
if (!exists()) |
688 |
if (!exists()) |
689 |
return; |
689 |
return; |
690 |
workspace.beginOperation(true); |
690 |
workspace.beginOperation(true); |
|
|
691 |
broadcastPreProjectDelete(); |
691 |
final IFileStore originalStore = getStore(); |
692 |
final IFileStore originalStore = getStore(); |
692 |
boolean wasLinked = isLinked(); |
693 |
boolean wasLinked = isLinked(); |
693 |
message = Messages.resources_deleteProblem; |
694 |
message = Messages.resources_deleteProblem; |
694 |
MultiStatus status = new MultiStatus(ResourcesPlugin.PI_RESOURCES, IResourceStatus.FAILED_DELETE_LOCAL, message, null); |
695 |
MultiStatus status = new MultiStatus(ResourcesPlugin.PI_RESOURCES, IResourceStatus.FAILED_DELETE_LOCAL, message, null); |
695 |
WorkManager workManager = workspace.getWorkManager(); |
696 |
WorkManager workManager = workspace.getWorkManager(); |
Lines 1344-1353
Link Here
|
1344 |
workspace.prepareOperation(rule, monitor); |
1345 |
workspace.prepareOperation(rule, monitor); |
1345 |
// The following assert method throws CoreExceptions as stated in the IResource.move API |
1346 |
// The following assert method throws CoreExceptions as stated in the IResource.move API |
1346 |
// and assert for programming errors. See checkMoveRequirements for more information. |
1347 |
// and assert for programming errors. See checkMoveRequirements for more information. |
1347 |
assertMoveRequirements(destination, getType(), updateFlags); |
1348 |
assertMoveRequirements(destination, getType(), updateFlags); |
1348 |
workspace.beginOperation(true); |
1349 |
workspace.beginOperation(true); |
|
|
1350 |
broadCastPreMove(destResource, updateFlags); |
1349 |
IFileStore originalStore = getStore(); |
1351 |
IFileStore originalStore = getStore(); |
1350 |
message = Messages.resources_moveProblem; |
1352 |
message = Messages.resources_moveProblem; |
1351 |
MultiStatus status = new MultiStatus(ResourcesPlugin.PI_RESOURCES, IStatus.ERROR, message, null); |
1353 |
MultiStatus status = new MultiStatus(ResourcesPlugin.PI_RESOURCES, IStatus.ERROR, message, null); |
1352 |
WorkManager workManager = workspace.getWorkManager(); |
1354 |
WorkManager workManager = workspace.getWorkManager(); |
1353 |
ResourceTree tree = new ResourceTree(workspace.getFileSystemManager(), workManager.getLock(), status, updateFlags); |
1355 |
ResourceTree tree = new ResourceTree(workspace.getFileSystemManager(), workManager.getLock(), status, updateFlags); |
Lines 1645-1655
Link Here
|
1645 |
|
1647 |
|
1646 |
/** |
1648 |
/** |
1647 |
* Calls the move/delete hook to perform the deletion. Since this method calls |
1649 |
* Calls the move/delete hook to perform the deletion. Since this method calls |
1648 |
* client code, it is run "unprotected", so the workspace lock is not held. |
1650 |
* client code, it is run "unprotected", so the workspace lock is not held. |
1649 |
*/ |
1651 |
*/ |
1650 |
private void unprotectedDelete(ResourceTree tree, int updateFlags, IProgressMonitor monitor) throws CoreException { |
1652 |
private void unprotectedDelete(ResourceTree tree, int updateFlags, IProgressMonitor monitor) { |
1651 |
IMoveDeleteHook hook = workspace.getMoveDeleteHook(); |
1653 |
IMoveDeleteHook hook = workspace.getMoveDeleteHook(); |
1652 |
switch (getType()) { |
1654 |
switch (getType()) { |
1653 |
case IResource.FILE : |
1655 |
case IResource.FILE : |
1654 |
if (!hook.deleteFile(tree, (IFile) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / 2))) |
1656 |
if (!hook.deleteFile(tree, (IFile) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / 2))) |
1655 |
tree.standardDeleteFile((IFile) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000)); |
1657 |
tree.standardDeleteFile((IFile) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000)); |
Lines 1657-1707
Link Here
|
1657 |
case IResource.FOLDER : |
1659 |
case IResource.FOLDER : |
1658 |
if (!hook.deleteFolder(tree, (IFolder) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / 2))) |
1660 |
if (!hook.deleteFolder(tree, (IFolder) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / 2))) |
1659 |
tree.standardDeleteFolder((IFolder) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000)); |
1661 |
tree.standardDeleteFolder((IFolder) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000)); |
1660 |
break; |
1662 |
break; |
1661 |
case IResource.PROJECT : |
1663 |
case IResource.PROJECT : |
1662 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_DELETE, this)); |
|
|
1663 |
if (!hook.deleteProject(tree, (IProject) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / 2))) |
1664 |
if (!hook.deleteProject(tree, (IProject) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / 2))) |
1664 |
tree.standardDeleteProject((IProject) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000)); |
1665 |
tree.standardDeleteProject((IProject) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000)); |
1665 |
break; |
1666 |
break; |
1666 |
case IResource.ROOT : |
1667 |
case IResource.ROOT : |
1667 |
IProject[] projects = ((IWorkspaceRoot) this).getProjects(); |
1668 |
IProject[] projects = ((IWorkspaceRoot) this).getProjects(); |
1668 |
for (int i = 0; i < projects.length; i++) { |
1669 |
for (int i = 0; i < projects.length; i++) { |
1669 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_DELETE, projects[i])); |
|
|
1670 |
if (!hook.deleteProject(tree, projects[i], updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / projects.length / 2))) |
1670 |
if (!hook.deleteProject(tree, projects[i], updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / projects.length / 2))) |
1671 |
tree.standardDeleteProject(projects[i], updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / projects.length)); |
1671 |
tree.standardDeleteProject(projects[i], updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / projects.length)); |
1672 |
} |
1672 |
} |
1673 |
} |
1673 |
} |
1674 |
} |
1674 |
} |
1675 |
|
1675 |
|
|
|
1676 |
private void broadcastPreProjectDelete() throws CoreException { |
1677 |
switch (getType()) { |
1678 |
case IResource.PROJECT : |
1679 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_DELETE, this)); |
1680 |
break; |
1681 |
case IResource.ROOT : |
1682 |
IProject[] projects = ((IWorkspaceRoot) this).getProjects(); |
1683 |
for (int i = 0; i < projects.length; i++) { |
1684 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_DELETE, projects[i])); |
1685 |
} |
1686 |
} |
1687 |
} |
1688 |
|
1676 |
/** |
1689 |
/** |
1677 |
* Calls the move/delete hook to perform the move. Since this method calls |
1690 |
* Calls the move/delete hook to perform the move. Since this method calls |
1678 |
* client code, it is run "unprotected", so the workspace lock is not held. |
1691 |
* client code, it is run "unprotected", so the workspace lock is not held. |
1679 |
* Returns true if resources were actually moved, and false otherwise. |
1692 |
* Returns true if resources were actually moved, and false otherwise. |
1680 |
*/ |
1693 |
*/ |
1681 |
private boolean unprotectedMove(ResourceTree tree, final IResource destination, int updateFlags, IProgressMonitor monitor) throws CoreException, ResourceException { |
1694 |
private boolean unprotectedMove(ResourceTree tree, final IResource destination, int updateFlags, IProgressMonitor monitor) throws CoreException, ResourceException { |
1682 |
IMoveDeleteHook hook = workspace.getMoveDeleteHook(); |
1695 |
IMoveDeleteHook hook = workspace.getMoveDeleteHook(); |
1683 |
switch (getType()) { |
1696 |
switch (getType()) { |
1684 |
case IResource.FILE : |
1697 |
case IResource.FILE : |
1685 |
if (isLinked()) |
|
|
1686 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_LINK_MOVE, this, destination, updateFlags)); |
1687 |
if (!hook.moveFile(tree, (IFile) this, (IFile) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2))) |
1698 |
if (!hook.moveFile(tree, (IFile) this, (IFile) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2))) |
1688 |
tree.standardMoveFile((IFile) this, (IFile) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork)); |
1699 |
tree.standardMoveFile((IFile) this, (IFile) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork)); |
1689 |
break; |
1700 |
break; |
1690 |
case IResource.FOLDER : |
1701 |
case IResource.FOLDER : |
1691 |
if (isLinked()) |
|
|
1692 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_LINK_MOVE, this, destination, updateFlags)); |
1693 |
if (!hook.moveFolder(tree, (IFolder) this, (IFolder) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2))) |
1702 |
if (!hook.moveFolder(tree, (IFolder) this, (IFolder) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2))) |
1694 |
tree.standardMoveFolder((IFolder) this, (IFolder) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork)); |
1703 |
tree.standardMoveFolder((IFolder) this, (IFolder) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork)); |
1695 |
break; |
1704 |
break; |
1696 |
case IResource.PROJECT : |
1705 |
case IResource.PROJECT : |
1697 |
IProject project = (IProject) this; |
1706 |
IProject project = (IProject) this; |
1698 |
// if there is no change in name, there is nothing to do so return. |
1707 |
// if there is no change in name, there is nothing to do so return. |
1699 |
if (getName().equals(destination.getName())) |
1708 |
if (getName().equals(destination.getName())) |
1700 |
return false; |
1709 |
return false; |
1701 |
//we are deleting the source project so notify. |
|
|
1702 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_MOVE, this, destination, updateFlags)); |
1703 |
IProjectDescription description = project.getDescription(); |
1710 |
IProjectDescription description = project.getDescription(); |
1704 |
description.setName(destination.getName()); |
1711 |
description.setName(destination.getName()); |
1705 |
if (!hook.moveProject(tree, project, description, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2))) |
1712 |
if (!hook.moveProject(tree, project, description, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2))) |
1706 |
tree.standardMoveProject(project, description, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork)); |
1713 |
tree.standardMoveProject(project, description, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork)); |
1707 |
break; |
1714 |
break; |
Lines 1709-1714
Link Here
|
1709 |
String msg = Messages.resources_moveRoot; |
1716 |
String msg = Messages.resources_moveRoot; |
1710 |
throw new ResourceException(new ResourceStatus(IResourceStatus.INVALID_VALUE, getFullPath(), msg)); |
1717 |
throw new ResourceException(new ResourceStatus(IResourceStatus.INVALID_VALUE, getFullPath(), msg)); |
1711 |
} |
1718 |
} |
1712 |
return true; |
1719 |
return true; |
1713 |
} |
1720 |
} |
|
|
1721 |
|
1722 |
private void broadCastPreMove(final IResource destination, int updateFlags) throws CoreException { |
1723 |
switch (getType()) { |
1724 |
case IResource.FILE : |
1725 |
if (isLinked()) |
1726 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_LINK_MOVE, this, destination, updateFlags)); |
1727 |
break; |
1728 |
case IResource.FOLDER : |
1729 |
if (isLinked()) |
1730 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_LINK_MOVE, this, destination, updateFlags)); |
1731 |
break; |
1732 |
case IResource.PROJECT : |
1733 |
if (!getName().equals(destination.getName())) { |
1734 |
// if there is a change in name, we are deleting the source project so notify. |
1735 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_MOVE, this, destination, updateFlags)); |
1736 |
} |
1737 |
break; |
1738 |
} |
1739 |
} |
1714 |
} |
1740 |
} |