blob: 1a7f48ccf9533246da8f6dc9d87098347743dc9b (
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
|
/*******************************************************************************
* Copyright (C) 2007, David Watson <dwatson@mimvista.com>
* Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
*
* 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.egit.ui.Activator;
import org.eclipse.egit.ui.internal.history.GitHistoryPage;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.history.IHistoryPage;
import org.eclipse.team.ui.history.IHistoryView;
/**
* Compare the resources filtered in the history view with the current revision.
*/
public class CompareWithRevisionActionHandler extends RepositoryActionHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
IHistoryView view = TeamUI.showHistoryFor(getPartPage(event),
getSelectedResources(event)[0], null);
if (view == null)
return null;
IHistoryPage page = view.getHistoryPage();
if (page instanceof GitHistoryPage) {
GitHistoryPage gitHistoryPage = (GitHistoryPage) page;
gitHistoryPage.setCompareMode(true);
}
return null;
}
public boolean isEnabled() {
try {
return !getSelection(null).isEmpty();
} catch (ExecutionException e) {
Activator.handleError(e.getMessage(), e, false);
return false;
}
}
}
|