001package jmri.jmrix.tams.swing;
002
003import java.util.Arrays;
004import java.util.HashSet;
005import java.util.Set;
006import jmri.SystemConnectionMemo;
007import jmri.jmrix.swing.SystemConnectionAction;
008import jmri.jmrix.tams.TamsSystemConnectionMemo;
009import jmri.util.swing.JmriPanel;
010
011/**
012 * JPanel extension to handle automatic creation of window title and help
013 * referetams for Tams panels
014 * <p>
015 * For use with JmriAbstractAction, etc
016 *
017 * Based on work by Bob Jacobsen
018 *
019 * @author Kevin Dickerson Copyright (C) 2012
020 */
021abstract public class TamsPanel extends JmriPanel implements TamsPanelInterface, SystemConnectionAction<TamsSystemConnectionMemo> {
022
023    /**
024     * make "memo" object available as convenience
025     */
026    protected TamsSystemConnectionMemo memo;
027
028    @Override
029    public void initComponents(TamsSystemConnectionMemo memo) {
030        this.memo = memo;
031    }
032
033    @Override
034    public void initContext(Object context) {
035        if (context instanceof TamsSystemConnectionMemo) {
036            initComponents((TamsSystemConnectionMemo) context);
037        }
038    }
039
040    @Override
041    public TamsSystemConnectionMemo getSystemConnectionMemo() {
042        return memo;
043    }
044
045    @Override
046    public void setSystemConnectionMemo(TamsSystemConnectionMemo memo) {
047        this.memo = memo;
048    }
049
050    @Override
051    public Set<Class<? extends SystemConnectionMemo>> getSystemConnectionMemoClasses() {
052        return new HashSet<>(Arrays.asList(TamsSystemConnectionMemo.class));
053    }
054}