001package jmri.jmrix.bachrus;
002
003import java.awt.event.ActionEvent;
004import javax.swing.AbstractAction;
005import jmri.InstanceManager;
006import org.slf4j.Logger;
007import org.slf4j.LoggerFactory;
008
009/**
010 * Swing action to create and register a SpeedoConsoleFrame object
011 *
012 * @author Andrew Crosland Copyright (C) 2010
013 */
014public class SpeedoConsoleAction extends AbstractAction {
015
016    SpeedoSystemConnectionMemo _memo = null;
017
018    public SpeedoConsoleAction(String s, SpeedoSystemConnectionMemo memo) {
019        super(s);
020        _memo = memo;
021    }
022    
023     public SpeedoConsoleAction() {
024        super(Bundle.getMessage("SpeedoConsole"));
025        try {
026            _memo = InstanceManager.getDefault(SpeedoSystemConnectionMemo.class);
027        }
028        catch (NullPointerException e) {
029            _memo = new SpeedoSystemConnectionMemo();
030            _memo.setSpeedoTrafficController(new SpeedoTrafficController(_memo));
031        }
032    }
033
034    @Override
035    public void actionPerformed(ActionEvent e) {
036        SpeedoConsoleFrame f = new SpeedoConsoleFrame(_memo);
037        try {
038            f.initComponents();
039        } catch (Exception ex) {
040            log.error("Uncaught Exception in SpeedoConsoleFrame: ", ex);
041        }
042        f.setVisible(true);
043    }
044    private final static Logger log = LoggerFactory.getLogger(SpeedoConsoleAction.class);
045}