Search in sources :

Example 1 with LocalResource

use of org.tigris.subversion.subclipse.core.resources.LocalResource in project subclipse by subclipse.

the class MarkMergedSynchronizeOperation method run.

protected void run(SVNTeamProvider provider, SyncInfoSet set, final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    final IResource[] resources = set.getResources();
    run(new WorkspaceModifyOperation() {

        protected void execute(IProgressMonitor mon) throws CoreException, InvocationTargetException, InterruptedException {
            for (int i = 0; i < resources.length; i++) {
                File tempFile = null;
                try {
                    tempFile = copyToTempFile(resources[i]);
                } catch (Exception e) {
                    SVNUIPlugin.log(e.getMessage());
                    showErrorMessage(e);
                    return;
                }
                if (monitor.isCanceled()) {
                    if (tempFile != null)
                        tempFile.delete();
                    return;
                }
                ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
                if (svnResource instanceof LocalResource)
                    ((LocalResource) svnResource).revert(false);
                else
                    svnResource.revert();
                new UpdateOperation(getPart(), resources[i], SVNRevision.HEAD).run(monitor);
                if (monitor.isCanceled()) {
                    if (tempFile != null)
                        tempFile.delete();
                    return;
                }
                File file = new File(resources[i].getLocation().toString());
                try {
                    copy(tempFile, file);
                } catch (Exception e1) {
                    SVNUIPlugin.log(e1.getMessage());
                    showErrorMessage(e1);
                }
                if (tempFile != null)
                    tempFile.delete();
            }
        }
    }, true, /* cancelable */
    PROGRESS_BUSYCURSOR);
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) UpdateOperation(org.tigris.subversion.subclipse.ui.operations.UpdateOperation) File(java.io.File) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) LocalResource(org.tigris.subversion.subclipse.core.resources.LocalResource)

Aggregations

File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IResource (org.eclipse.core.resources.IResource)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 WorkspaceModifyOperation (org.eclipse.ui.actions.WorkspaceModifyOperation)1 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)1 LocalResource (org.tigris.subversion.subclipse.core.resources.LocalResource)1 UpdateOperation (org.tigris.subversion.subclipse.ui.operations.UpdateOperation)1