/*
 * ReadTablesMenuItem.java
 *
 * Created on 26 Ноябрь 2009 г., 14:19
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package fptrtest;

/**
 *
 * @author V.Kravtsov
 */
public class ReadTablesMenuItem implements MenuItemInterface
{
    private final ConsoleUtil console;
    private final ShtrihFiscalPrinter printer;
    
    /** Creates a new instance of ReadTablesMenuItem */
    public ReadTablesMenuItem(
        ConsoleUtil console,
        ShtrihFiscalPrinter printer) {
        this.printer = printer;
        this.console = console;
    }
    
    public String getText(){
        return "Read tables to file";
    }
    
    public void execute()
    throws Exception
    {
        String fileName = console.readLine("Enter file name (Tables.csv): ");
        if (fileName.equalsIgnoreCase("")) {
            fileName = "Tables.csv";
        }
        
        System.out.println("Reading tables, please wait...");
        printer.readTables(fileName);
        System.out.println("OK");
    }
}
