/*******************************************************************************
 * 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.ui.internal.history.HistoryPageInput;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.team.ui.history.IHistoryView;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;

/**
 * An action to show the history for a resource.
 */
public class ShowHistoryActionHandler extends RepositoryActionHandler {
	@Override
	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 {
			IWorkbenchWindow activeWorkbenchWindow = HandlerUtil
					.getActiveWorkbenchWindow(event);
			if (activeWorkbenchWindow != null) {
				IWorkbenchPage page = activeWorkbenchWindow.getActivePage();
				if (page != null) {
					view = (IHistoryView) page.showView(IHistoryView.VIEW_ID);
					IResource[] resources = getSelectedResources(event);
					if (resources.length == 1) {
						view.showHistoryFor(resources[0]);
						return null;
					}
					HistoryPageInput list = new HistoryPageInput(repo,
							resources);
					view.showHistoryFor(list);
				}
			}
		} catch (PartInitException e) {
			throw new ExecutionException(e.getMessage(), e);
		}
		return null;
	}

	@Override
	public boolean isEnabled() {
		return selectionMapsToSingleRepository();
	}
}

@@ -100,17 +100,17 @@
 010, 201
-2
+6
  Mathias
@@ -544,16 +544,71 @@
 sources%0A
+ *   Thomas Wolf %3Cthomas.wolf@paranor.ch%3E - Bug 492336%0A
  *******
@@ -1556,29 +1556,8 @@
 %09%09%7D%0A
-%09%09IHistoryView view;%0A
 %09%09tr
@@ -1785,24 +1785,95 @@
 ull) %7B%0A%09%09%09%09%09
+IResource%5B%5D resources = getSelectedResources(event);%0A%09%09%09%09%09IHistoryView 
 view = (IHis
@@ -1886,16 +1886,24 @@
 ew) page
+%0A%09%09%09%09%09%09%09
 .showVie
@@ -1931,66 +1931,8 @@
 D);%0A
-%09%09%09%09%09IResource%5B%5D resources = getSelectedResources(event);%0A
 %09%09%09%09

Determine selected resources before opening history view