|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2006 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 11-43
Link Here
|
| 11 |
package org.eclipse.team.internal.ccvs.ui.subscriber; |
11 |
package org.eclipse.team.internal.ccvs.ui.subscriber; |
| 12 |
|
12 |
|
| 13 |
import java.lang.reflect.InvocationTargetException; |
13 |
import java.lang.reflect.InvocationTargetException; |
| 14 |
import java.util.ArrayList; |
14 |
import java.util.*; |
| 15 |
import java.util.HashSet; |
|
|
| 16 |
import java.util.List; |
| 17 |
import java.util.Set; |
| 18 |
|
15 |
|
| 19 |
import org.eclipse.compare.structuremergeviewer.IDiffElement; |
16 |
import org.eclipse.compare.structuremergeviewer.IDiffElement; |
| 20 |
import org.eclipse.core.resources.*; |
17 |
import org.eclipse.core.resources.*; |
|
|
18 |
import org.eclipse.core.resources.mapping.ResourceMapping; |
| 19 |
import org.eclipse.core.resources.mapping.ResourceMappingContext; |
| 20 |
import org.eclipse.core.runtime.CoreException; |
| 21 |
import org.eclipse.core.runtime.IProgressMonitor; |
21 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
|
22 |
import org.eclipse.core.runtime.jobs.ISchedulingRule; |
| 23 |
import org.eclipse.core.runtime.jobs.MultiRule; |
| 22 |
import org.eclipse.jface.dialogs.MessageDialog; |
24 |
import org.eclipse.jface.dialogs.MessageDialog; |
| 23 |
import org.eclipse.osgi.util.NLS; |
25 |
import org.eclipse.osgi.util.NLS; |
| 24 |
import org.eclipse.team.core.TeamException; |
26 |
import org.eclipse.team.core.TeamException; |
| 25 |
import org.eclipse.team.core.synchronize.FastSyncInfoFilter; |
27 |
import org.eclipse.team.core.mapping.provider.SynchronizationScopeManager; |
| 26 |
import org.eclipse.team.core.synchronize.SyncInfo; |
28 |
import org.eclipse.team.core.synchronize.*; |
| 27 |
import org.eclipse.team.core.synchronize.SyncInfoSet; |
29 |
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.*; |
| 28 |
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.AndSyncInfoFilter; |
|
|
| 29 |
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.OrSyncInfoFilter; |
| 30 |
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter; |
| 31 |
import org.eclipse.team.core.variants.IResourceVariant; |
30 |
import org.eclipse.team.core.variants.IResourceVariant; |
| 32 |
import org.eclipse.team.internal.ccvs.core.CVSException; |
31 |
import org.eclipse.team.internal.ccvs.core.*; |
| 33 |
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; |
|
|
| 34 |
import org.eclipse.team.internal.ccvs.core.ICVSFile; |
| 35 |
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; |
32 |
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; |
| 36 |
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; |
33 |
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; |
|
|
34 |
import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer; |
| 37 |
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; |
35 |
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; |
| 38 |
import org.eclipse.team.internal.ccvs.ui.*; |
36 |
import org.eclipse.team.internal.ccvs.ui.*; |
| 39 |
import org.eclipse.team.internal.ccvs.ui.operations.UpdateOnlyMergableOperation; |
37 |
import org.eclipse.team.internal.ccvs.ui.Policy; |
|
|
38 |
import org.eclipse.team.internal.ccvs.ui.operations.*; |
| 40 |
import org.eclipse.team.internal.ui.TeamUIPlugin; |
39 |
import org.eclipse.team.internal.ui.TeamUIPlugin; |
|
|
40 |
import org.eclipse.team.internal.ui.Utils; |
| 41 |
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; |
41 |
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; |
| 42 |
|
42 |
|
| 43 |
/** |
43 |
/** |
|
Lines 64-69
Link Here
|
| 64 |
public boolean shouldRun() { |
64 |
public boolean shouldRun() { |
| 65 |
return promptIfNeeded(); |
65 |
return promptIfNeeded(); |
| 66 |
} |
66 |
} |
|
|
67 |
|
| 68 |
/** |
| 69 |
* Run the operation for the sync infos from the given project. |
| 70 |
* |
| 71 |
* @param projectSyncInfos the project syncInfos |
| 72 |
* @param project the project |
| 73 |
* @param monitor a progress monitor |
| 74 |
* @throws InvocationTargetException |
| 75 |
*/ |
| 76 |
protected void run(final Map projectSyncInfos, final IProject project, |
| 77 |
IProgressMonitor monitor) throws InvocationTargetException { |
| 78 |
try { |
| 79 |
IResource[] resources = getIResourcesFrom(((SyncInfoSet) projectSyncInfos |
| 80 |
.get(project)).getSyncInfos()); |
| 81 |
ResourceMapping[] selectedMappings = Utils |
| 82 |
.getResourceMappings(resources); |
| 83 |
ResourceMappingContext context = new SingleProjectSubscriberContext( |
| 84 |
CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(), |
| 85 |
false, project); |
| 86 |
SynchronizationScopeManager manager = new SingleProjectScopeManager( |
| 87 |
getJobName(), selectedMappings, context, true, project); |
| 88 |
manager.initialize(null); |
| 89 |
|
| 90 |
// Pass the scheduling rule to the synchronizer so that sync change |
| 91 |
// events and cache commits to disk are batched |
| 92 |
EclipseSynchronizer.getInstance().run(getUpdateRule(manager), |
| 93 |
new ICVSRunnable() { |
| 94 |
public void run(IProgressMonitor monitor) |
| 95 |
throws CVSException { |
| 96 |
try { |
| 97 |
runWithProjectRule(project, |
| 98 |
(SyncInfoSet) projectSyncInfos |
| 99 |
.get(project), monitor); |
| 100 |
} catch (TeamException e) { |
| 101 |
throw CVSException.wrapException(e); |
| 102 |
} |
| 103 |
} |
| 104 |
}, Policy.subMonitorFor(monitor, 100)); |
| 105 |
} catch (TeamException e) { |
| 106 |
throw new InvocationTargetException(e); |
| 107 |
} catch (CoreException e) { |
| 108 |
throw new InvocationTargetException(e); |
| 109 |
} |
| 110 |
} |
| 111 |
|
| 112 |
private ISchedulingRule getUpdateRule(SynchronizationScopeManager manager) { |
| 113 |
ISchedulingRule rule = null; |
| 114 |
ResourceMapping[] mappings = manager.getScope().getMappings(); |
| 115 |
for (int i = 0; i < mappings.length; i++) { |
| 116 |
ResourceMapping mapping = mappings[i]; |
| 117 |
IProject[] mappingProjects = mapping.getProjects(); |
| 118 |
for (int j = 0; j < mappingProjects.length; j++) { |
| 119 |
if (rule == null) { |
| 120 |
rule = mappingProjects[j]; |
| 121 |
} else { |
| 122 |
rule = MultiRule.combine(rule, mappingProjects[j]); |
| 123 |
} |
| 124 |
} |
| 125 |
} |
| 126 |
return rule; |
| 127 |
} |
| 67 |
|
128 |
|
| 68 |
/* (non-Javadoc) |
129 |
/* (non-Javadoc) |
| 69 |
* @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#run(org.eclipse.core.runtime.IProgressMonitor) |
130 |
* @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#run(org.eclipse.core.runtime.IProgressMonitor) |