001package jmri.jmrit.operations.setup;
002
003import java.awt.Frame;
004import java.awt.event.ActionEvent;
005
006import javax.swing.AbstractAction;
007
008import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
009
010/**
011 * Swing action to create and register a OperationsSetupFrame object.
012 *
013 * @author Bob Jacobsen Copyright (C) 2001
014 * @author Daniel Boudreau Copyright (C) 2008
015 */
016public class OperationsSettingsAction extends AbstractAction {
017
018    public OperationsSettingsAction() {
019        super(Bundle.getMessage("MenuSetup")); // NOI18N
020    }
021
022    static OperationsSettingsFrame operationsSettingsFrame = null;
023
024    @Override
025    @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "Only one OperationsSetupFrame")
026    public void actionPerformed(ActionEvent e) {
027        // create a settings frame
028        if (operationsSettingsFrame == null || !operationsSettingsFrame.isVisible()) {
029            operationsSettingsFrame = new OperationsSettingsFrame();
030            operationsSettingsFrame.initComponents();
031        }
032        operationsSettingsFrame.setExtendedState(Frame.NORMAL);
033        operationsSettingsFrame.setVisible(true); // this also brings the frame into focus
034    }
035}
036
037