use of org.apache.tools.ant.input.InputRequest in project freeplane by freeplane.
the class TaskUtils method multipleChoice.
@SuppressWarnings("unchecked")
static String multipleChoice(Project project, String message, String validValues, String defaultValue) {
InputRequest request = null;
if (validValues != null) {
Vector<String> accept = StringUtils.split(validValues, ',');
request = new MultipleChoiceInputRequest(message, accept);
} else {
request = new InputRequest(message);
}
InputHandler handler = project.getInputHandler();
handler.handleInput(request);
final String value = request.getInput();
if ((value == null || value.trim().length() == 0) && defaultValue != null) {
return defaultValue;
}
return value;
}
use of org.apache.tools.ant.input.InputRequest in project ant by apache.
the class Input method execute.
/**
* Actual method executed by ant.
* @throws BuildException on error
*/
@Override
public void execute() throws BuildException {
if (addproperty != null && getProject().getProperty(addproperty) != null) {
log("skipping " + getTaskName() + " as property " + addproperty + " has already been set.");
return;
}
InputRequest request = null;
if (validargs != null) {
final List<String> accept = StringUtils.split(validargs, ',');
request = new MultipleChoiceInputRequest(message, accept);
} else {
request = new InputRequest(message);
}
request.setDefaultValue(defaultvalue);
final InputHandler h = handler == null ? getProject().getInputHandler() : handler.getInputHandler();
h.handleInput(request);
String value = request.getInput();
if ((value == null || value.trim().isEmpty()) && defaultvalue != null) {
value = defaultvalue;
}
if (addproperty != null && value != null) {
getProject().setNewProperty(addproperty, value);
}
}
Aggregations