001package apps.InstallTest;
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 testing JMRI installation.
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 Ken Cameron Copyright 2008
036 */
037public class InstallTest extends Apps {
038
039    InstallTest() {
040        super();
041    }
042
043    @Override
044    protected String logo() {
045        return "resources/InstallTest.gif";
046    }
047
048    @Override
049    protected String mainWindowHelpID() {
050        return "package.apps.InstallTest.InstallTest";
051    }
052
053    @Override
054    protected String line1() {
055        return MessageFormat.format(Bundle.getMessage("InstallTestVersionCredit"),
056                new Object[]{jmri.Version.name()});
057    }
058
059    @Override
060    protected String line2() {
061        return "http://jmri.org/InstallTest";
062    }
063
064    @Override
065    protected JPanel statusPanel() {
066        JPanel j = new JPanel();
067        j.setLayout(new BoxLayout(j, BoxLayout.Y_AXIS));
068        j.add(super.statusPanel());
069
070        Action serviceprog = new jmri.jmrit.symbolicprog.tabbedframe.PaneProgAction(Bundle.getMessage("DpButtonUseProgrammingTrack"));
071        Action opsprog = new jmri.jmrit.symbolicprog.tabbedframe.PaneOpsProgAction(Bundle.getMessage("DpButtonProgramOnMainTrack"));
072        Action quit = new AbstractAction(Bundle.getMessage("MenuItemQuit")) {
073            @Override
074            public void actionPerformed(ActionEvent e) {
075                Apps.handleQuit();
076            }
077        };
078
079        // Buttons
080        JButton b1 = new JButton(Bundle.getMessage("DpButtonUseProgrammingTrack"));
081        b1.addActionListener(serviceprog);
082        b1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
083        j.add(b1);
084        if (jmri.InstanceManager.getNullableDefault(jmri.GlobalProgrammerManager.class) == null
085                || !jmri.InstanceManager.getDefault(jmri.GlobalProgrammerManager.class).isGlobalProgrammerAvailable()) {
086            b1.setEnabled(false);
087            b1.setToolTipText(Bundle.getMessage("MsgServiceButtonDisabled"));
088        }
089        JButton m1 = new JButton(Bundle.getMessage("DpButtonProgramOnMainTrack"));
090        m1.addActionListener(opsprog);
091        m1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
092        j.add(m1);
093        if (jmri.InstanceManager.getNullableDefault(jmri.AddressedProgrammerManager.class) == null
094                || !jmri.InstanceManager.getDefault(jmri.AddressedProgrammerManager.class).isAddressedModePossible()) {
095            m1.setEnabled(false);
096            m1.setToolTipText(Bundle.getMessage("MsgOpsButtonDisabled"));
097        }
098
099        JButton q1 = new JButton(Bundle.getMessage("ButtonQuit"));
100        q1.addActionListener(quit);
101        q1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
102        j.add(q1);
103        return j;
104    }
105
106    // Main entry point
107    public static void main(String args[]) {
108
109        // Set up system properties that needs to be loaded early
110        jmri.util.EarlyInitializationPreferences.getInstance().loadAndSetPreferences();
111
112        // show splash screen early
113        splash(true);
114
115        Apps.setStartupInfo("InstallTest");
116
117        setConfigFilename("InstallTestConfig2.xml", args);
118        InstallTest it = new InstallTest();
119        JmriJFrame f = new JmriJFrame(jmri.Application.getApplicationName());
120        createFrame(it, f);
121
122        log.debug("main initialization done");
123        splash(false);
124    }
125
126    private final static Logger log = LoggerFactory.getLogger(InstallTest.class);
127}