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