001package jmri.jmrit.ctc;
002
003import java.awt.event.ActionEvent;
004import jmri.util.swing.JmriAbstractAction;
005
006/**
007 * Swing action to create and register the CTC Run Time.
008 * Replaces the original custom file opener.
009 *
010 * @author Dave Sand Copyright (C) 2019
011 */
012public class CtcRunAction extends JmriAbstractAction {
013
014    public CtcRunAction(String s) {
015        super(s);
016    }
017
018    public CtcRunAction() {
019        this(Bundle.getMessage("CtcRunActionButton"));  // NOI18N
020    }
021
022    @Override
023    public void actionPerformed(ActionEvent e) {
024        if (jmri.InstanceManager.getNullableDefault(CTCMain.class) != null) {
025            // Prevent duplicate copies
026            return;
027        }
028        CTCMain _mCTCMain = new CTCMain();
029        jmri.InstanceManager.setDefault(CTCMain.class, _mCTCMain);
030        _mCTCMain.startup();
031    }
032
033    // never invoked, because we overrode actionPerformed above
034    @Override
035    public jmri.util.swing.JmriPanel makePanel() {
036        throw new IllegalArgumentException("Should not be invoked");  // NOI18N
037    }
038
039}