001package jmri.jmrix.ecos.swing; 002 003import javax.swing.JMenu; 004 005import jmri.InstanceManager; 006import jmri.jmrix.ecos.EcosSystemConnectionMemo; 007import jmri.util.prefs.JmriPreferencesActionFactory; 008 009/** 010 * Create a "Systems" menu containing the Jmri ECoS-specific tools. 011 * 012 * @author Kevin Dickerson 013 */ 014public class EcosMenu extends JMenu { 015 016 public EcosMenu(EcosSystemConnectionMemo memo) { 017 super(); 018 019 String title; 020 if (memo != null) { 021 title = memo.getUserName(); 022 } else { 023 title = Bundle.getMessage("MenuEcos"); 024 } 025 setText(title); 026 027 jmri.util.swing.WindowInterface wi = new jmri.util.swing.sdi.JmriJFrameInterface(); 028 029 for (Item item : panelItems) { 030 if (item == null) { 031 add(new javax.swing.JSeparator()); 032 } else { 033 add(new EcosNamedPaneAction(Bundle.getMessage(item.name), wi, item.load, memo)); 034 } 035 } 036 037 add(new jmri.jmrit.beantable.ListedTableAction(Bundle.getMessage("MenuItemDatabase"), 038 "jmri.jmrix.ecos.swing.locodatabase.EcosLocoTableTabAction")); 039 add(InstanceManager.getDefault(JmriPreferencesActionFactory.class). 040 getCategorizedAction(Bundle.getMessage("MenuItemECoSPrefs"), "ECoS", title)); 041 if (memo != null) { 042 add(new jmri.jmrix.ecos.utilities.AddRosterEntryToEcos(Bundle.getMessage("MenuItemAddLocoToEcos"), memo)); 043 } 044 } 045 046 Item[] panelItems = new Item[]{ 047 new Item("MenuItemEcosMonitor", "jmri.jmrix.ecos.swing.monitor.EcosMonPane"), 048 new Item("MenuItemSendPacket", "jmri.jmrix.ecos.swing.packetgen.PacketGenPanel"), 049 new Item("MenuItemInfo", "jmri.jmrix.ecos.swing.statusframe.StatusPanel") 050 051 }; 052 053 static class Item { 054 055 Item(String name, String load) { 056 this.name = name; 057 this.load = load; 058 } 059 060 String name; 061 String load; 062 } 063 064 // private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(EcosMenu.class); 065 066}