001package jmri.jmrit.symbolicprog;
002
003import java.io.File;
004import java.io.IOException;
005import javax.swing.JFrame;
006import javax.swing.JLabel;
007
008/**
009 * Action to import the CV values from a CSV format file.
010 *
011 * @author Bob Jacobsen Copyright (C) 2003
012 * @author Dave Heap Copyright (C) 2015
013 */
014public class CsvImportAction extends GenericImportAction {
015
016    public CsvImportAction(String actionName, CvTableModel pModel, JFrame pParent, JLabel pStatus) {
017        super(actionName, pModel, pParent, pStatus, "CSV list files", "csv", null);
018    }
019
020    @Override
021    boolean launchImporter(File file, CvTableModel tableModel) {
022            try {
023                // ctor launches operation
024                new CsvImporter(file, mModel);
025                return true;
026            } catch (IOException | NumberFormatException ex) {
027                log.error("Error reading file", ex);
028                return false;
029        }
030    }
031
032    private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(CsvImportAction.class);
033}