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