use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class Exports method showExports.
private void showExports() {
List<PackageVersion> exports = packageService.getExports();
ShellTable table = new ShellTable();
table.column("Package Name");
if (!showOnlyName) {
table.column("Version");
table.column("ID");
table.column("Bundle Name");
}
for (PackageVersion pVer : exports) {
for (Bundle bundle : pVer.getBundles()) {
if (matchesFilter(pVer, bundle)) {
if (!showOnlyName) {
table.addRow().addContent(pVer.getPackageName(), pVer.getVersion().toString(), bundle.getBundleId(), bundle.getSymbolicName());
} else {
table.addRow().addContent(pVer.getPackageName());
}
}
}
}
table.print(System.out, !noFormat);
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class ListUrlCommand method doExecute.
protected void doExecute(RepositoryAdmin admin) {
ShellTable table = new ShellTable();
table.column("Index");
table.column("OBR URL");
table.emptyTableText("No OBR repository URL");
Repository[] repos = admin.listRepositories();
if (repos != null) {
for (int i = 0; i < repos.length; i++) {
table.addRow().addContent(i, repos[i].getURI());
}
}
table.print(System.out, !noFormat);
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class List method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column(new Col("ID"));
table.column(new Col("State"));
table.column(new Col("Web-State"));
table.column(new Col("Level"));
table.column(new Col("Web-ContextPath"));
table.column(new Col("Name"));
java.util.List<WebBundle> webBundles = webContainerService.list();
if (webBundles != null && !webBundles.isEmpty()) {
for (WebBundle webBundle : webBundles) {
table.addRow().addContent(webBundle.getBundleId(), webBundle.getState(), webBundle.getWebState(), webBundle.getLevel(), webBundle.getContextPath(), webBundle.getName());
}
}
table.print(System.out, !noFormat);
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class List method doExecute.
@Override
protected Object doExecute(java.util.List<Bundle> bundles) throws Exception {
if (noFormat) {
noEllipsis = true;
}
determineBundleLevelThreshold();
// Display active start level.
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();
if (!noEllipsis && terminal != null && terminal.getWidth() > 0) {
table.size(terminal.getWidth() - 1);
}
table.column("ID").alignRight();
table.column("State");
table.column("Lvl").alignRight();
table.column("Version");
boolean effectiveShowName = showName || (!showLocation && !showSymbolic && !showUpdate && !showRevisions);
if (effectiveShowName) {
table.column("Name");
}
if (showLocation) {
table.column(new Col("Location") {
@Override
protected String cut(String value, int size) {
if (showLocation && value.length() > size) {
String[] parts = value.split("/");
String cut = "";
int c = parts[0].length() + 4;
for (int idx = parts.length - 1; idx > 0; idx--) {
if (cut.length() + c + parts[idx].length() + 1 < size) {
cut = "/" + parts[idx] + cut;
} else {
break;
}
}
cut = parts[0] + "/..." + cut;
return cut;
} else {
return super.cut(value, size);
}
}
});
}
if (showSymbolic) {
table.column("Symbolic name");
}
if (showUpdate) {
table.column("Update location");
}
if (showRevisions) {
table.column("Revisions");
}
for (Bundle bundle : bundles) {
BundleInfo info = this.bundleService.getInfo(bundle);
if (info.getStartLevel() >= bundleLevelThreshold) {
String version = info.getVersion();
ArrayList<Object> rowData = new ArrayList<>();
rowData.add(info.getBundleId());
rowData.add(getStateString(info.getState()));
rowData.add(info.getStartLevel());
rowData.add(version);
if (effectiveShowName) {
String bundleName = (info.getName() == null) ? info.getSymbolicName() : info.getName();
bundleName = (bundleName == null) ? info.getUpdateLocation() : bundleName;
String name = bundleName + printFragments(info) + printHosts(info);
rowData.add(name);
}
if (showLocation) {
rowData.add(info.getUpdateLocation());
}
if (showSymbolic) {
rowData.add(info.getSymbolicName() == null ? "<no symbolic name>" : info.getSymbolicName());
}
if (showUpdate) {
rowData.add(info.getUpdateLocation());
}
if (showRevisions) {
rowData.add(info.getRevisions());
}
Row row = table.addRow();
row.addContent(rowData);
}
}
table.print(System.out, !noFormat);
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class ImagesCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column("Id");
table.column("RepoTags");
table.column("Created");
table.column("Labels");
table.column("Size");
table.column("Virtual Size");
for (Image image : getDockerService().images(url)) {
table.addRow().addContent(image.getId(), image.getRepoTags(), image.getCreated(), image.getLabels(), image.getSize(), image.getVirtualSize());
}
table.print(System.out);
return null;
}
Aggregations