Lines 692-697
Link Here
|
692 |
if (!exists()) |
692 |
if (!exists()) |
693 |
return; |
693 |
return; |
694 |
workspace.beginOperation(true); |
694 |
workspace.beginOperation(true); |
|
|
695 |
broadcastPreDeleteEvent(); |
695 |
final IFileStore originalStore = getStore(); |
696 |
final IFileStore originalStore = getStore(); |
696 |
boolean wasLinked = isLinked(); |
697 |
boolean wasLinked = isLinked(); |
697 |
message = Messages.resources_deleteProblem; |
698 |
message = Messages.resources_deleteProblem; |
Lines 1397-1402
Link Here
|
1397 |
// and assert for programming errors. See checkMoveRequirements for more information. |
1398 |
// and assert for programming errors. See checkMoveRequirements for more information. |
1398 |
assertMoveRequirements(destination, getType(), updateFlags); |
1399 |
assertMoveRequirements(destination, getType(), updateFlags); |
1399 |
workspace.beginOperation(true); |
1400 |
workspace.beginOperation(true); |
|
|
1401 |
broadcastPreMoveEvent(destResource, updateFlags); |
1400 |
IFileStore originalStore = getStore(); |
1402 |
IFileStore originalStore = getStore(); |
1401 |
message = Messages.resources_moveProblem; |
1403 |
message = Messages.resources_moveProblem; |
1402 |
MultiStatus status = new MultiStatus(ResourcesPlugin.PI_RESOURCES, IStatus.ERROR, message, null); |
1404 |
MultiStatus status = new MultiStatus(ResourcesPlugin.PI_RESOURCES, IStatus.ERROR, message, null); |
Lines 1713-1719
Link Here
|
1713 |
tree.standardDeleteFolder((IFolder) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000)); |
1715 |
tree.standardDeleteFolder((IFolder) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000)); |
1714 |
break; |
1716 |
break; |
1715 |
case IResource.PROJECT : |
1717 |
case IResource.PROJECT : |
1716 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_DELETE, this)); |
|
|
1717 |
if (!hook.deleteProject(tree, (IProject) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / 2))) |
1718 |
if (!hook.deleteProject(tree, (IProject) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / 2))) |
1718 |
tree.standardDeleteProject((IProject) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000)); |
1719 |
tree.standardDeleteProject((IProject) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000)); |
1719 |
break; |
1720 |
break; |
Lines 1725-1731
Link Here
|
1725 |
System.arraycopy(roots, 0, projects, 0, roots.length); |
1726 |
System.arraycopy(roots, 0, projects, 0, roots.length); |
1726 |
|
1727 |
|
1727 |
for (int i = 0; i < projects.length; i++) { |
1728 |
for (int i = 0; i < projects.length; i++) { |
1728 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_DELETE, projects[i])); |
|
|
1729 |
if (!hook.deleteProject(tree, projects[i], updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / projects.length / 2))) |
1729 |
if (!hook.deleteProject(tree, projects[i], updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / projects.length / 2))) |
1730 |
tree.standardDeleteProject(projects[i], updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / projects.length)); |
1730 |
tree.standardDeleteProject(projects[i], updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / projects.length)); |
1731 |
} |
1731 |
} |
Lines 1741-1754
Link Here
|
1741 |
IMoveDeleteHook hook = workspace.getMoveDeleteHook(); |
1741 |
IMoveDeleteHook hook = workspace.getMoveDeleteHook(); |
1742 |
switch (getType()) { |
1742 |
switch (getType()) { |
1743 |
case IResource.FILE : |
1743 |
case IResource.FILE : |
1744 |
if (isLinked()) |
|
|
1745 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_LINK_MOVE, this, destination, updateFlags)); |
1746 |
if (!hook.moveFile(tree, (IFile) this, (IFile) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2))) |
1744 |
if (!hook.moveFile(tree, (IFile) this, (IFile) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2))) |
1747 |
tree.standardMoveFile((IFile) this, (IFile) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork)); |
1745 |
tree.standardMoveFile((IFile) this, (IFile) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork)); |
1748 |
break; |
1746 |
break; |
1749 |
case IResource.FOLDER : |
1747 |
case IResource.FOLDER : |
1750 |
if (isLinked()) |
|
|
1751 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_LINK_MOVE, this, destination, updateFlags)); |
1752 |
if (!hook.moveFolder(tree, (IFolder) this, (IFolder) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2))) |
1748 |
if (!hook.moveFolder(tree, (IFolder) this, (IFolder) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2))) |
1753 |
tree.standardMoveFolder((IFolder) this, (IFolder) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork)); |
1749 |
tree.standardMoveFolder((IFolder) this, (IFolder) destination, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork)); |
1754 |
break; |
1750 |
break; |
Lines 1757-1764
Link Here
|
1757 |
// if there is no change in name, there is nothing to do so return. |
1753 |
// if there is no change in name, there is nothing to do so return. |
1758 |
if (getName().equals(destination.getName())) |
1754 |
if (getName().equals(destination.getName())) |
1759 |
return false; |
1755 |
return false; |
1760 |
//we are deleting the source project so notify. |
|
|
1761 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_MOVE, this, destination, updateFlags)); |
1762 |
IProjectDescription description = project.getDescription(); |
1756 |
IProjectDescription description = project.getDescription(); |
1763 |
description.setName(destination.getName()); |
1757 |
description.setName(destination.getName()); |
1764 |
if (!hook.moveProject(tree, project, description, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2))) |
1758 |
if (!hook.moveProject(tree, project, description, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2))) |
Lines 1770-1773
Link Here
|
1770 |
} |
1764 |
} |
1771 |
return true; |
1765 |
return true; |
1772 |
} |
1766 |
} |
|
|
1767 |
|
1768 |
private void broadcastPreDeleteEvent() throws CoreException { |
1769 |
switch (getType()) { |
1770 |
case IResource.PROJECT : |
1771 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_DELETE, this)); |
1772 |
break; |
1773 |
case IResource.ROOT : |
1774 |
// when the root is deleted, all its children including hidden projects |
1775 |
// have to be deleted |
1776 |
IResource[] roots = ((Container) this).getChildren(IContainer.INCLUDE_HIDDEN); |
1777 |
IProject[] projects = new IProject[roots.length]; |
1778 |
System.arraycopy(roots, 0, projects, 0, roots.length); |
1779 |
for (int i = 0; i < projects.length; i++) { |
1780 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_DELETE, projects[i])); |
1781 |
} |
1782 |
} |
1783 |
} |
1784 |
|
1785 |
private void broadcastPreMoveEvent(final IResource destination, int updateFlags) throws CoreException { |
1786 |
switch (getType()) { |
1787 |
case IResource.FILE : |
1788 |
if (isLinked()) |
1789 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_LINK_MOVE, this, destination, updateFlags)); |
1790 |
break; |
1791 |
case IResource.FOLDER : |
1792 |
if (isLinked()) |
1793 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_LINK_MOVE, this, destination, updateFlags)); |
1794 |
break; |
1795 |
case IResource.PROJECT : |
1796 |
if (!getName().equals(destination.getName())) { |
1797 |
// if there is a change in name, we are deleting the source project so notify. |
1798 |
workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_MOVE, this, destination, updateFlags)); |
1799 |
} |
1800 |
break; |
1801 |
} |
1802 |
} |
1773 |
} |
1803 |
} |