blob: de35f8b72622b6cb596e21c881cc2194c079787d (
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
|
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.debug.internal.ui.views.console;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.internal.ui.DebugPluginImages;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ILabelProvider;
/**
* Sets the console to display output for a specific process.
*/
public class ShowProcessAction extends Action {
private ConsoleView fView;
private IProcess fProcess;
/**
* Constructor for ShowProcessAction.
*/
public ShowProcessAction(ConsoleView view, IProcess process) {
fView = view;
fProcess = process;
IDebugTarget target = (IDebugTarget)process.getAdapter(IDebugTarget.class);
ImageDescriptor imageDescriptor = null;
String label = null;
ILabelProvider labelProvider = DebugUIPlugin.getDefaultLabelProvider();
if (target == null) {
if (process.isTerminated()) {
imageDescriptor = DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_OBJS_OS_PROCESS_TERMINATED);
} else {
imageDescriptor = DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_OBJS_OS_PROCESS);
}
label = labelProvider.getText(process);
} else {
if (target.isTerminated() || target.isDisconnected()) {
imageDescriptor = DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_TERMINATED);
} else {
imageDescriptor = DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_OBJS_DEBUG_TARGET);
}
label = labelProvider.getText(target);
}
setImageDescriptor(imageDescriptor);
// prefix label with launch name
ILaunch launch = process.getLaunch();
if (launch != null) {
ILaunchConfiguration configuration = launch.getLaunchConfiguration();
if (configuration != null) {
StringBuffer buffer = new StringBuffer();
buffer.append('[');
buffer.append(configuration.getName());
buffer.append("] "); //$NON-NLS-1$
buffer.append(label);
label = buffer.toString();
}
}
setText(label);
}
/**
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
fView.setMode(ConsoleView.MODE_SPECIFIC_PROCESS);
fView.setViewerInput(fProcess);
}
}
|