diff options
author | Uwe Stieber | 2014-04-08 08:53:12 +0000 |
---|---|---|
committer | Uwe Stieber | 2014-04-08 08:53:12 +0000 |
commit | f006bd11c27973b13e561c9c7e869baeb1ed9b3e (patch) | |
tree | 2dcc5698dc8bad815b0d31ff4b74d16348d901cd /target_explorer/plugins | |
parent | 8c945fc249e3d507885548c956426ff28f7b495e (diff) | |
download | org.eclipse.tcf-f006bd11c27973b13e561c9c7e869baeb1ed9b3e.tar.gz org.eclipse.tcf-f006bd11c27973b13e561c9c7e869baeb1ed9b3e.tar.xz org.eclipse.tcf-f006bd11c27973b13e561c9c7e869baeb1ed9b3e.zip |
Target Explorer: Add flag to control if the provided environment is merged with native process environment
Diffstat (limited to 'target_explorer/plugins')
5 files changed, 50 insertions, 6 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 23457f3f2..c210b66b3 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 @@ -155,6 +155,12 @@ public interface ITerminalsConnectorConstants { public static final String PROP_PROCESS_ENVIRONMENT = "process.environment"; //$NON-NLS-1$ /** + * Property: Flag to merge process environment with native environment. + * <p>Typical for process terminals. + */ + public static final String PROP_PROCESS_MERGE_ENVIRONMENT = "process.environment.merge"; //$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/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 13f0aeefa..60ac89885 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 @@ -126,6 +126,10 @@ public class LocalConnectorType extends AbstractConnectorType { processSettings.setWorkingDir(workingDir); processSettings.setEnvironment(envp); + if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT)) { + processSettings.setMergeWithNativeEnvironment(properties.getBooleanProperty(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT)); + } + // 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 7b8bff3f6..96416df9a 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 @@ -131,6 +131,10 @@ public class ProcessConnector extends AbstractStreamsConnector { envp = settings.getEnvironment(); } + if (settings.isMergeWithNativeEnvironment()) { + envp = Env.getEnvironment(envp, true); + } + if (pty != null) { // A PTY is available -> can use the ProcessFactory. @@ -151,10 +155,10 @@ public class ProcessConnector extends AbstractStreamsConnector { } // Execute the process - process = ProcessFactory.getFactory().exec(argv.toArray(new String[argv.size()]), Env.getEnvironment(envp, true), workingDir, pty); + process = ProcessFactory.getFactory().exec(argv.toArray(new String[argv.size()]), envp, workingDir, pty); } else { // No PTY -> just execute via the standard Java Runtime implementation. - process = Runtime.getRuntime().exec(command.toString(), Env.getEnvironment(envp, true), workingDir); + process = Runtime.getRuntime().exec(command.toString(), envp, workingDir); } } 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 27c9ec478..c7f67410e 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 @@ -73,6 +73,10 @@ public class ProcessConnectorType extends AbstractConnectorType { processSettings.setWorkingDir(workingDir); processSettings.setEnvironment(envp); + if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT)) { + processSettings.setMergeWithNativeEnvironment(properties.getBooleanProperty(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT)); + } + // 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 be356b9cc..c062f75cb 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 @@ -41,6 +41,10 @@ public class ProcessSettings { private String workingDir; // environment private String[] environment; + // Flag to control if the provided environment is + // automatically merged with the native process environment. + // Defaults to "true". + private boolean mergeWithNativeEnvironment = true; /** * Sets the process image. @@ -194,7 +198,7 @@ public class ProcessSettings { } /** - * Returns the working dir + * Returns the working directory * * @return */ @@ -203,16 +207,16 @@ public class ProcessSettings { } /** - * Sets the working dir of the process + * Sets the working directory of the process * - * @param workingDir the absolute path of the working dir + * @param workingDir the absolute path of the working directory */ public void setWorkingDir(String workingDir) { this.workingDir = workingDir; } /** - * Get theprocess environment + * Get the process environment * * @return */ @@ -230,6 +234,26 @@ public class ProcessSettings { } /** + * Returns if or if not the provided environment is merged with + * the native process environment. + * + * @return <code>True</code> if the provided environment is merged with the native process environment, <code>false</code> otherwise. + */ + public boolean isMergeWithNativeEnvironment() { + return mergeWithNativeEnvironment; + } + + /** + * Sets if or if not the provided environment is merged with the + * native process environment. + * + * @param value <code>True</code> if the provided environment is merged with the native process environment, <code>false</code> otherwise. + */ + public void setMergeWithNativeEnvironment(boolean value) { + this.mergeWithNativeEnvironment = value; + } + + /** * Loads the process settings from the given settings store. * * @param store The settings store. Must not be <code>null</code>. @@ -239,6 +263,7 @@ public class ProcessSettings { image = store.get("Path", null);//$NON-NLS-1$ arguments = store.get("Arguments", null); //$NON-NLS-1$ localEcho = Boolean.parseBoolean(store.get("LocalEcho", Boolean.FALSE.toString())); //$NON-NLS-1$ + mergeWithNativeEnvironment = Boolean.parseBoolean(store.get("MergeWithNativeEnvironment", Boolean.FALSE.toString())); //$NON-NLS-1$ lineSeparator = store.get("LineSeparator", null); //$NON-NLS-1$ workingDir = store.get("WorkingDir", null); //$NON-NLS-1$ if (store instanceof IPropertiesContainer) { @@ -260,6 +285,7 @@ public class ProcessSettings { store.put("Path", image);//$NON-NLS-1$ store.put("Arguments", arguments); //$NON-NLS-1$ store.put("LocalEcho", Boolean.toString(localEcho)); //$NON-NLS-1$ + store.put("MergeWithNativeEnvironment", Boolean.toString(mergeWithNativeEnvironment)); //$NON-NLS-1$ store.put("LineSeparator", lineSeparator); //$NON-NLS-1$ store.put("WorkingDir", workingDir); //$NON-NLS-1$ if (store instanceof IPropertiesContainer) { |