From 93542938156ab130b81d5e73450ad2a6c9eca6e9 Mon Sep 17 00:00:00 2001 From: Robin Rosenberg Date: Sun, 1 Jun 2008 23:45:20 +0200 Subject: [PATCH] Add a Track toolbar icon for adding resources We already had a track action, but it was only available in the team menu. I had to choose a different handler baseclass for this to work. Signed-off-by: Robin Rosenberg --- org.spearce.egit.ui/icons/toolbar/trackd.png | Bin 0 -> 387 bytes org.spearce.egit.ui/icons/toolbar/tracke.png | Bin 0 -> 411 bytes org.spearce.egit.ui/plugin.properties | 2 +- org.spearce.egit.ui/plugin.xml | 11 +++++ .../spearce/egit/ui/internal/actions/Track.java | 45 +++++++++++++++++---- 5 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 org.spearce.egit.ui/icons/toolbar/trackd.png create mode 100644 org.spearce.egit.ui/icons/toolbar/tracke.png diff --git a/org.spearce.egit.ui/icons/toolbar/trackd.png b/org.spearce.egit.ui/icons/toolbar/trackd.png new file mode 100644 index 0000000000000000000000000000000000000000..1ae9b5abd05c69681dd34485336f366772d530b4 GIT binary patch literal 387 zcwPa60et?6P)Nkls&L=Xg8wPjLODQ5P4-&$1#V6|GQh^UAt zKz3flWHR{{7!HS0%vxM$$yt$#jbtMO%;)pm2$1$*u~_KobYeD}F`Z7e+wC$QkH3Vn zc^ZCq0#c_=1c>siAm^*E* zg3IN?Znwj69M0!6Ns@3l9B8##0QkOd?MW)2s&qOX+U+)tMuU32PP5r0Ns?c@6qUc6 zB0m$C6DWf!fH8*6W<$T<=YGF)JRaHa_gt^nautk5BevUZ&S8wfah!hz$NVI h%hchzuJs`m@dBk;vWC9IYJva&002ovPDHLkV1m>)t&RWy literal 0 HcwPel00001 diff --git a/org.spearce.egit.ui/icons/toolbar/tracke.png b/org.spearce.egit.ui/icons/toolbar/tracke.png new file mode 100644 index 0000000000000000000000000000000000000000..b06c26581caef5b7bcd0e2f5f49840a0d47835e7 GIT binary patch literal 411 zcwPaU0c8G(P)`<%X@v+yo2*5-CdHPT%9d* zdAcB_TqbY}ZZd!lP{<}_Z*3mgIH5lkrPr>a>J+Olz^$5MM3g5MNwAW7}u|)t3!w5W+p@8%uva*jJ+d&IA z(59=Xa0QCZal9ck0PmIm=3}11sK9@q1K2f + + diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/Track.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/Track.java index 7622ee4e..e4de70c1 100644 --- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/Track.java +++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/Track.java @@ -8,20 +8,51 @@ *******************************************************************************/ package org.spearce.egit.ui.internal.actions; -import java.util.List; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; -import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; import org.spearce.egit.core.op.TrackOperation; /** * An action to add resources to the Git repository. - * + * * @see TrackOperation */ -public class Track extends AbstractOperationAction { - protected IWorkspaceRunnable createOperation(final IAction act, - final List sel) { - return sel.isEmpty() ? null : new TrackOperation(sel); +public class Track extends RepositoryAction { + + @Override + public void run(IAction action) { + try { + final TrackOperation op = new TrackOperation(Arrays + .asList(getSelectedResources())); + getTargetPart().getSite().getWorkbenchWindow().run(true, false, + new IRunnableWithProgress() { + public void run(IProgressMonitor arg0) + throws InvocationTargetException, + InterruptedException { + try { + op.run(arg0); + } catch (CoreException e) { + MessageDialog.openError(getShell(), + "Track failed", e.getMessage()); + } + } + }); + } catch (InvocationTargetException e) { + MessageDialog.openError(getShell(), "Track failed", e.getMessage()); + } catch (InterruptedException e) { + MessageDialog.openError(getShell(), "Track failed", e.getMessage()); + } + } + + @Override + public boolean isEnabled() { + return getSelectedAdaptables(getSelection(), IResource.class).length > 0; } } -- 2.11.4.GIT