001package apps.DispatcherPro;
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 program for creating control panels.
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
036 */
037public class DispatcherPro extends Apps {
038
039    DispatcherPro() {
040        super();
041    }
042
043    @Override
044    protected String logo() {
045        return "resources/logo.gif";
046    }
047
048    @Override
049    protected String mainWindowHelpID() {
050        return "package.apps.DispatcherPro.DispatcherPro";
051    }
052
053    @Override
054    protected String line1() {
055        return MessageFormat.format(Bundle.getMessage("DispatcherProVersionCredit"),
056                new Object[]{jmri.Version.name()});
057    }
058
059    @Override
060    protected String line2() {
061        return "http://jmri.org/DispatcherPro ";
062    }
063
064    /**
065     * JPanel displayed as DispatcherPro main screen.
066     */
067    @Override
068    protected JPanel statusPanel() {
069        JPanel j = new JPanel();
070        j.setLayout(new BoxLayout(j, BoxLayout.Y_AXIS));
071        j.add(super.statusPanel());
072
073        // Buttons
074        Action quit = new AbstractAction(Bundle.getMessage("MenuItemQuit")) {
075            @Override
076            public void actionPerformed(ActionEvent e) {
077                Apps.handleQuit();
078            }
079        };
080
081        JPanel p3 = new JPanel();
082        p3.setLayout(new java.awt.FlowLayout());
083        h1 = new JButton(Bundle.getMessage("ButtonHelp"));
084        // as globalHelpBroker is still null, wait to attach help target after help menu is created
085        h1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
086        p3.add(h1);
087        JButton q1 = new JButton(Bundle.getMessage("ButtonQuit"));
088        q1.addActionListener(quit);
089        q1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
090        p3.add(q1);
091        j.add(p3);
092
093        return j;
094    }
095
096    /**
097     * Help button on Main Screen.
098     */
099    private JButton h1;
100
101    /**
102     * {@inheritDoc}
103     */
104    @Override
105    protected void attachHelp() {
106        if (h1 != null) {
107            jmri.util.HelpUtil.addHelpToComponent(h1, "html.apps.DispatcherPro.index");
108        }
109    }
110    
111    // Main entry point
112    public static void main(String args[]) {
113
114        // Set up system properties that needs to be loaded early
115        jmri.util.EarlyInitializationPreferences.getInstance().loadAndSetPreferences();
116
117        // show splash screen early
118        splash(true);
119
120        Apps.setStartupInfo("DispatcherPro");
121
122        setConfigFilename("DispatcherProConfig2.xml", args);
123        DispatcherPro dp = new DispatcherPro();
124        JmriJFrame f = new JmriJFrame(jmri.Application.getApplicationName());
125        createFrame(dp, f);
126
127        log.debug("main initialization done");
128        splash(false);
129    }
130
131    private final static Logger log = LoggerFactory.getLogger(DispatcherPro.class);
132
133}