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 show the inline LogixNGs.
010 *
011 * @author Daniel Bergqvist Copyright (C) 2022
012 */
013public class InlineLogixNGsAction extends AbstractAction {
014
015    public InlineLogixNGsAction(String s) {
016        super(s);
017    }
018
019    public InlineLogixNGsAction() {
020        this(Bundle.getMessage("MenuInlineLogixNGs")); // NOI18N
021    }
022
023    private static InlineLogixNGsFrame inlineLogixNGsFrame = 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 (inlineLogixNGsFrame == null || !inlineLogixNGsFrame.isVisible()) {
030            inlineLogixNGsFrame = new InlineLogixNGsFrame();
031            inlineLogixNGsFrame.initComponents();
032        }
033        inlineLogixNGsFrame.setExtendedState(Frame.NORMAL);
034        inlineLogixNGsFrame.setVisible(true); // this also brings the frame into focus
035    }
036
037}