diff options
author | Sarika Sinha | 2014-11-25 17:21:19 +0000 |
---|---|---|
committer | Mike Rennie | 2014-11-25 17:21:19 +0000 |
commit | f8e14408928261dc167508ea6610f5abdaf09153 (patch) | |
tree | c6890454fadb346cf7ad173271ee721b10b8ddcb /org.eclipse.debug.ui | |
parent | 7c47c0f6697451e6c24d45d78376e3cb5acb33d3 (diff) | |
download | eclipse.platform.debug-f8e14408928261dc167508ea6610f5abdaf09153.tar.gz eclipse.platform.debug-f8e14408928261dc167508ea6610f5abdaf09153.tar.xz eclipse.platform.debug-f8e14408928261dc167508ea6610f5abdaf09153.zip |
Bug 155411 - [launch] Need a way to assign stdin to a file from Run
Dialog
Signed-off-by: Sarika Sinha <sarika.sinha@in.ibm.com>
Diffstat (limited to 'org.eclipse.debug.ui')
9 files changed, 267 insertions, 53 deletions
diff --git a/org.eclipse.debug.ui/META-INF/MANIFEST.MF b/org.eclipse.debug.ui/META-INF/MANIFEST.MF index 23e049f33..03f95a7e7 100644 --- a/org.eclipse.debug.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.debug.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.debug.ui; singleton:=true -Bundle-Version: 3.10.100.qualifier +Bundle-Version: 3.11.0.qualifier Bundle-Activator: org.eclipse.debug.internal.ui.DebugUIPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/org.eclipse.debug.ui/pom.xml b/org.eclipse.debug.ui/pom.xml index a3f860b2e..0268bba4e 100644 --- a/org.eclipse.debug.ui/pom.xml +++ b/org.eclipse.debug.ui/pom.xml @@ -18,7 +18,7 @@ </parent> <groupId>org.eclipse.debug</groupId> <artifactId>org.eclipse.debug.ui</artifactId> - <version>3.10.100-SNAPSHOT</version> + <version>3.11.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> <build> <plugins> diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java index 5bba34bd5..2cee56329 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2014 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 @@ -19,9 +19,11 @@ public class LaunchConfigurationsMessages extends NLS { public static String CommonTab__Common_15; public static String CommonTab_Display_in_favorites_menu__10; public static String CommonTab_Invalid_shared_configuration_location_14; + public static String CommonTab_Invalid_stdin_file_location_15; public static String CommonTab_L_ocal_3; public static String CommonTab_S_hared_4; public static String CommonTab_Select_a_location_for_the_launch_configuration_13; + public static String CommonTab_Select_a_location_for_the_Input_File_15; public static String CommonTab_Cannot_save_launch_configuration_in_a_closed_project__1; public static String CommonTab_10; public static String CommonTab_11; @@ -32,7 +34,12 @@ public class LaunchConfigurationsMessages extends NLS { public static String CommonTab_1; public static String CommonTab_15; + public static String CommonTab_16; + public static String CommonTab_17; + public static String CommonTab_18; + public static String CommonTab_19; public static String CommonTab_2; + public static String CommonTab_20; public static String CommonTab_3; public static String CommonTab_4; public static String CommonTab_5; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties index 2ac072cac..ce25f1b6f 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2013 IBM Corporation and others. +# Copyright (c) 2000, 2014 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 @@ -13,26 +13,33 @@ CommonTab__Browse_6=&Browse... CommonTab__Common_15=&Common CommonTab_Display_in_favorites_menu__10=Display in favor&ites menu CommonTab_Invalid_shared_configuration_location_14=Invalid shared configuration location +CommonTab_Invalid_stdin_file_location_15=No file specified for process input CommonTab_L_ocal_3=L&ocal file CommonTab_S_hared_4=S&hared file: CommonTab_Select_a_location_for_the_launch_configuration_13=Select a location for the launch configuration +CommonTab_Select_a_location_for_the_Input_File_15=Select a location for the standard input file CommonTab_Cannot_save_launch_configuration_in_a_closed_project__1=Cannot save launch configuration in a closed project. CommonTab_10=Launch in bac&kground CommonTab_11=A&ppend -CommonTab_12=&Workspace... +CommonTab_12=Output &Workspace... CommonTab_13=Select a Resource: CommonTab_14=Select a resource to redirect output to: CommonTab_0=Save as CommonTab_1=Encoding CommonTab_15=The selected encoding is not supported. +CommonTab_16=Input W&orkspace... +CommonTab_17=Input File +CommonTab_18=Select a resource to redirect input from: +CommonTab_19=Input File Sys&tem... CommonTab_2=Defa&ult - inherited ({0}) +CommonTab_20=Input Varia&bles... CommonTab_3=Oth&er CommonTab_4=Standard Input and Output CommonTab_5=&Allocate console (necessary for input) -CommonTab_6=Fi&le: -CommonTab_7=File Syste&m... +CommonTab_6=Output Fi&le: +CommonTab_7=Output File Syste&m... CommonTab_8=No file specified for process output -CommonTab_9=Variable&s... +CommonTab_9=Output Variable&s... CompileErrorPromptStatusHandler_0=Errors in Workspace CompileErrorPromptStatusHandler_1=Errors exist in a required project. Continue launch? diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.java index 935439620..5ad0c055b 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2014 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 @@ -25,6 +25,7 @@ public class ConsoleMessages extends NLS { public static String ProcessConsole_1; public static String ProcessConsole_2; + public static String ProcessConsole_3; static { // load message values from bundle file diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.properties index 9c441dc1a..55b4e0531 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2009 IBM Corporation and others. +# Copyright (c) 2000, 2014 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 @@ -21,5 +21,6 @@ ProcessConsole_0=<terminated> {0} ProcessConsole_1=[Console output redirected to file:{0}]\n ProcessConsole_2=[Invalid file specified for console output: {0}]\n +ProcessConsole_3=[Invalid file specified for stdin file: {0}]\n ShowStandardErrorAction_0=Show Console When Standard Error Changes ShowStandardOutAction_0=Show Console When Standard Out Changes diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java index abffd38da..ef2b50f81 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2014 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 @@ -12,9 +12,11 @@ package org.eclipse.debug.internal.ui.views.console; import java.io.ByteArrayInputStream; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.List; @@ -96,11 +98,12 @@ public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSe private IConsoleColorProvider fColorProvider; - private IOConsoleInputStream fInput; + private InputStream fInput; private FileOutputStream fFileOutputStream; private boolean fAllocateConsole = true; + private String fStdInFile = null; private boolean fStreamsClosed = false; @@ -126,11 +129,18 @@ public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSe boolean append = false; if (configuration != null) { try { - file = configuration.getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_FILE, (String) null); - if (file != null) { - IStringVariableManager stringVariableManager = VariablesPlugin.getDefault().getStringVariableManager(); - file = stringVariableManager.performStringSubstitution(file); - append = configuration.getAttribute(IDebugUIConstants.ATTR_APPEND_TO_FILE, false); + file = configuration.getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_FILE, (String) null); + fStdInFile = configuration.getAttribute(IDebugUIConstants.ATTR_CAPTURE_STDIN_FILE, (String) null); + if (file != null || fStdInFile != null) { + IStringVariableManager stringVariableManager = VariablesPlugin.getDefault().getStringVariableManager(); + if (file != null) { + file = stringVariableManager.performStringSubstitution(file); + append = configuration.getAttribute(IDebugUIConstants.ATTR_APPEND_TO_FILE, false); + } + + if (fStdInFile != null) { + fStdInFile = stringVariableManager.performStringSubstitution(fStdInFile); + } } } catch (CoreException e) { } @@ -181,15 +191,41 @@ public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSe } catch (CoreException e) { } } + if (fStdInFile != null && configuration != null) { + String message = null; + try { + fInput = new FileInputStream(new File(fStdInFile)); + if (fInput != null) { + setInputStream(fInput); + } + } catch (FileNotFoundException e) { + message = MessageFormat.format(ConsoleMessages.ProcessConsole_3, new Object[] { fStdInFile }); + } + if (message != null) { + try { + IOConsoleOutputStream stream = newOutputStream(); + stream.write(message); + stream.close(); + } catch (IOException e) { + DebugUIPlugin.log(e); + } + } + } fColorProvider = colorProvider; - fInput = getInputStream(); + if (fInput == null) { + fInput = getInputStream(); + } + + colorProvider.connect(fProcess, this); setName(computeName()); Color color = fColorProvider.getColor(IDebugUIConstants.ID_STANDARD_INPUT_STREAM); - fInput.setColor(color); + if (fInput instanceof IOConsoleInputStream) { + ((IOConsoleInputStream)fInput).setColor(color); + } IConsoleLineTracker[] lineTrackers = DebugUIPlugin.getDefault().getProcessConsoleManager().getLineTrackers(process); if (lineTrackers.length > 0) { @@ -315,8 +351,8 @@ public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSe stream.setColor(fColorProvider.getColor(IDebugUIConstants.ID_STANDARD_ERROR_STREAM)); } } else if (property.equals(IDebugPreferenceConstants.CONSOLE_SYS_IN_COLOR)) { - if (fInput != null) { - fInput.setColor(fColorProvider.getColor(IDebugUIConstants.ID_STANDARD_INPUT_STREAM)); + if (fInput != null && fInput instanceof IOConsoleInputStream) { + ((IOConsoleInputStream) fInput).setColor(fColorProvider.getColor(IDebugUIConstants.ID_STANDARD_INPUT_STREAM)); } } else if (property.equals(IDebugUIConstants.PREF_CONSOLE_FONT)) { setFont(JFaceResources.getFont(IDebugUIConstants.PREF_CONSOLE_FONT)); @@ -521,10 +557,11 @@ public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSe private void connect(IStreamMonitor streamMonitor, String streamIdentifier, boolean activateOnWrite) { IOConsoleOutputStream stream = null; if (fAllocateConsole) { - stream = newOutputStream(); - Color color = fColorProvider.getColor(streamIdentifier); - stream.setColor(color); - stream.setActivateOnWrite(activateOnWrite); + + stream = newOutputStream(); + Color color = fColorProvider.getColor(streamIdentifier); + stream.setColor(color); + stream.setActivateOnWrite(activateOnWrite); } synchronized (streamMonitor) { StreamListener listener = new StreamListener(streamIdentifier, streamMonitor, stream); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java index fdac516a5..94e333365 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2014 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 @@ -26,7 +26,9 @@ import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; @@ -74,6 +76,7 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.ContainerSelectionDialog; import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; +import org.eclipse.ui.dialogs.ISelectionStatusValidator; import org.eclipse.ui.ide.IDEEncoding; import org.eclipse.ui.model.WorkbenchContentProvider; import org.eclipse.ui.model.WorkbenchLabelProvider; @@ -123,13 +126,19 @@ public class CommonTab extends AbstractLaunchConfigurationTab { private Button fDefaultEncodingButton; private Button fAltEncodingButton; private Combo fEncodingCombo; - private Button fConsoleOutput; + private Button fConsoleOutput; private Button fFileOutput; private Button fFileBrowse; private Text fFileText; private Button fVariables; private Button fAppend; private Button fWorkspaceBrowse; + + private Button fInputFileCheckButton; + private Text fInputFileLocationText; + private Button fInputFileBrowse; + private Button fInputVariables; + private Button fInputWorkspaceBrowse; /** * Check box list for specifying favorites @@ -253,24 +262,13 @@ public class CommonTab extends AbstractLaunchConfigurationTab { * Creates the component set for the capture output composite * @param parent the parent to add this component to */ - private void createOutputCaptureComponent(Composite parent) { + private void createOutputCaptureComponent(Composite parent) { Group group = SWTFactory.createGroup(parent, LaunchConfigurationsMessages.CommonTab_4, 5, 2, GridData.FILL_HORIZONTAL); + createInputCaptureComponent(group); Composite comp = SWTFactory.createComposite(group, 5, 5, GridData.FILL_BOTH); - GridLayout ld = (GridLayout)comp.getLayout(); - ld.marginWidth = 1; - ld.marginHeight = 1; - fConsoleOutput = createCheckButton(comp, LaunchConfigurationsMessages.CommonTab_5); - GridData gd = new GridData(SWT.BEGINNING, SWT.NORMAL, true, false); - gd.horizontalSpan = 5; - fConsoleOutput.setLayoutData(gd); - fConsoleOutput.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateLaunchConfigurationDialog(); - } - }); - - fFileOutput = createCheckButton(comp, LaunchConfigurationsMessages.CommonTab_6); + + + fFileOutput = createCheckButton(comp, LaunchConfigurationsMessages.CommonTab_6); fFileOutput.setLayoutData(new GridData(SWT.BEGINNING, SWT.NORMAL, false, false)); fFileOutput.addSelectionListener(new SelectionAdapter() { @Override @@ -289,7 +287,7 @@ public class CommonTab extends AbstractLaunchConfigurationTab { fFileText.addModifyListener(fBasicModifyListener); Composite bcomp = SWTFactory.createComposite(comp, 3, 5, GridData.HORIZONTAL_ALIGN_END); - ld = (GridLayout)bcomp.getLayout(); + GridLayout ld = (GridLayout)bcomp.getLayout(); ld.marginHeight = 1; ld.marginWidth = 0; fWorkspaceBrowse = createPushButton(bcomp, LaunchConfigurationsMessages.CommonTab_12, null); @@ -339,7 +337,8 @@ public class CommonTab extends AbstractLaunchConfigurationTab { public void widgetDefaultSelected(SelectionEvent e) {} }); fAppend = createCheckButton(comp, LaunchConfigurationsMessages.CommonTab_11); - gd = new GridData(SWT.LEFT, SWT.TOP, true, false); + + GridData gd = new GridData(SWT.LEFT, SWT.TOP, true, false); gd.horizontalSpan = 4; fAppend.setLayoutData(gd); fAppend.addSelectionListener(new SelectionAdapter() { @@ -350,6 +349,102 @@ public class CommonTab extends AbstractLaunchConfigurationTab { }); } + private void createInputCaptureComponent(Composite parent){ + Composite comp1 = SWTFactory.createComposite(parent, parent.getFont(), 3, 3, GridData.FILL_BOTH, 0, 0); + fConsoleOutput = createCheckButton(comp1, LaunchConfigurationsMessages.CommonTab_5); + + Composite comp = SWTFactory.createComposite(comp1, 5, 5, GridData.FILL_BOTH); + fInputFileCheckButton = createCheckButton(comp, LaunchConfigurationsMessages.CommonTab_17); + GridData gd = new GridData(SWT.BEGINNING, SWT.NORMAL, false, false); + gd.horizontalSpan = 3; + + fInputFileCheckButton.setLayoutData(gd); + fInputFileCheckButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent evt) { + handleInputFileButtonSelected(); + updateLaunchConfigurationDialog(); + } + }); + + fInputFileLocationText = SWTFactory.createSingleText(comp, 1); + fInputFileLocationText.getAccessible().addAccessibleListener(new AccessibleAdapter() { + @Override + public void getName(AccessibleEvent e) { + e.result = LaunchConfigurationsMessages.CommonTab_17; + } + }); + fInputFileLocationText.addModifyListener(fBasicModifyListener); + Composite bcomp = SWTFactory.createComposite(comp, 3, 5, GridData.HORIZONTAL_ALIGN_END); + GridLayout ld = (GridLayout) bcomp.getLayout(); + ld.marginHeight = 1; + ld.marginWidth = 0; + fInputWorkspaceBrowse = createPushButton(bcomp, LaunchConfigurationsMessages.CommonTab_16, null); + fInputWorkspaceBrowse.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); + dialog.setTitle(LaunchConfigurationsMessages.CommonTab_13); + dialog.setValidator(new ISelectionStatusValidator() { + + @Override + public IStatus validate(Object[] selection) { + if (selection.length == 0) { + return new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), 0, IInternalDebugCoreConstants.EMPTY_STRING, null); + } + for (int i = 0; i < selection.length; i++) { + if (!(selection[i] instanceof IFile)) { + return new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), 0, IInternalDebugCoreConstants.EMPTY_STRING, null); + } + } + return new Status(IStatus.OK, DebugUIPlugin.getUniqueIdentifier(), 0, IInternalDebugCoreConstants.EMPTY_STRING, null); + } + }); + dialog.setMessage(LaunchConfigurationsMessages.CommonTab_18); + dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); + dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); + dialog.setDialogBoundsSettings(getDialogBoundsSettings(WORKSPACE_SELECTION_DIALOG), Dialog.DIALOG_PERSISTSIZE); + if (dialog.open() == IDialogConstants.OK_ID) { + IResource resource = (IResource) dialog.getFirstResult(); + if (resource != null) { + String arg = resource.getFullPath().toString(); + String fileLoc = VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression("workspace_loc", arg); //$NON-NLS-1$ + fInputFileLocationText.setText(fileLoc); + } + } + } + }); + fInputFileBrowse = createPushButton(bcomp, LaunchConfigurationsMessages.CommonTab_19, null); + fInputFileBrowse.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + String filePath = fInputFileLocationText.getText(); + FileDialog dialog = new FileDialog(getShell(), SWT.OK); + filePath = dialog.open(); + if (filePath != null) { + fInputFileLocationText.setText(filePath); + } + } + }); + fInputVariables = createPushButton(bcomp, LaunchConfigurationsMessages.CommonTab_20, null); + fInputVariables.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent e) { + StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); + dialog.open(); + String variable = dialog.getVariableExpression(); + if (variable != null) { + fInputFileLocationText.insert(variable); + } + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + + setInputFileEnabled(false); + } /** * Enables or disables the output capture widgets based on the the specified enablement * @param enable if the output capture widgets should be enabled or not @@ -496,6 +591,14 @@ public class CommonTab extends AbstractLaunchConfigurationTab { } /** + * handles the input file being selected + */ + private void handleInputFileButtonSelected() { + setInputFileEnabled(isInputFile()); + updateLaunchConfigurationDialog(); + } + + /** * Sets the widgets for specifying that a launch configuration is to be shared to the enable value * @param enable the enabled value for */ @@ -504,6 +607,13 @@ public class CommonTab extends AbstractLaunchConfigurationTab { fSharedLocationButton.setEnabled(enable); } + private void setInputFileEnabled(boolean enable) { + fInputFileLocationText.setEnabled(enable); + fInputFileBrowse.setEnabled(enable); + fInputWorkspaceBrowse.setEnabled(enable); + fInputVariables.setEnabled(enable); + } + private String getDefaultSharedConfigLocation(ILaunchConfiguration config) { String path = IInternalDebugCoreConstants.EMPTY_STRING; try { @@ -531,6 +641,16 @@ public class CommonTab extends AbstractLaunchConfigurationTab { } /** + * if the input file button is selected, indicating that the launch will + * take input file as stdin + * + * @return true if the check button is selected, false otherwise + */ + private boolean isInputFile() { + return fInputFileCheckButton.getSelection(); + } + + /** * Handles the shared location button being selected */ private void handleSharedLocationButtonSelected() { @@ -594,17 +714,20 @@ public class CommonTab extends AbstractLaunchConfigurationTab { */ private void updateConsoleOutput(ILaunchConfiguration configuration) { boolean outputToConsole = true; + String stdinFromFile = null; String outputFile = null; boolean append = false; try { outputToConsole = configuration.getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, true); + stdinFromFile = configuration.getAttribute(IDebugUIConstants.ATTR_CAPTURE_STDIN_FILE, (String) null); + outputFile = configuration.getAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_FILE, (String)null); append = configuration.getAttribute(IDebugUIConstants.ATTR_APPEND_TO_FILE, false); } catch (CoreException e) { } - fConsoleOutput.setSelection(outputToConsole); + fConsoleOutput.setSelection(outputToConsole); fAppend.setSelection(append); boolean haveOutputFile= outputFile != null; if (haveOutputFile) { @@ -612,6 +735,13 @@ public class CommonTab extends AbstractLaunchConfigurationTab { } fFileOutput.setSelection(haveOutputFile); enableOuputCaptureWidgets(haveOutputFile); + + boolean haveInputFile = stdinFromFile != null; + if (haveInputFile) { + fInputFileLocationText.setText(stdinFromFile); + } + fInputFileCheckButton.setSelection(haveInputFile); + setInputFileEnabled(haveInputFile); } /** @@ -797,7 +927,7 @@ public class CommonTab extends AbstractLaunchConfigurationTab { setMessage(null); setErrorMessage(null); - return validateLocalShared() && validateRedirectFile() && validateEncoding(); + return validateLocalShared() && validateRedirectFile() && validateEncoding() && validateStdinFile(); } /** @@ -850,6 +980,22 @@ public class CommonTab extends AbstractLaunchConfigurationTab { return true; } + /** + * validates the stdin file location + * + * @return true if the stdin file exists, false otherwise + */ + private boolean validateStdinFile() { + if (isInputFile()) { + int len = fInputFileLocationText.getText().trim().length(); + if (len == 0) { + setErrorMessage(LaunchConfigurationsMessages.CommonTab_Invalid_stdin_file_location_15); + return false; + } + } + return true; + } + /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ @@ -875,10 +1021,15 @@ public class CommonTab extends AbstractLaunchConfigurationTab { boolean captureOutput = false; if (fConsoleOutput.getSelection()) { captureOutput = true; - configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, (String)null); + configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, (String) null); } else { configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, false); } + if (fInputFileCheckButton.getSelection()) { + configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_STDIN_FILE, fInputFileLocationText.getText()); + } else { + configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_STDIN_FILE, (String) null); + } if (fFileOutput.getSelection()) { captureOutput = true; String file = fFileText.getText(); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java index 59913787e..48431b7a9 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2014 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 @@ -961,10 +961,20 @@ public interface IDebugUIConstants { public static final String ATTR_CAPTURE_IN_CONSOLE = PLUGIN_ID + ".ATTR_CONSOLE_OUTPUT_ON"; //$NON-NLS-1$ /** - * Launch configuration attribute specifying a file name that console output should - * be written to or <code>null</code> if none. Default value is <code>null</code>. - * When specified, all output from the launched process will be written to the file. - * The file name attribute may contain variables which will be resolved by the + * Launch configuration boolean attribute specifying whether input for the + * launched process will be captured from file. Default value is + * <code>null</code>. + * + * @since 3.11 + */ + public static final String ATTR_CAPTURE_STDIN_FILE = PLUGIN_ID + ".ATTR_CAPTURE_STDIN_FILE"; //$NON-NLS-1$ + + /** + * Launch configuration attribute specifying a file name that console output + * should be written to or <code>null</code> if none. Default value is + * <code>null</code>. When specified, all output from the launched process + * will be written to the file. The file name attribute may contain + * variables which will be resolved by the * {@link org.eclipse.core.variables.IStringVariableManager}. * * @since 3.1 |