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

package fptrtest;

/**
 *
 * @author V.Kravtsov
 */

public class WriteTablesMenuItem implements MenuItemInterface
{
    private final ConsoleUtil console;
    private final ShtrihFiscalPrinter printer;
    
    /**
     * Creates a new instance of WriteTablesMenuItem
     */
    public WriteTablesMenuItem(
        ConsoleUtil console,
        ShtrihFiscalPrinter printer) {
        this.printer = printer;
        this.console = console;
    }
    
    public String getText(){
        return "Write tables from file";
    }
    
    public void execute()
    throws Exception
    {
        String fileName = console.readLine("Enter file name (Tables.csv): ");
        if (fileName.equalsIgnoreCase("")) {
            fileName = "Tables.csv";
        }
        
        System.out.println("Writing tables, please wait...");
        printer.writeTables(fileName);
        System.out.println("OK");
    }
}
