From: Robin Rosenberg Date: Mon, 09 Jun 2008 22:50:16 GMT Subject: [PATCH] Add a Track toolbar icon for adding resources Message-ID: <1213051816-4046-8-git-send-email-robin.rosenberg.lists@dewire.com> In-Reply-To: <1213051816-4046-7-git-send-email-robin.rosenberg.lists@dewire.com> From: Robin Rosenberg 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 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 zcmV-}0et?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 HcmV?d00001 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 zcmV;M0c8G(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 7622ee4..6588cca 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,10 +8,15 @@ *******************************************************************************/ 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; /** @@ -19,9 +24,32 @@ import org.spearce.egit.core.op.TrackOperation; * * @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(),"Reset failed", e.getMessage()); + } catch (InterruptedException e) { + MessageDialog.openError(getShell(),"Reset failed", e.getMessage()); + } + } + + @Override + public boolean isEnabled() { + return getSelectedAdaptables(getSelection(), IResource.class).length > 0; } } -- 1.5.5.1.178.g1f811