Package org.apache.karaf.shell.support.table

Examples of org.apache.karaf.shell.support.table.ShellTable


        FrameworkStartLevel fsl = this.bundleContext.getBundle(0).adapt(FrameworkStartLevel.class);
        if (fsl != null) {
            System.out.println("START LEVEL " + fsl.getStartLevel() + " , List Threshold: " + bundleLevelThreshold);
        }

        ShellTable table = new ShellTable();
        table.column("ID").alignRight();
        table.column("State");
        table.column("Lvl").alignRight();
        table.column("Version");
        table.column(getNameHeader());
       
        for (Bundle bundle : bundles) {
            BundleInfo info = this.bundleService.getInfo(bundle);
            if (info.getStartLevel() >= bundleLevelThreshold) {
                String name = getNameToShow(info) + printFragments(info) + printHosts(info);
                String version = info.getVersion();
                table.addRow().addContent(info.getBundleId(), getStateString(info.getState()),
                        info.getStartLevel(), version, name);
            }
        }
        table.print(System.out, !noFormat);
        return null;
    }
View Full Code Here


    @Override
    public Object execute() throws Exception {
        Map<String, Set<String>> requirements = featuresService.listRequirements();

        ShellTable table = new ShellTable();
        table.column("Region");
        table.column("Requirement");
        table.emptyTableText("No requirements defined");

        for (Map.Entry<String, Set<String>> entry : requirements.entrySet()) {
            for (String requirement : entry.getValue()) {
                table.addRow().addContent(entry.getKey(), requirement);
            }
        }

        table.print(System.out, !noFormat);

        return null;
    }
View Full Code Here

    protected void doExecute(FeaturesService featuresService) throws Exception {
        if (reload) {
            reloadAllRepos(featuresService);
        }
       
        ShellTable table = new ShellTable();
        table.column("Repository");
        table.column("URL");
        table.emptyTableText("No repositories available");

        Repository[] repos = featuresService.listRepositories();
       for (Repository repo : repos) {
            if (repo != null) {
               table.addRow().addContent(repo.getName(), repo.getURI().toString());
            }
       }
       table.print(System.out, !noFormat);
    }
View Full Code Here

    boolean noFormat;

    protected void doExecute(FeaturesService featuresService) throws Exception {
        boolean needsLegend = false;
       
        ShellTable table = new ShellTable();
        table.column("Name");
        table.column("Version");
        table.column("Required");
        table.column("Installed");
        table.column("Repository");
        table.column("Description").maxSize(50);
        table.emptyTableText(onlyInstalled ? "No features installed" : "No features available");

        List<Repository> repos = Arrays.asList(featuresService.listRepositories());
        for (Repository r : repos) {
            List<Feature> features = Arrays.asList(r.getFeatures());
            if (ordered) {
                Collections.sort(features, new FeatureComparator());
            }
            for (Feature f : features) {
                if (onlyInstalled && !featuresService.isInstalled(f)) {
                    // Filter out not installed features if we only want to see the installed ones
                    continue;
                }
                if (onlyRequired && !featuresService.isRequired(f)) {
                    // Filter out not installed features if we only want to see the installed ones
                    continue;
                }
                if (!showHidden && f.isHidden()) {
                    // Filter out hidden feature if not asked to display those
                    continue;
                }
                table.addRow().addContent(
                        f.getName(),
                        f.getVersion(),
                        featuresService.isRequired(f) ? "x" : "",
                        featuresService.isInstalled(f) ? "x" : "",
                        r.getName(),
                        f.getDescription());
                if (isInstalledViaDeployDir(r.getName())) {
                    needsLegend = true;
                }
            }
        }

        table.print(System.out, !noFormat);

        if (needsLegend) {
            System.out.println("* Installed via deploy directory");
        }

View Full Code Here

    @Option(name = "--no-format", description = "Disable table rendered output", required = false, multiValued = false)
    boolean noFormat;

    protected void doExecute(FeaturesService admin) throws Exception {
        ShellTable table = new ShellTable();
        table.column("Version");
        table.column("Repository");
        table.column("Repository URL");
        table.emptyTableText("No versions available for features '" + feature + "'");
            
        for (Repository r : Arrays.asList(admin.listRepositories())) {
            for (Feature f : r.getFeatures()) {

                if (f.getName().equals(feature)) {
                    table.addRow().addContent(f.getVersion(), r.getName(), r.getURI());
                }
            }
        }

        table.print(System.out, !noFormat);
    }
View Full Code Here

    private KarService karService;

    @Override
    public Object execute() throws Exception {

        ShellTable table = new ShellTable();
        table.column("KAR Name");

        for (String karName : karService.list()) {
            table.addRow().addContent(karName);
        }

        table.print(System.out, !noFormat);

        return null;
    }
View Full Code Here

    @Reference
    JndiService jndiService;

    @Override
    public Object execute() throws Exception {
        ShellTable table = new ShellTable();

        table.column("JNDI Sub-Context");

        List<String> contexts;
        if (context == null) {
            contexts = jndiService.contexts();
        } else {
            contexts = jndiService.contexts(context);
        }

        for (String c : contexts) {
            table.addRow().addContent(c);
        }

        table.print(System.out);

        return null;
    }
View Full Code Here

    @Reference
    JndiService jndiService;

    @Override
    public Object execute() throws Exception {
        ShellTable table = new ShellTable();

        table.column("JNDI Name");
        table.column("Class Name");

        Map<String, String> names;
        if (context == null) {
            names = jndiService.names();
        } else {
            names = jndiService.names(context);
        }

        for (String name : names.keySet()) {
            table.addRow().addContent(name, names.get(name));
        }

        table.print(System.out);

        return null;
    }
View Full Code Here

    protected void printMethodList(Session session, PrintStream out, SortedMap<String, String> commands) {
        Terminal term = session.getTerminal();
        int termWidth = term != null ? term.getWidth() : 80;
        out.println(SimpleAnsi.INTENSITY_BOLD + "COMMANDS" + SimpleAnsi.INTENSITY_NORMAL);
        ShellTable table = new ShellTable().noHeaders().separator(" ").size(termWidth);
        table.column(new Col("Command").maxSize(64));
        table.column(new Col("Description"));
        for (Map.Entry<String,String> entry : commands.entrySet()) {
            String key = NameScoping.getCommandNameWithoutGlobalPrefix(session, entry.getKey());
            table.addRow().addContent(SimpleAnsi.INTENSITY_BOLD + key + SimpleAnsi.INTENSITY_NORMAL, entry.getValue());
        }
        table.print(out, true);
    }
View Full Code Here

    private final IdComparator idComparator = new IdComparator();

    @Override
    protected Object doScrAction(ScrService scrService) throws Exception {
        ShellTable table = new ShellTable();
        table.column("ID");
        table.column("State");
        table.column("Component Name");

        Component[] components = scrService.getComponents();
        Arrays.sort(components, idComparator);
        for (Component component : ScrUtils.emptyIfNull(Component.class, components)) {
            // Display only non hidden components, or all if showHidden is true
            if (showHidden || !ScrActionSupport.isHiddenComponent(component)) {
                table.addRow().addContent(component.getId(), ScrUtils.getState(component.getState()), component.getName());
            }
        }
        table.print(System.out);

        return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.karaf.shell.support.table.ShellTable

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.