001package jmri.jmrix.marklin.swing; 002 003import javax.swing.Icon; 004import jmri.jmrix.marklin.MarklinSystemConnectionMemo; 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 Marklin JmriPanel from just its name. 012 * 013 * @author Bob Jacobsen Copyright (C) 2010 014 */ 015public class MarklinNamedPaneAction extends jmri.util.swing.JmriNamedPaneAction { 016 017 /** 018 * Enhanced constructor for placing the pane in various GUIs 019 * @param s pane name. 020 * @param wi the window interface. 021 * @param paneClass pane class. 022 * @param memo system connection. 023 */ 024 public MarklinNamedPaneAction(String s, WindowInterface wi, String paneClass, MarklinSystemConnectionMemo memo) { 025 super(s, wi, paneClass); 026 this.memo = memo; 027 } 028 029 public MarklinNamedPaneAction(String s, Icon i, WindowInterface wi, String paneClass, MarklinSystemConnectionMemo memo) { 030 super(s, i, wi, paneClass); 031 this.memo = memo; 032 } 033 034 MarklinSystemConnectionMemo 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 ((MarklinPanelInterface) 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(MarklinNamedPaneAction.class); 054}