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 * See LICENSE for the full license text, also available.
7 *******************************************************************************/
8 package org
.spearce
.egit
.core
.op
;
10 import java
.util
.Collection
;
12 import org
.eclipse
.core
.resources
.IContainer
;
13 import org
.eclipse
.core
.resources
.IProject
;
14 import org
.eclipse
.core
.resources
.IResource
;
15 import org
.eclipse
.core
.resources
.IWorkspaceRunnable
;
16 import org
.eclipse
.core
.runtime
.CoreException
;
17 import org
.eclipse
.core
.runtime
.IAdaptable
;
18 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
19 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
20 import org
.eclipse
.core
.runtime
.SubProgressMonitor
;
21 import org
.eclipse
.team
.core
.RepositoryProvider
;
22 import org
.spearce
.egit
.core
.Activator
;
23 import org
.spearce
.egit
.core
.CoreText
;
26 * Disconnects the Git team provider from a project.
28 * Once disconnected, Git operations will no longer be available on the project.
31 public class DisconnectProviderOperation
implements IWorkspaceRunnable
{
32 private final Collection projectList
;
35 * Create a new disconnect operation.
38 * the collection of {@link IProject}s which should be
39 * disconnected from the Git team provider, and returned to
40 * untracked/unmanaged status.
42 public DisconnectProviderOperation(final Collection projs
) {
46 public void run(IProgressMonitor m
) throws CoreException
{
48 m
= new NullProgressMonitor();
51 m
.beginTask(CoreText
.DisconnectProviderOperation_disconnecting
,
52 projectList
.size() * 200);
54 for (Object obj
: projectList
) {
55 obj
= ((IAdaptable
)obj
).getAdapter(IResource
.class);
56 if (obj
instanceof IProject
) {
57 final IProject p
= (IProject
) obj
;
59 Activator
.trace("disconnect " + p
.getName());
61 RepositoryProvider
.unmap(p
);
64 p
.refreshLocal(IResource
.DEPTH_INFINITE
,
65 new SubProgressMonitor(m
, 100));
75 private void unmarkTeamPrivate(final IContainer p
) throws CoreException
{
77 c
= p
.members(IContainer
.INCLUDE_TEAM_PRIVATE_MEMBERS
);
79 for (int k
= 0; k
< c
.length
; k
++) {
80 if (c
[k
] instanceof IContainer
) {
81 unmarkTeamPrivate((IContainer
) c
[k
]);
83 if (c
[k
].isTeamPrivateMember()) {
84 Activator
.trace("notTeamPrivate " + c
[k
]);
85 c
[k
].setTeamPrivateMember(false);