001package jmri.jmrix.dcc4pc.swing; 002 003import javax.swing.Icon; 004import jmri.jmrix.dcc4pc.Dcc4PcSystemConnectionMemo; 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 014 */ 015public class Dcc4PcNamedPaneAction extends jmri.util.swing.JmriNamedPaneAction { 016 017 /** 018 * Enhanced constructor for placing the pane in various GUIs 019 * @param s action string name. 020 * @param wi window interface. 021 * @param paneClass pane class string. 022 * @param memo system connection. 023 */ 024 public Dcc4PcNamedPaneAction(String s, WindowInterface wi, String paneClass, Dcc4PcSystemConnectionMemo memo) { 025 super(s, wi, paneClass); 026 this.memo = memo; 027 } 028 029 public Dcc4PcNamedPaneAction(String s, Icon i, WindowInterface wi, String paneClass, Dcc4PcSystemConnectionMemo memo) { 030 super(s, i, wi, paneClass); 031 this.memo = memo; 032 } 033 034 Dcc4PcSystemConnectionMemo memo; 035 036 @Override 037 public JmriPanel makePanel() { 038 JmriPanel p = super.makePanel(); 039 if (p == null) { 040 return null; 041 } 042 043 try { 044 ((Dcc4PcPanelInterface) p).initComponents(memo); 045 return p; 046 } catch (Exception ex) { 047 log.warn("could not init pane class: {}", paneClass, ex); 048 } 049 050 return p; 051 } 052 053 private final static Logger log = LoggerFactory.getLogger(Dcc4PcNamedPaneAction.class); 054}