KickJava   Java API By Example, From Geeks To Geeks.

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


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.ArrayList JavaDoc;
14 import java.util.Arrays JavaDoc;
15 import java.util.List JavaDoc;
16
17 import org.eclipse.core.resources.*;
18 import org.eclipse.core.resources.mapping.ResourceMappingContext;
19 import org.eclipse.core.runtime.IProgressMonitor;
20 import org.eclipse.core.runtime.IStatus;
21 import org.eclipse.osgi.util.NLS;
22 import org.eclipse.team.core.mapping.provider.SynchronizationScopeManager;
23 import org.eclipse.team.internal.ccvs.core.*;
24 import org.eclipse.team.internal.ccvs.core.client.*;
25 import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
26 import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
27 import org.eclipse.ui.IWorkbenchPart;
28
29 /**
30  * This operation performs an update that will only effect files
31  * that have no conflicts or automergable conflicts.
32  */

33 public class UpdateOnlyMergableOperation extends SingleCommandOperation {
34
35     List JavaDoc skippedFiles = new ArrayList JavaDoc();
36     private final IProject project;
37     
38     public UpdateOnlyMergableOperation(IWorkbenchPart part, IProject project, IResource[] resources, LocalOption[] localOptions) {
39         super(part, asResourceMappers(resources), localOptions);
40         this.project = project;
41     }
42
43     /* (non-Javadoc)
44      * @see org.eclipse.team.internal.ccvs.ui.operations.SingleCommandOperation#executeCommand(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
45      */

46     protected IStatus executeCommand(Session session, CVSTeamProvider provider, ICVSResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException JavaDoc {
47         UpdateMergableOnly update = new UpdateMergableOnly();
48         IStatus status = update.execute(
49             session,
50             Command.NO_GLOBAL_OPTIONS,
51             getLocalOptions(recurse),
52             resources,
53             null,
54             monitor);
55         if (status.getSeverity() != IStatus.ERROR) {
56             addSkippedFiles(update.getSkippedFiles());
57             return OK;
58         }
59         return status;
60     }
61     
62     /* (non-Javadoc)
63      * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName()
64      */

65     protected String JavaDoc getTaskName() {
66         return CVSUIMessages.UpdateOnlyMergeable_taskName;
67     }
68
69     /* (non-Javadoc)
70      * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getTaskName(org.eclipse.team.internal.ccvs.core.CVSTeamProvider)
71      */

72     protected String JavaDoc getTaskName(CVSTeamProvider provider) {
73         return NLS.bind(CVSUIMessages.UpdateOperation_0, new String JavaDoc[] { provider.getProject().getName() });
74     }
75     
76     protected void addSkippedFiles(IFile[] files) {
77         skippedFiles.addAll(Arrays.asList(files));
78     }
79     
80     public IFile[] getSkippedFiles() {
81         return (IFile[]) skippedFiles.toArray(new IFile[skippedFiles.size()]);
82     }
83     
84     /* (non-Javadoc)
85      * @see org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation#getResourceMappingContext()
86      */

87     protected ResourceMappingContext getResourceMappingContext() {
88         return new SingleProjectSubscriberContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(), false, project);
89     }
90     
91     protected SynchronizationScopeManager createScopeManager(boolean consultModels) {
92         return new SingleProjectScopeManager(getJobName(), getSelectedMappings(), getResourceMappingContext(), consultModels, project);
93     }
94 }
95
Popular Tags