001package jmri.jmrix.dccpp.swing; 002/* 003 * <hr> 004 * This file is part of JMRI. 005 * <p> 006 * JMRI is free software; you can redistribute it and/or modify it under 007 * the terms of version 2 of the GNU General Public License as published 008 * by the Free Software Foundation. See the "COPYING" file for a copy 009 * of this license. 010 * <p> 011 * JMRI is distributed in the hope that it will be useful, but WITHOUT 012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 014 * for more details. 015 * <p> 016 * 017 * @author Mark Underwood Copyright (C) 2011 018 * 019 */ 020 021import java.awt.Frame; 022import java.awt.event.ActionEvent; 023 024import org.slf4j.Logger; 025import org.slf4j.LoggerFactory; 026 027import jmri.InstanceManager; 028import jmri.jmrix.dccpp.DCCppInterface; 029import jmri.jmrix.dccpp.DCCppMessage; 030import jmri.jmrix.dccpp.DCCppSystemConnectionMemo; 031import jmri.jmrix.dccpp.DCCppTrafficController; 032 033public class ConfigBaseStationAction extends DCCppSystemConnectionAction { 034 035 public ConfigBaseStationAction(String name, DCCppSystemConnectionMemo memo) { 036 super(name, memo); 037 } 038 039 public ConfigBaseStationAction(DCCppSystemConnectionMemo memo) { 040 super(Bundle.getMessage("FieldManageBaseStationFrameTitle"), memo); 041 } 042 043 public ConfigBaseStationAction() { 044 this(InstanceManager.getNullableDefault(DCCppSystemConnectionMemo.class)); 045 } 046 047 /** 048 * 049 */ 050 private ConfigBaseStationFrame f = null; 051 052 @Override 053 public void actionPerformed(ActionEvent e) { 054 if (f == null || !f.isVisible()) { 055 056 DCCppSystemConnectionMemo memo = getSystemConnectionMemo(); 057 if (memo == null) { 058 log.error("connection memo was null!"); 059 return; 060 } 061 f = new ConfigBaseStationFrame(memo); 062 DCCppTrafficController tc = memo.getDCCppTrafficController(); 063 tc.addDCCppListener(DCCppInterface.CS_INFO, f); 064 065 // Request definitions for Turnouts, TurnoutIDs, Sensors and Outputs 066 tc.sendDCCppMessage(DCCppMessage.makeSensorListMsg(), f); 067 tc.sendDCCppMessage(DCCppMessage.makeTurnoutListMsg(), f); 068 tc.sendDCCppMessage(DCCppMessage.makeOutputListMsg(), f); 069 if (tc.getCommandStation().isTurnoutIDsMessageRequired()) { 070 tc.sendDCCppMessage(DCCppMessage.makeTurnoutIDsMsg(), f); 071 } 072 } 073 f.setExtendedState(Frame.NORMAL); 074 } 075 private static final Logger log = LoggerFactory.getLogger(ConfigBaseStationAction.class); 076}