blob: b67450d5e544ff450c75cd827a572b8bb29e7aa6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.internal.ui.actions;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard;
/**
* Action for configuring a project. Configuring involves associating
* the project with a Team provider and performing any provider-specific
* configuration that is necessary.
*/
public class ConfigureProjectAction extends TeamAction {
@Override
protected void execute(IAction action) throws InvocationTargetException,
InterruptedException {
run(new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
if (!isEnabled())
return;
IProject[] projects = getSelectedProjects();
ConfigureProjectWizard.shareProjects(getShell(), projects);
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
}, TeamUIMessages.ConfigureProjectAction_configureProject, PROGRESS_BUSYCURSOR);
}
/**
* @see TeamAction#isEnabled()
*/
@Override
public boolean isEnabled() {
IProject[] selectedProjects = getSelectedProjects();
for (int i = 0; i < selectedProjects.length; i++) {
IProject project = selectedProjects[i];
if (!project.isAccessible()) return false;
if (RepositoryProvider.isShared(project)) return false;
}
return selectedProjects.length > 0;
}
}
|