eclipse plugin: Rewrite ExternalToolInvoker...
...to pass a list of arguments to ProcessBuilder, rather than a string of them. Untested because debian lenny still has eclipse 3.2.2, but the source compiles.
This commit is contained in:
parent
f3a8fa47ae
commit
fc428889c8
2 changed files with 18 additions and 11 deletions
|
@ -4,6 +4,9 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Timotei Dolean
|
||||
|
@ -24,9 +27,13 @@ public class ExternalToolInvoker {
|
|||
* @param useThread true if the process will run in a thread
|
||||
* @throws IOException
|
||||
*/
|
||||
public ExternalToolInvoker(String fileName, String arguments, boolean useThread) throws IOException
|
||||
public ExternalToolInvoker(String fileName, Collection<String> arguments, boolean useThread) throws IOException
|
||||
{
|
||||
processBuilder_ = new ProcessBuilder(fileName,arguments);
|
||||
List<String> commandline = new ArrayList<String>();
|
||||
commandline.add(fileName);
|
||||
commandline.addAll(arguments);
|
||||
/// @todo
|
||||
processBuilder_ = new ProcessBuilder(commandline);
|
||||
if (useThread)
|
||||
processThread_ = new Thread(new Runnable() {
|
||||
|
||||
|
@ -92,7 +99,7 @@ public class ExternalToolInvoker {
|
|||
return process_.getErrorStream();
|
||||
}
|
||||
|
||||
public static boolean launchTool(String fileName, String args, boolean showOutput, boolean useThread){
|
||||
public static boolean launchTool(String fileName, Collection<String> args, boolean showOutput, boolean useThread){
|
||||
try{
|
||||
ExternalToolInvoker toolInvoker = new ExternalToolInvoker(fileName, args, useThread);
|
||||
toolInvoker.run();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package wesnoth_eclipse_plugin.handlers;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
|
@ -15,12 +17,7 @@ import wesnoth_eclipse_plugin.preferences.PreferenceInitializer;
|
|||
|
||||
public class OpenEditorHandler extends AbstractHandler
|
||||
{
|
||||
/**
|
||||
* the arguments to launch the editor
|
||||
* %s - the filename of the file to be edited
|
||||
* %s - the data directory
|
||||
*/
|
||||
public final static String EDITOR_LAUNCH_ARGS = "-e %s";// %s";;
|
||||
public final static String EDITOR_LAUNCH_ARGS = "-e";
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException
|
||||
{
|
||||
|
@ -44,9 +41,12 @@ public class OpenEditorHandler extends AbstractHandler
|
|||
return null;
|
||||
}
|
||||
|
||||
public static String getLaunchEditorArguments(String mapName, String workingDir)
|
||||
public static Collection<String> getLaunchEditorArguments(String mapName, String workingDir)
|
||||
{
|
||||
String args = String.format(EDITOR_LAUNCH_ARGS, mapName,workingDir);
|
||||
Collection<String> args = new ArrayList<String>(2);
|
||||
String path = workingDir + File.separator + mapName;
|
||||
args.add(EDITOR_LAUNCH_ARGS);
|
||||
args.add(path);
|
||||
return args;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue