1 /*******************************************************************************
2 * Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
3 * Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * which accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
9 *******************************************************************************/
10 package org
.eclipse
.egit
.ui
.internal
.actions
;
12 import org
.eclipse
.core
.resources
.IResource
;
13 import org
.eclipse
.core
.runtime
.CoreException
;
14 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
15 import org
.eclipse
.core
.runtime
.IStatus
;
16 import org
.eclipse
.core
.runtime
.Status
;
17 import org
.eclipse
.core
.runtime
.jobs
.Job
;
18 import org
.eclipse
.egit
.core
.op
.TrackOperation
;
19 import org
.eclipse
.egit
.ui
.Activator
;
20 import org
.eclipse
.egit
.ui
.UIText
;
21 import org
.eclipse
.jface
.action
.IAction
;
24 * An action to add resources to the Git repository.
28 public class Track
extends RepositoryAction
{
31 public void execute(IAction action
) {
32 final TrackOperation op
= new TrackOperation(getSelectedResources());
33 String jobname
= UIText
.Track_addToVersionControl
;
34 Job job
= new Job(jobname
) {
36 protected IStatus
run(IProgressMonitor monitor
) {
39 } catch (CoreException e
) {
40 return Activator
.createErrorStatus(e
.getStatus()
43 return Status
.OK_STATUS
;
46 job
.setRule(op
.getSchedulingRule());
52 public boolean isEnabled() {
53 return getSelectedAdaptables(getSelection(), IResource
.class).length
> 0;