001package apps.SoundPro; 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 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 Bundle.getMessage("SoundProVersionCredit", jmri.Version.name()); 057 } 058 059 @Override 060 protected String line2() { 061 return "https://jmri.org/SoundPro"; 062 } 063 064 /** 065 * JPanel displayed as SoundPro 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 audioTable = new jmri.jmrit.beantable.AudioTableAction(Bundle.getMessage("SpButtonAudioTable")); 075 Action quit = new AbstractAction(Bundle.getMessage("MenuItemQuit")) { 076 @Override 077 public void actionPerformed(ActionEvent e) { 078 Apps.handleQuit(); 079 } 080 }; 081 082 JButton b1 = new JButton(Bundle.getMessage("SpButtonAudioTable")); 083 b1.addActionListener(audioTable); 084 b1.setAlignmentX(Component.CENTER_ALIGNMENT); 085 j.add(b1); 086 087 JPanel p3 = new JPanel(); 088 p3.setLayout(new java.awt.FlowLayout()); 089 h1 = new JButton(Bundle.getMessage("ButtonHelp")); 090 // as globalHelpBroker is still null, wait to attach help target after help menu is created 091 h1.setAlignmentX(Component.CENTER_ALIGNMENT); 092 p3.add(h1); 093 JButton q1 = new JButton(Bundle.getMessage("ButtonQuit")); 094 q1.addActionListener(quit); 095 q1.setAlignmentX(Component.CENTER_ALIGNMENT); 096 p3.add(q1); 097 j.add(p3); 098 099 return j; 100 } 101 102 /** 103 * Help button on Main Screen. 104 */ 105 private JButton h1; 106 107 /** 108 * {@inheritDoc} 109 */ 110 @Override 111 protected void attachHelp() { 112 if (h1 != null) { 113 jmri.util.HelpUtil.addHelpToComponent(h1, "html.apps.SoundPro.SoundPro"); 114 } 115 } 116 117 // Main entry point 118 public static void main(String args[]) { 119 120 // Set up system properties that needs to be loaded early 121 jmri.util.EarlyInitializationPreferences.getInstance().loadAndSetPreferences(); 122 123 // show splash screen early 124 splash(true); 125 126 Apps.setStartupInfo("SoundPro"); 127 128 setConfigFilename("SoundProConfig2.xml", args); 129 SoundPro sp = new SoundPro(); 130 JmriJFrame f = new JmriJFrame(jmri.Application.getApplicationName()); 131 createFrame(sp, f); 132 133 log.debug("main initialization done"); 134 splash(false); 135 } 136 137 private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(SoundPro.class); 138 139}