001package jmri.jmrix.can.swing;
002
003import javax.swing.JMenu;
004import jmri.jmrix.can.CanSystemConnectionMemo;
005
006/**
007 * Create a menu containing the Jmri CAN- and CBUS-specific tools
008 *
009 * @author Bob Jacobsen Copyright 2003, 2008, 2009
010 * @author Andrew Crosland 2008
011 */
012public class CanMenu extends JMenu {
013
014    public CanMenu(CanSystemConnectionMemo memo) {
015        super();
016
017        if (memo != null) {
018            setText(memo.getUserName());
019        } else {
020            setText(Bundle.getMessage("MenuItemCAN"));
021        }
022
023        jmri.util.swing.WindowInterface wi = new jmri.util.swing.sdi.JmriJFrameInterface();
024
025        for (Item item : panelItems) {
026            if (item == null) {
027                add(new javax.swing.JSeparator());
028            } else {
029                add(new CanNamedPaneAction(Bundle.getMessage(item.name), wi, item.load, memo));
030            }
031        }
032    }
033
034    Item[] panelItems = new Item[]{
035        new Item("MenuItemConsole", "jmri.jmrix.can.swing.monitor.MonitorPane"),
036        new Item("MenuItemSendFrame", "jmri.jmrix.can.swing.send.CanSendPane"),};
037
038    static class Item {
039
040        Item(String name, String load) {
041            this.name = name;
042            this.load = load;
043        }
044
045        String name;
046        String load;
047    }
048
049}