Git Repositories View: Simple fetch and push
[egit.git] / org.eclipse.egit.ui / src / org / eclipse / egit / ui / internal / actions / Track.java
blob0d5eb6605e88fdfe56f20d9cde0c8d8f54857c50
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;
23 /**
24 * An action to add resources to the Git repository.
26 * @see TrackOperation
28 public class Track extends RepositoryAction {
30 @Override
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) {
35 @Override
36 protected IStatus run(IProgressMonitor monitor) {
37 try {
38 op.execute(monitor);
39 } catch (CoreException e) {
40 return Activator.createErrorStatus(e.getStatus()
41 .getMessage(), e);
43 return Status.OK_STATUS;
46 job.setRule(op.getSchedulingRule());
47 job.setUser(true);
48 job.schedule();
51 @Override
52 public boolean isEnabled() {
53 return getSelectedAdaptables(getSelection(), IResource.class).length > 0;