+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.menu.item.console;
-
-import java.text.MessageFormat;
-import org.mxchange.addressbook.client.AddressbookClient;
-import org.mxchange.addressbook.menu.item.BaseMenuItem;
-import org.mxchange.addressbook.menu.item.SelectableMenuItem;
-import org.mxchange.jcore.client.Client;
-
-/**
- *
- * @author Roland Haeder
- */
-public class ConsoleMenuItem extends BaseMenuItem implements SelectableMenuItem {
-
- /**
- * Access key
- */
- private char accessKey;
-
- /**
- * Text to user
- */
- private String text;
-
- /**
- * Constructor for building a console menu with access key and text
- *
- * @param accessKey Access key for this menu entry
- * @param text Text to show to user
- */
- public ConsoleMenuItem (final char accessKey, final String text) {
- this.setAccessKey(accessKey);
- this.setText(text);
- }
-
- /**
- * Access key
- *
- * @return the accessKey
- */
- @Override
- public final char getAccessKey () {
- return this.accessKey;
- }
-
- /**
- * Access key
- *
- * @param accessKey the accessKey to set
- */
- private void setAccessKey (char accessKey) {
- this.accessKey = accessKey;
- }
-
- /**
- * Text to user
- *
- * @return the text
- */
- @Override
- public String getText () {
- return this.text;
- }
-
- /**
- * Text to user
- *
- * @param text the text to set
- */
- private void setText (String text) {
- this.text = text;
- }
-
- @Override
- public void show (final Client client) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("client={0} - CALLED!", client)); //NOI18N
-
- // Client must not be null
- if (client == null) {
- // Abort here
- throw new NullPointerException("client is null");
- } else if (!(client instanceof AddressbookClient)) {
- // Wrong interface
- throw new IllegalArgumentException("client " + client + " must implement AddressbookClient");
- }
-
- // Cast it
- AddressbookClient c = (AddressbookClient) client;
-
- // Call-back client over menu
- c.showEntry(this);
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-
-}