本文整理汇总了Java中org.springframework.shell.table.Tables类的典型用法代码示例。如果您正苦于以下问题:Java Tables类的具体用法?Java Tables怎么用?Java Tables使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tables类属于org.springframework.shell.table包,在下文中一共展示了Tables类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyStyleNoHeader
import org.springframework.shell.table.Tables; //导入依赖的package包/类
/**
* Customize the given TableBuilder with almost same way than
* {@link #applyStyle(TableBuilder)} but do not use any header styling.
*
* @param builder the table builder to use
* @return the configured table builder
*/
public static TableBuilder applyStyleNoHeader(TableBuilder builder) {
builder.addOutlineBorder(BorderStyle.fancy_double)
.paintBorder(BorderStyle.air, BorderSpecification.INNER_VERTICAL).fromTopLeft().toBottomRight()
.paintBorder(BorderStyle.fancy_light, BorderSpecification.INNER_VERTICAL).fromTopLeft()
.toBottomRight();
return Tables.configureKeyValueRendering(builder, " = ");
}
示例2: applyStyle
import org.springframework.shell.table.Tables; //导入依赖的package包/类
/**
* Customize the given TableBuilder with the following common features
* (these choices can always be overridden by applying later customizations) :<ul>
* <li>double border around the whole table and first row</li>
* <li>vertical space (air) borders, single line separators between rows</li>
* <li>first row is assumed to be a header and is centered horizontally and vertically</li>
* <li>cells containing Map values are rendered as {@literal key = value} lines, trying to align on equal signs</li>
* </ul>
*/
public static TableBuilder applyStyle(TableBuilder builder) {
builder.addOutlineBorder(BorderStyle.fancy_double)
.paintBorder(BorderStyle.air, BorderSpecification.INNER_VERTICAL)
.fromTopLeft().toBottomRight()
.paintBorder(BorderStyle.fancy_light, BorderSpecification.INNER_VERTICAL)
.fromTopLeft().toBottomRight()
.addHeaderBorder(BorderStyle.fancy_double)
.on(CellMatchers.row(0))
.addAligner(SimpleVerticalAligner.middle)
.addAligner(SimpleHorizontalAligner.center)
;
return Tables.configureKeyValueRendering(builder, " = ");
}
示例3: list
import org.springframework.shell.table.Tables; //导入依赖的package包/类
@CliCommand(value = LIST_APPS, help = "List runtime apps")
public Table list(
@CliOption(key = "summary", help = "whether to hide app instance details",
unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") boolean summary,
@CliOption(key = {"appId", "appIds"}, help = "app id(s) to display, also supports '<group>.*' pattern") String[] appIds) {
Set<String> filter = null;
if (appIds != null) {
filter = new HashSet<>(Arrays.asList(appIds));
}
TableModelBuilder<Object> modelBuilder = new TableModelBuilder<>();
if (!summary) {
modelBuilder.addRow()
.addValue("App Id / Instance Id")
.addValue("Unit Status")
.addValue("No. of Instances / Attributes");
}
else {
modelBuilder.addRow()
.addValue("App Id")
.addValue("Unit Status")
.addValue("No. of Instances");
}
// In detailed mode, keep track of app vs instance lines, to use
// a different border style later.
List<Integer> splits = new ArrayList<>();
int line = 1;
// Optimise for the single app case, which is likely less resource intensive on the server
// than client side filtering
Iterable<AppStatusResource> statuses;
if (filter != null && filter.size() == 1 && !filter.iterator().next().endsWith(".*")) {
statuses = Collections.singleton(runtimeOperations().status(filter.iterator().next()));
}
else {
statuses = runtimeOperations().status();
}
for (AppStatusResource appStatusResource : statuses) {
if (filter != null && !shouldRetain(filter, appStatusResource)) {
continue;
}
modelBuilder.addRow()
.addValue(appStatusResource.getDeploymentId())
.addValue(appStatusResource.getState())
.addValue(appStatusResource.getInstances().getContent().size());
splits.add(line);
line++;
if (!summary) {
for (AppInstanceStatusResource appInstanceStatusResource : appStatusResource.getInstances()) {
modelBuilder.addRow()
.addValue(appInstanceStatusResource.getInstanceId())
.addValue(appInstanceStatusResource.getState())
.addValue(appInstanceStatusResource.getAttributes());
line++;
}
}
}
TableModel model = modelBuilder.build();
final TableBuilder builder = new TableBuilder(model);
DataFlowTables.applyStyle(builder);
builder.on(column(0)).addAligner(middle)
.on(column(1)).addAligner(middle)
.on(column(1)).addAligner(center)
// This will match the "number of instances" cells only
.on(ofType(Integer.class)).addAligner(center);
Tables.configureKeyValueRendering(builder, " = ");
for (int i = 2; i < model.getRowCount(); i++) {
if (splits.contains(i)) {
builder.paintBorder(fancy_light, TOP).fromRowColumn(i, 0).toRowColumn(i + 1, model.getColumnCount());
}
else {
builder.paintBorder(fancy_light_quadruple_dash, TOP).fromRowColumn(i, 0).toRowColumn(i + 1, model.getColumnCount());
}
}
return builder.build();
}
示例4: list
import org.springframework.shell.table.Tables; //导入依赖的package包/类
@CliCommand(value = LIST_APPS, help = "List runtime apps")
public Table list(
@CliOption(key = "summary", help = "whether to hide app instance details", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") boolean summary,
@CliOption(key = { "appId",
"appIds" }, help = "app id(s) to display, also supports '<group>.*' pattern") String[] appIds) {
Set<String> filter = null;
if (appIds != null) {
filter = new HashSet<>(Arrays.asList(appIds));
}
TableModelBuilder<Object> modelBuilder = new TableModelBuilder<>();
if (!summary) {
modelBuilder.addRow().addValue("App Id / Instance Id").addValue("Unit Status")
.addValue("No. of Instances / Attributes");
}
else {
modelBuilder.addRow().addValue("App Id").addValue("Unit Status").addValue("No. of Instances");
}
// In detailed mode, keep track of app vs instance lines, to use
// a different border style later.
List<Integer> splits = new ArrayList<>();
int line = 1;
// Optimise for the single app case, which is likely less resource intensive on
// the server
// than client side filtering
Iterable<AppStatusResource> statuses;
if (filter != null && filter.size() == 1 && !filter.iterator().next().endsWith(".*")) {
statuses = Collections.singleton(runtimeOperations().status(filter.iterator().next()));
}
else {
statuses = runtimeOperations().status();
}
for (AppStatusResource appStatusResource : statuses) {
if (filter != null && !shouldRetain(filter, appStatusResource)) {
continue;
}
modelBuilder.addRow().addValue(appStatusResource.getDeploymentId()).addValue(appStatusResource.getState())
.addValue(appStatusResource.getInstances().getContent().size());
splits.add(line);
line++;
if (!summary) {
for (AppInstanceStatusResource appInstanceStatusResource : appStatusResource.getInstances()) {
modelBuilder.addRow().addValue(appInstanceStatusResource.getInstanceId())
.addValue(appInstanceStatusResource.getState())
.addValue(appInstanceStatusResource.getAttributes());
line++;
}
}
}
TableModel model = modelBuilder.build();
final TableBuilder builder = new TableBuilder(model);
DataFlowTables.applyStyle(builder);
builder.on(column(0)).addAligner(middle).on(column(1)).addAligner(middle).on(column(1)).addAligner(center)
// This will match the "number of instances" cells only
.on(ofType(Integer.class)).addAligner(center);
Tables.configureKeyValueRendering(builder, " = ");
for (int i = 2; i < model.getRowCount(); i++) {
if (splits.contains(i)) {
builder.paintBorder(fancy_light, TOP).fromRowColumn(i, 0).toRowColumn(i + 1, model.getColumnCount());
}
else {
builder.paintBorder(fancy_light_quadruple_dash, TOP).fromRowColumn(i, 0).toRowColumn(i + 1,
model.getColumnCount());
}
}
return builder.build();
}
示例5: applyStyle
import org.springframework.shell.table.Tables; //导入依赖的package包/类
/**
* Customize the given TableBuilder with the following common features (these choices can
* always be overridden by applying later customizations) :
* <ul>
* <li>double border around the whole table and first row</li>
* <li>vertical space (air) borders, single line separators between rows</li>
* <li>first row is assumed to be a header and is centered horizontally and
* vertically</li>
* <li>cells containing Map values are rendered as {@literal key = value} lines, trying to
* align on equal signs</li>
* </ul>
*
* @param builder the table builder to use
* @return the configured table builder
*/
public static TableBuilder applyStyle(TableBuilder builder) {
builder.addOutlineBorder(BorderStyle.fancy_double)
.paintBorder(BorderStyle.air, BorderSpecification.INNER_VERTICAL).fromTopLeft().toBottomRight()
.paintBorder(BorderStyle.fancy_light, BorderSpecification.INNER_VERTICAL).fromTopLeft()
.toBottomRight()
.addHeaderBorder(BorderStyle.fancy_double).on(CellMatchers.row(0))
.addAligner(SimpleVerticalAligner.middle).addAligner(SimpleHorizontalAligner.center);
return Tables.configureKeyValueRendering(builder, " = ");
}
示例6: applyStyle
import org.springframework.shell.table.Tables; //导入依赖的package包/类
/**
* Customize the given TableBuilder with the following common features (these choices
* can always be overridden by applying later customizations) :
* <ul>
* <li>double border around the whole table and first row</li>
* <li>vertical space (air) borders, single line separators between rows</li>
* <li>first row is assumed to be a header and is centered horizontally and
* vertically</li>
* <li>cells containing Map values are rendered as {@literal key = value} lines,
* trying to align on equal signs</li>
* </ul>
*
* @param builder the table builder to use
* @return the configured table builder
*/
public static TableBuilder applyStyle(TableBuilder builder) {
builder.addOutlineBorder(BorderStyle.fancy_double)
.paintBorder(BorderStyle.air, BorderSpecification.INNER_VERTICAL).fromTopLeft().toBottomRight()
.paintBorder(BorderStyle.fancy_light, BorderSpecification.INNER_VERTICAL).fromTopLeft().toBottomRight()
.addHeaderBorder(BorderStyle.fancy_double).on(CellMatchers.row(0))
.addAligner(SimpleVerticalAligner.middle).addAligner(SimpleHorizontalAligner.center);
return Tables.configureKeyValueRendering(builder, " = ");
}