Search in sources :

Example 11 with Completion

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;
}
Also used : Completion(org.springframework.roo.shell.Completion) ObrBundle(org.springframework.roo.obr.addon.search.model.ObrBundle)

Example 12 with Completion

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));
    }
}
Also used : JavaType(org.springframework.roo.model.JavaType) Completion(org.springframework.roo.shell.Completion)

Example 13 with Completion

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));
        }
    }
}
Also used : SortedSet(java.util.SortedSet) TreeSet(java.util.TreeSet) Set(java.util.Set) Calendar(java.util.Calendar) SortedSet(java.util.SortedSet) BigDecimal(java.math.BigDecimal) Date(java.util.Date) BigInteger(java.math.BigInteger) Completion(org.springframework.roo.shell.Completion) TreeSet(java.util.TreeSet) BigInteger(java.math.BigInteger) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) Queue(java.util.Queue) Map(java.util.Map)

Example 14 with Completion

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));
}
Also used : Completion(org.springframework.roo.shell.Completion)

Example 15 with Completion

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;
}
Also used : Repository(org.apache.felix.bundlerepository.Repository) Completion(org.springframework.roo.shell.Completion) Bundle(org.osgi.framework.Bundle) Resource(org.apache.felix.bundlerepository.Resource)

Aggregations

Completion (org.springframework.roo.shell.Completion)16 JavaType (org.springframework.roo.model.JavaType)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)4 Pom (org.springframework.roo.project.maven.Pom)4 File (java.io.File)1 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 Calendar (java.util.Calendar)1 Collection (java.util.Collection)1 Date (java.util.Date)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Queue (java.util.Queue)1 Set (java.util.Set)1 SortedSet (java.util.SortedSet)1 TreeSet (java.util.TreeSet)1 Repository (org.apache.felix.bundlerepository.Repository)1 Resource (org.apache.felix.bundlerepository.Resource)1