Package org.eclipse.core.resources.team

Examples of org.eclipse.core.resources.team.IMoveDeleteHook


  /**
   * Calls the move/delete hook to perform the deletion.  Since this method calls
   * client code, it is run "unprotected", so the workspace lock is not held. 
   */
  private void unprotectedDelete(ResourceTree tree, int updateFlags, IProgressMonitor monitor) throws CoreException {
    IMoveDeleteHook hook = workspace.getMoveDeleteHook();
    switch (getType()) {
      case IResource.FILE :
        if (!hook.deleteFile(tree, (IFile) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / 2)))
          tree.standardDeleteFile((IFile) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000));
        break;
      case IResource.FOLDER :
        if (!hook.deleteFolder(tree, (IFolder) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / 2)))
          tree.standardDeleteFolder((IFolder) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000));
        break;
      case IResource.PROJECT :
        workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_DELETE, this));
        if (!hook.deleteProject(tree, (IProject) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / 2)))
          tree.standardDeleteProject((IProject) this, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000));
        break;
      case IResource.ROOT :
        IProject[] projects = ((IWorkspaceRoot) this).getProjects();
        for (int i = 0; i < projects.length; i++) {
          workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_DELETE, projects[i]));
          if (!hook.deleteProject(tree, projects[i], updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / projects.length / 2)))
            tree.standardDeleteProject(projects[i], updateFlags, Policy.subMonitorFor(monitor, Policy.opWork * 1000 / projects.length));
        }
    }
  }
View Full Code Here


   * 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));
View Full Code Here

        workspace.beginOperation(true);
        message = Messages.resources_moveProblem;
        MultiStatus status = new MultiStatus(ResourcesPlugin.PI_RESOURCES, IStatus.ERROR, message, null);
        WorkManager workManager = workspace.getWorkManager();
        ResourceTree tree = new ResourceTree(getLocalManager(), workManager.getLock(), status, updateFlags);
        IMoveDeleteHook hook = workspace.getMoveDeleteHook();
        workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_MOVE, this, destination, updateFlags));
        int depth = 0;
        try {
          depth = workManager.beginUnprotected();
          if (!hook.moveProject(tree, this, description, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2)))
            tree.standardMoveProject(this, description, updateFlags, Policy.subMonitorFor(monitor, Policy.opWork / 2));
        } finally {
          workManager.endUnprotected(depth);
        }
        // Invalidate the tree for further use by clients.
View Full Code Here

TOP

Related Classes of org.eclipse.core.resources.team.IMoveDeleteHook

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.