001package jmri.jmrix.tmcc.packetgen;
002
003import java.awt.event.ActionEvent;
004import javax.swing.AbstractAction;
005import jmri.jmrix.tmcc.TmccSystemConnectionMemo;
006import org.slf4j.Logger;
007import org.slf4j.LoggerFactory;
008
009/**
010 * Swing action to create and register a SerialPacketGenFrame object.
011 *
012 * @author Bob Jacobsen Copyright (C) 2001
013 */
014public class SerialPacketGenAction extends AbstractAction {
015
016    private TmccSystemConnectionMemo _memo = null;
017
018    public SerialPacketGenAction(String s, TmccSystemConnectionMemo memo) {
019        super(s);
020        _memo = memo;
021    }
022
023    public SerialPacketGenAction(TmccSystemConnectionMemo memo) {
024        this("Generate TMCC message", memo);
025    }
026
027    public SerialPacketGenAction() {
028        this(Bundle.getMessage("SendCommandTitle"), jmri.InstanceManager.getDefault(TmccSystemConnectionMemo.class));
029    }
030
031    @Override
032    public void actionPerformed(ActionEvent e) {
033        SerialPacketGenFrame f = new SerialPacketGenFrame(_memo);
034        try {
035            f.initComponents();
036        } catch (Exception ex) {
037            log.error("Exception: {}", ex.toString());
038        }
039        f.setVisible(true);
040    }
041
042    private final static Logger log = LoggerFactory.getLogger(SerialPacketGenAction.class);
043
044}