diff options
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ShowHistoryActionHandler.java')
-rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ShowHistoryActionHandler.java | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ShowHistoryActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ShowHistoryActionHandler.java index e13d230a39..8a0315c101 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ShowHistoryActionHandler.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ShowHistoryActionHandler.java @@ -1,18 +1,20 @@ /******************************************************************************* - * Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com> + * Copyright (C) 2010, 2012 Mathias Kinzler <mathias.kinzler@sap.com> and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Mathias Kinzler - initial version + * François Rey - refactoring as part of gracefully ignoring linked resources *******************************************************************************/ package org.eclipse.egit.ui.internal.actions; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IResource; -import org.eclipse.egit.core.project.RepositoryMapping; -import org.eclipse.egit.ui.UIText; import org.eclipse.egit.ui.internal.history.HistoryPageInput; import org.eclipse.jgit.lib.Repository; import org.eclipse.team.ui.history.IHistoryView; @@ -24,6 +26,10 @@ import org.eclipse.ui.PlatformUI; */ public class ShowHistoryActionHandler extends RepositoryActionHandler { public Object execute(ExecutionEvent event) throws ExecutionException { + final Repository repo = getRepository(true, event); + // assert all resources map to the same repository + if (repo == null) + return null; IHistoryView view; try { view = (IHistoryView) PlatformUI.getWorkbench() @@ -34,19 +40,6 @@ public class ShowHistoryActionHandler extends RepositoryActionHandler { view.showHistoryFor(resources[0]); return null; } - - Repository repo = null; - for (IResource res : resources) { - RepositoryMapping map = RepositoryMapping.getMapping(res); - if (repo == null) - repo = map.getRepository(); - if (repo != map.getRepository()) - // we need to make sure are resources are from the same - // Repository - throw new ExecutionException( - UIText.AbstractHistoryCommanndHandler_NoUniqueRepository); - - } HistoryPageInput list = new HistoryPageInput(repo, resources); view.showHistoryFor(list); } catch (PartInitException e) { @@ -57,6 +50,6 @@ public class ShowHistoryActionHandler extends RepositoryActionHandler { @Override public boolean isEnabled() { - return !getSelection().isEmpty(); + return selectionMapsToSingleRepository(); } } |