KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > operations > OverrideAndUpdateOperation


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ccvs.ui.operations;
12
13 import java.util.Arrays JavaDoc;
14 import java.util.HashSet JavaDoc;
15 import java.util.Set JavaDoc;
16
17 import org.eclipse.core.resources.IProject;
18 import org.eclipse.core.resources.IResource;
19 import org.eclipse.core.resources.mapping.ResourceMappingContext;
20 import org.eclipse.team.core.mapping.provider.SynchronizationScopeManager;
21 import org.eclipse.team.internal.ccvs.core.*;
22 import org.eclipse.ui.IWorkbenchPart;
23
24 /**
25  * A specialized Replace operation that will update managed resources and
26  * unmanaged resources that are conflicting additions (so that the remote is fetched)
27  */

28 public class OverrideAndUpdateOperation extends ReplaceOperation {
29
30     private IResource[] conflictingAdditions;
31     private final IProject project;
32
33     public OverrideAndUpdateOperation(IWorkbenchPart part, IProject project, IResource[] allResources, IResource[] conflictingAdditions, CVSTag tag, boolean recurse) {
34         super(part, allResources, tag, recurse);
35         this.project = project;
36         this.conflictingAdditions = conflictingAdditions;
37     }
38
39     /* (non-Javadoc)
40      * @see org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation#getResourcesToUpdate(org.eclipse.team.internal.ccvs.core.ICVSResource[])
41      */

42     protected ICVSResource[] getResourcesToUpdate(ICVSResource[] resources) throws CVSException {
43         // Add the conflicting additions to the list of resources to update
44
Set JavaDoc update = new HashSet JavaDoc();
45         ICVSResource[] conflicts = getCVSArguments(conflictingAdditions);
46         update.addAll(Arrays.asList(conflicts));
47         update.addAll(Arrays.asList(super.getResourcesToUpdate(resources)));
48         return (ICVSResource[]) update.toArray(new ICVSResource[update.size()]);
49     }
50     
51     /* (non-Javadoc)
52      * @see org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation#getResourceMappingContext()
53      */

54     protected ResourceMappingContext getResourceMappingContext() {
55         return new SingleProjectSubscriberContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(), false, project);
56     }
57     
58     protected SynchronizationScopeManager createScopeManager(boolean consultModels) {
59         return new SingleProjectScopeManager(getJobName(), getSelectedMappings(), getResourceMappingContext(), consultModels, project);
60     }
61
62 }
63
Popular Tags