use of org.apache.karaf.shell.support.table.Row in project karaf by apache.
the class TablesCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
Map<String, List<String>> map = this.getJdbcService().tables(datasource);
int rowCount = 0;
for (String column : map.keySet()) {
table.column(column);
rowCount = map.get(column).size();
}
for (int i = 0; i < rowCount; i++) {
Row row = table.addRow();
for (String column : map.keySet()) {
row.addContent(map.get(column).get(i));
}
}
table.print(System.out);
return null;
}
use of org.apache.karaf.shell.support.table.Row 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.Row in project karaf by apache.
the class RepoListCommand method doExecute.
protected void doExecute(FeaturesService featuresService) throws Exception {
if (reload) {
reloadAllRepos(featuresService);
}
ShellTable table = new ShellTable();
table.column("Repository");
table.column("URL");
if (showBlacklisted) {
table.column("Blacklisted");
}
table.emptyTableText("No repositories available");
Repository[] repos = featuresService.listRepositories();
for (Repository repo : repos) {
if (repo != null) {
if (showBlacklisted || !repo.isBlacklisted()) {
Row row = table.addRow();
row.addContent(repo.getName(), repo.getURI().toString());
if (showBlacklisted) {
row.addContent(repo.isBlacklisted() ? "yes" : "no");
}
}
}
}
table.print(System.out, !noFormat);
}
use of org.apache.karaf.shell.support.table.Row in project karaf by apache.
the class HttpProxyListCommand method doAction.
@Override
public void doAction(String prefix, Dictionary<String, Object> config) throws Exception {
System.out.println();
if (mavenSettings != null && mavenSettings.getProxies() != null && mavenSettings.getProxies().size() > 0) {
ShellTable table = new ShellTable();
table.column("ID");
table.column("Host");
table.column("Port");
table.column("Non-proxy hosts");
table.column("Username");
if (showPasswords) {
table.column("Password");
}
for (Proxy _p : mavenSettings.getProxies()) {
Row row = table.addRow();
row.addContent(_p.getId(), _p.getHost(), _p.getPort(), _p.getNonProxyHosts());
row.addContent(_p.getUsername() != null ? _p.getUsername() : "");
if (showPasswords) {
addPasswordInfo(row, proxyPasswords, _p.getId(), _p.getPassword());
}
}
table.print(System.out);
} else {
System.out.print("No HTTP proxies configured");
if (settings != null && settings.value != null) {
System.out.print(" in " + settings.value);
}
System.out.println();
}
System.out.println();
}
use of org.apache.karaf.shell.support.table.Row in project karaf by apache.
the class SummaryCommand method addRow.
/**
* Helper to add row to {@link ShellTable}
* @param table
* @param label
* @param value
* @param descriptionText
*/
private <T> void addRow(ShellTable table, String label, SourceAnd<T> value, String descriptionText) {
Row row = table.addRow();
row.addContent(label, value.val());
if (source) {
row.addContent(value.source);
}
if (description) {
row.addContent(descriptionText);
}
}
Aggregations