blob: 762d3ee8ec0381ac568ca6545a9c09c963f61f33 (
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
63
64
65
66
|
/*******************************************************************************
* Copyright (c) 2006, 2009 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.examples.filesystem.ui;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.examples.filesystem.FileSystemPlugin;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.actions.ActionDelegate;
public class ShowHistoryAction extends ActionDelegate implements IObjectActionDelegate {
IStructuredSelection fSelection;
public void run(IAction action) {
final Shell shell = Display.getDefault().getActiveShell();
try {
new ProgressMonitorDialog(shell).run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
final IResource resource = (IResource) fSelection.getFirstElement();
Runnable r = new Runnable() {
public void run() {
TeamUI.showHistoryFor(TeamUIPlugin.getActivePage(), resource, null);
}
};
FileSystemPlugin.getStandardDisplay().asyncExec(r);
}
});
} catch (InvocationTargetException exception) {
// ignore
} catch (InterruptedException exception) {
// ignore
}
}
public void selectionChanged(IAction action, ISelection sel) {
if (sel instanceof IStructuredSelection) {
fSelection = (IStructuredSelection) sel;
}
}
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
// do nothing
}
}
|