001package jmri.jmrix.sprog.sprogslotmon;
002
003import java.awt.event.ActionEvent;
004
005import javax.swing.AbstractAction;
006
007import jmri.InstanceManager;
008import jmri.jmrix.sprog.SprogSystemConnectionMemo;
009
010/**
011 * Swing action to create and register a SprogSlotMonFrame object.
012 *
013 * @author Bob Jacobsen Copyright (C) 2001 
014 * @author      Andrew Crosland (C) 2006 ported to SPROG
015 */
016public class SprogSlotMonAction extends AbstractAction {
017
018    private SprogSystemConnectionMemo _memo = null;
019
020    public SprogSlotMonAction(String s, SprogSystemConnectionMemo memo) {
021        super(s);
022        _memo = memo;
023    }
024
025    public SprogSlotMonAction(SprogSystemConnectionMemo memo) {
026        this(Bundle.getMessage("SprogSlotMonitorTitle"), memo);
027    }
028
029    public SprogSlotMonAction() {
030        super(Bundle.getMessage("SprogSlotMonitorTitle"));
031        _memo = InstanceManager.getNullableDefault(SprogSystemConnectionMemo.class);
032    }
033
034    @Override
035    public void actionPerformed(ActionEvent e) {
036
037        if(_memo.getCommandStation() == null) {
038            // create SlotManager if it doesn't exist
039            _memo.configureCommandStation(_memo.getNumSlots());
040        }
041            
042        SprogSlotMonFrame f = new SprogSlotMonFrame(_memo);
043        f.setVisible(true);
044    }
045
046}