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/ui/org/eclipse/debug/internal/ui/views | |
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/ui/org/eclipse/debug/internal/ui/views')
3 files changed, 56 insertions, 17 deletions
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); |