use of org.omegat.core.threads.CommandMonitor in project omegat by omegat-org.
the class RealProject method doExternalCommand.
/**
* Set up and execute the user-specified external command.
* @param command Command to execute
*/
private void doExternalCommand(String command) {
if (StringUtil.isEmpty(command)) {
return;
}
Core.getMainWindow().showStatusMessageRB("CT_START_EXTERNAL_CMD");
CommandVarExpansion expander = new CommandVarExpansion(command);
command = expander.expandVariables(config);
Log.log("Executing command: " + command);
try {
Process p = Runtime.getRuntime().exec(StaticUtils.parseCLICommand(command));
processCache.push(p);
CommandMonitor stdout = CommandMonitor.newStdoutMonitor(p);
CommandMonitor stderr = CommandMonitor.newStderrMonitor(p);
stdout.start();
stderr.start();
} catch (IOException e) {
String message;
Throwable cause = e.getCause();
if (cause == null) {
message = e.getLocalizedMessage();
} else {
message = cause.getLocalizedMessage();
}
Core.getMainWindow().showStatusMessageRB("CT_ERROR_STARTING_EXTERNAL_CMD", message);
}
}
Aggregations