Package org.apache.karaf.shell.table

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


            }
        }
       
        } else {
       
        ShellTable table = new ShellTable();
        table.column("ID").alignRight();
        table.column("State");
        table.column("Lvl").alignRight();
        table.column("Version");
        table.column(getNameHeader());
       
        for (int i = 0; i < bundles.length; i++) {
            Bundle bundle = bundles[i];
            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);
        }
        return null;
    }
View Full Code Here


    boolean ordered;

    protected void doExecute(FeaturesService featuresService) throws Exception {
        boolean needsLegend = false;
       
        ShellTable table = new ShellTable();
        table.column("Name");
        table.column("Version");
        table.column("Installed");
        table.column("Repository");
        table.column("Description");
        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;
                }
                table.addRow().addContent(
                        f.getName(),
                        f.getVersion(),
                        featuresService.isInstalled(f) ? "x" : "",
                        r.getName(),
                        f.getDescription());
                if (isInstalledViaDeployDir(r.getName())) {
                    needsLegend = true;
                }
            }
        }

        table.print(System.out);

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

View Full Code Here

  @Argument(index = 0, name = "feature", description = "Name of feature.", required = true, multiValued = false)
  String feature;

    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);
    }
View Full Code Here

        }
    }

    void printThreadList(ThreadMXBean threadsBean) {
        ThreadInfo[] threadInfoAr = threadsBean.dumpAllThreads(false, false);
        ShellTable table = new ShellTable();
        table.column("Id");
        table.column("Name");
        table.column("State");
        table.column("CPU time");
        table.column("User time");
        for (ThreadInfo ti : threadInfoAr) {
            long id = ti.getThreadId();
            table.addRow().addContent(id, ti.getThreadName(), ti.getThreadState(), threadsBean.getThreadCpuTime(id) / 1000000, threadsBean.getThreadUserTime(id) / 1000000);
        }
        table.print(System.out);
    }
View Full Code Here

public class ShellTableTest {

    @Test
    public void testTable() {
        ShellTable table = new ShellTable();
        table.column(new Col("id").alignRight().maxSize(5));
        table.column(new Col("Name").maxSize(20));
        table.column(new Col("Centered").alignCenter());

        table.addRow().addContent(1, "Test", "Description");
        table.addRow().addContent(20, "My name", "Description");

        Row row = table.addRow();
        row.addContent(123456789);
        row.addContent("A very long text that should be cut");
        row.addContent("A very long text that should not be cut");

        StringWriter writer = new StringWriter();
        PrintStream out = new PrintStream(new WriterOutputStream(writer));
        table.print(out);
        out.flush();
        String expected =
                "   id | Name                 |                Centered                \n" +
                "----------------------------------------------------------------------\n" +
                "    1 | Test                 |               Description              \n" +
View Full Code Here

        Assert.assertEquals(expected, getString(writer));
    }

    @Test
    public void testGrow() {
        ShellTable table = new ShellTable().size(10);
        table.column(new Col("1"));
        table.column(new Col("2"));

        table.addRow().addContent("1", "2");

        StringWriter writer = new StringWriter();
        PrintStream out = new PrintStream(new WriterOutputStream(writer));
        table.print(out);
        out.flush();
        String expected =
                "1      | 2\n" +
            "----------\n" +
            "1      | 2\n";
View Full Code Here

        Assert.assertEquals(expected, getString(writer));
    }

    @Test
    public void testShrink() {
        ShellTable table = new ShellTable().size(10);
        table.column(new Col("1").maxSize(5));
        table.column(new Col("2").alignRight());

        table.addRow().addContent("quite long", "and here an even longer text");

        StringWriter writer = new StringWriter();
        PrintStream out = new PrintStream(new WriterOutputStream(writer));
        table.print(out);
        out.flush();
        String expected = //
                  "1     |  2\n" //
                + "----------\n" //
                + "quite |  a\n";
View Full Code Here

        Assert.assertEquals(expected, getString(writer));
    }

    @Test
    public void testTooSmall() {
        ShellTable table = new ShellTable().size(2);
        table.column(new Col("1").maxSize(5));
        table.column(new Col("2").alignRight());

        table.addRow().addContent("quite long", "and here an even longer text");

        StringWriter writer = new StringWriter();
        PrintStream out = new PrintStream(new WriterOutputStream(writer));
        table.print(out);
        out.flush();
        String expected = //
                  "1     | \n" + //
                  "--------\n" + //
                  "quite | \n";
View Full Code Here

        this.packageService = packageService;
    }

    protected Object doExecute() throws Exception {
        SortedMap<String, PackageRequirement> imports = packageService.getImports();
        ShellTable table = new ShellTable();
        table.column(new Col(onlyPackage ? "Package name" : "Filter"));
        table.column(new Col("Optional"));
        table.column(new Col("ID"));
        table.column(new Col("Bundle Name"));
        table.column(new Col("Resolveable"));
       
        for (String filter : imports.keySet()) {
            PackageRequirement req = imports.get(filter);
            Bundle bundle = req.getBundle();
            String firstCol = onlyPackage ? req.getPackageName() : req.getFilter();
            table.addRow().addContent(firstCol, req.isOptional() ? "optional" : "", bundle.getBundleId(), bundle.getSymbolicName(), req.isResolveable());
        }
        table.print(System.out);
        return null;
    }
View Full Code Here

        this.packageService = packageService;
    }

    protected Object doExecute() throws Exception {
        SortedMap<String, PackageVersion> exports = packageService.getExports();
        ShellTable table = new ShellTable();
        table.column(new Col("Package Name"));
        table.column(new Col("Version"));
        table.column(new Col("ID"));
        table.column(new Col("Bundle Name"));
       
        for (String key : exports.keySet()) {
            PackageVersion pVer = exports.get(key);
            for (Bundle bundle : pVer.getBundles()) {
                table.addRow().addContent(pVer.getPackageName(),pVer.getVersion().toString(), bundle.getBundleId(), bundle.getSymbolicName());
            }
        }
        table.print(System.out);
        return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.karaf.shell.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.