/*******************************************************************************
 * Copyright (c) 2005, 2006 Subclipse project and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Subclipse project committers - initial API and implementation
 ******************************************************************************/
package org.tigris.subversion.subclipse.core.commands;

import java.util.LinkedHashSet;
import java.util.Set;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.tigris.subversion.subclipse.core.SVNException;
import org.tigris.subversion.subclipse.core.client.OperationManager;
import org.tigris.subversion.subclipse.core.resources.SVNWorkspaceRoot;
import org.tigris.subversion.svnclientadapter.ISVNClientAdapter;
import org.tigris.subversion.svnclientadapter.SVNClientException;

/**
 * Remove stale transactions and locks from the working copy.  This operation can only be run
 * on folders.
 */
public class CleanupResourcesCommand implements ISVNCommand {

    private final SVNWorkspaceRoot root;
    private final IResource[] resources;
    private Set<IResource> cleanedUpResources = new LinkedHashSet<IResource>();

    public CleanupResourcesCommand(SVNWorkspaceRoot root, IResource[] resources) {
        this.root = root;
        this.resources = resources;
        
    }
    
    /* (non-Javadoc)
     * @see org.tigris.subversion.subclipse.core.commands.ISVNCommand#run(org.eclipse.core.runtime.IProgressMonitor)
     */
    public void run(IProgressMonitor monitor) throws SVNException {
    	ISVNClientAdapter svnClient = root.getRepository().getSVNClient();
        try {
            monitor.beginTask(null, 100 * resources.length);            
            OperationManager.getInstance().beginOperation(svnClient);           
            for (int i = 0; i < resources.length; i++) {
                svnClient.cleanup(resources[i].getLocation().toFile());
                cleanedUpResources.add(resources[i]);
                monitor.worked(100);
            }
        } catch (SVNClientException e) {
            throw SVNException.wrapException(e);
        } finally {
    		Set<IResource> refreshResources = new LinkedHashSet<IResource>();
    		for (IResource resource : cleanedUpResources) {
    			refreshResources.add(resource);
    			OperationManager.getInstance().onNotify(resource.getLocation().toFile(), null);
    		}
    		OperationManager.getInstance().endOperation(true, refreshResources);
            root.getRepository().returnSVNClient(svnClient);
            monitor.done();
        }
    } 
}

@@ -694,24 +694,117 @@
 ources.I
-Resource
+Container;%0Aimport org.eclipse.core.resources.IResource;%0Aimport org.eclipse.core.runtime.CoreException
 ;%0Aimport
@@ -2621,124 +2621,51 @@
  %09%09%09
-refreshResources.add(resource);%0A    %09%09%09OperationManager.getInstance().onNotify(resource.getLocation().toFile(), null
+addToRefreshList(refreshResources, resource
 );%0A 
@@ -2845,17 +2845,510 @@
       %7D%0A
-
     %7D
+%0A%0A%09private void addToRefreshList(Set%3CIResource%3E refreshResources, IResource resource) %7B%0A%09%09refreshResources.add(resource);%0A%09%09OperationManager.getInstance().onNotify(resource.getLocation().toFile(), null);%0A%09%09if (resource instanceof IContainer) %7B%0A%09%09%09try %7B%0A%09%09%09%09IResource%5B%5D children = ((IContainer)resource).members();%0A%09%09%09%09for (IResource child : children) %7B%0A%09%09%09%09%09if (child instanceof IContainer) %7B%0A%09%09%09%09%09%09addToRefreshList(refreshResources, child);%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D catch (CoreException e) %7B%7D%0A%09%09%7D%0A%09%7D
  %0A%7D%0A

Fix local refresh of subfolders after Cleanup.