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/** 018 * The JMRI application for controlling audio. 019 * <p> 020 * If an argument is provided at startup, it will be used as the name of the 021 * configuration file. Note that this is just the name, not the path; the file 022 * is searched for in the usual way, first in the preferences tree and then in 023 * xml/ 024 * 025 * <hr> 026 * This file is part of JMRI. 027 * <p> 028 * JMRI is free software; you can redistribute it and/or modify it under the 029 * terms of version 2 of the GNU General Public License as published by the Free 030 * Software Foundation. See the "COPYING" file for a copy of this license. 031 * <p> 032 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY 033 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 034 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 035 * 036 * @author Bob Jacobsen Copyright 2003, 2004, 2007 037 * @author Matthew Harris copyright (c) 2009 038 */ 039public class SoundPro extends Apps { 040 041 SoundPro() { 042 super(); 043 } 044 045 @Override 046 protected String logo() { 047 return "resources/SoundPro.gif"; 048 } 049 050 @Override 051 protected String mainWindowHelpID() { 052 return "package.apps.SoundPro.SoundPro"; 053 } 054 055 @Override 056 protected String line1() { 057 return Bundle.getMessage("SoundProVersionCredit", jmri.Version.name()); 058 } 059 060 @Override 061 protected String line2() { 062 return "https://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(Component.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(Component.CENTER_ALIGNMENT); 093 p3.add(h1); 094 JButton q1 = new JButton(Bundle.getMessage("ButtonQuit")); 095 q1.addActionListener(quit); 096 q1.setAlignmentX(Component.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 static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(SoundPro.class); 139 140}