001package apps.SoundPro;
002
003import apps.Apps;
004import java.awt.event.ActionEvent;
005import java.text.MessageFormat;
006import javax.swing.AbstractAction;
007import javax.swing.Action;
008import javax.swing.BoxLayout;
009import javax.swing.JButton;
010import javax.swing.JLabel;
011import javax.swing.JPanel;
012import jmri.util.JmriJFrame;
013import org.slf4j.Logger;
014import org.slf4j.LoggerFactory;
015
016/**
017 * The JMRI application for controlling audio.
018 * <p>
019 * If an argument is provided at startup, it will be used as the name of the
020 * configuration file. Note that this is just the name, not the path; the file
021 * is searched for in the usual way, first in the preferences tree and then in
022 * xml/
023 *
024 * <hr>
025 * This file is part of JMRI.
026 * <p>
027 * JMRI is free software; you can redistribute it and/or modify it under the
028 * terms of version 2 of the GNU General Public License as published by the Free
029 * Software Foundation. See the "COPYING" file for a copy of this license.
030 * <p>
031 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY
032 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
033 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
034 *
035 * @author Bob Jacobsen Copyright 2003, 2004, 2007
036 * @author Matthew Harris copyright (c) 2009
037 */
038public class SoundPro extends Apps {
039
040    SoundPro() {
041        super();
042    }
043
044    @Override
045    protected String logo() {
046        return "resources/SoundPro.gif";
047    }
048
049    @Override
050    protected String mainWindowHelpID() {
051        return "package.apps.SoundPro.SoundPro";
052    }
053
054    @Override
055    protected String line1() {
056        return MessageFormat.format(Bundle.getMessage("SoundProVersionCredit"),
057                new Object[]{jmri.Version.name()});
058    }
059
060    @Override
061    protected String line2() {
062        return "http://jmri.org/SoundPro ";
063    }
064
065    /**
066     * JPanel displayed as SoundPro main screen.
067     */
068    @Override
069    protected JPanel statusPanel() {
070        JPanel j = new JPanel();
071        j.setLayout(new BoxLayout(j, BoxLayout.Y_AXIS));
072        j.add(super.statusPanel());
073
074        // Buttons
075        Action audioTable = new jmri.jmrit.beantable.AudioTableAction(Bundle.getMessage("SpButtonAudioTable"));
076        Action quit = new AbstractAction(Bundle.getMessage("MenuItemQuit")) {
077            @Override
078            public void actionPerformed(ActionEvent e) {
079                Apps.handleQuit();
080            }
081        };
082
083        JButton b1 = new JButton(Bundle.getMessage("SpButtonAudioTable"));
084        b1.addActionListener(audioTable);
085        b1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
086        j.add(b1);
087
088        JPanel p3 = new JPanel();
089        p3.setLayout(new java.awt.FlowLayout());
090        h1 = new JButton(Bundle.getMessage("ButtonHelp"));
091        // as globalHelpBroker is still null, wait to attach help target after help menu is created
092        h1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
093        p3.add(h1);
094        JButton q1 = new JButton(Bundle.getMessage("ButtonQuit"));
095        q1.addActionListener(quit);
096        q1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
097        p3.add(q1);
098        j.add(p3);
099
100        return j;
101    }
102
103    /**
104     * Help button on Main Screen.
105     */
106    private JButton h1;
107
108    /**
109     * {@inheritDoc}
110     */
111    @Override
112    protected void attachHelp() {
113        if (h1 != null) {
114            jmri.util.HelpUtil.addHelpToComponent(h1, "html.apps.SoundPro.SoundPro");
115        }
116    }
117    
118    // Main entry point
119    public static void main(String args[]) {
120
121        // Set up system properties that needs to be loaded early
122        jmri.util.EarlyInitializationPreferences.getInstance().loadAndSetPreferences();
123
124        // show splash screen early
125        splash(true);
126
127        Apps.setStartupInfo("SoundPro");
128
129        setConfigFilename("SoundProConfig2.xml", args);
130        SoundPro sp = new SoundPro();
131        JmriJFrame f = new JmriJFrame(jmri.Application.getApplicationName());
132        createFrame(sp, f);
133
134        log.debug("main initialization done");
135        splash(false);
136    }
137
138    private final static Logger log = LoggerFactory.getLogger(SoundPro.class);
139
140}