001package jmri.jmrix.tams.swing; 002 003import javax.swing.JMenu; 004import jmri.Turnout; 005import jmri.jmrix.tams.TamsSystemConnectionMemo; 006import org.slf4j.Logger; 007import org.slf4j.LoggerFactory; 008 009/** 010 * Create a "Systems" menu containing the Tams-specific tools. 011 * 012 * Based on work by Bob Jacobsen 013 * @author Kevin Dickerson Copyright (C) 2012 014 */ 015public class TamsMenu extends JMenu { 016 017 public TamsMenu(TamsSystemConnectionMemo memo) { 018 super(); 019 020 if (memo != null) { 021 setText(memo.getUserName()); 022 } else { 023 setText(Bundle.getMessage("MenuTams")); 024 } 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 add(new TamsNamedPaneAction(Bundle.getMessage(item.name), wi, item.load, memo)); 033 } 034 } 035 036 if (jmri.InstanceManager.getNullableDefault(jmri.jmrit.beantable.ListedTableFrame.class) == null) { 037 try { 038 new jmri.jmrit.beantable.ListedTableFrame<Turnout>(); 039 } catch (java.lang.NullPointerException ex) { 040 log.error("Unable to register Tams table"); 041 } 042 } 043 } 044 045 Item[] panelItems = new Item[]{ 046 new Item("MenuItemTamsMonitor", "jmri.jmrix.tams.swing.monitor.TamsMonPane"), 047 new Item("MenuItemSendPacket", "jmri.jmrix.tams.swing.packetgen.PacketGenPanel"), 048 new Item("MenuItemInfo", "jmri.jmrix.tams.swing.statusframe.StatusPanel"), 049 new Item("MenuItemLocoData", "jmri.jmrix.tams.swing.locodatabase.LocoDataPane"),}; 050 051 static class Item { 052 053 Item(String name, String load) { 054 this.name = name; 055 this.load = load; 056 } 057 058 String name; 059 String load; 060 } 061 062 private final static Logger log = LoggerFactory.getLogger(TamsMenu.class); 063 064}