String inputType = component.getFacet(HintsFacet.class).getInputType();
OptionCompleter<CompleterInvocation> strategy = null;
if (InputType.FILE_PICKER.equals(inputType) && cwd.isDirectory())
{
strategy = new FileOptionCompleter(new AllResourceFilter());
}
else if (InputType.DIRECTORY_PICKER.equals(inputType) && cwd.isDirectory())
{
strategy = new FileOptionCompleter(new DirectoryResourceFilter());
}
else if (component instanceof SelectComponent)
{
strategy = new SelectComponentOptionCompleter((SelectComponent<?, Object>) component, converterFactory);
}
else if (Resource.class.isAssignableFrom(component.getValueType()))
{
// fall back to Resource completion.
strategy = new FileOptionCompleter(new AllResourceFilter());
}
// Always try UICompleter first and then fallback to the chosen strategy
strategy = new UICompleterOptionCompleter(strategy, context, component, converterFactory);
return strategy;
}