001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.hbtop.screen.help; 019 020import java.util.Arrays; 021import java.util.Objects; 022import org.apache.hadoop.hbase.hbtop.screen.ScreenView; 023import org.apache.yetus.audience.InterfaceAudience; 024 025/** 026 * The presentation logic for the help screen. 027 */ 028@InterfaceAudience.Private 029public class HelpScreenPresenter { 030 031 private static final CommandDescription[] COMMAND_DESCRIPTIONS = 032 new CommandDescription[] { new CommandDescription("f", "Add/Remove/Order/Sort the fields"), 033 new CommandDescription("R", "Toggle the sort order (ascending/descending)"), 034 new CommandDescription("m", "Select mode"), 035 new CommandDescription("o", "Add a filter with ignoring case"), 036 new CommandDescription("O", "Add a filter with case sensitive"), 037 new CommandDescription("^o", "Show the current filters"), 038 new CommandDescription("=", "Clear the current filters"), 039 new CommandDescription("i", "Drill down"), 040 new CommandDescription( 041 Arrays.asList("up", "down", "left", "right", "pageUp", "pageDown", "home", "end"), 042 "Scroll the metrics"), 043 new CommandDescription("d", "Change the refresh delay"), 044 new CommandDescription("X", "Adjust the field length"), 045 new CommandDescription("<Enter>", "Refresh the display"), 046 new CommandDescription("h", "Display this screen"), 047 new CommandDescription(Arrays.asList("q", "<Esc>"), "Quit") }; 048 049 private final HelpScreenView helpScreenView; 050 private final long refreshDelay; 051 private final ScreenView nextScreenView; 052 053 public HelpScreenPresenter(HelpScreenView helpScreenView, long refreshDelay, 054 ScreenView nextScreenView) { 055 this.helpScreenView = Objects.requireNonNull(helpScreenView); 056 this.refreshDelay = refreshDelay; 057 this.nextScreenView = Objects.requireNonNull(nextScreenView); 058 } 059 060 public void init() { 061 helpScreenView.hideCursor(); 062 helpScreenView.clearTerminal(); 063 helpScreenView.showHelpScreen(refreshDelay, COMMAND_DESCRIPTIONS); 064 helpScreenView.refreshTerminal(); 065 } 066 067 public ScreenView transitionToNextScreen() { 068 return nextScreenView; 069 } 070}