001package jmri.jmrix.can.swing; 002 003import javax.swing.Icon; 004import jmri.jmrix.can.CanSystemConnectionMemo; 005import jmri.util.swing.JmriPanel; 006import jmri.util.swing.WindowInterface; 007 008/** 009 * Action to create and load a CAN-specific JmriPanel 010 * 011 * @author Bob Jacobsen Copyright (C) 2012 012 */ 013public class CanNamedPaneAction extends jmri.util.swing.JmriNamedPaneAction { 014 015 /** 016 * Enhanced constructor for placing the pane in various GUIs. 017 * @param s Window Name 018 * @param wi JmriJFrameInterface 019 * @param paneClass Name of class to open 020 * @param memo System Connection 021 */ 022 public CanNamedPaneAction(String s, WindowInterface wi, String paneClass, CanSystemConnectionMemo memo) { 023 super(s, wi, paneClass); 024 this.memo = memo; 025 } 026 027 /** 028 * Enhanced constructor for placing the pane in various GUIs. 029 * @param s Window Name 030 * @param i Icon to display 031 * @param wi JmriJFrameInterface 032 * @param paneClass Name of class to open 033 * @param memo System Connection 034 */ 035 public CanNamedPaneAction(String s, Icon i, WindowInterface wi, String paneClass, CanSystemConnectionMemo memo) { 036 super(s, i, wi, paneClass); 037 this.memo = memo; 038 } 039 040 CanSystemConnectionMemo memo; 041 042 /** 043 * Makes Panel and calls initComponents 044 * {@inheritDoc} 045 */ 046 @Override 047 public JmriPanel makePanel() { 048 JmriPanel p = super.makePanel(); 049 if (p == null) { 050 return null; 051 } 052 053 try { 054 ((CanPanelInterface) p).initComponents(memo); 055 return p; 056 } catch (Exception ex) { 057 log.warn("could not init pane class: {}", paneClass, ex); 058 } 059 060 return p; 061 } 062 063 private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(CanNamedPaneAction.class); 064 065}