001package jmri.jmrix.sprog.swing; 002 003import jmri.jmrix.sprog.SPROGCSMenu; 004import jmri.jmrix.sprog.SPROGMenu; 005import jmri.jmrix.sprog.SprogConstants.SprogMode; 006import jmri.jmrix.sprog.SprogSystemConnectionMemo; 007 008/** 009 * Provide access to Swing components for the Sprog subsystem. 010 * 011 * @author Bob Jacobsen Copyright (C) 2010 012 * @author Paul Bender Copyright (C) 2010 013 * @since 3.5.1 014 */ 015public class SprogComponentFactory extends jmri.jmrix.swing.ComponentFactory { 016 017 public SprogComponentFactory(SprogSystemConnectionMemo memo) { 018 this.memo = memo; 019 } 020 021 SprogSystemConnectionMemo memo; 022 023 /** 024 * Provide a menu with all items attached to this system connection 025 */ 026 @Override 027 public javax.swing.JMenu getMenu() { 028 if (memo.getDisabled()) { 029 return null; 030 } 031 if(memo.getSprogMode() == SprogMode.SERVICE) { 032 return new SPROGMenu(memo); 033 } else { // must be command station mode. 034 return new SPROGCSMenu(memo); 035 } 036 } 037}