Path Search

The path search component asks base directory for scan and optional search expression. Results are shown in a single select list where user can pick a path. PathSearchConfig can be used to customise component behaviour.spring-doc.cn

PathSearchConfig config = new PathSearch.PathSearchConfig();
config.setMaxPathsShow(5);
config.setMaxPathsSearch(100);
config.setSearchForward(true);
config.setSearchCaseSensitive(false);
config.setSearchNormalize(false);

PathSearch component = new PathSearch(getTerminal(), "Enter value", config);
component.setResourceLoader(getResourceLoader());
component.setTemplateExecutor(getTemplateExecutor());

PathSearchContext context = component.run(PathSearchContext.empty());
return "Got value " + context.getResultValue();
Logic for search is passed as is into algorithms documented in Search Algorithms.

The following screencast shows typical output from a path search component:spring-doc.cn

The context object is PathSearchContext. The following table describes its context variables:spring-doc.cn

Table 1. PathSearchContext Template Variables
Key Description

pathViewItemsspring-doc.cn

The items available for rendering search results.spring-doc.cn

modelspring-doc.cn

The parent context variables (see TextComponentContext Template Variables).spring-doc.cn