KickJava   Java API By Example, From Geeks To Geeks.

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


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.resources.*;
14 import org.eclipse.core.runtime.IProgressMonitor;
15 import org.eclipse.core.runtime.jobs.ISchedulingRule;
16 import org.eclipse.osgi.util.NLS;
17 import org.eclipse.team.core.RepositoryProvider;
18 import org.eclipse.team.core.TeamException;
19 import org.eclipse.team.internal.ccvs.core.*;
20 import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
21 import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
22 import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
23 import org.eclipse.ui.IWorkbenchPart;
24
25 /**
26  * Disconnect the given projects from CVS control
27  */

28 public class DisconnectOperation extends RepositoryProviderOperation {
29
30     private boolean unmanage;
31
32     public DisconnectOperation(IWorkbenchPart part, IProject[] projects, boolean unmanage) {
33         super(part, projects);
34         this.unmanage = unmanage;
35     }
36
37     /* (non-Javadoc)
38      * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#execute(org.eclipse.team.internal.ccvs.core.CVSTeamProvider, org.eclipse.core.resources.IResource[], org.eclipse.core.runtime.IProgressMonitor)
39      */

40     protected void execute(
41         CVSTeamProvider provider,
42         IResource[] resources,
43         boolean recurse, IProgressMonitor monitor)
44         throws CVSException, InterruptedException JavaDoc {
45         
46         // This method will be invoked for each provider being disconnected
47
monitor.beginTask(null, IProgressMonitor.UNKNOWN);
48         IProject project = provider.getProject();
49         try {
50             RepositoryProvider.unmap(project);
51         } catch (TeamException e) {
52             throw CVSException.wrapException(e);
53         }
54         if (unmanage) {
55             ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(project);
56             cvsFolder.unmanage(monitor);
57             EclipseSynchronizer.getInstance().deconfigure(project, Policy.subMonitorFor(monitor, IProgressMonitor.UNKNOWN));
58         }
59         monitor.done();
60     }
61
62     /* (non-Javadoc)
63      * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName()
64      */

65     protected String JavaDoc getTaskName() {
66         return CVSUIMessages.DisconnectOperation_0;
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.DisconnectOperation_1, new String JavaDoc[] { provider.getProject().getName() });
74     }
75     
76     /* (non-Javadoc)
77      * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#canRunAsJob()
78      */

79     public boolean canRunAsJob() {
80         // Do not run in the background
81
return false;
82     }
83     
84     /* (non-Javadoc)
85      * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#consultModelsForMappings()
86      */

87     public boolean consultModelsForMappings() {
88         return false;
89     }
90     
91     /* (non-Javadoc)
92      * @see org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation#getSchedulingRule(org.eclipse.team.internal.ccvs.core.CVSTeamProvider)
93      */

94     protected ISchedulingRule getSchedulingRule(CVSTeamProvider provider) {
95         return ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(provider.getProject());
96     }
97
98 }
99
Popular Tags