1 /*******************************************************************************
2 * Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9 package org
.eclipse
.egit
.core
.op
;
11 import java
.util
.Collection
;
13 import org
.eclipse
.core
.resources
.IContainer
;
14 import org
.eclipse
.core
.resources
.IProject
;
15 import org
.eclipse
.core
.resources
.IResource
;
16 import org
.eclipse
.core
.resources
.IWorkspaceRunnable
;
17 import org
.eclipse
.core
.runtime
.CoreException
;
18 import org
.eclipse
.core
.runtime
.IAdaptable
;
19 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
20 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
21 import org
.eclipse
.core
.runtime
.SubProgressMonitor
;
22 import org
.eclipse
.egit
.core
.Activator
;
23 import org
.eclipse
.egit
.core
.CoreText
;
24 import org
.eclipse
.team
.core
.RepositoryProvider
;
27 * Disconnects the Git team provider from a project.
29 * Once disconnected, Git operations will no longer be available on the project.
32 public class DisconnectProviderOperation
implements IWorkspaceRunnable
{
33 private final Collection projectList
;
36 * Create a new disconnect operation.
39 * the collection of {@link IProject}s which should be
40 * disconnected from the Git team provider, and returned to
41 * untracked/unmanaged status.
43 public DisconnectProviderOperation(final Collection projs
) {
47 public void run(IProgressMonitor m
) throws CoreException
{
49 m
= new NullProgressMonitor();
52 m
.beginTask(CoreText
.DisconnectProviderOperation_disconnecting
,
53 projectList
.size() * 200);
55 for (Object obj
: projectList
) {
56 obj
= ((IAdaptable
)obj
).getAdapter(IResource
.class);
57 if (obj
instanceof IProject
) {
58 final IProject p
= (IProject
) obj
;
60 Activator
.trace("disconnect " + p
.getName());
62 RepositoryProvider
.unmap(p
);
65 p
.refreshLocal(IResource
.DEPTH_INFINITE
,
66 new SubProgressMonitor(m
, 100));
76 private void unmarkTeamPrivate(final IContainer p
) throws CoreException
{
78 c
= p
.members(IContainer
.INCLUDE_TEAM_PRIVATE_MEMBERS
);
80 for (int k
= 0; k
< c
.length
; k
++) {
81 if (c
[k
] instanceof IContainer
) {
82 unmarkTeamPrivate((IContainer
) c
[k
]);
84 if (c
[k
].isTeamPrivateMember()) {
85 Activator
.trace("notTeamPrivate " + c
[k
]);
86 c
[k
].setTeamPrivateMember(false);