001package jmri.jmrix.rps.swing.polling;
002
003import java.awt.event.ActionEvent;
004import javax.swing.AbstractAction;
005import org.slf4j.Logger;
006import org.slf4j.LoggerFactory;
007import jmri.jmrix.rps.RpsSystemConnectionMemo;
008
009/**
010 * Swing action to create and register a PollTableFrame object.
011 * <p>
012 * We only permit one, because notification is not entirely right yet.
013 *
014 * @author Bob Jacobsen Copyright (C) 2008
015 */
016public class PollTableAction extends AbstractAction {
017
018    public PollTableAction(String s,RpsSystemConnectionMemo _memo) {
019        super(s);
020        memo = _memo;
021    }
022
023    public PollTableAction(RpsSystemConnectionMemo _memo) {
024        this("RPS Polling Control", _memo);
025    }
026
027    PollTableFrame f = null;
028
029    RpsSystemConnectionMemo memo = null;
030
031    @Override
032    public void actionPerformed(ActionEvent e) {
033        log.debug("starting frame creation");
034        if (f == null) {
035            f = new PollTableFrame(memo);
036            try {
037                f.initComponents();
038            } catch (Exception ex) {
039                log.warn("Exception starting frame.", ex);
040            }
041        }
042        f.setVisible(true);
043    }
044
045    private final static Logger log = LoggerFactory.getLogger(PollTableAction.class);
046
047}