001package jmri.jmrix.ieee802154.swing.nodeconfig; 002 003import java.awt.event.ActionEvent; 004import javax.swing.AbstractAction; 005import org.slf4j.Logger; 006import org.slf4j.LoggerFactory; 007 008/** 009 * Swing action to create and register a NodeConfigFrame object 010 * 011 * @author Bob Jacobsen Copyright (C) 2001 012 */ 013public class NodeConfigAction extends AbstractAction { 014 015 private jmri.jmrix.ieee802154.IEEE802154SystemConnectionMemo icm = null; 016 017 public NodeConfigAction(String s, jmri.jmrix.ieee802154.IEEE802154SystemConnectionMemo cm) { 018 super(s); 019 if (cm == null) { 020 try { 021 // find the first registered memo. 022 icm = jmri.InstanceManager. 023 getList(jmri.jmrix.ieee802154.IEEE802154SystemConnectionMemo.class).get(0); 024 } catch (java.lang.NullPointerException|java.lang.IndexOutOfBoundsException e) { 025 // no memo exists, are we configuring this for the first time? 026 log.debug("No IEEE 802.15.4 System Connection Memo available"); 027 } 028 } else { 029 icm = cm; 030 } 031 } 032 033 public NodeConfigAction() { 034 this("Configure IEEE802154 Nodes", null); 035 } 036 037 public NodeConfigAction(String s) { 038 this(s, null); 039 } 040 041 public NodeConfigAction(jmri.jmrix.ieee802154.IEEE802154SystemConnectionMemo cm) { 042 this("Configure IEEE802154 Nodes", cm); 043 } 044 045 @Override 046 public void actionPerformed(ActionEvent e) { 047 NodeConfigFrame f = new NodeConfigFrame(icm.getTrafficController()); 048 try { 049 f.initComponents(); 050 } catch (Exception ex) { 051 log.error("Exception: {}", ex.toString()); 052 } 053 f.setLocation(100, 30); 054 f.setVisible(true); 055 } 056 057 private final static Logger log = LoggerFactory.getLogger(NodeConfigAction.class); 058 059}