001package jmri.jmrix.sprog.update;
002
003import jmri.jmrix.sprog.SprogSystemConnectionMemo;
004import jmri.util.swing.JmriJOptionPane;
005
006/**
007 * Display the firmware version of the attached SPROG hardware.
008 *
009 * @author Andrew Crosland Copyright (C) 2008
010 */
011public class SprogVersionFrame extends jmri.util.JmriJFrame implements SprogVersionListener {
012
013    private SprogSystemConnectionMemo _memo = null;
014
015    public SprogVersionFrame(SprogSystemConnectionMemo memo) {
016        super();
017        _memo = memo;
018    }
019
020    /** 
021     * {@inheritDoc}
022     */
023    @Override
024    synchronized public void initComponents() {
025        setTitle(Bundle.getMessage("SprogVersionTitle"));
026
027        // add help menu to window
028        addHelpMenu("package.jmri.jmrix.sprog.update.SprogVersionFrame", true);
029
030        // Start the query
031        SprogVersionQuery query = _memo.getSprogVersionQuery();
032        query.requestVersion(this);
033    }
034
035    /** 
036     * {@inheritDoc}
037     */
038    @Override
039    public synchronized void notifyVersion(SprogVersion v) {
040        log.debug("Version {} notified", v.toString());
041        JmriJOptionPane.showMessageDialog(this, Bundle.getMessage("SprogVersionDialogString", v.toString()),
042                Bundle.getMessage("SprogVersionTitle"), JmriJOptionPane.INFORMATION_MESSAGE);
043        setVisible(false);
044        dispose();
045    }
046
047    /**
048     * Removes SprogVersionListener.
049     * {@inheritDoc}
050     */
051    @Override
052    public void dispose() {
053        _memo.getSprogVersionQuery().removeSprogVersionListener(this);
054        super.dispose();
055    }
056
057    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(SprogVersionFrame.class);
058}