001/**
002 * Swing action to create and register a DisplayFrame
003 *
004 * @author Bob Jacobsen Copyright (C) 2023
005 */
006package jmri.jmrix.dccpp.swing.virtuallcd;
007
008import java.awt.event.ActionEvent;
009
010import jmri.InstanceManager;
011import jmri.jmrix.dccpp.*;
012import jmri.jmrix.dccpp.swing.DCCppSystemConnectionAction;
013
014public class VirtualLCDAction extends DCCppSystemConnectionAction {
015
016    public VirtualLCDAction(String s, jmri.jmrix.dccpp.DCCppSystemConnectionMemo memo) {
017        super(s, memo);
018    }
019
020    public VirtualLCDAction(jmri.jmrix.dccpp.DCCppSystemConnectionMemo memo) {
021        this(Bundle.getMessage("VirtualLCDFrameTitle"), memo);
022    }
023
024    public VirtualLCDAction() {
025        this(InstanceManager.getDefault(DCCppSystemConnectionMemo.class));
026    }
027
028    @Override
029    public void actionPerformed(ActionEvent e) {
030        DCCppSystemConnectionMemo memo = getSystemConnectionMemo();
031        if (memo == null) {
032            log.error("connection memo was null!");
033            return;
034        }
035
036        // create a VirtualLCDFrame
037        VirtualLCDFrame f = new VirtualLCDFrame(memo);
038        try {
039            DCCppTrafficController tc = memo.getDCCppTrafficController();
040            tc.addDCCppListener(DCCppInterface.CS_INFO, f);
041            f.initComponents();
042        } catch (Exception ex) {
043            log.error("Exception",ex);
044        }
045        f.setVisible(true);
046    }
047    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(VirtualLCDAction.class);
048}
049
050
051