use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.
the class JmsCommands method returnApplicationPackages.
@CliOptionAutocompleteIndicator(command = "jms receiver", param = "endpoint", validate = false, includeSpaceOnFinish = false, help = "--endpoint parameter parameter is the service where will be added the " + "support to send emails.")
public List<String> returnApplicationPackages(ShellContext shellContext) {
List<String> applicationPackages = new ArrayList<String>();
// Get only application modules
StringBuffer matcher = new StringBuffer("feature[");
matcher.append(ModuleFeatureName.APPLICATION).append("]");
JavaPackageConverter converter = (JavaPackageConverter) getJavaPackageConverterService().get(0);
List<Completion> completions = new ArrayList<Completion>();
converter.getAllPossibleValues(completions, String.class, shellContext.getParameters().get("endpoint"), matcher.toString(), null);
for (Completion completion : completions) {
applicationPackages.add(completion.getValue());
}
return applicationPackages;
}
use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.
the class TestCommands method getClassPosibleValues.
@CliOptionAutocompleteIndicator(command = "test unit", help = "Option `--class` must " + "be a non-abstract valid type. Please, use auto-complete feature to select it.", param = "class")
public List<String> getClassPosibleValues(ShellContext shellContext) {
// Get current value of class
String currentText = shellContext.getParameters().get("class");
// Create results to return
List<String> results = new ArrayList<String>();
// Look for all valid types for all available test creators
for (TestCreatorProvider creator : getAllTestCreators()) {
if (creator.isUnitTestCreationAvailable()) {
for (JavaType annotationType : creator.getValidTypes()) {
// Look for types with this annotation type
Set<ClassOrInterfaceTypeDetails> types = typeLocationService.findClassesOrInterfaceDetailsWithAnnotation(annotationType);
for (ClassOrInterfaceTypeDetails typeCid : types) {
String name = replaceTopLevelPackageString(typeCid.getType(), currentText);
if (!results.contains(name) && !typeCid.isAbstract()) {
results.add(name);
}
}
}
}
}
return results;
}
use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.
the class ControllerCommands method getAllAvailableViews.
@CliOptionAutocompleteIndicator(command = "web mvc detail", param = "views", includeSpaceOnFinish = false, help = "--views parameter could be autocomplete with a separated comma list including 'list' and 'show'. If --entity parameter " + "has been specified, is possible to autocomplete with existing finder views too.")
public List<String> getAllAvailableViews(ShellContext shellContext) {
List<String> viewsValuesToReturn = new ArrayList<String>();
// Get current views in --views value
String currentViewsValue = shellContext.getParameters().get("views");
String[] views = StringUtils.split(currentViewsValue, ",");
// Check for bad written separators and return no options
if (currentViewsValue.contains(",.") || currentViewsValue.contains(".,")) {
return viewsValuesToReturn;
}
// Check if --entity parameter has been specified
JavaType currentEntity = getTypeFromEntityParam(shellContext);
List<String> finderViews = new ArrayList<String>();
if (currentEntity != null) {
// Obtain search controllers for the current entity
Collection<ClassOrInterfaceTypeDetails> searchControllers = getControllerLocator().getControllers(currentEntity, ControllerType.SEARCH, RooJavaType.ROO_THYMELEAF);
for (ClassOrInterfaceTypeDetails searchController : searchControllers) {
SearchAnnotationValues searchAnnotationValues = new SearchAnnotationValues(searchController);
if (searchAnnotationValues.getFinders() != null && searchAnnotationValues.getFinders().length > 0) {
finderViews.addAll(Arrays.asList(searchAnnotationValues.getFinders()));
}
}
}
// Check if it is first view
if (currentViewsValue.equals("")) {
viewsValuesToReturn.add("list");
viewsValuesToReturn.add("show");
viewsValuesToReturn.addAll(finderViews);
} else if (currentViewsValue.endsWith(",")) {
String finishedViews = "";
for (int i = 0; i < views.length; i++) {
finishedViews += views[i] + ",";
}
if (!finishedViews.contains("list,")) {
viewsValuesToReturn.add(finishedViews + "list");
}
if (!finishedViews.contains("show,")) {
viewsValuesToReturn.add(finishedViews + "show");
}
for (String finderView : finderViews) {
if (!finishedViews.contains(finderView + ",")) {
viewsValuesToReturn.add(finishedViews + finderView);
}
}
} else if (views.length == 1) {
viewsValuesToReturn.add("list");
viewsValuesToReturn.add("show");
viewsValuesToReturn.addAll(finderViews);
} else {
String finishedViews = "";
for (int i = 0; i < views.length - 1; i++) {
finishedViews += views[i] + ",";
}
if (!finishedViews.contains("list,")) {
viewsValuesToReturn.add(finishedViews + "list");
}
if (!finishedViews.contains("show,")) {
viewsValuesToReturn.add(finishedViews + "show");
}
for (String finderView : finderViews) {
if (!finishedViews.contains(finderView + ",")) {
viewsValuesToReturn.add(finishedViews + finderView);
}
}
}
return viewsValuesToReturn;
}
use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.
the class ControllerCommands method getAllControllerForOperationCommandValues.
// operation command
@CliOptionAutocompleteIndicator(param = "controller", command = "web mvc operation", help = "--controller parameter should be completed with an controller generated previously or with a name that will be used to create a new controller.")
public List<String> getAllControllerForOperationCommandValues(ShellContext context) {
// Get the actual controller selected
String currentText = context.getParameters().get("controller");
// Create results to return
List<String> results = new ArrayList<String>();
// Get controllers full qualified names
Set<ClassOrInterfaceTypeDetails> controllers = getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_CONTROLLER);
for (ClassOrInterfaceTypeDetails controller : controllers) {
String name = getClasspathOperations().replaceTopLevelPackageString(controller, currentText);
if (!results.contains(name)) {
results.add(name);
}
}
return results;
}
use of org.springframework.roo.shell.CliOptionAutocompleteIndicator in project spring-roo by spring-projects.
the class ControllerCommands method getAllEntitiesForDetailCommands.
@CliOptionAutocompleteIndicator(command = "web mvc detail", param = "entity", help = "--entity parameter must be an existing class annotated with @RooJpaEntity. Please, assign a valid one.")
public List<String> getAllEntitiesForDetailCommands(ShellContext shellContext) {
// Get current value of class
String currentText = shellContext.getParameters().get("entity");
// Create results to return
List<String> results = new ArrayList<String>();
// Get entity full qualified names
Set<ClassOrInterfaceTypeDetails> entities = getTypeLocationService().findClassesOrInterfaceDetailsWithAnnotation(RooJavaType.ROO_JPA_ENTITY);
for (ClassOrInterfaceTypeDetails entity : entities) {
String name = getClasspathOperations().replaceTopLevelPackageString(entity, currentText);
if (!results.contains(name)) {
results.add(name);
}
}
return results;
}
Aggregations