blob: 44306594044f4dac68ffbb6e3b36aa28c587b2f9 (
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
package org.eclipse.debug.internal.ui.actions;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import org.eclipse.debug.internal.ui.DebugPluginImages;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
import org.eclipse.debug.internal.ui.LaunchHistoryElement;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.help.WorkbenchHelp;
/**
* Re-runs or re-debugs the last launch.
*/
public class RelaunchLastAction extends Action implements IWorkbenchWindowActionDelegate {
/**
* When this action is created as a delegate, this flag indicates
* whether the workbench presentation has had its associated
* images set.
*/
private boolean fInitializedImages = false;
public RelaunchLastAction() {
WorkbenchHelp.setHelp(
this,
new Object[] { IDebugHelpContextIds.RELAUNCH_LAST_ACTION });
setActionImages(this);
}
/**
* @see IAction
*/
public void run() {
final LaunchHistoryElement recent= DebugUIPlugin.getDefault().getLastLaunch();
if (recent == null) {
Display.getCurrent().beep();
} else {
if (!DebugUIPlugin.saveAndBuild()) {
return;
}
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
RelaunchActionDelegate.relaunch(recent);
}
});
}
}
/**
* @see IWorkbenchWindowActionDelegate
*/
public void dispose(){
}
/**
* @see IWorkbenchWindowActionDelegate
*/
public void init(IWorkbenchWindow window){
}
/**
* @see IActionDelegate
*/
public void run(IAction action){
run();
}
/**
* @see IActionDelegate
*/
public void selectionChanged(IAction action, ISelection selection){
setActionImages(action);
}
protected void setActionImages(IAction action) {
if (!fInitializedImages ) {
action.setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_RELAUNCH));
action.setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_RELAUNCH));
action.setImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_RELAUNCH));
// only set the flag to true when setting images
// for the associated workbench presentation
fInitializedImages = action != this;
}
}
}
|