use of org.springframework.roo.shell.Completion in project spring-roo by spring-projects.
the class ObrAddOnBundleSymbolicNameConverter method getAllPossibleValues.
public boolean getAllPossibleValues(final List<Completion> completions, final Class<?> requiredType, final String originalUserInput, final String optionContext, final MethodTarget target) {
final Map<String, ObrBundle> bundles = operations.getAddOnCache();
for (final Entry<String, ObrBundle> entry : bundles.entrySet()) {
final String bsn = entry.getKey();
final ObrBundle bundle = entry.getValue();
completions.add(new Completion(bsn));
}
return false;
}
use of org.springframework.roo.shell.Completion in project spring-roo by spring-projects.
the class JavaPackageConverter method addCompletionsForPackagesInTargetModule.
private void addCompletionsForPackagesInTargetModule(final Collection<Completion> completions, final Pom targetModule, final String heading, final String prefix, final String formattedPrefix) {
final String topLevelPackage = typeLocationService.getTopLevelPackageForModule(targetModule);
completions.add(new Completion(prefix + topLevelPackage, formattedPrefix + topLevelPackage, heading, 1));
for (final JavaType javaType : typeLocationService.getTypesForModule(targetModule)) {
String type = javaType.getFullyQualifiedTypeName();
completions.add(new Completion(prefix + type.substring(0, type.lastIndexOf('.')), formattedPrefix + type.substring(0, type.lastIndexOf('.')), heading, 1));
}
}
use of org.springframework.roo.shell.Completion in project spring-roo by spring-projects.
the class JavaTypeConverter method completeJavaSpecificPaths.
/**
* Adds common "java." types to the completions. For now we just provide
* them statically.
*/
private void completeJavaSpecificPaths(final List<Completion> completions, final String existingData, String optionContext) {
final SortedSet<String> types = new TreeSet<String>();
if (StringUtils.isBlank(optionContext)) {
optionContext = "java-all";
}
if (optionContext.contains("java-all") || optionContext.contains("java-lang")) {
// lang - other
types.add(Boolean.class.getName());
types.add(String.class.getName());
}
if (optionContext.contains("java-all") || optionContext.contains("java-lang") || optionContext.contains("java-number")) {
// lang - numeric
types.add(Number.class.getName());
types.add(Short.class.getName());
types.add(Byte.class.getName());
types.add(Integer.class.getName());
types.add(Long.class.getName());
types.add(Float.class.getName());
types.add(Double.class.getName());
types.add(Byte.TYPE.getName());
types.add(Short.TYPE.getName());
types.add(Integer.TYPE.getName());
types.add(Long.TYPE.getName());
types.add(Float.TYPE.getName());
types.add(Double.TYPE.getName());
}
if (optionContext.contains("java-all") || optionContext.contains("java-number")) {
// misc
types.add(BigDecimal.class.getName());
types.add(BigInteger.class.getName());
}
if (optionContext.contains("java-all") || optionContext.contains("java-util") || optionContext.contains("java-collections")) {
// util
types.add(Collection.class.getName());
types.add(List.class.getName());
types.add(Queue.class.getName());
types.add(Set.class.getName());
types.add(SortedSet.class.getName());
types.add(Map.class.getName());
}
if (optionContext.contains("java-all") || optionContext.contains("java-util") || optionContext.contains("java-date")) {
// util
types.add(Date.class.getName());
types.add(Calendar.class.getName());
}
for (final String type : types) {
if (type.startsWith(existingData) || existingData.startsWith(type)) {
completions.add(new Completion(type));
}
}
}
use of org.springframework.roo.shell.Completion in project spring-roo by spring-projects.
the class PomConverter method addCompletion.
private void addCompletion(final String moduleName, final List<Completion> completions) {
final String nonEmptyModuleName = StringUtils.defaultIfEmpty(moduleName, ROOT_MODULE_SYMBOL);
completions.add(new Completion(nonEmptyModuleName));
}
use of org.springframework.roo.shell.Completion in project spring-roo by spring-projects.
the class BundleSymbolicNameConverter method getAllPossibleValues.
public boolean getAllPossibleValues(final List<Completion> completions, final Class<?> requiredType, final String originalUserInput, final String optionContext, final MethodTarget target) {
boolean local = false;
boolean obr = false;
if ("".equals(optionContext)) {
local = true;
}
if (optionContext.contains("local")) {
local = true;
}
if (optionContext.contains("obr")) {
obr = true;
}
if (local) {
final Bundle[] bundles = context.getBundleContext().getBundles();
if (bundles != null) {
for (final Bundle bundle : bundles) {
final String bsn = bundle.getSymbolicName();
if (bsn != null && bsn.startsWith(originalUserInput)) {
completions.add(new Completion(bsn));
}
}
}
}
if (obr) {
final Repository[] repositories = repositoryAdmin.listRepositories();
if (repositories != null) {
for (final Repository repository : repositories) {
final Resource[] resources = repository.getResources();
if (resources != null) {
for (final Resource resource : resources) {
if (resource.getSymbolicName().startsWith(originalUserInput)) {
completions.add(new Completion(resource.getSymbolicName()));
}
}
}
}
}
}
return false;
}
Aggregations