001package jmri.jmrix.bidib.swing; 002 003import javax.swing.JMenu; 004import javax.swing.JSeparator; 005import jmri.jmrix.bidib.BiDiBSystemConnectionMemo; 006import jmri.util.swing.WindowInterface; 007import jmri.util.swing.sdi.JmriJFrameInterface; 008 009/** 010 * Create a "Systems" menu containing the Jmri BiDiB-specific tools. 011 * 012 * @author Bob Jacobsen Copyright 2003, 2006, 2007, 2008 013 * @author Matthew Harris Copyright 2011 014 * @since 2.11.4 015 * @author Eckart Meyer Copyright (C) 2020-2023 016 */ 017public class BiDiBMenu extends JMenu { 018 019// @SuppressWarnings("OverridableMethodCallInConstructor") 020 public BiDiBMenu(BiDiBSystemConnectionMemo memo) { 021 022 super(); 023 024 if (memo != null) { 025 setText(memo.getUserName()); 026 } else { 027 setText(Bundle.getMessage("MenuBiDiB")); 028 } 029 030 WindowInterface wi = new JmriJFrameInterface(); 031 032 for (Item item : panelItems) { 033 if (item == null || memo == null) { 034 add(new JSeparator()); 035 } else { 036 add(new BiDiBNamedPaneAction(item.name, wi, item.load, memo)); // NOI18N 037 } 038 } 039 if (memo != null) { 040 add(new javax.swing.JSeparator()); 041 add(new jmri.jmrix.bidib.tcpserver.TcpServerAction(memo, Bundle.getMessage("MenuItemStartBiDiBOverTCPServer"), Bundle.getMessage("MenuItemStopBiDiBOverTCPServer"))); 042 if (memo.getBiDiBTrafficController() != null && memo.getBiDiBTrafficController().isNetBiDiB()) { 043 add(new jmri.jmrix.bidib.netbidib.NetBiDiBLogonAction(memo, Bundle.getMessage("MenuItemLocalLogon"), Bundle.getMessage("MenuItemLocalLogoff"))); 044 } 045 } 046 } 047 048 Item[] panelItems = new Item[]{ 049 new Item(Bundle.getMessage("BiDiBMonPaneTitle"), "jmri.jmrix.bidib.swing.mon.BiDiBMonPane") 050 }; 051 052 static class Item { 053 054 String name; 055 String load; 056 057 Item(String name, String load) { 058 this.name = name; 059 this.load = load; 060 } 061 } 062 063}