001package jmri.jmrix.powerline.swing; 002 003import javax.swing.Icon; 004import jmri.jmrix.powerline.SerialSystemConnectionMemo; 005import jmri.util.swing.JmriPanel; 006import jmri.util.swing.WindowInterface; 007import org.slf4j.Logger; 008import org.slf4j.LoggerFactory; 009 010/** 011 * Action to create and load a JmriPanel from just its name. 012 * 013 * @author Bob Jacobsen Copyright (C) 2010 Copied from NCE Converted to multiple 014 * connection 015 * @author kcameron Copyright (C) 2011 016 */ 017public class PowerlineNamedPaneAction extends jmri.util.swing.JmriNamedPaneAction { 018 019 /** 020 * Enhanced constructor for placing the pane in various GUIs 021 * @param s Human-readable panel name for display by the action 022 * @param wi Window into which to install the new panel. If you want it to be put into a existing 023 * one, provide a reference. To create a new window 024 * containing just this pane, use "new jmri.util.swing.sdi.JmriJFrameInterface()" 025 * @param paneClass Name of the panel's class, which must be a subclass of JmriPanel. That's not 026 * checked at compile time or when the constructor runs, but must be true 027 * for the action to be invoked successfully. 028 * @param memo Connection details memo 029 */ 030 public PowerlineNamedPaneAction(String s, WindowInterface wi, String paneClass, SerialSystemConnectionMemo memo) { 031 super(s, wi, paneClass); 032 this.memo = memo; 033 } 034 035 public PowerlineNamedPaneAction(String s, Icon i, WindowInterface wi, String paneClass, SerialSystemConnectionMemo memo) { 036 super(s, i, wi, paneClass); 037 this.memo = memo; 038 } 039 040 SerialSystemConnectionMemo memo; 041 042 @Override 043 public JmriPanel makePanel() { 044 JmriPanel p = super.makePanel(); 045 if (p == null) { 046 return null; 047 } 048 049 try { 050 ((PowerlinePanelInterface) p).initComponents(memo); 051 return p; 052 } catch (Exception ex) { 053 log.warn("could not init pane class: {}", paneClass, ex); 054 } 055 056 return p; 057 } 058 059 private final static Logger log = LoggerFactory.getLogger(PowerlineNamedPaneAction.class); 060 061}