blob: e13d230a390f898dd90565c80c920de50c07d929 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/*******************************************************************************
* Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
*
* 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
*******************************************************************************/
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;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
/**
* An action to show the history for a resource.
*/
public class ShowHistoryActionHandler extends RepositoryActionHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
IHistoryView view;
try {
view = (IHistoryView) PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage().showView(
IHistoryView.VIEW_ID);
IResource[] resources = getSelectedResources(event);
if (resources.length == 1) {
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) {
throw new ExecutionException(e.getMessage(), e);
}
return null;
}
@Override
public boolean isEnabled() {
return !getSelection().isEmpty();
}
}
|