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 create and register a LogixNGEditor object. 010 * 011 * @author Daniel Bergqvist Copyright (C) 2018 012 */ 013public class ImportLogixAction extends AbstractAction { 014 015 public ImportLogixAction(String s) { 016 super(s); 017 } 018 019 public ImportLogixAction() { 020 this(Bundle.getMessage("MenuImportLogix")); // NOI18N 021 } 022 023 static ImportLogixFrame importLogixFrame = 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 (importLogixFrame == null || !importLogixFrame.isVisible()) { 030 importLogixFrame = new ImportLogixFrame(); 031 importLogixFrame.initComponents(); 032 } 033 importLogixFrame.setExtendedState(Frame.NORMAL); 034 importLogixFrame.setVisible(true); // this also brings the frame into focus 035 } 036 037}