001package jmri.jmrix.grapevine.serialmon; 002 003import java.awt.event.ActionEvent; 004import javax.swing.Action; 005import jmri.InstanceManager; 006import org.slf4j.Logger; 007import org.slf4j.LoggerFactory; 008import jmri.jmrix.grapevine.GrapevineSystemConnectionMemo; 009import jmri.jmrix.grapevine.swing.GrapevineSystemConnectionAction; 010 011/** 012 * Swing action to create and register a SerialMonFrame object. 013 * 014 * @author Bob Jacobsen Copyright (C) 2001, 2006, 2007 015 */ 016public class SerialMonAction extends GrapevineSystemConnectionAction { 017 018 public SerialMonAction(String s, GrapevineSystemConnectionMemo memo) { 019 super(s, memo); 020 } 021 022 public SerialMonAction(GrapevineSystemConnectionMemo memo) { 023 this(Bundle.getMessage("MonitorXTitle", "Grapevine"), memo); 024 } 025 026 public SerialMonAction() { 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 // create a SerialMonFrame 035 SerialMonFrame f = new SerialMonFrame(memo); 036 try { 037 f.initComponents(); 038 } catch (Exception ex) { 039 log.warn("SerialMonAction starting SerialMonFrame: Exception: {}", ex.toString()); 040 } 041 f.setVisible(true); 042 } else { 043 log.error("No connection to run {} with", getValue(Action.NAME)); 044 } 045 } 046 047 private final static Logger log = LoggerFactory.getLogger(SerialMonAction.class); 048 049}