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;
007
008/**
009 * Action to create and load a Marklin JmriPanel from just its name.
010 *
011 * @author Bob Jacobsen Copyright (C) 2010
012 */
013public class MarklinNamedPaneAction extends jmri.util.swing.JmriNamedPaneAction {
014
015    /**
016     * Enhanced constructor for placing the pane in various GUIs
017     * @param s pane name.
018     * @param wi the window interface.
019     * @param paneClass pane class.
020     * @param memo system connection.
021     */
022    public MarklinNamedPaneAction(String s, WindowInterface wi, String paneClass, MarklinSystemConnectionMemo memo) {
023        super(s, wi, paneClass);
024        this.memo = memo;
025    }
026
027    public MarklinNamedPaneAction(String s, Icon i, WindowInterface wi, String paneClass, MarklinSystemConnectionMemo memo) {
028        super(s, i, wi, paneClass);
029        this.memo = memo;
030    }
031
032    private final MarklinSystemConnectionMemo memo;
033
034    @Override
035    public JmriPanel makePanel() {
036        JmriPanel p = super.makePanel();
037        if (p == null) {
038            return null;
039        }
040
041        try {
042            ((MarklinPanelInterface) p).initComponents(memo);
043            return p;
044        } catch (Exception ex) {
045            log.warn("could not init pane class: {}", paneClass, ex);
046        }
047
048        return p;
049    }
050
051    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(MarklinNamedPaneAction.class);
052}