Interface View
public interface View
What a page shows, top to bottom: the dashboard draws each block in its own style. A block that
holds others (a card, columns, tabs) takes a view of its own to fill.
(view, viewer) -> {
view.stats(stats -> {
stats.add("Sales today", shop.salesToday()).sub("+12 since this morning").tone(Tone.GOOD);
stats.add("Stock", shop.stock()).unit("items").spark(shop.stockHistory());
});
view.card("Last sales", card -> card.table(table -> {
table.column("Player").column("Item").column("Price").search().pages(20);
for (Sale sale : shop.lastSales()) {
table.row().player(sale.buyer(), sale.name()).text(sale.item()).number(sale.price())
.buttons(buttons -> buttons.action("Refund", "refund").with("sale", sale.id())
.tone(Tone.BAD).confirm("Refund " + sale.name() + "?"));
}
}));
}
Text is shown as text, never read as HTML. A view is filled by one thread, the renderer's.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceThe bars ofbars(Consumer).static interfaceOne button ofView.Buttons.static interfaceButtons ofbuttons(Consumer)andView.Row.buttons(Consumer).static interfaceA chart ofchart(Consumer): lines over the same moments.static interfaceThe pairs offacts(Consumer).static interfaceOne field of aView.Form.static interfaceThe fields ofform(String, Consumer), in order.static interfaceA row of aView.Table: one cell per call.static interfaceOne figure ofView.Stats.static interfaceThe figures ofstats(Consumer).static interfaceA table oftable(Consumer).static interfaceThe tabs oftabs(Consumer). -
Method Summary
Modifier and TypeMethodDescriptionHorizontal bars, each against the longest: a ranking, a share.buttons(Consumer<View.Buttons> buttons) A row of buttons.A card: a title over the blocks its view holds.chart(Consumer<View.Chart> chart) A chart of lines over time.Blocks side by side, as many per row as fit up tocount, one under the other on a phone.A quiet line saying there is nothing to show.facts(Consumer<View.Facts> facts) Pairs of a label and a value, one under the other.A form, sent to an action with the values of its fields (ActionContext.string(String)...).One of the plugin's own web pages, in a frame among the blocks, as tall as its content.One of the plugin's own web pages, in a frame of a given height.A notice that stands out: a warning, a success, an error.A progress bar.A progress bar of a colour.stats(Consumer<View.Stats> stats) A row of figures, each in a tile.The line under the page's title.table(Consumer<View.Table> table) A table.Tabs, each with its own blocks; the dashboard remembers the one open.A paragraph.A paragraph of a colour:Tone.NEUTRALfor a quieter one.Replaces the page's title for this drawing: the name of what a detail page shows.
-
Method Details
-
title
-
subtitle
-
stats
A row of figures, each in a tile.- Parameters:
stats- what fills it- Returns:
- this view
-
card
-
columns
-
tabs
-
table
A table.- Parameters:
table- what fills it- Returns:
- this view
-
chart
A chart of lines over time.- Parameters:
chart- what fills it- Returns:
- this view
-
bars
-
facts
Pairs of a label and a value, one under the other.- Parameters:
facts- what fills them- Returns:
- this view
-
progress
-
progress
-
text
-
text
A paragraph of a colour:Tone.NEUTRALfor a quieter one.- Parameters:
text- the paragraphtone- its colour- Returns:
- this view
-
notice
-
buttons
A row of buttons.- Parameters:
buttons- what fills it- Returns:
- this view
-
form
A form, sent to an action with the values of its fields (ActionContext.string(String)...).- Parameters:
action- the action it runsform- what fills it- Returns:
- this view
-
frame
One of the plugin's own web pages, in a frame among the blocks, as tall as its content.- Parameters:
file- an HTML file of the assets (Extension.assets(String))- Returns:
- this view
-
frame
-
empty
-