blob: 777167a50aceb3aa362ec25ae5a092908bc396a9 (
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*******************************************************************************
* Copyright (c) 2000, 2006 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.debug.internal.ui.commands.actions;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.ILaunchesListener2;
import org.eclipse.debug.internal.ui.DebugPluginImages;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
import org.eclipse.debug.internal.ui.actions.ActionMessages;
import org.eclipse.debug.internal.ui.commands.provisional.ITerminateCommand;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IWorkbenchPart;
/**
* Terminates all launches.
*
* @since 3.3
*/
public class TerminateAllAction extends DebugCommandAction implements ILaunchesListener2 {
protected ISelection getContext() {
return new StructuredSelection(getLaunchManager().getLaunches());
}
public void contextActivated(ISelection context, IWorkbenchPart part) {
// DO NOTHING
}
public void contextChanged(ISelection context, IWorkbenchPart part) {
// DO NOTHING
}
public void dispose() {
getLaunchManager().removeLaunchListener(this);
super.dispose();
}
public void init(IWorkbenchPart part) {
super.init(part);
ILaunchManager launchManager = getLaunchManager();
launchManager.addLaunchListener(this);
// heuristic... rather than updating all the time, just assume there's
// something that's not terminated.
setEnabled(launchManager.getLaunches().length > 0);
}
private ILaunchManager getLaunchManager() {
return DebugPlugin.getDefault().getLaunchManager();
}
public String getHelpContextId() {
return "terminate_all_action_context"; //$NON-NLS-1$
}
public String getId() {
return "org.eclipse.debug.ui.debugview.popupMenu.terminateAll"; //$NON-NLS-1$
}
public String getText() {
return ActionMessages.TerminateAllAction_2;
}
public String getToolTipText() {
return ActionMessages.TerminateAllAction_3;
}
public ImageDescriptor getDisabledImageDescriptor() {
return DebugPluginImages
.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_TERMINATE_ALL);
}
public ImageDescriptor getHoverImageDescriptor() {
return DebugPluginImages
.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_ALL);
}
public ImageDescriptor getImageDescriptor() {
return DebugPluginImages
.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_TERMINATE_ALL);
}
protected Class getCommandType() {
return ITerminateCommand.class;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchesListener2#launchesTerminated(org.eclipse.debug.core.ILaunch[])
*/
public void launchesTerminated(ILaunch[] launches) {
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchesListener#launchesAdded(org.eclipse.debug.core.ILaunch[])
*/
public void launchesAdded(ILaunch[] launches) {
setEnabled(true);
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchesListener#launchesChanged(org.eclipse.debug.core.ILaunch[])
*/
public void launchesChanged(ILaunch[] launches) {
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchesListener#launchesRemoved(org.eclipse.debug.core.ILaunch[])
*/
public void launchesRemoved(ILaunch[] launches) {
setEnabled(getLaunchManager().getLaunches().length > 0);
}
}
|