KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > actions > CheckoutAction


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  * Philippe Ombredanne - bug 84808
11  *******************************************************************************/

12 package org.eclipse.team.internal.ccvs.ui.actions;
13
14 import java.lang.reflect.InvocationTargetException JavaDoc;
15
16 import org.eclipse.jface.action.IAction;
17 import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
18 import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
19 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
20 import org.eclipse.team.internal.ccvs.ui.operations.CheckoutMultipleProjectsOperation;
21 import org.eclipse.team.internal.ccvs.ui.operations.ProjectMetaFileOperation;
22
23 /**
24  * Checkout a remote module into the workspace ensuring that the user is prompted for
25  * any overwrites that may occur.
26  */

27 public class CheckoutAction extends CVSAction {
28     
29     /* (non-Javadoc)
30      * @see org.eclipse.team.internal.ccvs.ui.actions.CVSAction#execute(org.eclipse.jface.action.IAction)
31      */

32     protected void execute(IAction action) throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
33         new CheckoutMultipleProjectsOperation(getTargetPart(), getSelectedRemoteFoldersWithProjectName(), null)
34             .run();
35     }
36     
37     /* (non-Javadoc)
38      * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
39      */

40    public boolean isEnabled() {
41        ICVSRemoteFolder[] folders = getSelectedRemoteFolders();
42        if (folders.length == 0) return false;
43        // only enabled when all folders are in the same repository
44
ICVSRepositoryLocation location = folders[0].getRepository();
45        for (int i = 1; i < folders.length; i++) {
46            ICVSRemoteFolder folder = folders[i];
47            if (!folder.getRepository().equals(location)) {
48                return false;
49            }
50        }
51        return true;
52    }
53
54     /**
55      * Get selected CVS remote folders, and add Project Description
56      * from metafile if available based on preferences settings
57      * @throws InterruptedException
58      * @throws InvocationTargetException
59      */

60     private ICVSRemoteFolder[] getSelectedRemoteFoldersWithProjectName() throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
61         ICVSRemoteFolder[] folders = getSelectedRemoteFolders();
62         if (CVSUIPlugin.getPlugin().isUseProjectNameOnCheckout()){
63             folders = ProjectMetaFileOperation.updateFoldersWithProjectName(getTargetPart(), folders);
64         }
65         return folders;
66     }
67 }
68
Popular Tags