001package jmri.jmrix.grapevine.packetgen; 002 003import java.awt.event.ActionEvent; 004import javax.swing.Action; 005import jmri.InstanceManager; 006import jmri.jmrix.grapevine.GrapevineSystemConnectionMemo; 007import jmri.jmrix.grapevine.swing.GrapevineSystemConnectionAction; 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 015 */ 016public class SerialPacketGenAction extends GrapevineSystemConnectionAction { 017 018 public SerialPacketGenAction(String s, GrapevineSystemConnectionMemo memo) { 019 super(s, memo); 020 } 021 022 public SerialPacketGenAction(GrapevineSystemConnectionMemo memo) { 023 this(Bundle.getMessage("SendXCommandTitle", Bundle.getMessage("MenuSystem")), memo); 024 } 025 026 public SerialPacketGenAction() { 027 this(InstanceManager.getNullableDefault(GrapevineSystemConnectionMemo.class)); 028 } 029 030 @Override 031 public void actionPerformed(ActionEvent e) { 032 GrapevineSystemConnectionMemo memo = getSystemConnectionMemo(); 033 if (memo != null) { 034 SerialPacketGenFrame f = new SerialPacketGenFrame(memo); 035 try { 036 f.initComponents(); 037 } catch (Exception ex) { 038 log.error("Exception: {}", ex.toString()); 039 } 040 f.setVisible(true); 041 } else { 042 log.error("No connection, so not performing action {}", getValue(Action.NAME)); 043 } 044 } 045 046 private final static Logger log = LoggerFactory.getLogger(SerialPacketGenAction.class); 047 048}