public void processEnterKey() { if (currentView == helpView) { currentView = commandViews.get(helpView.getSelection()); } else { currentView = helpView; } }
private void addMenu(ArrayList<Pair<ImageID, String>> helpPages) { UiPagination menu = new UiPagination(""); commandViews.add(menu); int totalPages = helpPages.size(); for (int i = 0; i < totalPages; i++) { GridPane newGrid = gridHelper.setUpGrid(UiConstants.GRID_SETTINGS_ACTION_HELP_MENU); ImageID imageID = helpPages.get(i).getKey(); gridHelper.createImageInCell( 0, 0, UiImageManager.getInstance().getImage(imageID), imageWidth, 0, newGrid); UiTextBuilder myBuilder = new UiTextBuilder(); myBuilder.addMarker(0, UiConstants.STYLE_TEXT_DEFAULT); String helpText = helpPages.get(i).getValue(); gridHelper.createStyledCell(0, 1, UiConstants.STYLE_HIGHLIGHT_BOX, newGrid); gridHelper.addTextFlowToCell(0, 1, myBuilder.build(helpText), TextAlignment.CENTER, newGrid); menu.addGridToPagination(newGrid, new ArrayList<StackPane>()); // no interactions } menu.initializeDisplay(totalPages); // update UI and bind call back }
/** @@author A0125419H */ private void addMainMenu(ArrayList<Pair<String, String>> mainMenuOptions) { int numCommmands = mainMenuOptions.size(); int totalPages = (int) Math.ceil( numCommmands / 1.0 / UiConstants.ENTRIES_PER_PAGE_HELP_MENU); // convert to double int entryNo = 0; for (int i = 0; i < totalPages; i++) { GridPane newGrid = gridHelper.setUpGrid(UiConstants.GRID_SETTINGS_ACTION_HELP); ArrayList<StackPane> menuElements = new ArrayList<StackPane>(); // newGrid.setGridLinesVisible(true); for (int j = 0; j < UiConstants.ENTRIES_PER_PAGE_HELP_MENU; j++) { if (entryNo >= numCommmands) { break; } String optionText = mainMenuOptions.get(entryNo).getKey(); Label current = gridHelper.createLabelInCell( 0, j, optionText, UiConstants.STYLE_PROMPT_SELECTED, newGrid); GridPane.setFillWidth(current.getParent(), false); GridPane.setFillHeight(current.getParent(), false); GridPane.setHalignment(current.getParent(), HPos.CENTER); if (entryNo > 0) { menuElements.add(gridHelper.getWrapperAtCell(0, j, newGrid)); } UiTextBuilder myBuilder = new UiTextBuilder(); myBuilder.addMarker(0, UiConstants.STYLE_PROMPT_SELECTED); String descriptionText = mainMenuOptions.get(entryNo).getValue(); gridHelper.createStyledCell(1, j, "", newGrid); gridHelper.addTextFlowToCell( 1, j, myBuilder.build(descriptionText), TextAlignment.LEFT, newGrid); GridPane.setHalignment(current.getParent(), HPos.CENTER); entryNo++; } helpView.addGridToPagination(newGrid, menuElements); } helpView.initializeDisplay(totalPages); // update UI and bind call back }
public void clear() { for (int i = 0; i < commandViews.size(); i++) { commandViews.get(i).clear(); } helpView.clear(); }