001/**
002 * PacketGenAction.java
003 *
004 * Swing action to create and register a XpressNet PacketGenFrame
005 * object
006 *
007 * @author Bob Jacobsen Copyright (C) 2001, 2002
008 * @author      Mark Underwood Copyright (C) 2015
009 */
010package jmri.jmrix.dccpp.swing.packetgen;
011
012import java.awt.event.ActionEvent;
013import org.slf4j.Logger;
014import org.slf4j.LoggerFactory;
015
016import jmri.InstanceManager;
017import jmri.jmrix.dccpp.DCCppSystemConnectionMemo;
018import jmri.jmrix.dccpp.swing.DCCppSystemConnectionAction;
019
020public class PacketGenAction extends DCCppSystemConnectionAction {
021
022    public PacketGenAction(String s, jmri.jmrix.dccpp.DCCppSystemConnectionMemo memo) {
023        super(s, memo);
024    }
025
026    public PacketGenAction(jmri.jmrix.dccpp.DCCppSystemConnectionMemo memo) {
027        this("Generate DCC++ message", memo);
028    }
029
030    public PacketGenAction() {
031        this(InstanceManager.getDefault(DCCppSystemConnectionMemo.class));
032    }
033
034    @Override
035    public void actionPerformed(ActionEvent e) {
036        DCCppSystemConnectionMemo memo = getSystemConnectionMemo();
037        if (memo == null) {
038            log.error("connection memo was null!");
039            return;
040        }
041
042        // create a PacketGenFrame
043        PacketGenFrame f = new PacketGenFrame(memo);
044        try {
045            f.initComponents();
046        } catch (Exception ex) {
047            log.error("Exception",ex);
048        }
049        f.setVisible(true);
050    }
051    private static final Logger log = LoggerFactory.getLogger(PacketGenAction.class);
052}
053
054
055