Skip to content

Commit 12ba470

Browse files
committed
Add UI to allocate a terminal
1 parent 2bb22db commit 12ba470

File tree

4 files changed

+80
-10
lines changed

4 files changed

+80
-10
lines changed

debug/org.eclipse.debug.terminal/plugin.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
point="org.eclipse.debug.core.execFactories">
66
<execFactory
77
class="org.eclipse.debug.terminal.PtyExecFactory"
8-
id="org.eclipse.debug.terminal.execFactory1"
8+
id="org.eclipse.debug.terminal.execFactory"
99
priority="100">
1010
</execFactory>
1111
</extension>
1212
<extension
1313
point="org.eclipse.debug.core.processFactories">
1414
<processFactory
1515
class="org.eclipse.debug.terminal.PtyProcessFactory"
16-
id="org.eclipse.debug.terminal.processFactory.cdt">
16+
id="org.eclipse.debug.terminal.processFactory">
1717
</processFactory>
1818
</extension>
1919

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
@@ -666,8 +701,20 @@ private void updateConsoleOutput(ILaunchConfiguration configuration) {
666701
supportsMergeOutput = configuration.getType().supportsOutputMerging();
667702
} catch (CoreException e) {
668703
}
669-
670-
fConsoleOutput.setSelection(outputToConsole);
704+
if (hasTerminalSupport) {
705+
if (outputToConsole) {
706+
if (TERMINAL_PROCESS_FACTORY_ID
707+
.equals(getAttribute(configuration, DebugPlugin.ATTR_PROCESS_FACTORY_ID, ""))) { //$NON-NLS-1$
708+
terminalOutput.setSelection(true);
709+
} else {
710+
fConsoleOutput.setSelection(true);
711+
}
712+
} else {
713+
noConsoleOutput.setSelection(true);
714+
}
715+
} else {
716+
fConsoleOutput.setSelection(outputToConsole);
717+
}
671718
fAppend.setSelection(append);
672719
if (supportsMergeOutput) {
673720
fMergeOutput = createCheckButton(fIoComposit, LaunchConfigurationsMessages.CommonTab_21);
@@ -995,11 +1042,25 @@ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
9951042
}
9961043
configuration.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, encoding);
9971044
boolean captureOutput = false;
998-
if (fConsoleOutput.getSelection()) {
999-
captureOutput = true;
1000-
configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, (String) null);
1045+
if (hasTerminalSupport) {
1046+
if (noConsoleOutput.getSelection()) {
1047+
configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, false);
1048+
} else {
1049+
captureOutput = true;
1050+
configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, (String) null);
1051+
if (terminalOutput.getSelection()) {
1052+
configuration.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, TERMINAL_PROCESS_FACTORY_ID);
1053+
} else {
1054+
configuration.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, (String) null);
1055+
}
1056+
}
10011057
} else {
1002-
configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, false);
1058+
if (fConsoleOutput.getSelection()) {
1059+
captureOutput = true;
1060+
configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, (String) null);
1061+
} else {
1062+
configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, false);
1063+
}
10031064
}
10041065
if (fInputFileCheckButton.getSelection()) {
10051066
configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_STDIN_FILE, fInputFileLocationText.getText());

0 commit comments

Comments
 (0)