001package jmri.jmrix.zimo.swing; 002 003import javax.annotation.Nonnull; 004import javax.swing.JMenu; 005import jmri.jmrix.zimo.Mx1SystemConnectionMemo; 006 007/** 008 * Create a "Systems" menu containing the JMRI Zimo-specific tools. 009 * 010 * @author Bob Jacobsen Copyright 2003, 2010 Copied from nce.swing 011 * @author Ken Cameron 2014 012 * @author Kevin Dickerson 2014 013 */ 014public class Mx1Menu extends JMenu { 015 016 /** 017 * Create a Zimo menu. 018 * 019 * @param memo the connection to associate actions with 020 */ 021 public Mx1Menu(@Nonnull Mx1SystemConnectionMemo memo) { 022 super(); 023 024 setText(memo.getUserName()); 025 026 jmri.util.swing.WindowInterface wi = new jmri.util.swing.sdi.JmriJFrameInterface(); 027 028 for (Item item : panelItems) { 029 if (item == null) { 030 add(new javax.swing.JSeparator()); 031 } else { 032 Mx1NamedPaneAction a = new Mx1NamedPaneAction(Bundle.getMessage(item.name), wi, item.load, memo); 033 add(a); 034 } 035 } 036 037 // do we have an Mx1TrafficController? 038 setEnabled(memo.getMx1TrafficController() != null); // disable menu, no connection, no tools! 039 040 add(new javax.swing.JSeparator()); 041 } 042 043 private Item[] panelItems = new Item[]{ 044 new Item("MenuItemCommandMonitor", "jmri.jmrix.zimo.swing.monitor.Mx1MonPanel"), // NOI18N 045 new Item("MenuItemSendCommand", "jmri.jmrix.zimo.swing.packetgen.Mx1PacketGenPanel"), // NOI18N 046 }; 047 048 static class Item { 049 050 Item(String name, String load) { 051 this.name = name; 052 this.load = load; 053 } 054 String name; 055 String load; 056 } 057 058}