KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.eclipse.core.runtime.IProgressMonitor;
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.jface.action.IAction;
16 import org.eclipse.team.internal.ccvs.core.CVSException;
17 import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
18 import org.eclipse.team.internal.ccvs.ui.Policy;
19 import org.eclipse.ui.IWorkbenchPart;
20
21 public abstract class CheckoutOperation extends RemoteOperation {
22
23     public CheckoutOperation(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders) {
24         super(part, remoteFolders);
25     }
26
27     /* (non-Javadoc)
28      * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
29      */

30     public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException JavaDoc {
31         ICVSRemoteFolder[] folders = getRemoteFolders();
32         checkout(folders, monitor);
33     }
34     
35     /**
36      * This method invokes <code>checkout(ICVSRemoteFolder, IProgressMonitor)</code>
37      * for each remote folder of the operation.
38      * @param folders the remote folders for the operation
39      * @param monitor the progress monitor
40      * @throws CVSException if an error occured that should prevent the remaining
41      * folders from being checked out
42      */

43     protected void checkout(ICVSRemoteFolder[] folders, IProgressMonitor monitor) throws CVSException {
44         monitor.beginTask(null, folders.length * 100);
45         for (int i = 0; i < folders.length; i++) {
46             ICVSRemoteFolder folder = folders[i];
47             IStatus result = checkout(folder, Policy.subMonitorFor(monitor, 100));
48             collectStatus(result);
49             Policy.checkCanceled(monitor);
50         }
51         monitor.done();
52     }
53
54     protected ICVSRemoteFolder[] getRemoteFolders() {
55         return (ICVSRemoteFolder[])getRemoteResources();
56     }
57     
58     /**
59      * Checkout the selected remote folders in a form appropriate for the operation subclass.
60      * @param folders
61      * @param monitor
62      */

63     protected abstract IStatus checkout(ICVSRemoteFolder folder, IProgressMonitor monitor) throws CVSException;
64     
65     /* (non-Javadoc)
66      * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#canRunAsJob()
67      */

68     public boolean canRunAsJob() {
69         return true;
70     }
71     
72     /* (non-Javadoc)
73      * @see org.eclipse.team.ui.TeamOperation#isKeepOneProgressServiceEntry()
74      */

75     public boolean isKeepOneProgressServiceEntry() {
76         // Keep the last repository provider operation in the progress service
77
return true;
78     }
79     
80     /* (non-Javadoc)
81      * @see org.eclipse.team.ui.TeamOperation#getGotoAction()
82      */

83     protected IAction getGotoAction() {
84         return getShowConsoleAction();
85     }
86 }
87
Popular Tags