1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.hbtop.screen.help;
19
20 import java.util.Arrays;
21 import java.util.Objects;
22
23 import org.apache.hadoop.hbase.classification.InterfaceAudience;
24 import org.apache.hadoop.hbase.hbtop.screen.ScreenView;
25
26
27
28
29 @InterfaceAudience.Private
30 public class HelpScreenPresenter {
31
32 private static final CommandDescription[] COMMAND_DESCRIPTIONS = new CommandDescription[] {
33 new CommandDescription("f", "Add/Remove/Order/Sort the fields"),
34 new CommandDescription("R", "Toggle the sort order (ascending/descending)"),
35 new CommandDescription("m", "Select mode"),
36 new CommandDescription("o", "Add a filter with ignoring case"),
37 new CommandDescription("O", "Add a filter with case sensitive"),
38 new CommandDescription("^o", "Show the current filters"),
39 new CommandDescription("=", "Clear the current filters"),
40 new CommandDescription("i", "Drill down"),
41 new CommandDescription(
42 Arrays.asList("up", "down", "left", "right", "pageUp", "pageDown", "home", "end"),
43 "Scroll the metrics"),
44 new CommandDescription("d", "Change the refresh delay"),
45 new CommandDescription("X", "Adjust the field length"),
46 new CommandDescription("<Enter>", "Refresh the display"),
47 new CommandDescription("h", "Display this screen"),
48 new CommandDescription(Arrays.asList("q", "<Esc>"), "Quit")
49 };
50
51 private final HelpScreenView helpScreenView;
52 private final long refreshDelay;
53 private final ScreenView nextScreenView;
54
55 public HelpScreenPresenter(HelpScreenView helpScreenView, long refreshDelay,
56 ScreenView nextScreenView) {
57 this.helpScreenView = Objects.requireNonNull(helpScreenView);
58 this.refreshDelay = refreshDelay;
59 this.nextScreenView = Objects.requireNonNull(nextScreenView);
60 }
61
62 public void init() {
63 helpScreenView.hideCursor();
64 helpScreenView.clearTerminal();
65 helpScreenView.showHelpScreen(refreshDelay, COMMAND_DESCRIPTIONS);
66 helpScreenView.refreshTerminal();
67 }
68
69 public ScreenView transitionToNextScreen() {
70 return nextScreenView;
71 }
72 }