From cdb2eb8ca1315860d0381931b5b4465a0e99af99 Mon Sep 17 00:00:00 2001 From: Janne Valkealahti Date: Sat, 17 Feb 2024 14:28:51 +0000 Subject: [PATCH] Rename Context to ProgressContext - Relates #995 --- .../component/view/control/ProgressView.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/spring-shell-core/src/main/java/org/springframework/shell/component/view/control/ProgressView.java b/spring-shell-core/src/main/java/org/springframework/shell/component/view/control/ProgressView.java index 4e405ba5..6b2bbf24 100644 --- a/spring-shell-core/src/main/java/org/springframework/shell/component/view/control/ProgressView.java +++ b/spring-shell-core/src/main/java/org/springframework/shell/component/view/control/ProgressView.java @@ -63,16 +63,16 @@ public class ProgressView extends BoxView { private GridView grid; private long startTime; private long updateTime; - private List> cells = new ArrayList<>(); + private List> cells = new ArrayList<>(); - private final static Function> DEFAULT_DESCRIPTION_FACTORY = + private final static Function> DEFAULT_DESCRIPTION_FACTORY = (item) -> TextCell.of(item, ctx -> { return ctx.getDescription(); }); - private final static Function> DEFAULT_PERCENT_FACTORY = + private final static Function> DEFAULT_PERCENT_FACTORY = (item) -> { - TextCell cell = TextCell.of(item, ctx -> { + TextCell cell = TextCell.of(item, ctx -> { ProgressState state = ctx.getState(); int percentAbs = state.tickEnd() - state.tickStart(); int relativeValue = state.tickValue() - state.tickStart(); @@ -82,9 +82,9 @@ public class ProgressView extends BoxView { return cell; }; - private final static Function> DEFAULT_SPINNER_FACTORY = + private final static Function> DEFAULT_SPINNER_FACTORY = item -> { - TextCell cell = TextCell.of(item, ctx -> { + TextCell cell = TextCell.of(item, ctx -> { int frame = 0; // via view setting, then via theming, then fallback default @@ -166,11 +166,11 @@ public class ProgressView extends BoxView { */ public static class ProgressViewItem { - private final Function> factory; + private final Function> factory; private final int size; private final HorizontalAlign align; - public ProgressViewItem(Function> factory, int size, HorizontalAlign align) { + public ProgressViewItem(Function> factory, int size, HorizontalAlign align) { this.factory = factory; this.size = size; this.align = align; @@ -300,8 +300,8 @@ public class ProgressView extends BoxView { } private static class BoxWrapper extends BoxView { - TextCell delegate; - BoxWrapper(TextCell delegate) { + TextCell delegate; + BoxWrapper(TextCell delegate) { this.delegate = delegate; } @Override @@ -319,7 +319,7 @@ public class ProgressView extends BoxView { int index = 0; for (ProgressViewItem item : items) { columnSizes[index] = item.size; - TextCell cell = item.factory.apply(buildContext()); + TextCell cell = item.factory.apply(buildContext()); cells.add(cell); cell.setHorizontalAlign(item.align); grid.addItem(new BoxWrapper(cell), 0, index, 1, 1, 0, 0); @@ -335,8 +335,8 @@ public class ProgressView extends BoxView { long current = System.currentTimeMillis(); updateTime = current; - Context context = buildContext(); - for (TextCell cell : cells) { + ProgressContext context = buildContext(); + for (TextCell cell : cells) { cell.setItem(context); } @@ -394,8 +394,8 @@ public class ProgressView extends BoxView { return ProgressState.of(tickStart, tickEnd, tickValue, running, startTime, updateTime); } - private Context buildContext() { - return new Context() { + private ProgressContext buildContext() { + return new ProgressContext() { @Override public String getDescription() { @@ -432,7 +432,7 @@ public class ProgressView extends BoxView { /** * Context for {@code ProgressView} cell components. */ - public interface Context { + public interface ProgressContext { /** * Get a {@link ProgressView} description.