Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 03ce62031ffee43ec5f8f28518a1c483940c9e6f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.operations;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.action.IAction;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.ui.IWorkbenchPart;

public abstract class CheckoutOperation extends RemoteOperation {

	public CheckoutOperation(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders) {
		super(part, remoteFolders);
	}

	@Override
	public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException {
		ICVSRemoteFolder[] folders = getRemoteFolders();
		checkout(folders, monitor);
	}
	
	/**
	 * This method invokes <code>checkout(ICVSRemoteFolder, IProgressMonitor)</code>
	 * for each remote folder of the operation.
	 * @param folders the remote folders for the operation
	 * @param monitor the progress monitor
	 * @throws CVSException if an error occured that should prevent the remaining
	 * folders from being checked out
	 */
	protected void checkout(ICVSRemoteFolder[] folders, IProgressMonitor monitor) throws CVSException {
		monitor.beginTask(null, folders.length * 100);
		for (int i = 0; i < folders.length; i++) {
			ICVSRemoteFolder folder = folders[i];
			IStatus result = checkout(folder, Policy.subMonitorFor(monitor, 100));
			collectStatus(result);
			Policy.checkCanceled(monitor);
		}
		monitor.done();
	}

	protected ICVSRemoteFolder[] getRemoteFolders() {
		return (ICVSRemoteFolder[])getRemoteResources();
	}
	
	/**
	 * Checkout the selected remote folders in a form appropriate for the operation subclass.
	 * @param folders
	 * @param monitor
	 */
	protected abstract IStatus checkout(ICVSRemoteFolder folder, IProgressMonitor monitor)  throws CVSException;
	
	@Override
	public boolean canRunAsJob() {
		return true;
	}
	
	@Override
    public boolean isKeepOneProgressServiceEntry() {
        // Keep the last repository provider operation in the progress service
        return true;
    }
    
	@Override
    protected IAction getGotoAction() {
        return getShowConsoleAction();
    }
}

Back to the top