001package jmri.jmrix.powerline.swing.packetgen;
002
003import java.awt.event.ActionEvent;
004import jmri.InstanceManager;
005import jmri.jmrix.powerline.SerialSystemConnectionMemo;
006import jmri.jmrix.powerline.SerialTrafficController;
007import jmri.jmrix.powerline.swing.PowerlineSystemConnectionAction;
008import org.slf4j.Logger;
009import org.slf4j.LoggerFactory;
010
011/**
012 * Swing action to create and register a SerialPacketGenFrame object.
013 *
014 * @author Bob Jacobsen Copyright (C) 2001, 2007, 2008 Converted to multiple
015 * connection
016 * @author kcameron Copyright (C) 2011
017 */
018public class SerialPacketGenAction extends PowerlineSystemConnectionAction {
019
020    public SerialPacketGenAction(String s, SerialTrafficController tc) {
021        super(s, tc.getAdapterMemo());
022        this.tc = tc;
023    }
024
025    public SerialPacketGenAction(SerialTrafficController tc) {
026        this(Bundle.getMessage("SendPacketTitle"), tc);
027        this.tc = tc;
028    }
029
030    public SerialPacketGenAction() {
031        this(InstanceManager.getDefault(SerialSystemConnectionMemo.class).getTrafficController());
032    }
033
034    SerialTrafficController tc = null;
035
036    @Override
037    public void actionPerformed(ActionEvent e) {
038        SerialPacketGenFrame f = new SerialPacketGenFrame(tc);
039        try {
040            f.initComponents();
041        } catch (Exception ex) {
042            log.error("Exception: ", ex);
043        }
044        f.setVisible(true);
045    }
046
047    private final static Logger log = LoggerFactory.getLogger(SerialPacketGenAction.class);
048
049}