001package apps.DecoderPro; 002 003import apps.Apps; 004 005import java.awt.Component; 006import java.awt.FlowLayout; 007import java.awt.event.ActionEvent; 008 009import javax.swing.AbstractAction; 010import javax.swing.Action; 011import javax.swing.BoxLayout; 012import javax.swing.JButton; 013import javax.swing.JPanel; 014 015import jmri.InstanceManager; 016import jmri.jmrit.roster.swing.RosterFrameAction; 017import jmri.jmrit.symbolicprog.tabbedframe.PaneOpsProgAction; 018import jmri.jmrit.symbolicprog.tabbedframe.PaneProgAction; 019 020/** 021 * The JMRI application for configuring DCC decoders. 022 * <p> 023 * If an argument is provided at startup, it will be used as the name of the 024 * configuration file. Note that this is just the name, not the path; the file 025 * is searched for in the usual way, first in the preferences tree and then in 026 * xml/ 027 * 028 * <hr> 029 * This file is part of JMRI. 030 * <p> 031 * JMRI is free software; you can redistribute it and/or modify it under the 032 * terms of version 2 of the GNU General Public License as published by the Free 033 * Software Foundation. See the "COPYING" file for a copy of this license. 034 * <p> 035 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY 036 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 037 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 038 * 039 * @author Bob Jacobsen Copyright 2003, 2004, 2007 040 */ 041public class DecoderPro extends Apps { 042 043 DecoderPro() { 044 super(); 045 } 046 047 @Override 048 protected String logo() { 049 return "resources/decoderpro.gif"; 050 } 051 052 @Override 053 protected String mainWindowHelpID() { 054 return "package.apps.DecoderPro.DecoderPro"; 055 } 056 057 @Override 058 protected String line1() { 059 return Bundle.getMessage("DecoderProVersionCredit", jmri.Version.name()); 060 } 061 062 @Override 063 protected String line2() { 064 return "https://jmri.org/DecoderPro"; 065 } 066 067 /** 068 * JPanel displayed as DecoderPro v2 main screen. 069 */ 070 @Override 071 protected JPanel statusPanel() { 072 JPanel j = new JPanel(); 073 j.setLayout(new BoxLayout(j, BoxLayout.Y_AXIS)); 074 j.add(super.statusPanel()); 075 076 // Buttons 077 Action serviceprog = new PaneProgAction(Bundle.getMessage("DpButtonUseProgrammingTrack")); 078 Action opsprog = new PaneOpsProgAction(Bundle.getMessage("DpButtonProgramOnMainTrack")); 079 Action quit = new AbstractAction(Bundle.getMessage("MenuItemQuit")) { 080 @Override 081 public void actionPerformed(ActionEvent e) { 082 Apps.handleQuit(); 083 } 084 }; 085 086 JButton roster = new JButton(new RosterFrameAction()); 087 roster.setAlignmentX(Component.CENTER_ALIGNMENT); 088 j.add(roster); 089 JButton b1 = new JButton(Bundle.getMessage("DpButtonUseProgrammingTrack")); 090 b1.addActionListener(serviceprog); 091 b1.setAlignmentX(Component.CENTER_ALIGNMENT); 092 j.add(b1); 093 if (InstanceManager.getNullableDefault(jmri.GlobalProgrammerManager.class) == null 094 || !InstanceManager.getDefault(jmri.GlobalProgrammerManager.class).isGlobalProgrammerAvailable()) { 095 b1.setEnabled(false); 096 b1.setToolTipText(Bundle.getMessage("MsgServiceButtonDisabled")); 097 } 098 JButton m1 = new JButton(Bundle.getMessage("DpButtonProgramOnMainTrack")); 099 m1.addActionListener(opsprog); 100 m1.setAlignmentX(Component.CENTER_ALIGNMENT); 101 j.add(m1); 102 if (InstanceManager.getNullableDefault(jmri.AddressedProgrammerManager.class) == null 103 || !InstanceManager.getDefault(jmri.AddressedProgrammerManager.class).isAddressedModePossible()) { 104 m1.setEnabled(false); 105 m1.setToolTipText(Bundle.getMessage("MsgOpsButtonDisabled")); 106 } 107 108 JPanel p3 = new JPanel(); 109 p3.setLayout(new FlowLayout()); 110 h1 = new JButton(Bundle.getMessage("ButtonHelp")); 111 // as globalHelpBroker is still null, wait to attach help target after help menu is created 112 h1.setAlignmentX(Component.CENTER_ALIGNMENT); 113 p3.add(h1); 114 JButton q1 = new JButton(Bundle.getMessage("ButtonQuit")); 115 q1.addActionListener(quit); 116 q1.setAlignmentX(Component.CENTER_ALIGNMENT); 117 p3.add(q1); 118 j.add(p3); 119 120 return j; 121 } 122 123 /** 124 * Help button on Main Screen. 125 */ 126 private JButton h1; 127 128 /** 129 * {@inheritDoc} 130 */ 131 @Override 132 protected void attachHelp() { 133 if (h1 != null) { 134 jmri.util.HelpUtil.addHelpToComponent(h1, "html.apps.DecoderPro.index"); 135 } 136 } 137 138// main() method is commented out since it's probably not used anymore 139// See: https://jmri-developers.groups.io/g/jmri/message/12240 140/* 141 // Main entry point 142 public static void main(String args[]) { 143 144 // Set up system properties that needs to be loaded early 145 jmri.util.EarlyInitializationPreferences.getInstance().loadAndSetPreferences(); 146 147 // show splash screen early 148 splash(true); 149 150 Apps.setStartupInfo("DecoderPro"); 151 152 setConfigFilename("DecoderProConfig2.xml", args); 153 DecoderPro dp = new DecoderPro(); 154 JmriJFrame f = new JmriJFrame(jmri.Application.getApplicationName()); 155 createFrame(dp, f); 156 157 log.debug("main initialization done"); 158 splash(false); 159 } 160*/ 161// private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(DecoderPro.class); 162}