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