001package jmri.jmrix.acela.acelamon; 002 003import java.awt.event.ActionEvent; 004import java.util.Arrays; 005import java.util.HashSet; 006import java.util.Set; 007import jmri.SystemConnectionMemo; 008import jmri.jmrix.acela.AcelaSystemConnectionMemo; 009import jmri.jmrix.swing.AbstractSystemConnectionAction; 010import org.slf4j.Logger; 011import org.slf4j.LoggerFactory; 012 013/** 014 * Swing action to create and register an AcelaMonFrame object 015 * 016 * @author Bob Jacobsen Copyright (C) 2001 017 * 018 * @author Bob Coleman, Copyright (C) 2007, 2008 Based on CMRI serial example, 019 * modified to establish Acela support. 020 */ 021public class AcelaMonAction extends AbstractSystemConnectionAction<AcelaSystemConnectionMemo> { 022 023 public AcelaMonAction(String s, AcelaSystemConnectionMemo memo) { 024 super(s, memo); 025 } 026 027 public AcelaMonAction() { 028 this(Bundle.getMessage("MonitorXTitle", "Acela"), jmri.InstanceManager.getDefault(AcelaSystemConnectionMemo.class)); 029 } 030 031 @Override 032 public void actionPerformed(ActionEvent e) { 033 // create an AcelaMonFrame 034 AcelaMonFrame f = new AcelaMonFrame(getSystemConnectionMemo()); 035 try { 036 f.initComponents(); 037 } catch (Exception ex) { 038 log.warn("AcelaMonAction starting AcelaMonFrame: Exception: {}", ex.toString()); 039 } 040 f.setVisible(true); 041 } 042 043 private final static Logger log = LoggerFactory.getLogger(AcelaMonAction.class); 044 045 @Override 046 public Set<Class<? extends SystemConnectionMemo>> getSystemConnectionMemoClasses() { 047 return new HashSet<>(Arrays.asList(AcelaSystemConnectionMemo.class)); 048 } 049 050}