001package apps.jmrit;
002
003import java.io.File;
004import java.net.URISyntaxException;
005import java.util.ResourceBundle;
006
007import javax.swing.JMenu;
008import javax.swing.JMenuItem;
009import javax.swing.JPanel;
010import javax.swing.JSeparator;
011
012import jmri.jmrit.jython.RunJythonScript;
013import jmri.util.FileUtil;
014
015/**
016 * Create a "Debug" menu containing the JMRI system-independent debugging tools.
017 *
018 * @author Bob Jacobsen Copyright 2003
019 */
020public class DebugMenu extends JMenu {
021
022    static final ResourceBundle rb = ResourceBundle.getBundle("apps.AppsBundle");
023
024    public DebugMenu(String name, JPanel panel) {
025        this(panel);
026        setText(name);
027    }
028
029    public DebugMenu(JPanel panel) {
030
031        super();
032
033        setText(Bundle.getMessage("MenuDebug"));
034
035        add(new jmri.jmrit.MemoryFrameAction(Bundle.getMessage("MenuItemMemoryUsageMonitor")));
036
037        add(new JSeparator());
038        add(new jmri.jmrit.decoderdefn.InstallDecoderFileAction(Bundle.getMessage("MenuItemImportDecoderFile"), panel));
039        add(new jmri.jmrit.decoderdefn.InstallDecoderURLAction(Bundle.getMessage("MenuItemImportDecoderURL"), panel));
040        add(new jmri.jmrit.decoderdefn.DecoderIndexCreateAction(Bundle.getMessage("MenuItemRecreateDecoderIndex")));
041        add(new jmri.jmrit.roster.RecreateRosterAction(Bundle.getMessage("MenuItemRecreateRoster")));
042        add(new jmri.jmrit.roster.UpdateDecoderDefinitionAction(Bundle.getMessage("MenuItemUpdateDecoderDefinition")));
043
044        add(new JSeparator());
045        add(new jmri.jmrit.XmlFileValidateAction(Bundle.getMessage("MenuItemValidateXMLFile"), panel));
046        add(new jmri.jmrit.decoderdefn.NameCheckAction(Bundle.getMessage("MenuItemCheckDecoderNames"), panel));
047        add(new jmri.jmrit.symbolicprog.tabbedframe.ProgCheckAction(Bundle.getMessage("MenuItemCheckProgrammerNames"), panel));
048        add(new jmri.configurexml.StoreAndCompare(Bundle.getMessage("MenuTestStoreCompare")));  // NOI18N
049
050        add(new JSeparator());
051        add(new apps.jmrit.log.LogAction(Bundle.getMessage("MenuItemLogAction")));
052        add(new jmri.util.swing.JmriNamedPaneAction(Bundle.getMessage("MenuItemLogTreeAction"),
053                new jmri.util.swing.sdi.JmriJFrameInterface(),
054                "apps.jmrit.log.Log4JTreePane"));
055
056        add(new JSeparator());
057        add(new jmri.jmrit.LogixLoadAction(Bundle.getMessage("MenuItemLogixDisabled"), panel));
058
059        // also add some tentative items from jmrix
060        add(new JSeparator());
061        add(new jmri.jmrix.pricom.PricomMenu());
062
063        add(new JSeparator());
064        add(new jmri.jmrix.jinput.treecontrol.TreeAction());
065        add(new jmri.jmrix.libusb.UsbViewAction());
066
067        add(new JSeparator());
068        try {
069            add(new RunJythonScript(rb.getString("MenuRailDriverThrottle"), new File(FileUtil.findURL("jython/RailDriver.py").toURI())));  // NOI18N
070        } catch (URISyntaxException | NullPointerException ex) {
071            log.error("Unable to load RailDriver Throttle", ex);  // NOI18N
072            JMenuItem i = new JMenuItem(rb.getString("MenuRailDriverThrottle"));  // NOI18N
073            i.setEnabled(false);
074            add(i);
075        }
076
077        add(new JSeparator());
078        add(new apps.TrainCrew.InstallFromURL());
079    }
080
081    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(DebugMenu.class);
082}