Package org.apache.karaf.shell.console.completer

Examples of org.apache.karaf.shell.console.completer.StringsCompleter


    public void setAdminService(AdminService adminService) {
        this.adminService = adminService;
    }

    public int complete(String buffer, int cursor, List candidates) {
        StringsCompleter delegate = new StringsCompleter();
        for (Instance instance : adminService.getInstances()) {
            delegate.getStrings().add(instance.getName());
        }
        return delegate.complete(buffer, cursor, candidates);
    }
View Full Code Here


    public CaveRepositoryService getCaveRepositoryService() {
        return this.caveRepositoryService;
    }

    public int complete(String buffer, int cursor, List candidates) {
        StringsCompleter delegate = new StringsCompleter();
        for (CaveRepository caveRepository : caveRepositoryService.getRepositories()) {
            delegate.getStrings().add(caveRepository.getName());
        }
        return delegate.complete(buffer, cursor, candidates);
    }
View Full Code Here

    }

    @Override
    public int complete(String buffer, int cursor, List<String> candidates) {

        StringsCompleter delegate = new StringsCompleter();
        try {
            if (buffer == null) {
                if (lastCommand == null) {
                    addStandardArguments(delegate);
                } else {
                    addCandidates(delegate, lastCommand);
                }
            } else {
                lastCommand = ServiceCommandArguments.valueOf(buffer.toUpperCase());
                switch (lastCommand) {
                    case LIST:
                        return delegate.complete(buffer, cursor, candidates);
                    case CREATE:
                        lastCommand = CREATE;
                        addDomains(candidates);
                        return new StringsCompleter().complete(buffer, cursor, candidates);
                    case UPDATE:
                        // TODO: see OPENENGSB-2282
                        break;
                    case DELETE:
                        lastCommand = DELETE;
                        addServiceIds(candidates);
                        return new StringsCompleter().complete(buffer, cursor, candidates);
                    default:
                        break;
                }
            }
        } catch (IllegalArgumentException ex) {
            if (lastCommand != null) {
                addCandidates(delegate, lastCommand);
                lastCommand = null;
            } else {
                addStandardArguments(delegate);
            }
        }
        return delegate.complete(buffer, cursor, candidates);
    }
View Full Code Here

     * @see Completer#complete(java.lang.String, int, java.util.List)
     * @since 1.0
     */
    @Override
    public int complete(String buffer, int cursor, List candidates) {
        StringsCompleter delegate = new StringsCompleter();
        delegate.getStrings().add("success");
        delegate.getStrings().add("failure");
        delegate.getStrings().add("warning");
        delegate.getStrings().add("building");
        delegate.getStrings().add("off");
        return delegate.complete(buffer, cursor, candidates);
    }
View Full Code Here

     * @see Completer#complete(java.lang.String, int, java.util.List)
     * @since 1.0
     */
    @Override
    public int complete(String buffer, int cursor, List candidates) {
        StringsCompleter delegate = new StringsCompleter();
        Iterator iter = indicators.iterator();
        int i = -1;
        while(iter.hasNext()){
            i++;
            IBuildStatusIndicator ibsi = (IBuildStatusIndicator) iter.next();
            // we only need the id for this one
            delegate.getStrings().add(String.valueOf(i));
        }
        return delegate.complete(buffer, cursor, candidates);
    }
View Full Code Here

        this.unassigned = unassigned;
    }

    @Override
    public int complete(String buffer, int cursor, List<String> candidates) {
        StringsCompleter delegate = new StringsCompleter();
        try {
            Version version = getFabricService().getRequiredDefaultVersion();
            Container container = getFabricService().getCurrentContainer();
            try{
                container =  getFabricService().getContainer(getContainer(CommandSessionHolder.getSession(), containerArgumentIndex));
            } catch (Exception ex) {
                // Ignore and use current container.
            }

            Profile[] containerProfiles = container.getProfiles();
            List<String> containerProfileNames = new LinkedList<String>();
            if (containerProfiles != null) {
                for (Profile p : containerProfiles) {
                    containerProfileNames.add(p.getId());
                }
            }

            List<Profile> profiles = version.getProfiles();
            List<String> allProfileNames = new LinkedList<String>();
            if (containerProfiles != null) {
                for (Profile p : profiles) {
                    allProfileNames.add(p.getId());
                }
            }

            if ( assigned && unassigned) {
                delegate.getStrings().addAll(allProfileNames);
            } else if (assigned) {
                delegate.getStrings().addAll(containerProfileNames);
            } else if (unassigned) {
                allProfileNames.removeAll(containerProfileNames);
                delegate.getStrings().addAll(allProfileNames);
            }
        } catch (Exception ex) {
            //Ignore Exceptions
        }
        return delegate.complete(buffer, cursor, candidates);
    }
View Full Code Here

        this.uninstalled = false;
    }

    @Override
    public int complete(String buffer, int cursor, List<String> candidates) {
        StringsCompleter delegate = new StringsCompleter();
        for (Patch patch : service.getPatches()) {
            if (isInstalled() && patch.isInstalled()
                    || isUninstalled() && !patch.isInstalled()) {
                delegate.getStrings().add(patch.getId());
            }
        }
        return delegate.complete(buffer, cursor, candidates);
    }
View Full Code Here

    private List<String> archetypes = new ArrayList<String>();

    @Override
    public int complete(final String buffer, final int cursor, final List candidates) {
        StringsCompleter delegate = new StringsCompleter(archetypes);
        return delegate.complete(buffer, cursor, candidates);
    }
View Full Code Here

        deactivateComponent();
    }

    @SuppressWarnings("unchecked")
    public int complete(String buffer, int cursor, List candidates) {
        StringsCompleter delegate = new StringsCompleter();
        try {
            if (curator.getZookeeperClient().isConnected()) {
                delegate.getStrings().addAll(getChildren(curator, CLUSTER_PATH));
            }
        } catch (Exception ex) {
            //ignore
        }
        return delegate.complete(buffer, cursor, candidates);
    }
View Full Code Here

    @Reference
    private FeaturesService featuresService;

    @Override
    public int complete(String buffer, int cursor, List<String> candidates) {
        StringsCompleter delegate = new StringsCompleter();
        try {
            delegate.getStrings().addAll(getFeatureLocations());
        } catch (Exception ex) {
            //ignore
        }
        return delegate.complete(buffer, cursor, candidates);
    }
View Full Code Here

TOP

Related Classes of org.apache.karaf.shell.console.completer.StringsCompleter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.