Search in sources :

Example 1 with SVNLightweightDecorator

use of org.tigris.subversion.subclipse.ui.decorator.SVNLightweightDecorator in project subclipse by subclipse.

the class SwitchOperation method execute.

protected void execute(SVNTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws SVNException, InterruptedException {
    monitor.beginTask("Switch to Branch/Tag", resources.length);
    try {
        final List<IProject> projectList = new ArrayList<IProject>();
        for (int i = 0; i < resources.length; i++) {
            monitor.subTask("Switching " + resources[i].getName() + ". . .");
            SVNUrl svnUrl = (SVNUrl) urlMap.get(resources[i]);
            if (conflictResolver != null && conflictResolver instanceof SVNConflictResolver) {
                ((SVNConflictResolver) conflictResolver).setPart(getPart());
            }
            SVNWorkspaceSubscriber.getInstance().updateRemote(resources);
            SwitchToUrlCommand command = new SwitchToUrlCommand(provider.getSVNWorkspaceRoot(), resources[i], svnUrl, svnRevision);
            command.setDepth(depth);
            command.setSetDepth(setDepth);
            command.setIgnoreExternals(ignoreExternals);
            command.setForce(force);
            command.setIgnoreAncestry(ignoreAncestry);
            command.setConflictResolver(conflictResolver);
            command.run(monitor);
            monitor.worked(1);
            if (resources[i].getProject() != null && !projectList.contains(resources[i].getProject())) {
                projectList.add(resources[i].getProject());
            }
        }
        // Trigger lightweight refresh of decorators for project.  This is needed because refreshLocal
        // is not triggering a refresh for unchanged
        // resources in Project Explorer.
        Display.getDefault().asyncExec(new Runnable() {

            public void run() {
                SVNLightweightDecorator decorator = (SVNLightweightDecorator) SVNUIPlugin.getPlugin().getWorkbench().getDecoratorManager().getBaseLabelProvider(SVNUIPlugin.DECORATOR_ID);
                for (IProject project : projectList) {
                    decorator.refresh(project);
                }
            }
        });
    } catch (SVNException e) {
        if (e.operationInterrupted()) {
            showCancelledMessage();
        } else {
            collectStatus(e.getStatus());
        }
    } catch (TeamException e) {
        collectStatus(e.getStatus());
    } finally {
        monitor.done();
    }
}
Also used : TeamException(org.eclipse.team.core.TeamException) SwitchToUrlCommand(org.tigris.subversion.subclipse.core.commands.SwitchToUrlCommand) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ArrayList(java.util.ArrayList) SVNException(org.tigris.subversion.subclipse.core.SVNException) IProject(org.eclipse.core.resources.IProject) ISVNConflictResolver(org.tigris.subversion.svnclientadapter.ISVNConflictResolver) SVNConflictResolver(org.tigris.subversion.subclipse.ui.conflicts.SVNConflictResolver) SVNLightweightDecorator(org.tigris.subversion.subclipse.ui.decorator.SVNLightweightDecorator)

Aggregations

ArrayList (java.util.ArrayList)1 IProject (org.eclipse.core.resources.IProject)1 TeamException (org.eclipse.team.core.TeamException)1 SVNException (org.tigris.subversion.subclipse.core.SVNException)1 SwitchToUrlCommand (org.tigris.subversion.subclipse.core.commands.SwitchToUrlCommand)1 SVNConflictResolver (org.tigris.subversion.subclipse.ui.conflicts.SVNConflictResolver)1 SVNLightweightDecorator (org.tigris.subversion.subclipse.ui.decorator.SVNLightweightDecorator)1 ISVNConflictResolver (org.tigris.subversion.svnclientadapter.ISVNConflictResolver)1 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)1