X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java index 8d45c41..d33e69e 100644 --- a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java +++ b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java @@ -1,6 +1,11 @@ package net.sourceforge.phpdt.internal.launching; import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import net.sourceforge.phpdt.internal.core.JavaProject; @@ -9,12 +14,16 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.internal.ui.launchConfigurations.EnvironmentVariable; + public class InterpreterRunnerConfiguration { protected ILaunchConfiguration configuration; + private HashMap fEnvironment; public InterpreterRunnerConfiguration(ILaunchConfiguration aConfiguration) { configuration = aConfiguration; + fEnvironment= new HashMap(); } public String getAbsoluteFileName() { @@ -94,6 +103,47 @@ public class InterpreterRunnerConfiguration { return false; } + public void setEnvironment(String[] envp) + { + if (envp== null) + return; + for (int i = 0; i<envp.length; i++ ) { + addEnvironmentValue(envp[i],true); + } + } + + public void addEnvironmentValue(String env,boolean replace) + { + String value = env.substring(env.indexOf('=')+1); + String key = env.substring(0,env.indexOf('=')); + addEnvironmentValue(key,value,replace); + } + + public void addEnvironmentValue(String key, String value,boolean replace) + { + if (!replace && fEnvironment.containsKey(key)) { + EnvironmentVariable ev = (EnvironmentVariable) fEnvironment.get(key); + ev.setValue(ev.getValue()+";"+value); + fEnvironment.put(key,ev); + } else + this.fEnvironment.put(key, new EnvironmentVariable(key, value)); + } + + public String[] getEnvironment() + { + + Iterator iter= fEnvironment.entrySet().iterator(); + List strings= new ArrayList(fEnvironment.size()); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry) iter.next(); + StringBuffer buffer= new StringBuffer((String) entry.getKey()); + buffer.append('=').append(((EnvironmentVariable) entry.getValue()).getValue()); + strings.add(buffer.toString()); + } + return (String[]) strings.toArray(new String[strings.size()]); + + } + public String getRemoteSourcePath() { IProject project = getProject().getProject();