001package jmri.jmrix.easydcc.packetgen;
002
003import java.awt.event.ActionEvent;
004import javax.swing.AbstractAction;
005import jmri.jmrix.easydcc.EasyDccSystemConnectionMemo;
006import org.slf4j.Logger;
007import org.slf4j.LoggerFactory;
008
009/**
010 * Swing action to create and register an EasyDccPacketGenFrame object
011 *
012 * @author Bob Jacobsen Copyright (C) 2001
013 */
014public class EasyDccPacketGenAction extends AbstractAction {
015
016    private EasyDccSystemConnectionMemo _memo = null;
017
018    public EasyDccPacketGenAction(String s, EasyDccSystemConnectionMemo memo) {
019        super(s);
020        _memo = memo;
021    }
022
023    public EasyDccPacketGenAction(EasyDccSystemConnectionMemo memo) {
024        this(Bundle.getMessage("SendXCommandTitle", "EasyDCC"), memo);
025    }
026
027    public EasyDccPacketGenAction() {
028        this(jmri.InstanceManager.getDefault(jmri.jmrix.easydcc.EasyDccSystemConnectionMemo.class));
029    }
030
031    @Override
032    public void actionPerformed(ActionEvent e) {
033        EasyDccPacketGenFrame f = new EasyDccPacketGenFrame(_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(EasyDccPacketGenAction.class);
043
044}