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 * See LICENSE for the full license text, also available.
8 *******************************************************************************/
9 package org
.spearce
.egit
.ui
.internal
.actions
;
11 import java
.lang
.reflect
.InvocationTargetException
;
12 import java
.util
.Arrays
;
14 import org
.eclipse
.core
.resources
.IResource
;
15 import org
.eclipse
.core
.runtime
.CoreException
;
16 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
17 import org
.eclipse
.jface
.action
.IAction
;
18 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
19 import org
.eclipse
.jface
.operation
.IRunnableWithProgress
;
20 import org
.spearce
.egit
.core
.op
.TrackOperation
;
23 * An action to add resources to the Git repository.
27 public class Track
extends RepositoryAction
{
30 public void run(IAction action
) {
32 final TrackOperation op
= new TrackOperation(Arrays
33 .asList(getSelectedResources()));
34 getTargetPart().getSite().getWorkbenchWindow().run(true, false,
35 new IRunnableWithProgress() {
36 public void run(IProgressMonitor arg0
)
37 throws InvocationTargetException
,
38 InterruptedException
{
41 } catch (CoreException e
) {
42 MessageDialog
.openError(getShell(),
43 "Track failed", e
.getMessage());
47 } catch (InvocationTargetException e
) {
48 MessageDialog
.openError(getShell(), "Track failed", e
.getMessage());
49 } catch (InterruptedException e
) {
50 MessageDialog
.openError(getShell(), "Track failed", e
.getMessage());
55 public boolean isEnabled() {
56 return getSelectedAdaptables(getSelection(), IResource
.class).length
> 0;