diff options
author | Max Weninger | 2013-08-06 13:35:43 +0000 |
---|---|---|
committer | Uwe Stieber | 2013-08-06 13:36:26 +0000 |
commit | 329295f08ff122d41c5ccfa1c4c8996b195d1066 (patch) | |
tree | 9e95064fcb7e5939370b54f6f68423862f7e1f30 /target_explorer/plugins | |
parent | d7e09384659f1bd61c8391b79752bdd4e7528b58 (diff) | |
download | org.eclipse.tcf-329295f08ff122d41c5ccfa1c4c8996b195d1066.tar.gz org.eclipse.tcf-329295f08ff122d41c5ccfa1c4c8996b195d1066.tar.xz org.eclipse.tcf-329295f08ff122d41c5ccfa1c4c8996b195d1066.zip |
Target Explorer: Added support for passed in environment for process and local terminal connectors.
Signed-off-by: Max Weninger <max.weninger@windriver.com>
Diffstat (limited to 'target_explorer/plugins')
7 files changed, 247 insertions, 139 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/ITerminalsConnectorConstants.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/ITerminalsConnectorConstants.java index 7779e5af4..85740d562 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/ITerminalsConnectorConstants.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/ITerminalsConnectorConstants.java @@ -141,6 +141,12 @@ public interface ITerminalsConnectorConstants { public static final String PROP_PROCESS_WORKING_DIR = "process.working_dir"; //$NON-NLS-1$ /** + * Property: Process environment. + * <p>Typical for process terminals. + */ + public static final String PROP_PROCESS_ENVIRONMENT = "process.environment"; //$NON-NLS-1$ + + /** * Property: Runtime process instance. * <p>Typical for process terminals. */ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/LocalConnector.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/LocalConnector.java index 0ab68d990..ed2314ba6 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/LocalConnector.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/LocalConnector.java @@ -127,36 +127,40 @@ public class LocalConnector extends AbstractStreamsConnector { } File workingDir =null; - if(settings.getWorkingDir()!=null){ + if (settings.getWorkingDir()!=null){ workingDir = new File(settings.getWorkingDir()); } + String[] envp = null; + if (settings.getEnvironment()!=null){ + envp = settings.getEnvironment(); + } + + if (pty != null) { + // A PTY is available -> can use the ProcessFactory. + + // Tokenize the command (ProcessFactory takes an array) + StreamTokenizer st = new StreamTokenizer(new StringReader(command.toString())); + st.resetSyntax(); + st.whitespaceChars(0, 32); + st.whitespaceChars(0xa0, 0xa0); + st.wordChars(33, 255); + st.quoteChar('"'); + st.quoteChar('\''); + + List<String> argv = new ArrayList<String>(); + int ttype = st.nextToken(); + while (ttype != StreamTokenizer.TT_EOF) { + argv.add(st.sval); + ttype = st.nextToken(); + } - if (pty != null) { - // A PTY is available -> can use the ProcessFactory. - - // Tokenize the command (ProcessFactory takes an array) - StreamTokenizer st = new StreamTokenizer(new StringReader(command.toString())); - st.resetSyntax(); - st.whitespaceChars(0, 32); - st.whitespaceChars(0xa0, 0xa0); - st.wordChars(33, 255); - st.quoteChar('"'); - st.quoteChar('\''); - - List<String> argv = new ArrayList<String>(); - int ttype = st.nextToken(); - while (ttype != StreamTokenizer.TT_EOF) { - argv.add(st.sval); - ttype = st.nextToken(); - } - - // Execute the process - process = ProcessFactory.getFactory().exec(argv.toArray(new String[argv.size()]), getProcessEnvironment(), workingDir, pty); - } else { - // No PTY -> just execute via the standard Java Runtime implementation. - process = Runtime.getRuntime().exec(command.toString(), null, workingDir); - } + // Execute the process + process = ProcessFactory.getFactory().exec(argv.toArray(new String[argv.size()]), getProcessEnvironment(envp), workingDir, pty); + } else { + // No PTY -> just execute via the standard Java Runtime implementation. + process = Runtime.getRuntime().exec(command.toString(), envp, workingDir); + } } String lineSeparator = settings.getLineSeparator(); @@ -185,7 +189,7 @@ public class LocalConnector extends AbstractStreamsConnector { } catch (IOException e) { IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), - NLS.bind(Messages.ProcessConnector_error_creatingProcess, e.getLocalizedMessage()), e); + NLS.bind(Messages.ProcessConnector_error_creatingProcess, e.getLocalizedMessage()), e); UIPlugin.getDefault().getLog().log(status); } } @@ -269,23 +273,36 @@ public class LocalConnector extends AbstractStreamsConnector { * * @return The process environment. */ - private static String[] getProcessEnvironment() { - Map<String, String> env = getNativeEnvironment(); - - env.put("TERM", "ansi"); //$NON-NLS-1$ //$NON-NLS-2$ + private static String[] getProcessEnvironment(String[] envp) { + Map<String, String> env = getNativeEnvironment(); + + env.put("TERM", "ansi"); //$NON-NLS-1$ //$NON-NLS-2$ + + Iterator<Map.Entry<String, String>> iter = env.entrySet().iterator(); + List<String> strings = new ArrayList<String>(env.size()); + StringBuffer buffer = null; + while (iter.hasNext()) { + Map.Entry<String, String>entry = iter.next(); + buffer = new StringBuffer(entry.getKey()); + buffer.append('=').append(entry.getValue()); + strings.add(buffer.toString()); + } - Iterator<Map.Entry<String, String>> iter = env.entrySet().iterator(); - List<String> strings = new ArrayList<String>(env.size()); - StringBuffer buffer = null; - while (iter.hasNext()) { - Map.Entry<String, String>entry = iter.next(); - buffer = new StringBuffer(entry.getKey()); - buffer.append('=').append(entry.getValue()); - strings.add(buffer.toString()); - } + // if "local" environment is provided - append + if (envp!=null){ + // add provided + for (int i=0; i<envp.length; i++){ + String envpPart = envp[i]; + // dont override TERM + String[] parts=envpPart.split("=");//$NON-NLS-1$ + if (!parts[0].trim().equals("TERM")){//$NON-NLS-1$ + strings.add(envpPart); + } + } + } - return strings.toArray(new String[strings.size()]); - } + return strings.toArray(new String[strings.size()]); + } /** * Determine the native environment, but returns all environment variable @@ -317,21 +334,21 @@ public class LocalConnector extends AbstractStreamsConnector { * * @return The native environment, or an empty map. */ - private static Map<String, String> getNativeEnvironmentCasePreserved() { - synchronized (ENV_GET_MONITOR) { - if (nativeEnvironmentCasePreserved == null) { - nativeEnvironmentCasePreserved= new HashMap<String, String>(); - cacheNativeEnvironment(nativeEnvironmentCasePreserved); - } - return new HashMap<String, String>(nativeEnvironmentCasePreserved); - } - } - - /** - * Query the native environment and store it to the specified cache. - * - * @param cache The environment cache. Must not be <code>null</code>. - */ + private static Map<String, String> getNativeEnvironmentCasePreserved() { + synchronized (ENV_GET_MONITOR) { + if (nativeEnvironmentCasePreserved == null) { + nativeEnvironmentCasePreserved= new HashMap<String, String>(); + cacheNativeEnvironment(nativeEnvironmentCasePreserved); + } + return new HashMap<String, String>(nativeEnvironmentCasePreserved); + } + } + + /** + * Query the native environment and store it to the specified cache. + * + * @param cache The environment cache. Must not be <code>null</code>. + */ private static void cacheNativeEnvironment(Map<String, String> cache) { Assert.isNotNull(cache); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/LocalSettings.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/LocalSettings.java index c3444e098..b7a2c8ac8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/LocalSettings.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/LocalSettings.java @@ -39,6 +39,8 @@ public class LocalSettings { private OutputStreamMonitor.Listener[] stderrListeners = null; // working directory for process private String workingDir; + // environment + private String[] environment; /** * Sets the process image. @@ -192,6 +194,7 @@ public class LocalSettings { } /** + * Returns the working dir * * @return */ @@ -200,14 +203,33 @@ public class LocalSettings { } /** + * Sets the working dir of the process * - * @param workingDir + * @param workingDir the absolute path of the working dir */ public void setWorkingDir(String workingDir) { this.workingDir = workingDir; } /** + * Get theprocess environment + * + * @return + */ + public String[] getEnvironment() { + return environment; + } + + /** + * Sets the process environment + * + * @param environment - will be added to the "parent" environment of the process + */ + public void setEnvironment(String[] environment) { + this.environment = environment; + } + + /** * Loads the process settings from the given settings store. * * @param store The settings store. Must not be <code>null</code>. @@ -224,6 +246,7 @@ public class LocalSettings { pty = (PTY)((IPropertiesContainer)store).getProperty("PTY"); //$NON-NLS-1$ stdoutListeners = (OutputStreamMonitor.Listener[])((IPropertiesContainer)store).getProperty("StdOutListeners"); //$NON-NLS-1$ stderrListeners = (OutputStreamMonitor.Listener[])((IPropertiesContainer)store).getProperty("StdErrListeners"); //$NON-NLS-1$ + environment = (String[])((IPropertiesContainer)store).getProperty("Environment"); //$NON-NLS-1$ } } @@ -244,6 +267,7 @@ public class LocalSettings { ((IPropertiesContainer)store).setProperty("PTY", pty); //$NON-NLS-1$ ((IPropertiesContainer)store).setProperty("StdOutListeners", stdoutListeners); //$NON-NLS-1$ ((IPropertiesContainer)store).setProperty("StdErrListeners", stderrListeners); //$NON-NLS-1$ + ((IPropertiesContainer)store).setProperty("Environment", environment); //$NON-NLS-1$ } } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/types/LocalConnectorType.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/types/LocalConnectorType.java index b87618cb7..bcff0b31c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/types/LocalConnectorType.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.local/src/org/eclipse/tcf/te/ui/terminals/local/types/LocalConnectorType.java @@ -48,12 +48,12 @@ public class LocalConnectorType extends AbstractConnectorType { /* (non-Javadoc) * @see org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType#createTerminalConnector(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer) */ - @Override + @Override public ITerminalConnector createTerminalConnector(IPropertiesContainer properties) { Assert.isNotNull(properties); - // Check for the terminal connector id - String connectorId = properties.getStringProperty(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID); + // Check for the terminal connector id + String connectorId = properties.getStringProperty(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID); if (connectorId == null) connectorId = "org.eclipse.tcf.te.ui.terminals.local.LocalConnector"; //$NON-NLS-1$ // Extract the process properties using defaults @@ -89,6 +89,13 @@ public class LocalConnectorType extends AbstractConnectorType { OutputStreamMonitor.Listener[] stderrListeners = (OutputStreamMonitor.Listener[])properties.getProperty(ITerminalsConnectorConstants.PROP_STDERR_LISTENERS); String workingDir = properties.getStringProperty(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR); + String[] envp = null; + if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) && + properties.getProperty(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) != null && + properties.getProperty(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) instanceof String[]){ + envp = (String[])properties.getProperty(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT); + } + Assert.isTrue(image != null || process != null); // Construct the terminal settings store @@ -99,12 +106,13 @@ public class LocalConnectorType extends AbstractConnectorType { processSettings.setImage(image); processSettings.setArguments(arguments); processSettings.setProcess(process); - processSettings.setPTY(pty); - processSettings.setLocalEcho(localEcho); - processSettings.setLineSeparator(lineSeparator); - processSettings.setStdOutListeners(stdoutListeners); - processSettings.setStdErrListeners(stderrListeners); - processSettings.setWorkingDir(workingDir); + processSettings.setPTY(pty); + processSettings.setLocalEcho(localEcho); + processSettings.setLineSeparator(lineSeparator); + processSettings.setStdOutListeners(stdoutListeners); + processSettings.setStdErrListeners(stderrListeners); + processSettings.setWorkingDir(workingDir); + processSettings.setEnvironment(envp); // And save the settings to the store processSettings.save(store); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnector.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnector.java index bc69a3587..28df4ec63 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnector.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnector.java @@ -130,35 +130,40 @@ public class ProcessConnector extends AbstractStreamsConnector { } File workingDir =null; - if(settings.getWorkingDir()!=null){ + if (settings.getWorkingDir()!=null){ workingDir = new File(settings.getWorkingDir()); } - if (pty != null) { - // A PTY is available -> can use the ProcessFactory. - - // Tokenize the command (ProcessFactory takes an array) - StreamTokenizer st = new StreamTokenizer(new StringReader(command.toString())); - st.resetSyntax(); - st.whitespaceChars(0, 32); - st.whitespaceChars(0xa0, 0xa0); - st.wordChars(33, 255); - st.quoteChar('"'); - st.quoteChar('\''); - - List<String> argv = new ArrayList<String>(); - int ttype = st.nextToken(); - while (ttype != StreamTokenizer.TT_EOF) { - argv.add(st.sval); - ttype = st.nextToken(); - } - - // Execute the process - process = ProcessFactory.getFactory().exec(argv.toArray(new String[argv.size()]), getProcessEnvironment(), workingDir, pty); - } else { - // No PTY -> just execute via the standard Java Runtime implementation. - process = Runtime.getRuntime().exec(command.toString(), null, workingDir); - } + String[] envp = null; + if (settings.getEnvironment()!=null){ + envp = settings.getEnvironment(); + } + + if (pty != null) { + // A PTY is available -> can use the ProcessFactory. + + // Tokenize the command (ProcessFactory takes an array) + StreamTokenizer st = new StreamTokenizer(new StringReader(command.toString())); + st.resetSyntax(); + st.whitespaceChars(0, 32); + st.whitespaceChars(0xa0, 0xa0); + st.wordChars(33, 255); + st.quoteChar('"'); + st.quoteChar('\''); + + List<String> argv = new ArrayList<String>(); + int ttype = st.nextToken(); + while (ttype != StreamTokenizer.TT_EOF) { + argv.add(st.sval); + ttype = st.nextToken(); + } + + // Execute the process + process = ProcessFactory.getFactory().exec(argv.toArray(new String[argv.size()]), getProcessEnvironment(envp), workingDir, pty); + } else { + // No PTY -> just execute via the standard Java Runtime implementation. + process = Runtime.getRuntime().exec(command.toString(), envp, workingDir); + } } String lineSeparator = settings.getLineSeparator(); @@ -190,7 +195,7 @@ public class ProcessConnector extends AbstractStreamsConnector { monitor.startMonitoring(); } catch (IOException e) { IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), - NLS.bind(Messages.ProcessConnector_error_creatingProcess, e.getLocalizedMessage()), e); + NLS.bind(Messages.ProcessConnector_error_creatingProcess, e.getLocalizedMessage()), e); UIPlugin.getDefault().getLog().log(status); } } @@ -281,23 +286,36 @@ public class ProcessConnector extends AbstractStreamsConnector { * * @return The process environment. */ - private static String[] getProcessEnvironment() { - Map<String, String> env = getNativeEnvironment(); - - env.put("TERM", "ansi"); //$NON-NLS-1$ //$NON-NLS-2$ + private static String[] getProcessEnvironment(String[] envp) { + Map<String, String> env = getNativeEnvironment(); + + env.put("TERM", "ansi"); //$NON-NLS-1$ //$NON-NLS-2$ + + Iterator<Map.Entry<String, String>> iter = env.entrySet().iterator(); + List<String> strings = new ArrayList<String>(env.size()); + StringBuffer buffer = null; + while (iter.hasNext()) { + Map.Entry<String, String>entry = iter.next(); + buffer = new StringBuffer(entry.getKey()); + buffer.append('=').append(entry.getValue()); + strings.add(buffer.toString()); + } - Iterator<Map.Entry<String, String>> iter = env.entrySet().iterator(); - List<String> strings = new ArrayList<String>(env.size()); - StringBuffer buffer = null; - while (iter.hasNext()) { - Map.Entry<String, String>entry = iter.next(); - buffer = new StringBuffer(entry.getKey()); - buffer.append('=').append(entry.getValue()); - strings.add(buffer.toString()); - } + // if "local" environment is provided - append + if (envp!=null){ + // add provided + for (int i=0; i<envp.length; i++){ + String envpPart = envp[i]; + // dont override TERM + String[] parts=envpPart.split("=");//$NON-NLS-1$ + if (!parts[0].trim().equals("TERM")){//$NON-NLS-1$ + strings.add(envpPart); + } + } + } - return strings.toArray(new String[strings.size()]); - } + return strings.toArray(new String[strings.size()]); + } /** * Determine the native environment, but returns all environment variable @@ -329,21 +347,21 @@ public class ProcessConnector extends AbstractStreamsConnector { * * @return The native environment, or an empty map. */ - private static Map<String, String> getNativeEnvironmentCasePreserved() { - synchronized (ENV_GET_MONITOR) { - if (nativeEnvironmentCasePreserved == null) { - nativeEnvironmentCasePreserved= new HashMap<String, String>(); - cacheNativeEnvironment(nativeEnvironmentCasePreserved); - } - return new HashMap<String, String>(nativeEnvironmentCasePreserved); - } - } - - /** - * Query the native environment and store it to the specified cache. - * - * @param cache The environment cache. Must not be <code>null</code>. - */ + private static Map<String, String> getNativeEnvironmentCasePreserved() { + synchronized (ENV_GET_MONITOR) { + if (nativeEnvironmentCasePreserved == null) { + nativeEnvironmentCasePreserved= new HashMap<String, String>(); + cacheNativeEnvironment(nativeEnvironmentCasePreserved); + } + return new HashMap<String, String>(nativeEnvironmentCasePreserved); + } + } + + /** + * Query the native environment and store it to the specified cache. + * + * @param cache The environment cache. Must not be <code>null</code>. + */ private static void cacheNativeEnvironment(Map<String, String> cache) { Assert.isNotNull(cache); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnectorType.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnectorType.java index 7d0d667b3..2e61b91ca 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnectorType.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnectorType.java @@ -29,12 +29,12 @@ public class ProcessConnectorType extends AbstractConnectorType { /* (non-Javadoc) * @see org.eclipse.tcf.te.ui.terminals.interfaces.IConnectorType#createTerminalConnector(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer) */ - @Override + @Override public ITerminalConnector createTerminalConnector(IPropertiesContainer properties) { Assert.isNotNull(properties); - // Check for the terminal connector id - String connectorId = properties.getStringProperty(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID); + // Check for the terminal connector id + String connectorId = properties.getStringProperty(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID); if (connectorId == null) connectorId = "org.eclipse.tcf.te.ui.terminals.ProcessConnector"; //$NON-NLS-1$ // Extract the process properties @@ -46,6 +46,14 @@ public class ProcessConnectorType extends AbstractConnectorType { String lineSeparator = properties.getStringProperty(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR); OutputStreamMonitor.Listener[] stdoutListeners = (OutputStreamMonitor.Listener[])properties.getProperty(ITerminalsConnectorConstants.PROP_STDOUT_LISTENERS); OutputStreamMonitor.Listener[] stderrListeners = (OutputStreamMonitor.Listener[])properties.getProperty(ITerminalsConnectorConstants.PROP_STDERR_LISTENERS); + String workingDir = properties.getStringProperty(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR); + + String[] envp = null; + if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) && + properties.getProperty(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) != null && + properties.getProperty(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT) instanceof String[]){ + envp = (String[])properties.getProperty(ITerminalsConnectorConstants.PROP_PROCESS_ENVIRONMENT); + } Assert.isTrue(image != null || process != null); @@ -57,11 +65,14 @@ public class ProcessConnectorType extends AbstractConnectorType { processSettings.setImage(image); processSettings.setArguments(arguments); processSettings.setProcess(process); - processSettings.setPTY(pty); - processSettings.setLocalEcho(localEcho); - processSettings.setLineSeparator(lineSeparator); - processSettings.setStdOutListeners(stdoutListeners); - processSettings.setStdErrListeners(stderrListeners); + processSettings.setPTY(pty); + processSettings.setLocalEcho(localEcho); + processSettings.setLineSeparator(lineSeparator); + processSettings.setStdOutListeners(stdoutListeners); + processSettings.setStdErrListeners(stderrListeners); + processSettings.setWorkingDir(workingDir); + processSettings.setEnvironment(envp); + // And save the settings to the store processSettings.save(store); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessSettings.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessSettings.java index a0b16b34f..005cf8372 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessSettings.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessSettings.java @@ -33,12 +33,14 @@ public class ProcessSettings { private boolean localEcho = !PTY.isSupported(); // The line separator setting private String lineSeparator = null; - // The list of stdout output listeners - private OutputStreamMonitor.Listener[] stdoutListeners = null; - // The list of stderr output listeners - private OutputStreamMonitor.Listener[] stderrListeners = null; - // working directory for process - private String workingDir; + // The list of stdout output listeners + private OutputStreamMonitor.Listener[] stdoutListeners = null; + // The list of stderr output listeners + private OutputStreamMonitor.Listener[] stderrListeners = null; + // working directory for process + private String workingDir; + // environment + private String[] environment; /** * Sets the process image. @@ -192,6 +194,7 @@ public class ProcessSettings { } /** + * Returns the working dir * * @return */ @@ -200,14 +203,33 @@ public class ProcessSettings { } /** + * Sets the working dir of the process * - * @param workingDir + * @param workingDir the absolute path of the working dir */ public void setWorkingDir(String workingDir) { this.workingDir = workingDir; } /** + * Get theprocess environment + * + * @return + */ + public String[] getEnvironment() { + return environment; + } + + /** + * Sets the process environment + * + * @param environment - will be added to the "parent" environment of the process + */ + public void setEnvironment(String[] environment) { + this.environment = environment; + } + + /** * Loads the process settings from the given settings store. * * @param store The settings store. Must not be <code>null</code>. @@ -224,6 +246,7 @@ public class ProcessSettings { pty = (PTY)((IPropertiesContainer)store).getProperty("PTY"); //$NON-NLS-1$ stdoutListeners = (OutputStreamMonitor.Listener[])((IPropertiesContainer)store).getProperty("StdOutListeners"); //$NON-NLS-1$ stderrListeners = (OutputStreamMonitor.Listener[])((IPropertiesContainer)store).getProperty("StdErrListeners"); //$NON-NLS-1$ + environment = (String[])((IPropertiesContainer)store).getProperty("Environment"); //$NON-NLS-1$ } } @@ -244,6 +267,7 @@ public class ProcessSettings { ((IPropertiesContainer)store).setProperty("PTY", pty); //$NON-NLS-1$ ((IPropertiesContainer)store).setProperty("StdOutListeners", stdoutListeners); //$NON-NLS-1$ ((IPropertiesContainer)store).setProperty("StdErrListeners", stderrListeners); //$NON-NLS-1$ + ((IPropertiesContainer)store).setProperty("Environment", environment); //$NON-NLS-1$ } } } |