001package jmri.jmrit.logixng.tools.swing;
002
003import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
004import java.awt.Frame;
005import java.awt.event.ActionEvent;
006import javax.swing.AbstractAction;
007
008/**
009 * Swing action to open the table for LogixNG initialization.
010 *
011 * @author Daniel Bergqvist Copyright (C) 2021
012 */
013public class LogixNGInitializationTableAction extends AbstractAction {
014
015    public LogixNGInitializationTableAction(String s) {
016        super(s);
017    }
018
019    public LogixNGInitializationTableAction() {
020        this(Bundle.getMessage("MenuLogixNGInitializationTable")); // NOI18N
021    }
022
023    private static LogixNGInitializationTable initializationTableFrame = null;
024
025    @Override
026    @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "Only one ImportLogixFrame")
027    public void actionPerformed(ActionEvent e) {
028        // create a settings frame
029        if (initializationTableFrame == null || !initializationTableFrame.isVisible()) {
030            initializationTableFrame = new LogixNGInitializationTable();
031            initializationTableFrame.initComponents();
032        }
033        initializationTableFrame.setExtendedState(Frame.NORMAL);
034        initializationTableFrame.setVisible(true); // this also brings the frame into focus
035    }
036    
037}