001package jmri.jmrix.powerline.swing; 002 003import javax.annotation.Nonnull; 004import javax.swing.JMenu; 005import jmri.jmrix.powerline.SerialSystemConnectionMemo; 006import jmri.jmrix.powerline.SerialSystemConnectionMemo.MenuItem; 007 008/** 009 * Create a "Systems" menu containing the JMRI Powerline-specific tools. 010 * 011 * @author Bob Jacobsen Copyright 2003, 2010 Copied from NCE Converted to 012 * multiple connection 013 * @author kcameron Copyright (C) 2011 014 */ 015public class PowerlineMenu extends JMenu { 016 017 /** 018 * Create a Powerline menu. And loads the SerialSystemConnectionMemo to the 019 * various actions. Actions will open new windows. 020 * @param memo Connection details memo 021 */ 022 // Need to Sort out the Powerline server menu items; 023 public PowerlineMenu(@Nonnull SerialSystemConnectionMemo memo) { 024 super(); 025 026 setText(memo.getUserName()); 027 028 jmri.util.swing.WindowInterface wi = new jmri.util.swing.sdi.JmriJFrameInterface(); 029 030 // rely on list of menu items 031 for (MenuItem item : memo.provideMenuItemList()) { 032 if (item == null) { 033 add(new javax.swing.JSeparator()); 034 } else { 035 PowerlineNamedPaneAction a = new PowerlineNamedPaneAction(Bundle.getMessage(item.name), wi, item.load, memo); 036 add(a); 037 a.setEnabled(true); 038 } 039 } 040 041 // do we have a TrafficController? 042 setEnabled(memo.getTrafficController() != null); // disable menu, no connection, no tools! 043 044 add(new javax.swing.JSeparator()); 045 } 046 047}