Search in sources :

Example 1 with InfiniteSubProgressMonitor

use of org.tigris.subversion.subclipse.core.internal.InfiniteSubProgressMonitor in project subclipse by subclipse.

the class UnmanageAction method getOperation.

/**
 * get the WorkspaceModifyOperation. The operation will : - delete svn directories if this option
 * has been chosen - unmap the project
 *
 * @return
 */
private IRunnableWithProgress getOperation() {
    return new WorkspaceModifyOperation() {

        public void execute(IProgressMonitor monitor) throws InvocationTargetException {
            try {
                // maps the selected resources (projects) to their providers
                Hashtable table = getProviderMapping(getSelectedResources());
                Set keySet = table.keySet();
                // $NON-NLS-1$
                monitor.beginTask("", keySet.size() * 1000);
                // $NON-NLS-1$
                monitor.setTaskName(Policy.bind("Unmanage.unmanaging"));
                Iterator iterator = keySet.iterator();
                while (iterator.hasNext()) {
                    IProgressMonitor subMonitor = new InfiniteSubProgressMonitor(monitor, 1000);
                    subMonitor.beginTask(null, 100);
                    SVNTeamProvider provider = (SVNTeamProvider) iterator.next();
                    // get the resources (projects) to unmanage for the given provider
                    List list = (List) table.get(provider);
                    IResource[] providerResources = (IResource[]) list.toArray(new IResource[list.size()]);
                    for (int i = 0; i < providerResources.length; i++) {
                        // get the folder for the project
                        IResource resource = providerResources[i];
                        ISVNLocalFolder folder = SVNWorkspaceRoot.getSVNFolderFor((IContainer) resource);
                        try {
                            if (deleteContent) {
                                folder.unmanage(Policy.subMonitorFor(subMonitor, 10));
                            }
                        } finally {
                            // We want to remove the nature even if the unmanage operation fails
                            RepositoryProvider.unmap((IProject) resource);
                        }
                    }
                }
            } catch (TeamException e) {
                throw new InvocationTargetException(e);
            } finally {
                monitor.done();
            }
        }
    };
}
Also used : Set(java.util.Set) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) Hashtable(java.util.Hashtable) InvocationTargetException(java.lang.reflect.InvocationTargetException) ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder) TeamException(org.eclipse.team.core.TeamException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) InfiniteSubProgressMonitor(org.tigris.subversion.subclipse.core.internal.InfiniteSubProgressMonitor) Iterator(java.util.Iterator) List(java.util.List) IResource(org.eclipse.core.resources.IResource)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Hashtable (java.util.Hashtable)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Set (java.util.Set)1 IResource (org.eclipse.core.resources.IResource)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 TeamException (org.eclipse.team.core.TeamException)1 WorkspaceModifyOperation (org.eclipse.ui.actions.WorkspaceModifyOperation)1 ISVNLocalFolder (org.tigris.subversion.subclipse.core.ISVNLocalFolder)1 SVNTeamProvider (org.tigris.subversion.subclipse.core.SVNTeamProvider)1 InfiniteSubProgressMonitor (org.tigris.subversion.subclipse.core.internal.InfiniteSubProgressMonitor)1