Skip to content

Commit a02997e

Browse files
committed
Add UI to select if a terminal session should be allocated
Currently the user only has the option to choose to allocate a (text)console or not. This now adds a new option to allocate a terminal session for a run if the platforms terminal bundle is installed.
1 parent ccf00e8 commit a02997e

File tree

3 files changed

+78
-8
lines changed

3 files changed

+78
-8
lines changed

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public class LaunchConfigurationsMessages extends NLS {
4848
public static String CommonTab_20;
4949
public static String CommonTab_21;
5050
public static String CommonTab_22;
51+
52+
public static String CommonTab_23;
53+
54+
public static String CommonTab_24;
5155
public static String CommonTab_3;
5256
public static String CommonTab_4;
5357
public static String CommonTab_5;
@@ -66,6 +70,8 @@ public class LaunchConfigurationsMessages extends NLS {
6670
public static String CommonTab_AttributeLabel_FavoriteGroups;
6771
public static String CommonTab_AttributeLabel_TerminateDescendants;
6872

73+
public static String CommonTab_disable_console_input;
74+
6975
public static String CompileErrorProjectPromptStatusHandler_0;
7076
public static String CompileErrorProjectPromptStatusHandler_1;
7177
public static String CompileErrorPromptStatusHandler_0;

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ CommonTab_2=Defa&ult - inherited from project and workspace ({0})
4141
CommonTab_22=Use &system encoding ({0})
4242
CommonTab_20=Variables...
4343
CommonTab_21=&Merge standard and error output (disables coloring of error output)
44+
CommonTab_23=Allocate Terminal
45+
CommonTab_24=&Allocate text console
4446
CommonTab_3=Oth&er
4547
CommonTab_4=Standard Input and Output
4648
CommonTab_5=&Allocate console (necessary for input)
@@ -57,6 +59,7 @@ CommonTab_AttributeLabel_AppendToFile=Append to file
5759
CommonTab_AttributeLabel_LaunchInBackground=Launch in background
5860
CommonTab_AttributeLabel_FavoriteGroups=Favorite groups
5961
CommonTab_AttributeLabel_TerminateDescendants=&Terminate child-processes if terminating the launched process
62+
CommonTab_disable_console_input=Disable Input/Output
6063

6164
CompileErrorPromptStatusHandler_0=Errors in Workspace
6265
CompileErrorPromptStatusHandler_1=Errors exist in a required project. Continue launch?

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import org.eclipse.core.resources.IWorkspaceRoot;
3434
import org.eclipse.core.resources.ResourcesPlugin;
3535
import org.eclipse.core.runtime.CoreException;
36+
import org.eclipse.core.runtime.IConfigurationElement;
37+
import org.eclipse.core.runtime.IExtensionPoint;
3638
import org.eclipse.core.runtime.IPath;
3739
import org.eclipse.core.runtime.IStatus;
3840
import org.eclipse.core.runtime.Platform;
@@ -98,6 +100,7 @@
98100
*/
99101
public class CommonTab extends AbstractLaunchConfigurationTab {
100102

103+
private static final String TERMINAL_PROCESS_FACTORY_ID = "org.eclipse.debug.terminal.processFactory"; //$NON-NLS-1$
101104
/**
102105
* Constant representing the id of the {@link IDialogSettings} location for the {@link ContainerSelectionDialog} used
103106
* on this tab
@@ -130,6 +133,8 @@ public class CommonTab extends AbstractLaunchConfigurationTab {
130133
private Button forceSystemEncodingButton;
131134
private Combo fEncodingCombo;
132135
private Button fConsoleOutput;
136+
private Button noConsoleOutput;
137+
private Button terminalOutput;
133138
private Button fFileOutput;
134139
private Button fFileBrowse;
135140
private Text fFileText;
@@ -153,13 +158,15 @@ public class CommonTab extends AbstractLaunchConfigurationTab {
153158
* Modify listener that simply updates the owning launch configuration dialog.
154159
*/
155160
private final ModifyListener fBasicModifyListener = evt -> scheduleUpdateJob();
161+
private boolean hasTerminalSupport;
156162

157163
/**
158164
* Constructs a new tab with default context help.
159165
*/
160166
public CommonTab() {
161167
super();
162168
setHelpContextId(IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_COMMON_TAB);
169+
hasTerminalSupport = hasTerminalSupport();
163170
}
164171

165172
@Override
@@ -311,8 +318,22 @@ private void createOutputCaptureComponent(Composite parent) {
311318

312319
private void createInputCaptureComponent(Composite parent){
313320
Composite comp1 = SWTFactory.createComposite(parent, parent.getFont(), 5, 5, GridData.FILL_BOTH, 0, 0);
314-
fConsoleOutput = createCheckButton(comp1, LaunchConfigurationsMessages.CommonTab_5);
315-
fConsoleOutput.addSelectionListener(widgetSelectedAdapter(e -> updateLaunchConfigurationDialog()));
321+
if (hasTerminalSupport) {
322+
SelectionListener adapter = widgetSelectedAdapter(e -> updateLaunchConfigurationDialog());
323+
Composite buttonComposite = new Composite(comp1, SWT.NONE);
324+
buttonComposite.setLayout(new GridLayout(3, false));
325+
fConsoleOutput = createRadioButton(buttonComposite, LaunchConfigurationsMessages.CommonTab_24);
326+
fConsoleOutput.addSelectionListener(adapter);
327+
terminalOutput = createRadioButton(buttonComposite, LaunchConfigurationsMessages.CommonTab_23);
328+
terminalOutput.addSelectionListener(adapter);
329+
noConsoleOutput = createRadioButton(buttonComposite,
330+
LaunchConfigurationsMessages.CommonTab_disable_console_input);
331+
noConsoleOutput.addSelectionListener(adapter);
332+
333+
} else {
334+
fConsoleOutput = createCheckButton(comp1, LaunchConfigurationsMessages.CommonTab_5);
335+
fConsoleOutput.addSelectionListener(widgetSelectedAdapter(e -> updateLaunchConfigurationDialog()));
336+
}
316337

317338
Composite comp = SWTFactory.createComposite(comp1, comp1.getFont(), 5, 5, GridData.FILL_BOTH, 0, 0);
318339
fInputFileCheckButton = createCheckButton(comp, LaunchConfigurationsMessages.CommonTab_17);
@@ -388,6 +409,20 @@ private void createInputCaptureComponent(Composite parent){
388409

389410
setInputFileEnabled(false);
390411
}
412+
413+
private static boolean hasTerminalSupport() {
414+
IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
415+
.getExtensionPoint(DebugPlugin.getUniqueIdentifier(), DebugPlugin.EXTENSION_POINT_PROCESS_FACTORIES);
416+
IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
417+
for (IConfigurationElement configurationElement : infos) {
418+
String id = configurationElement.getAttribute("id"); //$NON-NLS-1$
419+
if (TERMINAL_PROCESS_FACTORY_ID.equals(id)) {
420+
return true;
421+
}
422+
}
423+
return false;
424+
}
425+
391426
/**
392427
* Enables or disables the output capture widgets based on the the specified enablement
393428
* @param enable if the output capture widgets should be enabled or not
@@ -665,8 +700,20 @@ private void updateConsoleOutput(ILaunchConfiguration configuration) {
665700
supportsMergeOutput = configuration.getType().supportsOutputMerging();
666701
} catch (CoreException e) {
667702
}
668-
669-
fConsoleOutput.setSelection(outputToConsole);
703+
if (hasTerminalSupport) {
704+
if (outputToConsole) {
705+
if (TERMINAL_PROCESS_FACTORY_ID
706+
.equals(getAttribute(configuration, DebugPlugin.ATTR_PROCESS_FACTORY_ID, ""))) { //$NON-NLS-1$
707+
terminalOutput.setSelection(true);
708+
} else {
709+
fConsoleOutput.setSelection(true);
710+
}
711+
} else {
712+
noConsoleOutput.setSelection(true);
713+
}
714+
} else {
715+
fConsoleOutput.setSelection(outputToConsole);
716+
}
670717
fAppend.setSelection(append);
671718
if (supportsMergeOutput) {
672719
fMergeOutput = createCheckButton(fIoComposit, LaunchConfigurationsMessages.CommonTab_21);
@@ -994,11 +1041,25 @@ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
9941041
}
9951042
configuration.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, encoding);
9961043
boolean captureOutput = false;
997-
if (fConsoleOutput.getSelection()) {
998-
captureOutput = true;
999-
configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, (String) null);
1044+
if (hasTerminalSupport) {
1045+
if (noConsoleOutput.getSelection()) {
1046+
configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, false);
1047+
} else {
1048+
captureOutput = true;
1049+
configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, (String) null);
1050+
if (terminalOutput.getSelection()) {
1051+
configuration.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, TERMINAL_PROCESS_FACTORY_ID);
1052+
} else {
1053+
configuration.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, (String) null);
1054+
}
1055+
}
10001056
} else {
1001-
configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, false);
1057+
if (fConsoleOutput.getSelection()) {
1058+
captureOutput = true;
1059+
configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, (String) null);
1060+
} else {
1061+
configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, false);
1062+
}
10021063
}
10031064
if (fInputFileCheckButton.getSelection()) {
10041065
configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_STDIN_FILE, fInputFileLocationText.getText());

0 commit comments

Comments
 (0)