Skip to content

Commit b91e4aa

Browse files
committed
Option to add console argument in the launch configuration
This commit adds an option in launch configuration to add -console argument in program arguments. Fixes : #1851
1 parent 12eae51 commit b91e4aa

File tree

5 files changed

+44
-5
lines changed

5 files changed

+44
-5
lines changed

ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/EclipseApplicationLaunchConfiguration.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2005, 2024 IBM Corporation and others.
2+
* Copyright (c) 2005, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -158,6 +158,9 @@ public String[] getProgramArguments(ILaunchConfiguration configuration) throws C
158158
programArgs.add(1, computeShowsplashArgument());
159159
}
160160
}
161+
if (configuration.getAttribute(IPDELauncherConstants.ADD_CONSOLE, false)) {
162+
programArgs.add("-console"); //$NON-NLS-1$
163+
}
161164
return programArgs.toArray(new String[programArgs.size()]);
162165
}
163166

ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/IPDELauncherConstants.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2005, 2022 IBM Corporation and others.
2+
* Copyright (c) 2005, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -580,4 +580,13 @@ public interface IPDELauncherConstants {
580580
* @since 3.6
581581
*/
582582
String ADDITIONAL_PLUGINS = "additional_plugins"; //$NON-NLS-1$
583+
/**
584+
* Launch configuration attribute key. The value is a boolean specifying whether
585+
* the <code>-console</code> argument should be added when launching.
586+
* When set to <code>true</code>, the application will be started with
587+
* console support enabled.
588+
*
589+
* @since 3.14
590+
*/
591+
String ADD_CONSOLE = "add_console"; //$NON-NLS-1$
583592
}

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2014, 2025 IBM Corporation and others.
2+
* Copyright (c) 2014, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -40,6 +40,8 @@ public class PDEUIMessages extends NLS {
4040

4141
public static String AbstractTargetPage_setTarget;
4242

43+
public static String ProgramBlock_runWithConsoleOption;
44+
4345
public static String AbstractTargetPage_reloadTarget;
4446

4547
public static String AbstractTargetPage_openPreferences;

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/ProgramBlock.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2005, 2015 IBM Corporation and others.
2+
* Copyright (c) 2005, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -46,6 +46,7 @@ public class ProgramBlock {
4646
private Button fProductButton;
4747
private Combo fProductCombo;
4848
private Button fApplicationButton;
49+
private Button fRunAsConsoleSectionButton;
4950
private final AbstractLauncherTab fTab;
5051
private final Listener fListener = new Listener();
5152
private ControlDecoration fProductComboDecoration;
@@ -109,6 +110,7 @@ public void createControl(Composite parent) {
109110

110111
createProductSection(group);
111112
createApplicationSection(group);
113+
createRunWithConsoleOption(group);
112114
}
113115

114116
protected void createProductSection(Composite parent) {
@@ -135,16 +137,24 @@ protected void createApplicationSection(Composite parent) {
135137
fApplicationCombo.addSelectionListener(fListener);
136138
}
137139

140+
protected void createRunWithConsoleOption(Composite parent) {
141+
fRunAsConsoleSectionButton = new Button(parent, SWT.CHECK);
142+
fRunAsConsoleSectionButton.setText(PDEUIMessages.ProgramBlock_runWithConsoleOption);
143+
fRunAsConsoleSectionButton.addSelectionListener(fListener);
144+
}
145+
138146
public void initializeFrom(ILaunchConfiguration config) throws CoreException {
139147
initializeProductSection(config);
140148
initializeApplicationSection(config);
141149

142150
boolean useProduct = config.getAttribute(IPDELauncherConstants.USE_PRODUCT, false) && fProductCombo.getItemCount() > 0;
151+
boolean addConsole = config.getAttribute(IPDELauncherConstants.ADD_CONSOLE, false);
143152
fApplicationButton.setSelection(!useProduct);
144153
fApplicationCombo.setEnabled(!useProduct);
145154
fProductButton.setSelection(useProduct);
146155
fProductButton.setEnabled(fProductCombo.getItemCount() > 0);
147156
fProductCombo.setEnabled(useProduct);
157+
fRunAsConsoleSectionButton.setSelection(addConsole);
148158
}
149159

150160
protected void initializeProductSection(ILaunchConfiguration config) throws CoreException {
@@ -196,6 +206,8 @@ protected void initializeApplicationSection(ILaunchConfiguration config) throws
196206
public void performApply(ILaunchConfigurationWorkingCopy config) {
197207
saveApplicationSection(config);
198208
saveProductSection(config);
209+
saveConsoleSection(config);
210+
199211
}
200212

201213
protected void saveProductSection(ILaunchConfigurationWorkingCopy config) {
@@ -213,6 +225,18 @@ protected void saveApplicationSection(ILaunchConfigurationWorkingCopy config) {
213225
}
214226
}
215227

228+
protected void saveConsoleSection(ILaunchConfigurationWorkingCopy config) {
229+
try {
230+
boolean updatePreferences = false;
231+
if (fRunAsConsoleSectionButton.getSelection()) {
232+
updatePreferences = true;
233+
}
234+
config.setAttribute(IPDELauncherConstants.ADD_CONSOLE, updatePreferences);
235+
config.doSave();
236+
} catch (CoreException e) {
237+
}
238+
}
239+
216240
public void setDefaults(ILaunchConfigurationWorkingCopy config) {
217241
String product = TargetPlatform.getDefaultProduct();
218242
if (product != null) {

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
###############################################################################
2-
# Copyright (c) 2000, 2025 IBM Corporation and others.
2+
# Copyright (c) 2000, 2026 IBM Corporation and others.
33
#
44
# This program and the accompanying materials
55
# are made available under the terms of the Eclipse Public License 2.0
@@ -536,6 +536,7 @@ ProgramBlock_runProduct=Run a &product:
536536
ProgramBlock_productDecorationWarning0=A product with this name cannot be found in any required bundle. This launch may fail to start as expected unless there is an available IProductProvider that can supply this product.
537537
ProgramBlock_programToRun=Program to Run
538538
ProgramBlock_runApplication=Run an &application:
539+
ProgramBlock_runWithConsoleOption = Run with console argument
539540
BasicLauncherTab_javaExec=Java executable:
540541
BasicLauncherTab_unbound=unbound
541542
BasicLauncherTab_ee=E&xecution environment:

0 commit comments

Comments
 (0)