1 11 package org.eclipse.team.internal.ccvs.ui.mappings; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 import org.eclipse.core.resources.IResource; 17 import org.eclipse.core.resources.ResourcesPlugin; 18 import org.eclipse.core.resources.mapping.ResourceMapping; 19 import org.eclipse.core.runtime.*; 20 import org.eclipse.team.core.mapping.ISynchronizationContext; 21 import org.eclipse.team.core.mapping.provider.SynchronizationContext; 22 import org.eclipse.team.core.subscribers.SubscriberScopeManager; 23 import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; 24 import org.eclipse.team.internal.ccvs.core.ICVSResource; 25 import org.eclipse.team.internal.ccvs.core.client.PruneFolderVisitor; 26 import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; 27 import org.eclipse.team.internal.ccvs.ui.*; 28 import org.eclipse.team.internal.core.mapping.CompoundResourceTraversal; 29 import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant; 30 import org.eclipse.ui.IWorkbenchPart; 31 32 public class ModelUpdateOperation extends AbstractModelMergeOperation { 33 34 public ModelUpdateOperation(IWorkbenchPart targetPart, ResourceMapping[] selectedResourceMappings, boolean consultModels) { 35 this(targetPart, WorkspaceSubscriberContext.createUpdateScopeManager(selectedResourceMappings, consultModels)); 36 } 37 38 public ModelUpdateOperation(IWorkbenchPart targetPart, ResourceMapping[] resourceMappings) { 39 this(targetPart, resourceMappings, true); 40 } 41 42 public ModelUpdateOperation(IWorkbenchPart targetPart, SubscriberScopeManager manager) { 43 super(targetPart, manager, true); 44 } 45 46 49 protected String getJobName() { 50 return CVSUIMessages.UpdateOperation_taskName; 51 } 52 53 56 public boolean isPreviewRequested() { 57 return super.isPreviewRequested() || !isAttemptHeadlessMerge(); 58 } 59 60 protected boolean isAttemptHeadlessMerge() { 61 return CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_UPDATE_HANDLING).equals(ICVSUIConstants.PREF_UPDATE_HANDLING_PERFORM); 62 } 63 64 68 protected int getMergeType() { 69 return ISynchronizationContext.THREE_WAY; 70 } 71 72 75 protected ModelSynchronizeParticipant createParticipant() { 76 return new WorkspaceModelParticipant(createMergeContext()); 77 } 78 79 82 protected SynchronizationContext createMergeContext() { 83 return WorkspaceSubscriberContext.createContext(getScopeManager(), getMergeType()); 84 } 85 86 protected void executeMerge(IProgressMonitor monitor) throws CoreException { 87 super.executeMerge(monitor); 88 if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories()) { 90 CompoundResourceTraversal ct = new CompoundResourceTraversal(); 91 ct.addTraversals(getContext().getScope().getTraversals()); 92 IResource[] roots = ct.getRoots(); 93 List cvsResources = new ArrayList (); 94 for (int i = 0; i < roots.length; i++) { 95 IResource resource = roots[i]; 96 if (resource.getProject().isAccessible()) { 97 cvsResources.add(CVSWorkspaceRoot.getCVSResourceFor(roots[i])); 98 } 99 } 100 new PruneFolderVisitor().visit( 101 CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot()), 102 (ICVSResource[]) cvsResources.toArray(new ICVSResource[cvsResources.size()])); 103 } 104 } 105 } 106 | Popular Tags |