001package jmri.jmrix.marklin.swing;
002
003import javax.swing.JMenu;
004import jmri.jmrix.marklin.MarklinSystemConnectionMemo;
005import org.slf4j.Logger;
006import org.slf4j.LoggerFactory;
007
008/**
009 * Create a "Systems" menu containing the Jmri Marklin-specific tools.
010 *
011 * @author Kevin Dickerson
012 */
013public class MarklinMenu extends JMenu {
014
015    public MarklinMenu(MarklinSystemConnectionMemo memo) {
016        super();
017
018        if (memo != null) {
019            setText(memo.getUserName());
020        } else {
021            setText(Bundle.getMessage("MenuMarklin"));
022        }
023
024        jmri.util.swing.WindowInterface wi = new jmri.util.swing.sdi.JmriJFrameInterface();
025
026        for (Item item : panelItems) {
027            if (item == null) {
028                add(new javax.swing.JSeparator());
029            } else {
030                add(new MarklinNamedPaneAction(Bundle.getMessage(item.name), wi, item.load, memo));
031            }
032        }
033
034        if (jmri.InstanceManager.getNullableDefault(jmri.jmrit.beantable.ListedTableFrame.class) == null) {
035            try {
036                new jmri.jmrit.beantable.ListedTableFrame<jmri.Turnout>();
037            } catch (java.lang.NullPointerException ex) {
038                log.error("Unable to register Marklin table");
039            }
040        }
041
042    }
043
044    Item[] panelItems = new Item[]{
045        new Item("MenuItemMarklinMonitor", "jmri.jmrix.marklin.swing.monitor.MarklinMonPane"),
046        new Item("MenuItemSendPacket", "jmri.jmrix.marklin.swing.packetgen.PacketGenPanel"),};
047
048    static class Item {
049
050        Item(String name, String load) {
051            this.name = name;
052            this.load = load;
053        }
054
055        String name;
056        String load;
057    }
058
059    private final static Logger log = LoggerFactory.getLogger(MarklinMenu.class);
060
061}