001package jmri.jmrit.ctc.editor;
002
003import java.awt.event.ActionEvent;
004import jmri.InstanceManager;
005import jmri.jmrit.ctc.editor.gui.FrmMainForm;
006import jmri.util.swing.JmriAbstractAction;
007
008/**
009 * Swing action to create and register a CtcEditor.
010 *
011 * @author Dave Sand Copyright (C) 2019
012 */
013public class CtcEditorAction extends JmriAbstractAction {
014
015    public CtcEditorAction(String s) {
016        super(s);
017    }
018
019    public CtcEditorAction() {
020        this(Bundle.getMessage("CtcEditorActionButton"));  // NOI18N
021    }
022
023    @Override
024    public void actionPerformed(ActionEvent e) {
025        InstanceManager.getOptionalDefault(FrmMainForm.class).orElseGet(() -> new FrmMainForm())
026                .setVisible(true);
027    }
028
029    // never invoked, because we overrode actionPerformed above
030    @Override
031    public jmri.util.swing.JmriPanel makePanel() {
032        throw new IllegalArgumentException("Should not be invoked");  // NOI18N
033    }
034
035}